~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/atlx/atl1.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
#include "atl1.h"
84
84
 
85
85
#define ATLX_DRIVER_VERSION "2.1.3"
86
 
MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \
87
 
Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
 
86
MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, "
 
87
              "Chris Snook <csnook@redhat.com>, "
 
88
              "Jay Cliburn <jcliburn@gmail.com>");
88
89
MODULE_LICENSE("GPL");
89
90
MODULE_VERSION(ATLX_DRIVER_VERSION);
90
91
 
950
951
        hw->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
951
952
 
952
953
        adapter->wol = 0;
 
954
        device_set_wakeup_enable(&adapter->pdev->dev, false);
953
955
        adapter->rx_buffer_len = (hw->max_frame_size + 7) & ~7;
954
956
        adapter->ict = 50000;           /* 100ms */
955
957
        adapter->link_speed = SPEED_0;  /* hardware init */
2073
2075
        cmb_tpd_next_to_clean = le16_to_cpu(adapter->cmb.cmb->tpd_cons_idx);
2074
2076
 
2075
2077
        while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) {
2076
 
                struct tx_packet_desc *tpd;
2077
 
 
2078
 
                tpd = ATL1_TPD_DESC(tpd_ring, sw_tpd_next_to_clean);
2079
2078
                buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean];
2080
2079
                if (buffer_info->dma) {
2081
2080
                        pci_unmap_page(adapter->pdev, buffer_info->dma,
2571
2570
{
2572
2571
        struct net_device *netdev = adapter->netdev;
2573
2572
        int err;
2574
 
        int irq_flags = IRQF_SAMPLE_RANDOM;
 
2573
        int irq_flags = 0;
2575
2574
 
2576
2575
        /* hardware has been reset, we need to reload some things */
2577
2576
        atlx_set_multi(netdev);
2735
2734
}
2736
2735
 
2737
2736
#ifdef CONFIG_PM
2738
 
static int atl1_suspend(struct pci_dev *pdev, pm_message_t state)
 
2737
static int atl1_suspend(struct device *dev)
2739
2738
{
 
2739
        struct pci_dev *pdev = to_pci_dev(dev);
2740
2740
        struct net_device *netdev = pci_get_drvdata(pdev);
2741
2741
        struct atl1_adapter *adapter = netdev_priv(netdev);
2742
2742
        struct atl1_hw *hw = &adapter->hw;
2743
2743
        u32 ctrl = 0;
2744
2744
        u32 wufc = adapter->wol;
2745
2745
        u32 val;
2746
 
        int retval;
2747
2746
        u16 speed;
2748
2747
        u16 duplex;
2749
2748
 
2751
2750
        if (netif_running(netdev))
2752
2751
                atl1_down(adapter);
2753
2752
 
2754
 
        retval = pci_save_state(pdev);
2755
 
        if (retval)
2756
 
                return retval;
2757
 
 
2758
2753
        atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
2759
2754
        atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
2760
2755
        val = ctrl & BMSR_LSTATUS;
2761
2756
        if (val)
2762
2757
                wufc &= ~ATLX_WUFC_LNKC;
 
2758
        if (!wufc)
 
2759
                goto disable_wol;
2763
2760
 
2764
 
        if (val && wufc) {
 
2761
        if (val) {
2765
2762
                val = atl1_get_speed_and_duplex(hw, &speed, &duplex);
2766
2763
                if (val) {
2767
2764
                        if (netif_msg_ifdown(adapter))
2798
2795
                ctrl |= PCIE_PHYMISC_FORCE_RCV_DET;
2799
2796
                iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC);
2800
2797
                ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2801
 
 
2802
 
                pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
2803
 
                goto exit;
2804
 
        }
2805
 
 
2806
 
        if (!val && wufc) {
 
2798
        } else {
2807
2799
                ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN);
2808
2800
                iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL);
2809
2801
                ioread32(hw->hw_addr + REG_WOL_CTRL);
2810
2802
                iowrite32(0, hw->hw_addr + REG_MAC_CTRL);
2811
2803
                ioread32(hw->hw_addr + REG_MAC_CTRL);
2812
2804
                hw->phy_configured = false;
2813
 
                pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
2814
 
                goto exit;
2815
2805
        }
2816
2806
 
2817
 
disable_wol:
 
2807
        return 0;
 
2808
 
 
2809
 disable_wol:
2818
2810
        iowrite32(0, hw->hw_addr + REG_WOL_CTRL);
2819
2811
        ioread32(hw->hw_addr + REG_WOL_CTRL);
2820
2812
        ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2822
2814
        iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC);
2823
2815
        ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2824
2816
        hw->phy_configured = false;
2825
 
        pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
2826
 
exit:
2827
 
        if (netif_running(netdev))
2828
 
                pci_disable_msi(adapter->pdev);
2829
 
        pci_disable_device(pdev);
2830
 
        pci_set_power_state(pdev, pci_choose_state(pdev, state));
2831
2817
 
2832
2818
        return 0;
2833
2819
}
2834
2820
 
2835
 
static int atl1_resume(struct pci_dev *pdev)
 
2821
static int atl1_resume(struct device *dev)
2836
2822
{
 
2823
        struct pci_dev *pdev = to_pci_dev(dev);
2837
2824
        struct net_device *netdev = pci_get_drvdata(pdev);
2838
2825
        struct atl1_adapter *adapter = netdev_priv(netdev);
2839
 
        u32 err;
2840
 
 
2841
 
        pci_set_power_state(pdev, PCI_D0);
2842
 
        pci_restore_state(pdev);
2843
 
 
2844
 
        err = pci_enable_device(pdev);
2845
 
        if (err) {
2846
 
                if (netif_msg_ifup(adapter))
2847
 
                        dev_printk(KERN_DEBUG, &pdev->dev,
2848
 
                                "error enabling pci device\n");
2849
 
                return err;
2850
 
        }
2851
 
 
2852
 
        pci_set_master(pdev);
 
2826
 
2853
2827
        iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL);
2854
 
        pci_enable_wake(pdev, PCI_D3hot, 0);
2855
 
        pci_enable_wake(pdev, PCI_D3cold, 0);
2856
2828
 
2857
2829
        atl1_reset_hw(&adapter->hw);
2858
2830
 
2864
2836
 
2865
2837
        return 0;
2866
2838
}
 
2839
 
 
2840
static SIMPLE_DEV_PM_OPS(atl1_pm_ops, atl1_suspend, atl1_resume);
 
2841
#define ATL1_PM_OPS     (&atl1_pm_ops)
 
2842
 
2867
2843
#else
2868
 
#define atl1_suspend NULL
2869
 
#define atl1_resume NULL
 
2844
 
 
2845
static int atl1_suspend(struct device *dev) { return 0; }
 
2846
 
 
2847
#define ATL1_PM_OPS     NULL
2870
2848
#endif
2871
2849
 
2872
2850
static void atl1_shutdown(struct pci_dev *pdev)
2873
2851
{
2874
 
#ifdef CONFIG_PM
2875
 
        atl1_suspend(pdev, PMSG_SUSPEND);
2876
 
#endif
 
2852
        struct net_device *netdev = pci_get_drvdata(pdev);
 
2853
        struct atl1_adapter *adapter = netdev_priv(netdev);
 
2854
 
 
2855
        atl1_suspend(&pdev->dev);
 
2856
        pci_wake_from_d3(pdev, adapter->wol);
 
2857
        pci_set_power_state(pdev, PCI_D3hot);
2877
2858
}
2878
2859
 
2879
2860
#ifdef CONFIG_NET_POLL_CONTROLLER
3003
2984
        netdev->features |= NETIF_F_SG;
3004
2985
        netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX);
3005
2986
 
 
2987
        netdev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_TSO;
 
2988
 
 
2989
        /* is this valid? see atl1_setup_mac_ctrl() */
 
2990
        netdev->features |= NETIF_F_RXCSUM;
 
2991
 
3006
2992
        /*
3007
2993
         * patch for some L1 of old version,
3008
2994
         * the final version of L1 may not need these
3117
3103
        .id_table = atl1_pci_tbl,
3118
3104
        .probe = atl1_probe,
3119
3105
        .remove = __devexit_p(atl1_remove),
3120
 
        .suspend = atl1_suspend,
3121
 
        .resume = atl1_resume,
3122
 
        .shutdown = atl1_shutdown
 
3106
        .shutdown = atl1_shutdown,
 
3107
        .driver.pm = ATL1_PM_OPS,
3123
3108
};
3124
3109
 
3125
3110
/*
3247
3232
        if (netif_carrier_ok(adapter->netdev)) {
3248
3233
                u16 link_speed, link_duplex;
3249
3234
                atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
3250
 
                ecmd->speed = link_speed;
 
3235
                ethtool_cmd_speed_set(ecmd, link_speed);
3251
3236
                if (link_duplex == FULL_DUPLEX)
3252
3237
                        ecmd->duplex = DUPLEX_FULL;
3253
3238
                else
3254
3239
                        ecmd->duplex = DUPLEX_HALF;
3255
3240
        } else {
3256
 
                ecmd->speed = -1;
 
3241
                ethtool_cmd_speed_set(ecmd, -1);
3257
3242
                ecmd->duplex = -1;
3258
3243
        }
3259
3244
        if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
3284
3269
        if (ecmd->autoneg == AUTONEG_ENABLE)
3285
3270
                hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
3286
3271
        else {
3287
 
                if (ecmd->speed == SPEED_1000) {
 
3272
                u32 speed = ethtool_cmd_speed(ecmd);
 
3273
                if (speed == SPEED_1000) {
3288
3274
                        if (ecmd->duplex != DUPLEX_FULL) {
3289
3275
                                if (netif_msg_link(adapter))
3290
3276
                                        dev_warn(&adapter->pdev->dev,
3293
3279
                                goto exit_sset;
3294
3280
                        }
3295
3281
                        hw->media_type = MEDIA_TYPE_1000M_FULL;
3296
 
                } else if (ecmd->speed == SPEED_100) {
 
3282
                } else if (speed == SPEED_100) {
3297
3283
                        if (ecmd->duplex == DUPLEX_FULL)
3298
3284
                                hw->media_type = MEDIA_TYPE_100M_FULL;
3299
3285
                        else
3409
3395
        adapter->wol = 0;
3410
3396
        if (wol->wolopts & WAKE_MAGIC)
3411
3397
                adapter->wol |= ATLX_WUFC_MAG;
 
3398
 
 
3399
        device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
 
3400
 
3412
3401
        return 0;
3413
3402
}
3414
3403
 
3610
3599
        return 0;
3611
3600
}
3612
3601
 
3613
 
/* FIXME: is this right? -- CHS */
3614
 
static u32 atl1_get_rx_csum(struct net_device *netdev)
3615
 
{
3616
 
        return 1;
3617
 
}
3618
 
 
3619
3602
static void atl1_get_strings(struct net_device *netdev, u32 stringset,
3620
3603
        u8 *data)
3621
3604
{
3683
3666
        .set_ringparam          = atl1_set_ringparam,
3684
3667
        .get_pauseparam         = atl1_get_pauseparam,
3685
3668
        .set_pauseparam         = atl1_set_pauseparam,
3686
 
        .get_rx_csum            = atl1_get_rx_csum,
3687
 
        .set_tx_csum            = ethtool_op_set_tx_hw_csum,
3688
3669
        .get_link               = ethtool_op_get_link,
3689
 
        .set_sg                 = ethtool_op_set_sg,
3690
3670
        .get_strings            = atl1_get_strings,
3691
3671
        .nway_reset             = atl1_nway_reset,
3692
3672
        .get_ethtool_stats      = atl1_get_ethtool_stats,
3693
3673
        .get_sset_count         = atl1_get_sset_count,
3694
 
        .set_tso                = ethtool_op_set_tso,
3695
3674
};