diff options
Diffstat (limited to 'include/linux/phy.h')
| -rw-r--r-- | include/linux/phy.h | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index 7224c4099a28..77c4ed60b982 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
| @@ -99,7 +99,14 @@ struct mii_bus { | |||
| 99 | */ | 99 | */ |
| 100 | struct mutex mdio_lock; | 100 | struct mutex mdio_lock; |
| 101 | 101 | ||
| 102 | struct device *dev; | 102 | struct device *parent; |
| 103 | enum { | ||
| 104 | MDIOBUS_ALLOCATED = 1, | ||
| 105 | MDIOBUS_REGISTERED, | ||
| 106 | MDIOBUS_UNREGISTERED, | ||
| 107 | MDIOBUS_RELEASED, | ||
| 108 | } state; | ||
| 109 | struct device dev; | ||
| 103 | 110 | ||
| 104 | /* list of all PHYs on bus */ | 111 | /* list of all PHYs on bus */ |
| 105 | struct phy_device *phy_map[PHY_MAX_ADDR]; | 112 | struct phy_device *phy_map[PHY_MAX_ADDR]; |
| @@ -113,6 +120,16 @@ struct mii_bus { | |||
| 113 | */ | 120 | */ |
| 114 | int *irq; | 121 | int *irq; |
| 115 | }; | 122 | }; |
| 123 | #define to_mii_bus(d) container_of(d, struct mii_bus, dev) | ||
| 124 | |||
| 125 | struct mii_bus *mdiobus_alloc(void); | ||
| 126 | int mdiobus_register(struct mii_bus *bus); | ||
| 127 | void mdiobus_unregister(struct mii_bus *bus); | ||
| 128 | void mdiobus_free(struct mii_bus *bus); | ||
| 129 | struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); | ||
| 130 | int mdiobus_read(struct mii_bus *bus, int addr, u16 regnum); | ||
| 131 | int mdiobus_write(struct mii_bus *bus, int addr, u16 regnum, u16 val); | ||
| 132 | |||
| 116 | 133 | ||
| 117 | #define PHY_INTERRUPT_DISABLED 0x0 | 134 | #define PHY_INTERRUPT_DISABLED 0x0 |
| 118 | #define PHY_INTERRUPT_ENABLED 0x80000000 | 135 | #define PHY_INTERRUPT_ENABLED 0x80000000 |
| @@ -391,8 +408,35 @@ struct phy_fixup { | |||
| 391 | int (*run)(struct phy_device *phydev); | 408 | int (*run)(struct phy_device *phydev); |
| 392 | }; | 409 | }; |
| 393 | 410 | ||
| 394 | int phy_read(struct phy_device *phydev, u16 regnum); | 411 | /** |
| 395 | int phy_write(struct phy_device *phydev, u16 regnum, u16 val); | 412 | * phy_read - Convenience function for reading a given PHY register |
| 413 | * @phydev: the phy_device struct | ||
| 414 | * @regnum: register number to read | ||
| 415 | * | ||
| 416 | * NOTE: MUST NOT be called from interrupt context, | ||
| 417 | * because the bus read/write functions may wait for an interrupt | ||
| 418 | * to conclude the operation. | ||
| 419 | */ | ||
| 420 | static inline int phy_read(struct phy_device *phydev, u16 regnum) | ||
| 421 | { | ||
| 422 | return mdiobus_read(phydev->bus, phydev->addr, regnum); | ||
| 423 | } | ||
| 424 | |||
| 425 | /** | ||
| 426 | * phy_write - Convenience function for writing a given PHY register | ||
| 427 | * @phydev: the phy_device struct | ||
| 428 | * @regnum: register number to write | ||
| 429 | * @val: value to write to @regnum | ||
| 430 | * | ||
| 431 | * NOTE: MUST NOT be called from interrupt context, | ||
| 432 | * because the bus read/write functions may wait for an interrupt | ||
| 433 | * to conclude the operation. | ||
| 434 | */ | ||
| 435 | static inline int phy_write(struct phy_device *phydev, u16 regnum, u16 val) | ||
| 436 | { | ||
| 437 | return mdiobus_write(phydev->bus, phydev->addr, regnum, val); | ||
| 438 | } | ||
| 439 | |||
| 396 | int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); | 440 | int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); |
| 397 | struct phy_device* get_phy_device(struct mii_bus *bus, int addr); | 441 | struct phy_device* get_phy_device(struct mii_bus *bus, int addr); |
| 398 | int phy_clear_interrupt(struct phy_device *phydev); | 442 | int phy_clear_interrupt(struct phy_device *phydev); |
| @@ -408,8 +452,6 @@ void phy_start(struct phy_device *phydev); | |||
| 408 | void phy_stop(struct phy_device *phydev); | 452 | void phy_stop(struct phy_device *phydev); |
| 409 | int phy_start_aneg(struct phy_device *phydev); | 453 | int phy_start_aneg(struct phy_device *phydev); |
| 410 | 454 | ||
| 411 | int mdiobus_register(struct mii_bus *bus); | ||
| 412 | void mdiobus_unregister(struct mii_bus *bus); | ||
| 413 | void phy_sanitize_settings(struct phy_device *phydev); | 455 | void phy_sanitize_settings(struct phy_device *phydev); |
| 414 | int phy_stop_interrupts(struct phy_device *phydev); | 456 | int phy_stop_interrupts(struct phy_device *phydev); |
| 415 | int phy_enable_interrupts(struct phy_device *phydev); | 457 | int phy_enable_interrupts(struct phy_device *phydev); |
