phy.c (00db8189d984d6c51226dafbbe4a667ce9b7d5da) | phy.c (67c4f3fa25502ce7ed82fb0307e09cf36f1f81da) |
---|---|
1/* 2 * drivers/net/phy/phy.c 3 * 4 * Framework for configuring and reading PHY devices 5 * Based on code in sungem_phy.c and gianfar_phy.c 6 * 7 * Author: Andy Fleming 8 * --- 25 unchanged lines hidden (view full) --- 34#include <linux/mii.h> 35#include <linux/ethtool.h> 36#include <linux/phy.h> 37 38#include <asm/io.h> 39#include <asm/irq.h> 40#include <asm/uaccess.h> 41 | 1/* 2 * drivers/net/phy/phy.c 3 * 4 * Framework for configuring and reading PHY devices 5 * Based on code in sungem_phy.c and gianfar_phy.c 6 * 7 * Author: Andy Fleming 8 * --- 25 unchanged lines hidden (view full) --- 34#include <linux/mii.h> 35#include <linux/ethtool.h> 36#include <linux/phy.h> 37 38#include <asm/io.h> 39#include <asm/irq.h> 40#include <asm/uaccess.h> 41 |
42static void phy_change(void *data); | |
43static void phy_timer(unsigned long data); 44 45/* Convenience function to print out the current phy status 46 */ 47void phy_print_status(struct phy_device *phydev) 48{ 49 pr_info("%s: Link is %s", phydev->dev.bus_id, 50 phydev->link ? "Up" : "Down"); --- 408 unchanged lines hidden (view full) --- 459 spin_unlock(&phydev->lock); 460 461 if (phydev->irq != PHY_POLL) 462 phy_stop_interrupts(phydev); 463 464 phydev->adjust_state = NULL; 465} 466 | 42static void phy_timer(unsigned long data); 43 44/* Convenience function to print out the current phy status 45 */ 46void phy_print_status(struct phy_device *phydev) 47{ 48 pr_info("%s: Link is %s", phydev->dev.bus_id, 49 phydev->link ? "Up" : "Down"); --- 408 unchanged lines hidden (view full) --- 458 spin_unlock(&phydev->lock); 459 460 if (phydev->irq != PHY_POLL) 461 phy_stop_interrupts(phydev); 462 463 phydev->adjust_state = NULL; 464} 465 |
467#ifdef CONFIG_PHYCONTROL | |
468/* phy_error: 469 * 470 * Moves the PHY to the HALTED state in response to a read 471 * or write error, and tells the controller the link is down. 472 * Must not be called from interrupt context, or while the 473 * phydev->lock is held. 474 */ 475void phy_error(struct phy_device *phydev) 476{ 477 spin_lock(&phydev->lock); 478 phydev->state = PHY_HALTED; 479 spin_unlock(&phydev->lock); 480} 481 | 466/* phy_error: 467 * 468 * Moves the PHY to the HALTED state in response to a read 469 * or write error, and tells the controller the link is down. 470 * Must not be called from interrupt context, or while the 471 * phydev->lock is held. 472 */ 473void phy_error(struct phy_device *phydev) 474{ 475 spin_lock(&phydev->lock); 476 phydev->state = PHY_HALTED; 477 spin_unlock(&phydev->lock); 478} 479 |
480#ifdef CONFIG_PHYCONTROL 481 482static void phy_change(void *data); 483 |
|
482/* phy_interrupt 483 * 484 * description: When a PHY interrupt occurs, the handler disables 485 * interrupts, and schedules a work task to clear the interrupt. 486 */ 487static irqreturn_t phy_interrupt(int irq, void *phy_dat, struct pt_regs *regs) 488{ 489 struct phy_device *phydev = phy_dat; --- 177 unchanged lines hidden (view full) --- 667 default: 668 break; 669 } 670 spin_unlock(&phydev->lock); 671} 672EXPORT_SYMBOL(phy_stop); 673EXPORT_SYMBOL(phy_start); 674 | 484/* phy_interrupt 485 * 486 * description: When a PHY interrupt occurs, the handler disables 487 * interrupts, and schedules a work task to clear the interrupt. 488 */ 489static irqreturn_t phy_interrupt(int irq, void *phy_dat, struct pt_regs *regs) 490{ 491 struct phy_device *phydev = phy_dat; --- 177 unchanged lines hidden (view full) --- 669 default: 670 break; 671 } 672 spin_unlock(&phydev->lock); 673} 674EXPORT_SYMBOL(phy_stop); 675EXPORT_SYMBOL(phy_start); 676 |
677#endif /* CONFIG_PHYCONTROL */ 678 |
|
675/* PHY timer which handles the state machine */ 676static void phy_timer(unsigned long data) 677{ 678 struct phy_device *phydev = (struct phy_device *)data; 679 int needs_aneg = 0; 680 int err = 0; 681 682 spin_lock(&phydev->lock); --- 171 unchanged lines hidden (view full) --- 854 err = phy_start_aneg(phydev); 855 856 if (err < 0) 857 phy_error(phydev); 858 859 mod_timer(&phydev->phy_timer, jiffies + PHY_STATE_TIME * HZ); 860} 861 | 679/* PHY timer which handles the state machine */ 680static void phy_timer(unsigned long data) 681{ 682 struct phy_device *phydev = (struct phy_device *)data; 683 int needs_aneg = 0; 684 int err = 0; 685 686 spin_lock(&phydev->lock); --- 171 unchanged lines hidden (view full) --- 858 err = phy_start_aneg(phydev); 859 860 if (err < 0) 861 phy_error(phydev); 862 863 mod_timer(&phydev->phy_timer, jiffies + PHY_STATE_TIME * HZ); 864} 865 |
862#endif /* CONFIG_PHYCONTROL */ | |