diff options
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r-- | include/linux/phy.h | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index 5e43ae751412..02df20f085fe 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
@@ -39,7 +39,8 @@ | |||
39 | SUPPORTED_1000baseT_Half | \ | 39 | SUPPORTED_1000baseT_Half | \ |
40 | SUPPORTED_1000baseT_Full) | 40 | SUPPORTED_1000baseT_Full) |
41 | 41 | ||
42 | /* Set phydev->irq to PHY_POLL if interrupts are not supported, | 42 | /* |
43 | * Set phydev->irq to PHY_POLL if interrupts are not supported, | ||
43 | * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if | 44 | * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if |
44 | * the attached driver handles the interrupt | 45 | * the attached driver handles the interrupt |
45 | */ | 46 | */ |
@@ -63,8 +64,6 @@ typedef enum { | |||
63 | PHY_INTERFACE_MODE_RTBI | 64 | PHY_INTERFACE_MODE_RTBI |
64 | } phy_interface_t; | 65 | } phy_interface_t; |
65 | 66 | ||
66 | #define MII_BUS_MAX 4 | ||
67 | |||
68 | 67 | ||
69 | #define PHY_INIT_TIMEOUT 100000 | 68 | #define PHY_INIT_TIMEOUT 100000 |
70 | #define PHY_STATE_TIME 1 | 69 | #define PHY_STATE_TIME 1 |
@@ -74,20 +73,30 @@ typedef enum { | |||
74 | #define PHY_MAX_ADDR 32 | 73 | #define PHY_MAX_ADDR 32 |
75 | 74 | ||
76 | /* Used when trying to connect to a specific phy (mii bus id:phy device id) */ | 75 | /* Used when trying to connect to a specific phy (mii bus id:phy device id) */ |
77 | #define PHY_ID_FMT "%x:%02x" | 76 | #define PHY_ID_FMT "%s:%02x" |
77 | |||
78 | /* | ||
79 | * Need to be a little smaller than phydev->dev.bus_id to leave room | ||
80 | * for the ":%02x" | ||
81 | */ | ||
82 | #define MII_BUS_ID_SIZE (BUS_ID_SIZE - 3) | ||
78 | 83 | ||
79 | /* The Bus class for PHYs. Devices which provide access to | 84 | /* |
80 | * PHYs should register using this structure */ | 85 | * The Bus class for PHYs. Devices which provide access to |
86 | * PHYs should register using this structure | ||
87 | */ | ||
81 | struct mii_bus { | 88 | struct mii_bus { |
82 | const char *name; | 89 | const char *name; |
83 | int id; | 90 | char id[MII_BUS_ID_SIZE]; |
84 | void *priv; | 91 | void *priv; |
85 | int (*read)(struct mii_bus *bus, int phy_id, int regnum); | 92 | int (*read)(struct mii_bus *bus, int phy_id, int regnum); |
86 | int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val); | 93 | int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val); |
87 | int (*reset)(struct mii_bus *bus); | 94 | int (*reset)(struct mii_bus *bus); |
88 | 95 | ||
89 | /* A lock to ensure that only one thing can read/write | 96 | /* |
90 | * the MDIO bus at a time */ | 97 | * A lock to ensure that only one thing can read/write |
98 | * the MDIO bus at a time | ||
99 | */ | ||
91 | struct mutex mdio_lock; | 100 | struct mutex mdio_lock; |
92 | 101 | ||
93 | struct device *dev; | 102 | struct device *dev; |
@@ -98,8 +107,10 @@ struct mii_bus { | |||
98 | /* Phy addresses to be ignored when probing */ | 107 | /* Phy addresses to be ignored when probing */ |
99 | u32 phy_mask; | 108 | u32 phy_mask; |
100 | 109 | ||
101 | /* Pointer to an array of interrupts, each PHY's | 110 | /* |
102 | * interrupt at the index matching its address */ | 111 | * Pointer to an array of interrupts, each PHY's |
112 | * interrupt at the index matching its address | ||
113 | */ | ||
103 | int *irq; | 114 | int *irq; |
104 | }; | 115 | }; |
105 | 116 | ||
@@ -251,7 +262,8 @@ struct phy_device { | |||
251 | /* Bus address of the PHY (0-32) */ | 262 | /* Bus address of the PHY (0-32) */ |
252 | int addr; | 263 | int addr; |
253 | 264 | ||
254 | /* forced speed & duplex (no autoneg) | 265 | /* |
266 | * forced speed & duplex (no autoneg) | ||
255 | * partner speed & duplex & pause (autoneg) | 267 | * partner speed & duplex & pause (autoneg) |
256 | */ | 268 | */ |
257 | int speed; | 269 | int speed; |
@@ -274,8 +286,10 @@ struct phy_device { | |||
274 | 286 | ||
275 | int link_timeout; | 287 | int link_timeout; |
276 | 288 | ||
277 | /* Interrupt number for this PHY | 289 | /* |
278 | * -1 means no interrupt */ | 290 | * Interrupt number for this PHY |
291 | * -1 means no interrupt | ||
292 | */ | ||
279 | int irq; | 293 | int irq; |
280 | 294 | ||
281 | /* private data pointer */ | 295 | /* private data pointer */ |
@@ -325,22 +339,28 @@ struct phy_driver { | |||
325 | u32 features; | 339 | u32 features; |
326 | u32 flags; | 340 | u32 flags; |
327 | 341 | ||
328 | /* Called to initialize the PHY, | 342 | /* |
329 | * including after a reset */ | 343 | * Called to initialize the PHY, |
344 | * including after a reset | ||
345 | */ | ||
330 | int (*config_init)(struct phy_device *phydev); | 346 | int (*config_init)(struct phy_device *phydev); |
331 | 347 | ||
332 | /* Called during discovery. Used to set | 348 | /* |
333 | * up device-specific structures, if any */ | 349 | * Called during discovery. Used to set |
350 | * up device-specific structures, if any | ||
351 | */ | ||
334 | int (*probe)(struct phy_device *phydev); | 352 | int (*probe)(struct phy_device *phydev); |
335 | 353 | ||
336 | /* PHY Power Management */ | 354 | /* PHY Power Management */ |
337 | int (*suspend)(struct phy_device *phydev); | 355 | int (*suspend)(struct phy_device *phydev); |
338 | int (*resume)(struct phy_device *phydev); | 356 | int (*resume)(struct phy_device *phydev); |
339 | 357 | ||
340 | /* Configures the advertisement and resets | 358 | /* |
359 | * Configures the advertisement and resets | ||
341 | * autonegotiation if phydev->autoneg is on, | 360 | * autonegotiation if phydev->autoneg is on, |
342 | * forces the speed to the current settings in phydev | 361 | * forces the speed to the current settings in phydev |
343 | * if phydev->autoneg is off */ | 362 | * if phydev->autoneg is off |
363 | */ | ||
344 | int (*config_aneg)(struct phy_device *phydev); | 364 | int (*config_aneg)(struct phy_device *phydev); |
345 | 365 | ||
346 | /* Determines the negotiated speed and duplex */ | 366 | /* Determines the negotiated speed and duplex */ |
@@ -359,14 +379,27 @@ struct phy_driver { | |||
359 | }; | 379 | }; |
360 | #define to_phy_driver(d) container_of(d, struct phy_driver, driver) | 380 | #define to_phy_driver(d) container_of(d, struct phy_driver, driver) |
361 | 381 | ||
382 | #define PHY_ANY_ID "MATCH ANY PHY" | ||
383 | #define PHY_ANY_UID 0xffffffff | ||
384 | |||
385 | /* A Structure for boards to register fixups with the PHY Lib */ | ||
386 | struct phy_fixup { | ||
387 | struct list_head list; | ||
388 | char bus_id[BUS_ID_SIZE]; | ||
389 | u32 phy_uid; | ||
390 | u32 phy_uid_mask; | ||
391 | int (*run)(struct phy_device *phydev); | ||
392 | }; | ||
393 | |||
362 | int phy_read(struct phy_device *phydev, u16 regnum); | 394 | int phy_read(struct phy_device *phydev, u16 regnum); |
363 | int phy_write(struct phy_device *phydev, u16 regnum, u16 val); | 395 | int phy_write(struct phy_device *phydev, u16 regnum, u16 val); |
396 | int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); | ||
364 | struct phy_device* get_phy_device(struct mii_bus *bus, int addr); | 397 | struct phy_device* get_phy_device(struct mii_bus *bus, int addr); |
365 | int phy_clear_interrupt(struct phy_device *phydev); | 398 | int phy_clear_interrupt(struct phy_device *phydev); |
366 | int phy_config_interrupt(struct phy_device *phydev, u32 interrupts); | 399 | int phy_config_interrupt(struct phy_device *phydev, u32 interrupts); |
367 | struct phy_device * phy_attach(struct net_device *dev, | 400 | struct phy_device * phy_attach(struct net_device *dev, |
368 | const char *phy_id, u32 flags, phy_interface_t interface); | 401 | const char *bus_id, u32 flags, phy_interface_t interface); |
369 | struct phy_device * phy_connect(struct net_device *dev, const char *phy_id, | 402 | struct phy_device * phy_connect(struct net_device *dev, const char *bus_id, |
370 | void (*handler)(struct net_device *), u32 flags, | 403 | void (*handler)(struct net_device *), u32 flags, |
371 | phy_interface_t interface); | 404 | phy_interface_t interface); |
372 | void phy_disconnect(struct phy_device *phydev); | 405 | void phy_disconnect(struct phy_device *phydev); |
@@ -406,5 +439,13 @@ void phy_print_status(struct phy_device *phydev); | |||
406 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); | 439 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); |
407 | void phy_device_free(struct phy_device *phydev); | 440 | void phy_device_free(struct phy_device *phydev); |
408 | 441 | ||
442 | int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, | ||
443 | int (*run)(struct phy_device *)); | ||
444 | int phy_register_fixup_for_id(const char *bus_id, | ||
445 | int (*run)(struct phy_device *)); | ||
446 | int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask, | ||
447 | int (*run)(struct phy_device *)); | ||
448 | int phy_scan_fixups(struct phy_device *phydev); | ||
449 | |||
409 | extern struct bus_type mdio_bus_type; | 450 | extern struct bus_type mdio_bus_type; |
410 | #endif /* __PHY_H */ | 451 | #endif /* __PHY_H */ |