diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2009-04-29 04:04:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-29 20:32:29 -0400 |
commit | 1b1c2e95103ce391c2ea39a9460968fcb73deb30 (patch) | |
tree | 1e94eb6be16d539c579af6384f44850f91e98f6a /include/linux/mdio.h | |
parent | 52c94dfae11d9ffd70b7bd003a36a4e210f2866a (diff) |
mdio: Add generic MDIO (clause 45) support functions
These roughly mirror many of the MII library functions and are based
on code from the sfc driver.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/mdio.h')
-rw-r--r-- | include/linux/mdio.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/linux/mdio.h b/include/linux/mdio.h index d57ddb08a1b2..ba41537eaa8a 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h | |||
@@ -234,4 +234,70 @@ static inline __u16 mdio_phy_id_devad(int phy_id) | |||
234 | return phy_id & MDIO_PHY_ID_DEVAD; | 234 | return phy_id & MDIO_PHY_ID_DEVAD; |
235 | } | 235 | } |
236 | 236 | ||
237 | #ifdef __KERNEL__ | ||
238 | |||
239 | /** | ||
240 | * struct mdio_if_info - Ethernet controller MDIO interface | ||
241 | * @prtad: PRTAD of the PHY (%MDIO_PRTAD_NONE if not present/unknown) | ||
242 | * @mmds: Mask of MMDs expected to be present in the PHY. This must be | ||
243 | * non-zero unless @prtad = %MDIO_PRTAD_NONE. | ||
244 | * @mode_support: MDIO modes supported. If %MDIO_SUPPORTS_C22 is set then | ||
245 | * MII register access will be passed through with @devad = | ||
246 | * %MDIO_DEVAD_NONE. If %MDIO_EMULATE_C22 is set then access to | ||
247 | * commonly used clause 22 registers will be translated into | ||
248 | * clause 45 registers. | ||
249 | * @dev: Net device structure | ||
250 | * @mdio_read: Register read function; returns value or negative error code | ||
251 | * @mdio_write: Register write function; returns 0 or negative error code | ||
252 | */ | ||
253 | struct mdio_if_info { | ||
254 | int prtad; | ||
255 | u32 __bitwise mmds; | ||
256 | unsigned mode_support; | ||
257 | |||
258 | struct net_device *dev; | ||
259 | int (*mdio_read)(struct net_device *dev, int prtad, int devad, | ||
260 | u16 addr); | ||
261 | int (*mdio_write)(struct net_device *dev, int prtad, int devad, | ||
262 | u16 addr, u16 val); | ||
263 | }; | ||
264 | |||
265 | #define MDIO_PRTAD_NONE (-1) | ||
266 | #define MDIO_DEVAD_NONE (-1) | ||
267 | #define MDIO_SUPPORTS_C22 1 | ||
268 | #define MDIO_SUPPORTS_C45 2 | ||
269 | #define MDIO_EMULATE_C22 4 | ||
270 | |||
271 | struct ethtool_cmd; | ||
272 | struct ethtool_pauseparam; | ||
273 | extern int mdio45_probe(struct mdio_if_info *mdio, int prtad); | ||
274 | extern int mdio_set_flag(const struct mdio_if_info *mdio, | ||
275 | int prtad, int devad, u16 addr, int mask, | ||
276 | bool sense); | ||
277 | extern int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmds); | ||
278 | extern int mdio45_nway_restart(const struct mdio_if_info *mdio); | ||
279 | extern void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio, | ||
280 | struct ethtool_cmd *ecmd, | ||
281 | u32 npage_adv, u32 npage_lpa); | ||
282 | |||
283 | /** | ||
284 | * mdio45_ethtool_gset - get settings for ETHTOOL_GSET | ||
285 | * @mdio: MDIO interface | ||
286 | * @ecmd: Ethtool request structure | ||
287 | * | ||
288 | * Since the CSRs for auto-negotiation using next pages are not fully | ||
289 | * standardised, this function does not attempt to decode them. Use | ||
290 | * mdio45_ethtool_gset_npage() to specify advertisement bits from next | ||
291 | * pages. | ||
292 | */ | ||
293 | static inline void mdio45_ethtool_gset(const struct mdio_if_info *mdio, | ||
294 | struct ethtool_cmd *ecmd) | ||
295 | { | ||
296 | mdio45_ethtool_gset_npage(mdio, ecmd, 0, 0); | ||
297 | } | ||
298 | |||
299 | extern int mdio_mii_ioctl(const struct mdio_if_info *mdio, | ||
300 | struct mii_ioctl_data *mii_data, int cmd); | ||
301 | |||
302 | #endif /* __KERNEL__ */ | ||
237 | #endif /* __LINUX_MDIO_H__ */ | 303 | #endif /* __LINUX_MDIO_H__ */ |