diff options
author | Randy Dunlap <randy.dunlap@oracle.com> | 2007-03-06 05:41:48 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 11:00:57 -0400 |
commit | b3df0da886ffdb3e70c3197f589e959e5f8c9c04 (patch) | |
tree | 7a1f564d31835f31ebab9da370dace187b0aefc6 /drivers/net/phy/phy.c | |
parent | 56e1393f82349d8206fe7feb94db96b065c55e51 (diff) |
phy layer: add kernel-doc + DocBook
Convert function documentation in drivers/net/phy/ to kernel-doc
and add it to DocBook.
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/phy/phy.c')
-rw-r--r-- | drivers/net/phy/phy.c | 188 |
1 files changed, 134 insertions, 54 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index c94a1fb3a4be..a602d06d85ab 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -39,7 +39,9 @@ | |||
39 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
40 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
41 | 41 | ||
42 | /* Convenience function to print out the current phy status | 42 | /** |
43 | * phy_print_status - Convenience function to print out the current phy status | ||
44 | * @phydev: the phy_device struct | ||
43 | */ | 45 | */ |
44 | void phy_print_status(struct phy_device *phydev) | 46 | void phy_print_status(struct phy_device *phydev) |
45 | { | 47 | { |
@@ -55,10 +57,15 @@ void phy_print_status(struct phy_device *phydev) | |||
55 | EXPORT_SYMBOL(phy_print_status); | 57 | EXPORT_SYMBOL(phy_print_status); |
56 | 58 | ||
57 | 59 | ||
58 | /* Convenience functions for reading/writing a given PHY | 60 | /** |
59 | * register. They MUST NOT be called from interrupt context, | 61 | * phy_read - Convenience function for reading a given PHY register |
62 | * @phydev: the phy_device struct | ||
63 | * @regnum: register number to read | ||
64 | * | ||
65 | * NOTE: MUST NOT be called from interrupt context, | ||
60 | * because the bus read/write functions may wait for an interrupt | 66 | * because the bus read/write functions may wait for an interrupt |
61 | * to conclude the operation. */ | 67 | * to conclude the operation. |
68 | */ | ||
62 | int phy_read(struct phy_device *phydev, u16 regnum) | 69 | int phy_read(struct phy_device *phydev, u16 regnum) |
63 | { | 70 | { |
64 | int retval; | 71 | int retval; |
@@ -72,6 +79,16 @@ int phy_read(struct phy_device *phydev, u16 regnum) | |||
72 | } | 79 | } |
73 | EXPORT_SYMBOL(phy_read); | 80 | EXPORT_SYMBOL(phy_read); |
74 | 81 | ||
82 | /** | ||
83 | * phy_write - Convenience function for writing a given PHY register | ||
84 | * @phydev: the phy_device struct | ||
85 | * @regnum: register number to write | ||
86 | * @val: value to write to @regnum | ||
87 | * | ||
88 | * NOTE: MUST NOT be called from interrupt context, | ||
89 | * because the bus read/write functions may wait for an interrupt | ||
90 | * to conclude the operation. | ||
91 | */ | ||
75 | int phy_write(struct phy_device *phydev, u16 regnum, u16 val) | 92 | int phy_write(struct phy_device *phydev, u16 regnum, u16 val) |
76 | { | 93 | { |
77 | int err; | 94 | int err; |
@@ -85,7 +102,15 @@ int phy_write(struct phy_device *phydev, u16 regnum, u16 val) | |||
85 | } | 102 | } |
86 | EXPORT_SYMBOL(phy_write); | 103 | EXPORT_SYMBOL(phy_write); |
87 | 104 | ||
88 | 105 | /** | |
106 | * phy_clear_interrupt - Ack the phy device's interrupt | ||
107 | * @phydev: the phy_device struct | ||
108 | * | ||
109 | * If the @phydev driver has an ack_interrupt function, call it to | ||
110 | * ack and clear the phy device's interrupt. | ||
111 | * | ||
112 | * Returns 0 on success on < 0 on error. | ||
113 | */ | ||
89 | int phy_clear_interrupt(struct phy_device *phydev) | 114 | int phy_clear_interrupt(struct phy_device *phydev) |
90 | { | 115 | { |
91 | int err = 0; | 116 | int err = 0; |
@@ -96,7 +121,13 @@ int phy_clear_interrupt(struct phy_device *phydev) | |||
96 | return err; | 121 | return err; |
97 | } | 122 | } |
98 | 123 | ||
99 | 124 | /** | |
125 | * phy_config_interrupt - configure the PHY device for the requested interrupts | ||
126 | * @phydev: the phy_device struct | ||
127 | * @interrupts: interrupt flags to configure for this @phydev | ||
128 | * | ||
129 | * Returns 0 on success on < 0 on error. | ||
130 | */ | ||
100 | int phy_config_interrupt(struct phy_device *phydev, u32 interrupts) | 131 | int phy_config_interrupt(struct phy_device *phydev, u32 interrupts) |
101 | { | 132 | { |
102 | int err = 0; | 133 | int err = 0; |
@@ -109,9 +140,11 @@ int phy_config_interrupt(struct phy_device *phydev, u32 interrupts) | |||
109 | } | 140 | } |
110 | 141 | ||
111 | 142 | ||
112 | /* phy_aneg_done | 143 | /** |
144 | * phy_aneg_done - return auto-negotiation status | ||
145 | * @phydev: target phy_device struct | ||
113 | * | 146 | * |
114 | * description: Reads the status register and returns 0 either if | 147 | * Description: Reads the status register and returns 0 either if |
115 | * auto-negotiation is incomplete, or if there was an error. | 148 | * auto-negotiation is incomplete, or if there was an error. |
116 | * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done. | 149 | * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done. |
117 | */ | 150 | */ |
@@ -173,9 +206,12 @@ static const struct phy_setting settings[] = { | |||
173 | 206 | ||
174 | #define MAX_NUM_SETTINGS (sizeof(settings)/sizeof(struct phy_setting)) | 207 | #define MAX_NUM_SETTINGS (sizeof(settings)/sizeof(struct phy_setting)) |
175 | 208 | ||
176 | /* phy_find_setting | 209 | /** |
210 | * phy_find_setting - find a PHY settings array entry that matches speed & duplex | ||
211 | * @speed: speed to match | ||
212 | * @duplex: duplex to match | ||
177 | * | 213 | * |
178 | * description: Searches the settings array for the setting which | 214 | * Description: Searches the settings array for the setting which |
179 | * matches the desired speed and duplex, and returns the index | 215 | * matches the desired speed and duplex, and returns the index |
180 | * of that setting. Returns the index of the last setting if | 216 | * of that setting. Returns the index of the last setting if |
181 | * none of the others match. | 217 | * none of the others match. |
@@ -192,11 +228,12 @@ static inline int phy_find_setting(int speed, int duplex) | |||
192 | return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1; | 228 | return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1; |
193 | } | 229 | } |
194 | 230 | ||
195 | /* phy_find_valid | 231 | /** |
196 | * idx: The first index in settings[] to search | 232 | * phy_find_valid - find a PHY setting that matches the requested features mask |
197 | * features: A mask of the valid settings | 233 | * @idx: The first index in settings[] to search |
234 | * @features: A mask of the valid settings | ||
198 | * | 235 | * |
199 | * description: Returns the index of the first valid setting less | 236 | * Description: Returns the index of the first valid setting less |
200 | * than or equal to the one pointed to by idx, as determined by | 237 | * than or equal to the one pointed to by idx, as determined by |
201 | * the mask in features. Returns the index of the last setting | 238 | * the mask in features. Returns the index of the last setting |
202 | * if nothing else matches. | 239 | * if nothing else matches. |
@@ -209,11 +246,13 @@ static inline int phy_find_valid(int idx, u32 features) | |||
209 | return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1; | 246 | return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1; |
210 | } | 247 | } |
211 | 248 | ||
212 | /* phy_sanitize_settings | 249 | /** |
250 | * phy_sanitize_settings - make sure the PHY is set to supported speed and duplex | ||
251 | * @phydev: the target phy_device struct | ||
213 | * | 252 | * |
214 | * description: Make sure the PHY is set to supported speeds and | 253 | * Description: Make sure the PHY is set to supported speeds and |
215 | * duplexes. Drop down by one in this order: 1000/FULL, | 254 | * duplexes. Drop down by one in this order: 1000/FULL, |
216 | * 1000/HALF, 100/FULL, 100/HALF, 10/FULL, 10/HALF | 255 | * 1000/HALF, 100/FULL, 100/HALF, 10/FULL, 10/HALF. |
217 | */ | 256 | */ |
218 | void phy_sanitize_settings(struct phy_device *phydev) | 257 | void phy_sanitize_settings(struct phy_device *phydev) |
219 | { | 258 | { |
@@ -232,16 +271,17 @@ void phy_sanitize_settings(struct phy_device *phydev) | |||
232 | } | 271 | } |
233 | EXPORT_SYMBOL(phy_sanitize_settings); | 272 | EXPORT_SYMBOL(phy_sanitize_settings); |
234 | 273 | ||
235 | /* phy_ethtool_sset: | 274 | /** |
236 | * A generic ethtool sset function. Handles all the details | 275 | * phy_ethtool_sset - generic ethtool sset function, handles all the details |
276 | * @phydev: target phy_device struct | ||
277 | * @cmd: ethtool_cmd | ||
237 | * | 278 | * |
238 | * A few notes about parameter checking: | 279 | * A few notes about parameter checking: |
239 | * - We don't set port or transceiver, so we don't care what they | 280 | * - We don't set port or transceiver, so we don't care what they |
240 | * were set to. | 281 | * were set to. |
241 | * - phy_start_aneg() will make sure forced settings are sane, and | 282 | * - phy_start_aneg() will make sure forced settings are sane, and |
242 | * choose the next best ones from the ones selected, so we don't | 283 | * choose the next best ones from the ones selected, so we don't |
243 | * care if ethtool tries to give us bad values | 284 | * care if ethtool tries to give us bad values. |
244 | * | ||
245 | */ | 285 | */ |
246 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) | 286 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) |
247 | { | 287 | { |
@@ -304,9 +344,15 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd) | |||
304 | } | 344 | } |
305 | EXPORT_SYMBOL(phy_ethtool_gset); | 345 | EXPORT_SYMBOL(phy_ethtool_gset); |
306 | 346 | ||
307 | /* Note that this function is currently incompatible with the | 347 | /** |
348 | * phy_mii_ioctl - generic PHY MII ioctl interface | ||
349 | * @phydev: the phy_device struct | ||
350 | * @mii_data: MII ioctl data | ||
351 | * @cmd: ioctl cmd to execute | ||
352 | * | ||
353 | * Note that this function is currently incompatible with the | ||
308 | * PHYCONTROL layer. It changes registers without regard to | 354 | * PHYCONTROL layer. It changes registers without regard to |
309 | * current state. Use at own risk | 355 | * current state. Use at own risk. |
310 | */ | 356 | */ |
311 | int phy_mii_ioctl(struct phy_device *phydev, | 357 | int phy_mii_ioctl(struct phy_device *phydev, |
312 | struct mii_ioctl_data *mii_data, int cmd) | 358 | struct mii_ioctl_data *mii_data, int cmd) |
@@ -358,13 +404,14 @@ int phy_mii_ioctl(struct phy_device *phydev, | |||
358 | return 0; | 404 | return 0; |
359 | } | 405 | } |
360 | 406 | ||
361 | /* phy_start_aneg | 407 | /** |
408 | * phy_start_aneg - start auto-negotiation for this PHY device | ||
409 | * @phydev: the phy_device struct | ||
362 | * | 410 | * |
363 | * description: Sanitizes the settings (if we're not | 411 | * Description: Sanitizes the settings (if we're not autonegotiating |
364 | * autonegotiating them), and then calls the driver's | 412 | * them), and then calls the driver's config_aneg function. |
365 | * config_aneg function. If the PHYCONTROL Layer is operating, | 413 | * If the PHYCONTROL Layer is operating, we change the state to |
366 | * we change the state to reflect the beginning of | 414 | * reflect the beginning of Auto-negotiation or forcing. |
367 | * Auto-negotiation or forcing. | ||
368 | */ | 415 | */ |
369 | int phy_start_aneg(struct phy_device *phydev) | 416 | int phy_start_aneg(struct phy_device *phydev) |
370 | { | 417 | { |
@@ -400,15 +447,19 @@ EXPORT_SYMBOL(phy_start_aneg); | |||
400 | static void phy_change(struct work_struct *work); | 447 | static void phy_change(struct work_struct *work); |
401 | static void phy_timer(unsigned long data); | 448 | static void phy_timer(unsigned long data); |
402 | 449 | ||
403 | /* phy_start_machine: | 450 | /** |
451 | * phy_start_machine - start PHY state machine tracking | ||
452 | * @phydev: the phy_device struct | ||
453 | * @handler: callback function for state change notifications | ||
404 | * | 454 | * |
405 | * description: The PHY infrastructure can run a state machine | 455 | * Description: The PHY infrastructure can run a state machine |
406 | * which tracks whether the PHY is starting up, negotiating, | 456 | * which tracks whether the PHY is starting up, negotiating, |
407 | * etc. This function starts the timer which tracks the state | 457 | * etc. This function starts the timer which tracks the state |
408 | * of the PHY. If you want to be notified when the state | 458 | * of the PHY. If you want to be notified when the state changes, |
409 | * changes, pass in the callback, otherwise, pass NULL. If you | 459 | * pass in the callback @handler, otherwise, pass NULL. If you |
410 | * want to maintain your own state machine, do not call this | 460 | * want to maintain your own state machine, do not call this |
411 | * function. */ | 461 | * function. |
462 | */ | ||
412 | void phy_start_machine(struct phy_device *phydev, | 463 | void phy_start_machine(struct phy_device *phydev, |
413 | void (*handler)(struct net_device *)) | 464 | void (*handler)(struct net_device *)) |
414 | { | 465 | { |
@@ -420,9 +471,11 @@ void phy_start_machine(struct phy_device *phydev, | |||
420 | mod_timer(&phydev->phy_timer, jiffies + HZ); | 471 | mod_timer(&phydev->phy_timer, jiffies + HZ); |
421 | } | 472 | } |
422 | 473 | ||
423 | /* phy_stop_machine | 474 | /** |
475 | * phy_stop_machine - stop the PHY state machine tracking | ||
476 | * @phydev: target phy_device struct | ||
424 | * | 477 | * |
425 | * description: Stops the state machine timer, sets the state to UP | 478 | * Description: Stops the state machine timer, sets the state to UP |
426 | * (unless it wasn't up yet). This function must be called BEFORE | 479 | * (unless it wasn't up yet). This function must be called BEFORE |
427 | * phy_detach. | 480 | * phy_detach. |
428 | */ | 481 | */ |
@@ -438,12 +491,14 @@ void phy_stop_machine(struct phy_device *phydev) | |||
438 | phydev->adjust_state = NULL; | 491 | phydev->adjust_state = NULL; |
439 | } | 492 | } |
440 | 493 | ||
441 | /* phy_force_reduction | 494 | /** |
495 | * phy_force_reduction - reduce PHY speed/duplex settings by one step | ||
496 | * @phydev: target phy_device struct | ||
442 | * | 497 | * |
443 | * description: Reduces the speed/duplex settings by | 498 | * Description: Reduces the speed/duplex settings by one notch, |
444 | * one notch. The order is so: | 499 | * in this order-- |
445 | * 1000/FULL, 1000/HALF, 100/FULL, 100/HALF, | 500 | * 1000/FULL, 1000/HALF, 100/FULL, 100/HALF, 10/FULL, 10/HALF. |
446 | * 10/FULL, 10/HALF. The function bottoms out at 10/HALF. | 501 | * The function bottoms out at 10/HALF. |
447 | */ | 502 | */ |
448 | static void phy_force_reduction(struct phy_device *phydev) | 503 | static void phy_force_reduction(struct phy_device *phydev) |
449 | { | 504 | { |
@@ -464,7 +519,9 @@ static void phy_force_reduction(struct phy_device *phydev) | |||
464 | } | 519 | } |
465 | 520 | ||
466 | 521 | ||
467 | /* phy_error: | 522 | /** |
523 | * phy_error - enter HALTED state for this PHY device | ||
524 | * @phydev: target phy_device struct | ||
468 | * | 525 | * |
469 | * Moves the PHY to the HALTED state in response to a read | 526 | * Moves the PHY to the HALTED state in response to a read |
470 | * or write error, and tells the controller the link is down. | 527 | * or write error, and tells the controller the link is down. |
@@ -478,9 +535,12 @@ void phy_error(struct phy_device *phydev) | |||
478 | spin_unlock(&phydev->lock); | 535 | spin_unlock(&phydev->lock); |
479 | } | 536 | } |
480 | 537 | ||
481 | /* phy_interrupt | 538 | /** |
539 | * phy_interrupt - PHY interrupt handler | ||
540 | * @irq: interrupt line | ||
541 | * @phy_dat: phy_device pointer | ||
482 | * | 542 | * |
483 | * description: When a PHY interrupt occurs, the handler disables | 543 | * Description: When a PHY interrupt occurs, the handler disables |
484 | * interrupts, and schedules a work task to clear the interrupt. | 544 | * interrupts, and schedules a work task to clear the interrupt. |
485 | */ | 545 | */ |
486 | static irqreturn_t phy_interrupt(int irq, void *phy_dat) | 546 | static irqreturn_t phy_interrupt(int irq, void *phy_dat) |
@@ -501,7 +561,10 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) | |||
501 | return IRQ_HANDLED; | 561 | return IRQ_HANDLED; |
502 | } | 562 | } |
503 | 563 | ||
504 | /* Enable the interrupts from the PHY side */ | 564 | /** |
565 | * phy_enable_interrupts - Enable the interrupts from the PHY side | ||
566 | * @phydev: target phy_device struct | ||
567 | */ | ||
505 | int phy_enable_interrupts(struct phy_device *phydev) | 568 | int phy_enable_interrupts(struct phy_device *phydev) |
506 | { | 569 | { |
507 | int err; | 570 | int err; |
@@ -517,7 +580,10 @@ int phy_enable_interrupts(struct phy_device *phydev) | |||
517 | } | 580 | } |
518 | EXPORT_SYMBOL(phy_enable_interrupts); | 581 | EXPORT_SYMBOL(phy_enable_interrupts); |
519 | 582 | ||
520 | /* Disable the PHY interrupts from the PHY side */ | 583 | /** |
584 | * phy_disable_interrupts - Disable the PHY interrupts from the PHY side | ||
585 | * @phydev: target phy_device struct | ||
586 | */ | ||
521 | int phy_disable_interrupts(struct phy_device *phydev) | 587 | int phy_disable_interrupts(struct phy_device *phydev) |
522 | { | 588 | { |
523 | int err; | 589 | int err; |
@@ -543,13 +609,15 @@ phy_err: | |||
543 | } | 609 | } |
544 | EXPORT_SYMBOL(phy_disable_interrupts); | 610 | EXPORT_SYMBOL(phy_disable_interrupts); |
545 | 611 | ||
546 | /* phy_start_interrupts | 612 | /** |
613 | * phy_start_interrupts - request and enable interrupts for a PHY device | ||
614 | * @phydev: target phy_device struct | ||
547 | * | 615 | * |
548 | * description: Request the interrupt for the given PHY. If | 616 | * Description: Request the interrupt for the given PHY. |
549 | * this fails, then we set irq to PHY_POLL. | 617 | * If this fails, then we set irq to PHY_POLL. |
550 | * Otherwise, we enable the interrupts in the PHY. | 618 | * Otherwise, we enable the interrupts in the PHY. |
551 | * Returns 0 on success. | ||
552 | * This should only be called with a valid IRQ number. | 619 | * This should only be called with a valid IRQ number. |
620 | * Returns 0 on success or < 0 on error. | ||
553 | */ | 621 | */ |
554 | int phy_start_interrupts(struct phy_device *phydev) | 622 | int phy_start_interrupts(struct phy_device *phydev) |
555 | { | 623 | { |
@@ -574,6 +642,10 @@ int phy_start_interrupts(struct phy_device *phydev) | |||
574 | } | 642 | } |
575 | EXPORT_SYMBOL(phy_start_interrupts); | 643 | EXPORT_SYMBOL(phy_start_interrupts); |
576 | 644 | ||
645 | /** | ||
646 | * phy_stop_interrupts - disable interrupts from a PHY device | ||
647 | * @phydev: target phy_device struct | ||
648 | */ | ||
577 | int phy_stop_interrupts(struct phy_device *phydev) | 649 | int phy_stop_interrupts(struct phy_device *phydev) |
578 | { | 650 | { |
579 | int err; | 651 | int err; |
@@ -596,7 +668,10 @@ int phy_stop_interrupts(struct phy_device *phydev) | |||
596 | EXPORT_SYMBOL(phy_stop_interrupts); | 668 | EXPORT_SYMBOL(phy_stop_interrupts); |
597 | 669 | ||
598 | 670 | ||
599 | /* Scheduled by the phy_interrupt/timer to handle PHY changes */ | 671 | /** |
672 | * phy_change - Scheduled by the phy_interrupt/timer to handle PHY changes | ||
673 | * @work: work_struct that describes the work to be done | ||
674 | */ | ||
600 | static void phy_change(struct work_struct *work) | 675 | static void phy_change(struct work_struct *work) |
601 | { | 676 | { |
602 | int err; | 677 | int err; |
@@ -630,7 +705,10 @@ phy_err: | |||
630 | phy_error(phydev); | 705 | phy_error(phydev); |
631 | } | 706 | } |
632 | 707 | ||
633 | /* Bring down the PHY link, and stop checking the status. */ | 708 | /** |
709 | * phy_stop - Bring down the PHY link, and stop checking the status | ||
710 | * @phydev: target phy_device struct | ||
711 | */ | ||
634 | void phy_stop(struct phy_device *phydev) | 712 | void phy_stop(struct phy_device *phydev) |
635 | { | 713 | { |
636 | spin_lock(&phydev->lock); | 714 | spin_lock(&phydev->lock); |
@@ -659,9 +737,11 @@ out_unlock: | |||
659 | } | 737 | } |
660 | 738 | ||
661 | 739 | ||
662 | /* phy_start | 740 | /** |
741 | * phy_start - start or restart a PHY device | ||
742 | * @phydev: target phy_device struct | ||
663 | * | 743 | * |
664 | * description: Indicates the attached device's readiness to | 744 | * Description: Indicates the attached device's readiness to |
665 | * handle PHY-related work. Used during startup to start the | 745 | * handle PHY-related work. Used during startup to start the |
666 | * PHY, and after a call to phy_stop() to resume operation. | 746 | * PHY, and after a call to phy_stop() to resume operation. |
667 | * Also used to indicate the MDIO bus has cleared an error | 747 | * Also used to indicate the MDIO bus has cleared an error |