aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e100.c
diff options
context:
space:
mode:
authorJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-05-03 01:28:23 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-05-07 06:08:38 -0400
commita70b86ae206fdd3bef13c5ac148c22a805e83896 (patch)
treeed47ddeb4620f7fd35ddd877d2cfd2de0aa5a961 /drivers/net/e100.c
parent706527280ec38fcdcd0466f10b607105fd23801b (diff)
e100: implemenet set_phys_id
Based on the original patch from Stephen Hemminger. Implement set_phys_id to control LED. CC: Stephen Hemminger <shemminger@vyatta.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/e100.c')
-rw-r--r--drivers/net/e100.c66
1 files changed, 28 insertions, 38 deletions
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 29f812dc1098..e336c7937f05 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -593,7 +593,6 @@ struct nic {
593 enum phy phy; 593 enum phy phy;
594 struct params params; 594 struct params params;
595 struct timer_list watchdog; 595 struct timer_list watchdog;
596 struct timer_list blink_timer;
597 struct mii_if_info mii; 596 struct mii_if_info mii;
598 struct work_struct tx_timeout_task; 597 struct work_struct tx_timeout_task;
599 enum loopback loopback; 598 enum loopback loopback;
@@ -618,7 +617,6 @@ struct nic {
618 u32 rx_tco_frames; 617 u32 rx_tco_frames;
619 u32 rx_over_length_errors; 618 u32 rx_over_length_errors;
620 619
621 u16 leds;
622 u16 eeprom_wc; 620 u16 eeprom_wc;
623 __le16 eeprom[256]; 621 __le16 eeprom[256];
624 spinlock_t mdio_lock; 622 spinlock_t mdio_lock;
@@ -2353,30 +2351,6 @@ err_clean_rx:
2353#define E100_82552_LED_OVERRIDE 0x19 2351#define E100_82552_LED_OVERRIDE 0x19
2354#define E100_82552_LED_ON 0x000F /* LEDTX and LED_RX both on */ 2352#define E100_82552_LED_ON 0x000F /* LEDTX and LED_RX both on */
2355#define E100_82552_LED_OFF 0x000A /* LEDTX and LED_RX both off */ 2353#define E100_82552_LED_OFF 0x000A /* LEDTX and LED_RX both off */
2356static void e100_blink_led(unsigned long data)
2357{
2358 struct nic *nic = (struct nic *)data;
2359 enum led_state {
2360 led_on = 0x01,
2361 led_off = 0x04,
2362 led_on_559 = 0x05,
2363 led_on_557 = 0x07,
2364 };
2365 u16 led_reg = MII_LED_CONTROL;
2366
2367 if (nic->phy == phy_82552_v) {
2368 led_reg = E100_82552_LED_OVERRIDE;
2369
2370 nic->leds = (nic->leds == E100_82552_LED_ON) ?
2371 E100_82552_LED_OFF : E100_82552_LED_ON;
2372 } else {
2373 nic->leds = (nic->leds & led_on) ? led_off :
2374 (nic->mac < mac_82559_D101M) ? led_on_557 :
2375 led_on_559;
2376 }
2377 mdio_write(nic->netdev, nic->mii.phy_id, led_reg, nic->leds);
2378 mod_timer(&nic->blink_timer, jiffies + HZ / 4);
2379}
2380 2354
2381static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) 2355static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
2382{ 2356{
@@ -2600,19 +2574,38 @@ static void e100_diag_test(struct net_device *netdev,
2600 msleep_interruptible(4 * 1000); 2574 msleep_interruptible(4 * 1000);
2601} 2575}
2602 2576
2603static int e100_phys_id(struct net_device *netdev, u32 data) 2577static int e100_set_phys_id(struct net_device *netdev,
2578 enum ethtool_phys_id_state state)
2604{ 2579{
2605 struct nic *nic = netdev_priv(netdev); 2580 struct nic *nic = netdev_priv(netdev);
2581 enum led_state {
2582 led_on = 0x01,
2583 led_off = 0x04,
2584 led_on_559 = 0x05,
2585 led_on_557 = 0x07,
2586 };
2606 u16 led_reg = (nic->phy == phy_82552_v) ? E100_82552_LED_OVERRIDE : 2587 u16 led_reg = (nic->phy == phy_82552_v) ? E100_82552_LED_OVERRIDE :
2607 MII_LED_CONTROL; 2588 MII_LED_CONTROL;
2589 u16 leds = 0;
2590
2591 switch (state) {
2592 case ETHTOOL_ID_ACTIVE:
2593 return 2;
2608 2594
2609 if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) 2595 case ETHTOOL_ID_ON:
2610 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); 2596 leds = (nic->phy == phy_82552_v) ? E100_82552_LED_ON :
2611 mod_timer(&nic->blink_timer, jiffies); 2597 (nic->mac < mac_82559_D101M) ? led_on_557 : led_on_559;
2612 msleep_interruptible(data * 1000); 2598 break;
2613 del_timer_sync(&nic->blink_timer); 2599
2614 mdio_write(netdev, nic->mii.phy_id, led_reg, 0); 2600 case ETHTOOL_ID_OFF:
2601 leds = (nic->phy == phy_82552_v) ? E100_82552_LED_OFF : led_off;
2602 break;
2603
2604 case ETHTOOL_ID_INACTIVE:
2605 break;
2606 }
2615 2607
2608 mdio_write(netdev, nic->mii.phy_id, led_reg, leds);
2616 return 0; 2609 return 0;
2617} 2610}
2618 2611
@@ -2693,7 +2686,7 @@ static const struct ethtool_ops e100_ethtool_ops = {
2693 .set_ringparam = e100_set_ringparam, 2686 .set_ringparam = e100_set_ringparam,
2694 .self_test = e100_diag_test, 2687 .self_test = e100_diag_test,
2695 .get_strings = e100_get_strings, 2688 .get_strings = e100_get_strings,
2696 .phys_id = e100_phys_id, 2689 .set_phys_id = e100_set_phys_id,
2697 .get_ethtool_stats = e100_get_ethtool_stats, 2690 .get_ethtool_stats = e100_get_ethtool_stats,
2698 .get_sset_count = e100_get_sset_count, 2691 .get_sset_count = e100_get_sset_count,
2699}; 2692};
@@ -2834,9 +2827,6 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2834 init_timer(&nic->watchdog); 2827 init_timer(&nic->watchdog);
2835 nic->watchdog.function = e100_watchdog; 2828 nic->watchdog.function = e100_watchdog;
2836 nic->watchdog.data = (unsigned long)nic; 2829 nic->watchdog.data = (unsigned long)nic;
2837 init_timer(&nic->blink_timer);
2838 nic->blink_timer.function = e100_blink_led;
2839 nic->blink_timer.data = (unsigned long)nic;
2840 2830
2841 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task); 2831 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2842 2832