smsc95xx.c (5f5a00eaa1ddd3754963e077ff514ded9fc88b7a) smsc95xx.c (13722bbe97b55bbd31651a2e1e12b460f33de134)
1 /***************************************************************************
2 *
3 * Copyright (C) 2007-2008 SMSC
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.

--- 19 unchanged lines hidden (view full) ---

28#include <linux/crc16.h>
29#include <linux/crc32.h>
30#include <linux/usb/usbnet.h>
31#include <linux/slab.h>
32#include <linux/of_net.h>
33#include "smsc95xx.h"
34
35#define SMSC_CHIPNAME "smsc95xx"
1 /***************************************************************************
2 *
3 * Copyright (C) 2007-2008 SMSC
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.

--- 19 unchanged lines hidden (view full) ---

28#include <linux/crc16.h>
29#include <linux/crc32.h>
30#include <linux/usb/usbnet.h>
31#include <linux/slab.h>
32#include <linux/of_net.h>
33#include "smsc95xx.h"
34
35#define SMSC_CHIPNAME "smsc95xx"
36#define SMSC_DRIVER_VERSION "1.0.4"
36#define SMSC_DRIVER_VERSION "1.0.5"
37#define HS_USB_PKT_SIZE (512)
38#define FS_USB_PKT_SIZE (64)
39#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE)
40#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE)
41#define DEFAULT_BULK_IN_DELAY (0x00002000)
42#define MAX_SINGLE_PACKET_SIZE (2048)
43#define LAN95XX_EEPROM_MAGIC (0x9500)
44#define EEPROM_MAC_OFFSET (0x01)

--- 14 unchanged lines hidden (view full) ---

59#define SUSPEND_SUSPEND2 (0x04)
60#define SUSPEND_SUSPEND3 (0x08)
61#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
62 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
63
64#define CARRIER_CHECK_DELAY (2 * HZ)
65
66struct smsc95xx_priv {
37#define HS_USB_PKT_SIZE (512)
38#define FS_USB_PKT_SIZE (64)
39#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE)
40#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE)
41#define DEFAULT_BULK_IN_DELAY (0x00002000)
42#define MAX_SINGLE_PACKET_SIZE (2048)
43#define LAN95XX_EEPROM_MAGIC (0x9500)
44#define EEPROM_MAC_OFFSET (0x01)

--- 14 unchanged lines hidden (view full) ---

59#define SUSPEND_SUSPEND2 (0x04)
60#define SUSPEND_SUSPEND3 (0x08)
61#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
62 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
63
64#define CARRIER_CHECK_DELAY (2 * HZ)
65
66struct smsc95xx_priv {
67 u32 chip_id;
67 u32 mac_cr;
68 u32 hash_hi;
69 u32 hash_lo;
70 u32 wolopts;
71 spinlock_t mac_cr_lock;
72 u8 features;
73 u8 suspend_flags;
68 u32 mac_cr;
69 u32 hash_hi;
70 u32 hash_lo;
71 u32 wolopts;
72 spinlock_t mac_cr_lock;
73 u8 features;
74 u8 suspend_flags;
75 u8 mdix_ctrl;
74 bool link_ok;
75 struct delayed_work carrier_check;
76 struct usbnet *dev;
77};
78
79static bool turbo_mode = true;
80module_param(turbo_mode, bool, 0644);
81MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");

--- 695 unchanged lines hidden (view full) ---

777
778 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
779 if (ret < 0)
780 netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret);
781
782 return ret;
783}
784
76 bool link_ok;
77 struct delayed_work carrier_check;
78 struct usbnet *dev;
79};
80
81static bool turbo_mode = true;
82module_param(turbo_mode, bool, 0644);
83MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");

--- 695 unchanged lines hidden (view full) ---

779
780 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
781 if (ret < 0)
782 netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret);
783
784 return ret;
785}
786
787static int get_mdix_status(struct net_device *net)
788{
789 struct usbnet *dev = netdev_priv(net);
790 u32 val;
791 int buf;
792
793 buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, SPECIAL_CTRL_STS);
794 if (buf & SPECIAL_CTRL_STS_OVRRD_AMDIX_) {
795 if (buf & SPECIAL_CTRL_STS_AMDIX_ENABLE_)
796 return ETH_TP_MDI_AUTO;
797 else if (buf & SPECIAL_CTRL_STS_AMDIX_STATE_)
798 return ETH_TP_MDI_X;
799 } else {
800 buf = smsc95xx_read_reg(dev, STRAP_STATUS, &val);
801 if (val & STRAP_STATUS_AMDIX_EN_)
802 return ETH_TP_MDI_AUTO;
803 }
804
805 return ETH_TP_MDI;
806}
807
808static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl)
809{
810 struct usbnet *dev = netdev_priv(net);
811 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
812 int buf;
813
814 if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) ||
815 (pdata->chip_id == ID_REV_CHIP_ID_9530_) ||
816 (pdata->chip_id == ID_REV_CHIP_ID_89530_) ||
817 (pdata->chip_id == ID_REV_CHIP_ID_9730_)) {
818 /* Extend Manual AutoMDIX timer for 9500A/9500Ai */
819 buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id,
820 PHY_EDPD_CONFIG);
821 buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_;
822 smsc95xx_mdio_write(dev->net, dev->mii.phy_id,
823 PHY_EDPD_CONFIG, buf);
824 }
825
826 if (mdix_ctrl == ETH_TP_MDI) {
827 buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id,
828 SPECIAL_CTRL_STS);
829 buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_;
830 buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
831 SPECIAL_CTRL_STS_AMDIX_STATE_);
832 smsc95xx_mdio_write(dev->net, dev->mii.phy_id,
833 SPECIAL_CTRL_STS, buf);
834 } else if (mdix_ctrl == ETH_TP_MDI_X) {
835 buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id,
836 SPECIAL_CTRL_STS);
837 buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_;
838 buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
839 SPECIAL_CTRL_STS_AMDIX_STATE_);
840 buf |= SPECIAL_CTRL_STS_AMDIX_STATE_;
841 smsc95xx_mdio_write(dev->net, dev->mii.phy_id,
842 SPECIAL_CTRL_STS, buf);
843 } else if (mdix_ctrl == ETH_TP_MDI_AUTO) {
844 buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id,
845 SPECIAL_CTRL_STS);
846 buf &= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_;
847 buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
848 SPECIAL_CTRL_STS_AMDIX_STATE_);
849 buf |= SPECIAL_CTRL_STS_AMDIX_ENABLE_;
850 smsc95xx_mdio_write(dev->net, dev->mii.phy_id,
851 SPECIAL_CTRL_STS, buf);
852 }
853 pdata->mdix_ctrl = mdix_ctrl;
854}
855
856static int smsc95xx_get_settings(struct net_device *net,
857 struct ethtool_cmd *cmd)
858{
859 struct usbnet *dev = netdev_priv(net);
860 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
861 int retval;
862
863 retval = usbnet_get_settings(net, cmd);
864
865 cmd->eth_tp_mdix = pdata->mdix_ctrl;
866 cmd->eth_tp_mdix_ctrl = pdata->mdix_ctrl;
867
868 return retval;
869}
870
871static int smsc95xx_set_settings(struct net_device *net,
872 struct ethtool_cmd *cmd)
873{
874 struct usbnet *dev = netdev_priv(net);
875 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
876 int retval;
877
878 if (pdata->mdix_ctrl != cmd->eth_tp_mdix_ctrl)
879 set_mdix_status(net, cmd->eth_tp_mdix_ctrl);
880
881 retval = usbnet_set_settings(net, cmd);
882
883 return retval;
884}
885
785static const struct ethtool_ops smsc95xx_ethtool_ops = {
786 .get_link = usbnet_get_link,
787 .nway_reset = usbnet_nway_reset,
788 .get_drvinfo = usbnet_get_drvinfo,
789 .get_msglevel = usbnet_get_msglevel,
790 .set_msglevel = usbnet_set_msglevel,
886static const struct ethtool_ops smsc95xx_ethtool_ops = {
887 .get_link = usbnet_get_link,
888 .nway_reset = usbnet_nway_reset,
889 .get_drvinfo = usbnet_get_drvinfo,
890 .get_msglevel = usbnet_get_msglevel,
891 .set_msglevel = usbnet_set_msglevel,
791 .get_settings = usbnet_get_settings,
792 .set_settings = usbnet_set_settings,
892 .get_settings = smsc95xx_get_settings,
893 .set_settings = smsc95xx_set_settings,
793 .get_eeprom_len = smsc95xx_ethtool_get_eeprom_len,
794 .get_eeprom = smsc95xx_ethtool_get_eeprom,
795 .set_eeprom = smsc95xx_ethtool_set_eeprom,
796 .get_regs_len = smsc95xx_ethtool_getregslen,
797 .get_regs = smsc95xx_ethtool_getregs,
798 .get_wol = smsc95xx_ethtool_get_wol,
799 .set_wol = smsc95xx_ethtool_set_wol,
800};

--- 388 unchanged lines hidden (view full) ---

1189 /* Init all registers */
1190 ret = smsc95xx_reset(dev);
1191
1192 /* detect device revision as different features may be available */
1193 ret = smsc95xx_read_reg(dev, ID_REV, &val);
1194 if (ret < 0)
1195 return ret;
1196 val >>= 16;
894 .get_eeprom_len = smsc95xx_ethtool_get_eeprom_len,
895 .get_eeprom = smsc95xx_ethtool_get_eeprom,
896 .set_eeprom = smsc95xx_ethtool_set_eeprom,
897 .get_regs_len = smsc95xx_ethtool_getregslen,
898 .get_regs = smsc95xx_ethtool_getregs,
899 .get_wol = smsc95xx_ethtool_get_wol,
900 .set_wol = smsc95xx_ethtool_set_wol,
901};

--- 388 unchanged lines hidden (view full) ---

1290 /* Init all registers */
1291 ret = smsc95xx_reset(dev);
1292
1293 /* detect device revision as different features may be available */
1294 ret = smsc95xx_read_reg(dev, ID_REV, &val);
1295 if (ret < 0)
1296 return ret;
1297 val >>= 16;
1298 pdata->chip_id = val;
1299 pdata->mdix_ctrl = get_mdix_status(dev->net);
1197
1198 if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) ||
1199 (val == ID_REV_CHIP_ID_89530_) || (val == ID_REV_CHIP_ID_9730_))
1200 pdata->features = (FEATURE_8_WAKEUP_FILTERS |
1201 FEATURE_PHY_NLP_CROSSOVER |
1202 FEATURE_REMOTE_WAKEUP);
1203 else if (val == ID_REV_CHIP_ID_9512_)
1204 pdata->features = FEATURE_8_WAKEUP_FILTERS;

--- 886 unchanged lines hidden ---
1300
1301 if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) ||
1302 (val == ID_REV_CHIP_ID_89530_) || (val == ID_REV_CHIP_ID_9730_))
1303 pdata->features = (FEATURE_8_WAKEUP_FILTERS |
1304 FEATURE_PHY_NLP_CROSSOVER |
1305 FEATURE_REMOTE_WAKEUP);
1306 else if (val == ID_REV_CHIP_ID_9512_)
1307 pdata->features = FEATURE_8_WAKEUP_FILTERS;

--- 886 unchanged lines hidden ---