1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/mdio.h: definitions for MDIO (clause 45) transceivers
4 * Copyright 2006-2009 Solarflare Communications Inc.
6 #ifndef __LINUX_MDIO_H__
7 #define __LINUX_MDIO_H__
9 #include <uapi/linux/mdio.h>
10 #include <linux/bitfield.h>
11 #include <linux/mod_devicetable.h>
17 /* Multiple levels of nesting are possible. However typically this is
18 * limited to nested DSA like layer, a MUX layer, and the normal
19 * user. Instead of trying to handle the general case, just define
22 enum mdio_mutex_lock_class {
32 char modalias[MDIO_NAME_SIZE];
34 int (*bus_match)(struct device *dev, struct device_driver *drv);
35 void (*device_free)(struct mdio_device *mdiodev);
36 void (*device_remove)(struct mdio_device *mdiodev);
38 /* Bus address of the MDIO device (0-31) */
41 struct gpio_desc *reset_gpio;
42 struct reset_control *reset_ctrl;
43 unsigned int reset_assert_delay;
44 unsigned int reset_deassert_delay;
47 static inline struct mdio_device *to_mdio_device(const struct device *dev)
49 return container_of(dev, struct mdio_device, dev);
52 /* struct mdio_driver_common: Common to all MDIO drivers */
53 struct mdio_driver_common {
54 struct device_driver driver;
57 #define MDIO_DEVICE_FLAG_PHY 1
59 static inline struct mdio_driver_common *
60 to_mdio_common_driver(const struct device_driver *driver)
62 return container_of(driver, struct mdio_driver_common, driver);
65 /* struct mdio_driver: Generic MDIO driver */
67 struct mdio_driver_common mdiodrv;
70 * Called during discovery. Used to set
71 * up device-specific structures, if any
73 int (*probe)(struct mdio_device *mdiodev);
75 /* Clears up any memory if needed */
76 void (*remove)(struct mdio_device *mdiodev);
78 /* Quiesces the device on system shutdown, turns off interrupts etc */
79 void (*shutdown)(struct mdio_device *mdiodev);
82 static inline struct mdio_driver *
83 to_mdio_driver(const struct device_driver *driver)
85 return container_of(to_mdio_common_driver(driver), struct mdio_driver,
89 /* device driver data */
90 static inline void mdiodev_set_drvdata(struct mdio_device *mdio, void *data)
92 dev_set_drvdata(&mdio->dev, data);
95 static inline void *mdiodev_get_drvdata(struct mdio_device *mdio)
97 return dev_get_drvdata(&mdio->dev);
100 void mdio_device_free(struct mdio_device *mdiodev);
101 struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr);
102 int mdio_device_register(struct mdio_device *mdiodev);
103 void mdio_device_remove(struct mdio_device *mdiodev);
104 void mdio_device_reset(struct mdio_device *mdiodev, int value);
105 int mdio_driver_register(struct mdio_driver *drv);
106 void mdio_driver_unregister(struct mdio_driver *drv);
107 int mdio_device_bus_match(struct device *dev, struct device_driver *drv);
109 static inline void mdio_device_get(struct mdio_device *mdiodev)
111 get_device(&mdiodev->dev);
114 static inline void mdio_device_put(struct mdio_device *mdiodev)
116 mdio_device_free(mdiodev);
119 static inline bool mdio_phy_id_is_c45(int phy_id)
121 return (phy_id & MDIO_PHY_ID_C45) && !(phy_id & ~MDIO_PHY_ID_C45_MASK);
124 static inline __u16 mdio_phy_id_prtad(int phy_id)
126 return (phy_id & MDIO_PHY_ID_PRTAD) >> 5;
129 static inline __u16 mdio_phy_id_devad(int phy_id)
131 return phy_id & MDIO_PHY_ID_DEVAD;
135 * struct mdio_if_info - Ethernet controller MDIO interface
136 * @prtad: PRTAD of the PHY (%MDIO_PRTAD_NONE if not present/unknown)
137 * @mmds: Mask of MMDs expected to be present in the PHY. This must be
138 * non-zero unless @prtad = %MDIO_PRTAD_NONE.
139 * @mode_support: MDIO modes supported. If %MDIO_SUPPORTS_C22 is set then
140 * MII register access will be passed through with @devad =
141 * %MDIO_DEVAD_NONE. If %MDIO_EMULATE_C22 is set then access to
142 * commonly used clause 22 registers will be translated into
143 * clause 45 registers.
144 * @dev: Net device structure
145 * @mdio_read: Register read function; returns value or negative error code
146 * @mdio_write: Register write function; returns 0 or negative error code
148 struct mdio_if_info {
151 unsigned mode_support;
153 struct net_device *dev;
154 int (*mdio_read)(struct net_device *dev, int prtad, int devad,
156 int (*mdio_write)(struct net_device *dev, int prtad, int devad,
160 #define MDIO_PRTAD_NONE (-1)
161 #define MDIO_DEVAD_NONE (-1)
162 #define MDIO_SUPPORTS_C22 1
163 #define MDIO_SUPPORTS_C45 2
164 #define MDIO_EMULATE_C22 4
167 struct ethtool_pauseparam;
168 extern int mdio45_probe(struct mdio_if_info *mdio, int prtad);
169 extern int mdio_set_flag(const struct mdio_if_info *mdio,
170 int prtad, int devad, u16 addr, int mask,
172 extern int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmds);
173 extern int mdio45_nway_restart(const struct mdio_if_info *mdio);
174 extern void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
175 struct ethtool_cmd *ecmd,
176 u32 npage_adv, u32 npage_lpa);
178 mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
179 struct ethtool_link_ksettings *cmd,
180 u32 npage_adv, u32 npage_lpa);
183 * mdio45_ethtool_gset - get settings for ETHTOOL_GSET
184 * @mdio: MDIO interface
185 * @ecmd: Ethtool request structure
187 * Since the CSRs for auto-negotiation using next pages are not fully
188 * standardised, this function does not attempt to decode them. Use
189 * mdio45_ethtool_gset_npage() to specify advertisement bits from next
192 static inline void mdio45_ethtool_gset(const struct mdio_if_info *mdio,
193 struct ethtool_cmd *ecmd)
195 mdio45_ethtool_gset_npage(mdio, ecmd, 0, 0);
199 * mdio45_ethtool_ksettings_get - get settings for ETHTOOL_GLINKSETTINGS
200 * @mdio: MDIO interface
201 * @cmd: Ethtool request structure
203 * Since the CSRs for auto-negotiation using next pages are not fully
204 * standardised, this function does not attempt to decode them. Use
205 * mdio45_ethtool_ksettings_get_npage() to specify advertisement bits
209 mdio45_ethtool_ksettings_get(const struct mdio_if_info *mdio,
210 struct ethtool_link_ksettings *cmd)
212 mdio45_ethtool_ksettings_get_npage(mdio, cmd, 0, 0);
215 extern int mdio_mii_ioctl(const struct mdio_if_info *mdio,
216 struct mii_ioctl_data *mii_data, int cmd);
219 * mmd_eee_cap_to_ethtool_sup_t
220 * @eee_cap: value of the MMD EEE Capability register
222 * A small helper function that translates MMD EEE Capability (3.20) bits
223 * to ethtool supported settings.
225 static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap)
229 if (eee_cap & MDIO_EEE_100TX)
230 supported |= SUPPORTED_100baseT_Full;
231 if (eee_cap & MDIO_EEE_1000T)
232 supported |= SUPPORTED_1000baseT_Full;
233 if (eee_cap & MDIO_EEE_10GT)
234 supported |= SUPPORTED_10000baseT_Full;
235 if (eee_cap & MDIO_EEE_1000KX)
236 supported |= SUPPORTED_1000baseKX_Full;
237 if (eee_cap & MDIO_EEE_10GKX4)
238 supported |= SUPPORTED_10000baseKX4_Full;
239 if (eee_cap & MDIO_EEE_10GKR)
240 supported |= SUPPORTED_10000baseKR_Full;
246 * mmd_eee_adv_to_ethtool_adv_t
247 * @eee_adv: value of the MMD EEE Advertisement/Link Partner Ability registers
249 * A small helper function that translates the MMD EEE Advertisment (7.60)
250 * and MMD EEE Link Partner Ability (7.61) bits to ethtool advertisement
253 static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
257 if (eee_adv & MDIO_EEE_100TX)
258 adv |= ADVERTISED_100baseT_Full;
259 if (eee_adv & MDIO_EEE_1000T)
260 adv |= ADVERTISED_1000baseT_Full;
261 if (eee_adv & MDIO_EEE_10GT)
262 adv |= ADVERTISED_10000baseT_Full;
263 if (eee_adv & MDIO_EEE_1000KX)
264 adv |= ADVERTISED_1000baseKX_Full;
265 if (eee_adv & MDIO_EEE_10GKX4)
266 adv |= ADVERTISED_10000baseKX4_Full;
267 if (eee_adv & MDIO_EEE_10GKR)
268 adv |= ADVERTISED_10000baseKR_Full;
274 * ethtool_adv_to_mmd_eee_adv_t
275 * @adv: the ethtool advertisement settings
277 * A small helper function that translates ethtool advertisement settings
278 * to EEE advertisements for the MMD EEE Advertisement (7.60) and
279 * MMD EEE Link Partner Ability (7.61) registers.
281 static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv)
285 if (adv & ADVERTISED_100baseT_Full)
286 reg |= MDIO_EEE_100TX;
287 if (adv & ADVERTISED_1000baseT_Full)
288 reg |= MDIO_EEE_1000T;
289 if (adv & ADVERTISED_10000baseT_Full)
290 reg |= MDIO_EEE_10GT;
291 if (adv & ADVERTISED_1000baseKX_Full)
292 reg |= MDIO_EEE_1000KX;
293 if (adv & ADVERTISED_10000baseKX4_Full)
294 reg |= MDIO_EEE_10GKX4;
295 if (adv & ADVERTISED_10000baseKR_Full)
296 reg |= MDIO_EEE_10GKR;
302 * linkmode_adv_to_mii_10gbt_adv_t
303 * @advertising: the linkmode advertisement settings
305 * A small helper function that translates linkmode advertisement
306 * settings to phy autonegotiation advertisements for the C45
307 * 10GBASE-T AN CONTROL (7.32) register.
309 static inline u32 linkmode_adv_to_mii_10gbt_adv_t(unsigned long *advertising)
313 if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
315 result |= MDIO_AN_10GBT_CTRL_ADV2_5G;
316 if (linkmode_test_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
318 result |= MDIO_AN_10GBT_CTRL_ADV5G;
319 if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
321 result |= MDIO_AN_10GBT_CTRL_ADV10G;
327 * mii_10gbt_stat_mod_linkmode_lpa_t
328 * @advertising: target the linkmode advertisement settings
329 * @lpa: value of the C45 10GBASE-T AN STATUS register
331 * A small helper function that translates C45 10GBASE-T AN STATUS register bits
332 * to linkmode advertisement settings. Other bits in advertising aren't changed.
334 static inline void mii_10gbt_stat_mod_linkmode_lpa_t(unsigned long *advertising,
337 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
338 advertising, lpa & MDIO_AN_10GBT_STAT_LP2_5G);
339 linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
340 advertising, lpa & MDIO_AN_10GBT_STAT_LP5G);
341 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
342 advertising, lpa & MDIO_AN_10GBT_STAT_LP10G);
346 * mii_t1_adv_l_mod_linkmode_t
347 * @advertising: target the linkmode advertisement settings
348 * @lpa: value of the BASE-T1 Autonegotiation Advertisement [15:0] Register
350 * A small helper function that translates BASE-T1 Autonegotiation
351 * Advertisement [15:0] Register bits to linkmode advertisement settings.
352 * Other bits in advertising aren't changed.
354 static inline void mii_t1_adv_l_mod_linkmode_t(unsigned long *advertising, u32 lpa)
356 linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising,
357 lpa & MDIO_AN_T1_ADV_L_PAUSE_CAP);
358 linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising,
359 lpa & MDIO_AN_T1_ADV_L_PAUSE_ASYM);
363 * mii_t1_adv_m_mod_linkmode_t
364 * @advertising: target the linkmode advertisement settings
365 * @lpa: value of the BASE-T1 Autonegotiation Advertisement [31:16] Register
367 * A small helper function that translates BASE-T1 Autonegotiation
368 * Advertisement [31:16] Register bits to linkmode advertisement settings.
369 * Other bits in advertising aren't changed.
371 static inline void mii_t1_adv_m_mod_linkmode_t(unsigned long *advertising, u32 lpa)
373 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,
374 advertising, lpa & MDIO_AN_T1_ADV_M_B10L);
378 * linkmode_adv_to_mii_t1_adv_l_t
379 * @advertising: the linkmode advertisement settings
381 * A small helper function that translates linkmode advertisement
382 * settings to phy autonegotiation advertisements for the
383 * BASE-T1 Autonegotiation Advertisement [15:0] Register.
385 static inline u32 linkmode_adv_to_mii_t1_adv_l_t(unsigned long *advertising)
389 if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising))
390 result |= MDIO_AN_T1_ADV_L_PAUSE_CAP;
391 if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising))
392 result |= MDIO_AN_T1_ADV_L_PAUSE_ASYM;
398 * linkmode_adv_to_mii_t1_adv_m_t
399 * @advertising: the linkmode advertisement settings
401 * A small helper function that translates linkmode advertisement
402 * settings to phy autonegotiation advertisements for the
403 * BASE-T1 Autonegotiation Advertisement [31:16] Register.
405 static inline u32 linkmode_adv_to_mii_t1_adv_m_t(unsigned long *advertising)
409 if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, advertising))
410 result |= MDIO_AN_T1_ADV_M_B10L;
416 * mii_eee_cap1_mod_linkmode_t()
417 * @adv: target the linkmode advertisement settings
418 * @val: register value
420 * A function that translates value of following registers to the linkmode:
421 * IEEE 802.3-2018 45.2.3.10 "EEE control and capability 1" register (3.20)
422 * IEEE 802.3-2018 45.2.7.13 "EEE advertisement 1" register (7.60)
423 * IEEE 802.3-2018 45.2.7.14 "EEE link partner ability 1" register (7.61)
425 static inline void mii_eee_cap1_mod_linkmode_t(unsigned long *adv, u32 val)
427 linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
428 adv, val & MDIO_EEE_100TX);
429 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
430 adv, val & MDIO_EEE_1000T);
431 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
432 adv, val & MDIO_EEE_10GT);
433 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
434 adv, val & MDIO_EEE_1000KX);
435 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT,
436 adv, val & MDIO_EEE_10GKX4);
437 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT,
438 adv, val & MDIO_EEE_10GKR);
442 * linkmode_to_mii_eee_cap1_t()
443 * @adv: the linkmode advertisement settings
445 * A function that translates linkmode to value for IEEE 802.3-2018 45.2.7.13
446 * "EEE advertisement 1" register (7.60)
448 static inline u32 linkmode_to_mii_eee_cap1_t(unsigned long *adv)
452 if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, adv))
453 result |= MDIO_EEE_100TX;
454 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, adv))
455 result |= MDIO_EEE_1000T;
456 if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, adv))
457 result |= MDIO_EEE_10GT;
458 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, adv))
459 result |= MDIO_EEE_1000KX;
460 if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, adv))
461 result |= MDIO_EEE_10GKX4;
462 if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, adv))
463 result |= MDIO_EEE_10GKR;
469 * mii_10base_t1_adv_mod_linkmode_t()
470 * @adv: linkmode advertisement settings
471 * @val: register value
473 * A function that translates IEEE 802.3cg-2019 45.2.7.26 "10BASE-T1 AN status"
474 * register (7.527) value to the linkmode.
476 static inline void mii_10base_t1_adv_mod_linkmode_t(unsigned long *adv, u16 val)
478 linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,
479 adv, val & MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L);
483 * linkmode_adv_to_mii_10base_t1_t()
484 * @adv: linkmode advertisement settings
486 * A function that translates the linkmode to IEEE 802.3cg-2019 45.2.7.25
487 * "10BASE-T1 AN control" register (7.526) value.
489 static inline u32 linkmode_adv_to_mii_10base_t1_t(unsigned long *adv)
493 if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, adv))
494 result |= MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L;
500 * mii_c73_mod_linkmode - convert a Clause 73 advertisement to linkmodes
501 * @adv: linkmode advertisement setting
502 * @lpa: array of three u16s containing the advertisement
504 * Convert an IEEE 802.3 Clause 73 advertisement to ethtool link modes.
506 static inline void mii_c73_mod_linkmode(unsigned long *adv, u16 *lpa)
508 linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT,
509 adv, lpa[0] & MDIO_AN_C73_0_PAUSE);
510 linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
511 adv, lpa[0] & MDIO_AN_C73_0_ASM_DIR);
512 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
513 adv, lpa[1] & MDIO_AN_C73_1_1000BASE_KX);
514 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT,
515 adv, lpa[1] & MDIO_AN_C73_1_10GBASE_KX4);
516 linkmode_mod_bit(ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT,
517 adv, lpa[1] & MDIO_AN_C73_1_40GBASE_KR4);
518 linkmode_mod_bit(ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT,
519 adv, lpa[1] & MDIO_AN_C73_1_40GBASE_CR4);
520 /* 100GBASE_CR10 and 100GBASE_KP4 not implemented */
521 linkmode_mod_bit(ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT,
522 adv, lpa[1] & MDIO_AN_C73_1_100GBASE_KR4);
523 linkmode_mod_bit(ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT,
524 adv, lpa[1] & MDIO_AN_C73_1_100GBASE_CR4);
525 /* 25GBASE_R_S not implemented */
526 /* The 25GBASE_R bit can be used for 25Gbase KR or CR modes */
527 linkmode_mod_bit(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT,
528 adv, lpa[1] & MDIO_AN_C73_1_25GBASE_R);
529 linkmode_mod_bit(ETHTOOL_LINK_MODE_25000baseCR_Full_BIT,
530 adv, lpa[1] & MDIO_AN_C73_1_25GBASE_R);
531 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT,
532 adv, lpa[1] & MDIO_AN_C73_1_10GBASE_KR);
533 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT,
534 adv, lpa[2] & MDIO_AN_C73_2_2500BASE_KX);
535 /* 5GBASE_KR not implemented */
538 int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
539 int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
540 int __mdiobus_modify(struct mii_bus *bus, int addr, u32 regnum, u16 mask,
542 int __mdiobus_modify_changed(struct mii_bus *bus, int addr, u32 regnum,
545 int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
546 int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum);
547 int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
548 int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val);
549 int mdiobus_modify(struct mii_bus *bus, int addr, u32 regnum, u16 mask,
551 int mdiobus_modify_changed(struct mii_bus *bus, int addr, u32 regnum,
553 int __mdiobus_c45_read(struct mii_bus *bus, int addr, int devad, u32 regnum);
554 int mdiobus_c45_read(struct mii_bus *bus, int addr, int devad, u32 regnum);
555 int mdiobus_c45_read_nested(struct mii_bus *bus, int addr, int devad,
557 int __mdiobus_c45_write(struct mii_bus *bus, int addr, int devad, u32 regnum,
559 int mdiobus_c45_write(struct mii_bus *bus, int addr, int devad, u32 regnum,
561 int mdiobus_c45_write_nested(struct mii_bus *bus, int addr, int devad,
562 u32 regnum, u16 val);
563 int mdiobus_c45_modify(struct mii_bus *bus, int addr, int devad, u32 regnum,
566 int mdiobus_c45_modify_changed(struct mii_bus *bus, int addr, int devad,
567 u32 regnum, u16 mask, u16 set);
569 static inline int __mdiodev_read(struct mdio_device *mdiodev, u32 regnum)
571 return __mdiobus_read(mdiodev->bus, mdiodev->addr, regnum);
574 static inline int __mdiodev_write(struct mdio_device *mdiodev, u32 regnum,
577 return __mdiobus_write(mdiodev->bus, mdiodev->addr, regnum, val);
580 static inline int __mdiodev_modify(struct mdio_device *mdiodev, u32 regnum,
583 return __mdiobus_modify(mdiodev->bus, mdiodev->addr, regnum, mask, set);
586 static inline int __mdiodev_modify_changed(struct mdio_device *mdiodev,
587 u32 regnum, u16 mask, u16 set)
589 return __mdiobus_modify_changed(mdiodev->bus, mdiodev->addr, regnum,
593 static inline int mdiodev_read(struct mdio_device *mdiodev, u32 regnum)
595 return mdiobus_read(mdiodev->bus, mdiodev->addr, regnum);
598 static inline int mdiodev_write(struct mdio_device *mdiodev, u32 regnum,
601 return mdiobus_write(mdiodev->bus, mdiodev->addr, regnum, val);
604 static inline int mdiodev_modify(struct mdio_device *mdiodev, u32 regnum,
607 return mdiobus_modify(mdiodev->bus, mdiodev->addr, regnum, mask, set);
610 static inline int mdiodev_modify_changed(struct mdio_device *mdiodev,
611 u32 regnum, u16 mask, u16 set)
613 return mdiobus_modify_changed(mdiodev->bus, mdiodev->addr, regnum,
617 static inline int mdiodev_c45_modify(struct mdio_device *mdiodev, int devad,
618 u32 regnum, u16 mask, u16 set)
620 return mdiobus_c45_modify(mdiodev->bus, mdiodev->addr, devad, regnum,
624 static inline int mdiodev_c45_modify_changed(struct mdio_device *mdiodev,
625 int devad, u32 regnum, u16 mask,
628 return mdiobus_c45_modify_changed(mdiodev->bus, mdiodev->addr, devad,
632 static inline int mdiodev_c45_read(struct mdio_device *mdiodev, int devad,
635 return mdiobus_c45_read(mdiodev->bus, mdiodev->addr, devad, regnum);
638 static inline int mdiodev_c45_write(struct mdio_device *mdiodev, u32 devad,
641 return mdiobus_c45_write(mdiodev->bus, mdiodev->addr, devad, regnum,
645 int mdiobus_register_device(struct mdio_device *mdiodev);
646 int mdiobus_unregister_device(struct mdio_device *mdiodev);
647 bool mdiobus_is_registered_device(struct mii_bus *bus, int addr);
648 struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr);
651 * mdio_module_driver() - Helper macro for registering mdio drivers
652 * @_mdio_driver: driver to register
654 * Helper macro for MDIO drivers which do not do anything special in module
655 * init/exit. Each module may only use this macro once, and calling it
656 * replaces module_init() and module_exit().
658 #define mdio_module_driver(_mdio_driver) \
659 static int __init mdio_module_init(void) \
661 return mdio_driver_register(&_mdio_driver); \
663 module_init(mdio_module_init); \
664 static void __exit mdio_module_exit(void) \
666 mdio_driver_unregister(&_mdio_driver); \
668 module_exit(mdio_module_exit)
670 #endif /* __LINUX_MDIO_H__ */