aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/phy.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r--include/linux/phy.h52
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
125struct mii_bus *mdiobus_alloc(void);
126int mdiobus_register(struct mii_bus *bus);
127void mdiobus_unregister(struct mii_bus *bus);
128void mdiobus_free(struct mii_bus *bus);
129struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
130int mdiobus_read(struct mii_bus *bus, int addr, u16 regnum);
131int 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
394int phy_read(struct phy_device *phydev, u16 regnum); 411/**
395int 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 */
420static 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 */
435static 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
396int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); 440int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
397struct phy_device* get_phy_device(struct mii_bus *bus, int addr); 441struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
398int phy_clear_interrupt(struct phy_device *phydev); 442int phy_clear_interrupt(struct phy_device *phydev);
@@ -408,8 +452,6 @@ void phy_start(struct phy_device *phydev);
408void phy_stop(struct phy_device *phydev); 452void phy_stop(struct phy_device *phydev);
409int phy_start_aneg(struct phy_device *phydev); 453int phy_start_aneg(struct phy_device *phydev);
410 454
411int mdiobus_register(struct mii_bus *bus);
412void mdiobus_unregister(struct mii_bus *bus);
413void phy_sanitize_settings(struct phy_device *phydev); 455void phy_sanitize_settings(struct phy_device *phydev);
414int phy_stop_interrupts(struct phy_device *phydev); 456int phy_stop_interrupts(struct phy_device *phydev);
415int phy_enable_interrupts(struct phy_device *phydev); 457int phy_enable_interrupts(struct phy_device *phydev);