diff options
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r-- | include/linux/phy.h | 116 |
1 files changed, 82 insertions, 34 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index 48a4dc3cb8cf..565188ca328f 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * include/linux/phy.h | ||
3 | * | ||
4 | * Framework and drivers for configuring and reading different PHYs | 2 | * Framework and drivers for configuring and reading different PHYs |
5 | * Based on code in sungem_phy.c and gianfar_phy.c | 3 | * Based on code in sungem_phy.c and gianfar_phy.c |
6 | * | 4 | * |
@@ -27,18 +25,27 @@ | |||
27 | 25 | ||
28 | #include <linux/atomic.h> | 26 | #include <linux/atomic.h> |
29 | 27 | ||
30 | #define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \ | 28 | #define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \ |
31 | SUPPORTED_10baseT_Full | \ | ||
32 | SUPPORTED_100baseT_Half | \ | ||
33 | SUPPORTED_100baseT_Full | \ | ||
34 | SUPPORTED_Autoneg | \ | ||
35 | SUPPORTED_TP | \ | 29 | SUPPORTED_TP | \ |
36 | SUPPORTED_MII) | 30 | SUPPORTED_MII) |
37 | 31 | ||
38 | #define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \ | 32 | #define PHY_10BT_FEATURES (SUPPORTED_10baseT_Half | \ |
39 | SUPPORTED_1000baseT_Half | \ | 33 | SUPPORTED_10baseT_Full) |
34 | |||
35 | #define PHY_100BT_FEATURES (SUPPORTED_100baseT_Half | \ | ||
36 | SUPPORTED_100baseT_Full) | ||
37 | |||
38 | #define PHY_1000BT_FEATURES (SUPPORTED_1000baseT_Half | \ | ||
40 | SUPPORTED_1000baseT_Full) | 39 | SUPPORTED_1000baseT_Full) |
41 | 40 | ||
41 | #define PHY_BASIC_FEATURES (PHY_10BT_FEATURES | \ | ||
42 | PHY_100BT_FEATURES | \ | ||
43 | PHY_DEFAULT_FEATURES) | ||
44 | |||
45 | #define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \ | ||
46 | PHY_1000BT_FEATURES) | ||
47 | |||
48 | |||
42 | /* | 49 | /* |
43 | * Set phydev->irq to PHY_POLL if interrupts are not supported, | 50 | * Set phydev->irq to PHY_POLL if interrupts are not supported, |
44 | * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if | 51 | * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if |
@@ -66,6 +73,7 @@ typedef enum { | |||
66 | PHY_INTERFACE_MODE_RGMII_TXID, | 73 | PHY_INTERFACE_MODE_RGMII_TXID, |
67 | PHY_INTERFACE_MODE_RTBI, | 74 | PHY_INTERFACE_MODE_RTBI, |
68 | PHY_INTERFACE_MODE_SMII, | 75 | PHY_INTERFACE_MODE_SMII, |
76 | PHY_INTERFACE_MODE_XGMII, | ||
69 | } phy_interface_t; | 77 | } phy_interface_t; |
70 | 78 | ||
71 | 79 | ||
@@ -231,7 +239,7 @@ int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); | |||
231 | * - phy_stop moves to HALTED | 239 | * - phy_stop moves to HALTED |
232 | */ | 240 | */ |
233 | enum phy_state { | 241 | enum phy_state { |
234 | PHY_DOWN=0, | 242 | PHY_DOWN = 0, |
235 | PHY_STARTING, | 243 | PHY_STARTING, |
236 | PHY_READY, | 244 | PHY_READY, |
237 | PHY_PENDING, | 245 | PHY_PENDING, |
@@ -275,11 +283,9 @@ struct phy_c45_device_ids { | |||
275 | * attached_dev: The attached enet driver's device instance ptr | 283 | * attached_dev: The attached enet driver's device instance ptr |
276 | * adjust_link: Callback for the enet controller to respond to | 284 | * adjust_link: Callback for the enet controller to respond to |
277 | * changes in the link state. | 285 | * changes in the link state. |
278 | * adjust_state: Callback for the enet driver to respond to | ||
279 | * changes in the state machine. | ||
280 | * | 286 | * |
281 | * speed, duplex, pause, supported, advertising, and | 287 | * speed, duplex, pause, supported, advertising, lp_advertising, |
282 | * autoneg are used like in mii_if_info | 288 | * and autoneg are used like in mii_if_info |
283 | * | 289 | * |
284 | * interrupts currently only supports enabled or disabled, | 290 | * interrupts currently only supports enabled or disabled, |
285 | * but could be changed in the future to support enabling | 291 | * but could be changed in the future to support enabling |
@@ -331,6 +337,7 @@ struct phy_device { | |||
331 | /* See mii.h for more info */ | 337 | /* See mii.h for more info */ |
332 | u32 supported; | 338 | u32 supported; |
333 | u32 advertising; | 339 | u32 advertising; |
340 | u32 lp_advertising; | ||
334 | 341 | ||
335 | int autoneg; | 342 | int autoneg; |
336 | 343 | ||
@@ -356,8 +363,6 @@ struct phy_device { | |||
356 | struct net_device *attached_dev; | 363 | struct net_device *attached_dev; |
357 | 364 | ||
358 | void (*adjust_link)(struct net_device *dev); | 365 | void (*adjust_link)(struct net_device *dev); |
359 | |||
360 | void (*adjust_state)(struct net_device *dev); | ||
361 | }; | 366 | }; |
362 | #define to_phy_device(d) container_of(d, struct phy_device, dev) | 367 | #define to_phy_device(d) container_of(d, struct phy_device, dev) |
363 | 368 | ||
@@ -484,6 +489,24 @@ struct phy_fixup { | |||
484 | }; | 489 | }; |
485 | 490 | ||
486 | /** | 491 | /** |
492 | * phy_read_mmd - Convenience function for reading a register | ||
493 | * from an MMD on a given PHY. | ||
494 | * @phydev: The phy_device struct | ||
495 | * @devad: The MMD to read from | ||
496 | * @regnum: The register on the MMD to read | ||
497 | * | ||
498 | * Same rules as for phy_read(); | ||
499 | */ | ||
500 | static inline int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) | ||
501 | { | ||
502 | if (!phydev->is_c45) | ||
503 | return -EOPNOTSUPP; | ||
504 | |||
505 | return mdiobus_read(phydev->bus, phydev->addr, | ||
506 | MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff)); | ||
507 | } | ||
508 | |||
509 | /** | ||
487 | * phy_read - Convenience function for reading a given PHY register | 510 | * phy_read - Convenience function for reading a given PHY register |
488 | * @phydev: the phy_device struct | 511 | * @phydev: the phy_device struct |
489 | * @regnum: register number to read | 512 | * @regnum: register number to read |
@@ -533,20 +556,46 @@ static inline bool phy_is_internal(struct phy_device *phydev) | |||
533 | return phydev->is_internal; | 556 | return phydev->is_internal; |
534 | } | 557 | } |
535 | 558 | ||
559 | /** | ||
560 | * phy_write_mmd - Convenience function for writing a register | ||
561 | * on an MMD on a given PHY. | ||
562 | * @phydev: The phy_device struct | ||
563 | * @devad: The MMD to read from | ||
564 | * @regnum: The register on the MMD to read | ||
565 | * @val: value to write to @regnum | ||
566 | * | ||
567 | * Same rules as for phy_write(); | ||
568 | */ | ||
569 | static inline int phy_write_mmd(struct phy_device *phydev, int devad, | ||
570 | u32 regnum, u16 val) | ||
571 | { | ||
572 | if (!phydev->is_c45) | ||
573 | return -EOPNOTSUPP; | ||
574 | |||
575 | regnum = MII_ADDR_C45 | ((devad & 0x1f) << 16) | (regnum & 0xffff); | ||
576 | |||
577 | return mdiobus_write(phydev->bus, phydev->addr, regnum, val); | ||
578 | } | ||
579 | |||
536 | struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, | 580 | struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, |
537 | bool is_c45, struct phy_c45_device_ids *c45_ids); | 581 | bool is_c45, |
582 | struct phy_c45_device_ids *c45_ids); | ||
538 | struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); | 583 | struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); |
539 | int phy_device_register(struct phy_device *phy); | 584 | int phy_device_register(struct phy_device *phy); |
540 | int phy_init_hw(struct phy_device *phydev); | 585 | int phy_init_hw(struct phy_device *phydev); |
541 | struct phy_device * phy_attach(struct net_device *dev, | 586 | int phy_suspend(struct phy_device *phydev); |
542 | const char *bus_id, phy_interface_t interface); | 587 | int phy_resume(struct phy_device *phydev); |
588 | struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, | ||
589 | phy_interface_t interface); | ||
543 | struct phy_device *phy_find_first(struct mii_bus *bus); | 590 | struct phy_device *phy_find_first(struct mii_bus *bus); |
591 | int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, | ||
592 | u32 flags, phy_interface_t interface); | ||
544 | int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, | 593 | int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, |
545 | void (*handler)(struct net_device *), | 594 | void (*handler)(struct net_device *), |
546 | phy_interface_t interface); | 595 | phy_interface_t interface); |
547 | struct phy_device * phy_connect(struct net_device *dev, const char *bus_id, | 596 | struct phy_device *phy_connect(struct net_device *dev, const char *bus_id, |
548 | void (*handler)(struct net_device *), | 597 | void (*handler)(struct net_device *), |
549 | phy_interface_t interface); | 598 | phy_interface_t interface); |
550 | void phy_disconnect(struct phy_device *phydev); | 599 | void phy_disconnect(struct phy_device *phydev); |
551 | void phy_detach(struct phy_device *phydev); | 600 | void phy_detach(struct phy_device *phydev); |
552 | void phy_start(struct phy_device *phydev); | 601 | void phy_start(struct phy_device *phydev); |
@@ -555,7 +604,8 @@ int phy_start_aneg(struct phy_device *phydev); | |||
555 | 604 | ||
556 | int phy_stop_interrupts(struct phy_device *phydev); | 605 | int phy_stop_interrupts(struct phy_device *phydev); |
557 | 606 | ||
558 | static inline int phy_read_status(struct phy_device *phydev) { | 607 | static inline int phy_read_status(struct phy_device *phydev) |
608 | { | ||
559 | return phydev->drv->read_status(phydev); | 609 | return phydev->drv->read_status(phydev); |
560 | } | 610 | } |
561 | 611 | ||
@@ -573,31 +623,29 @@ int phy_drivers_register(struct phy_driver *new_driver, int n); | |||
573 | void phy_state_machine(struct work_struct *work); | 623 | void phy_state_machine(struct work_struct *work); |
574 | void phy_change(struct work_struct *work); | 624 | void phy_change(struct work_struct *work); |
575 | void phy_mac_interrupt(struct phy_device *phydev, int new_link); | 625 | void phy_mac_interrupt(struct phy_device *phydev, int new_link); |
576 | void phy_start_machine(struct phy_device *phydev, | 626 | void phy_start_machine(struct phy_device *phydev); |
577 | void (*handler)(struct net_device *)); | ||
578 | void phy_stop_machine(struct phy_device *phydev); | 627 | void phy_stop_machine(struct phy_device *phydev); |
579 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd); | 628 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd); |
580 | int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd); | 629 | int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd); |
581 | int phy_mii_ioctl(struct phy_device *phydev, | 630 | int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd); |
582 | struct ifreq *ifr, int cmd); | ||
583 | int phy_start_interrupts(struct phy_device *phydev); | 631 | int phy_start_interrupts(struct phy_device *phydev); |
584 | void phy_print_status(struct phy_device *phydev); | 632 | void phy_print_status(struct phy_device *phydev); |
585 | void phy_device_free(struct phy_device *phydev); | 633 | void phy_device_free(struct phy_device *phydev); |
586 | 634 | ||
587 | int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, | 635 | int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, |
588 | int (*run)(struct phy_device *)); | 636 | int (*run)(struct phy_device *)); |
589 | int phy_register_fixup_for_id(const char *bus_id, | 637 | int phy_register_fixup_for_id(const char *bus_id, |
590 | int (*run)(struct phy_device *)); | 638 | int (*run)(struct phy_device *)); |
591 | int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask, | 639 | int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask, |
592 | int (*run)(struct phy_device *)); | 640 | int (*run)(struct phy_device *)); |
593 | int phy_scan_fixups(struct phy_device *phydev); | ||
594 | 641 | ||
595 | int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); | 642 | int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); |
596 | int phy_get_eee_err(struct phy_device *phydev); | 643 | int phy_get_eee_err(struct phy_device *phydev); |
597 | int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); | 644 | int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); |
598 | int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data); | 645 | int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data); |
599 | int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); | 646 | int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); |
600 | void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); | 647 | void phy_ethtool_get_wol(struct phy_device *phydev, |
648 | struct ethtool_wolinfo *wol); | ||
601 | 649 | ||
602 | int __init mdio_bus_init(void); | 650 | int __init mdio_bus_init(void); |
603 | void mdio_bus_exit(void); | 651 | void mdio_bus_exit(void); |