aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorSteve Glendinning <steve.glendinning@shawell.net>2012-11-22 03:05:23 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-23 14:15:16 -0500
commit9ebca5071c8679bba96981af6bc29370f1c2f0aa (patch)
tree86c8ac32babd9ac737d065b66ba081a5595315cf /drivers/net/usb
parentaf3d7c1e55a6c3ce92ac86d5e1a3b606028c0145 (diff)
smsc95xx: detect chip revision specific features
Instead of storing the number of wake-up frame filter registers in the pdata structure, this patch changes the driver to detect the type of device we have and store its available features. The new two features will be used in future patches. This patch is intended to have no change in behaviour. Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/smsc95xx.c29
-rw-r--r--drivers/net/usb/smsc95xx.h3
2 files changed, 23 insertions, 9 deletions
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index e8465fecf43a..3bacb4153f3d 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -51,6 +51,10 @@
51#define SUPPORTED_WAKE (WAKE_UCAST | WAKE_BCAST | \ 51#define SUPPORTED_WAKE (WAKE_UCAST | WAKE_BCAST | \
52 WAKE_MCAST | WAKE_ARP | WAKE_MAGIC) 52 WAKE_MCAST | WAKE_ARP | WAKE_MAGIC)
53 53
54#define FEATURE_8_WAKEUP_FILTERS (0x01)
55#define FEATURE_PHY_NLP_CROSSOVER (0x02)
56#define FEATURE_AUTOSUSPEND (0x04)
57
54#define check_warn(ret, fmt, args...) \ 58#define check_warn(ret, fmt, args...) \
55 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); }) 59 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); })
56 60
@@ -66,7 +70,7 @@ struct smsc95xx_priv {
66 u32 hash_lo; 70 u32 hash_lo;
67 u32 wolopts; 71 u32 wolopts;
68 spinlock_t mac_cr_lock; 72 spinlock_t mac_cr_lock;
69 int wuff_filter_count; 73 u8 features;
70}; 74};
71 75
72static bool turbo_mode = true; 76static bool turbo_mode = true;
@@ -1031,10 +1035,14 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
1031 ret = smsc95xx_read_reg(dev, ID_REV, &val); 1035 ret = smsc95xx_read_reg(dev, ID_REV, &val);
1032 check_warn_return(ret, "Failed to read ID_REV: %d\n", ret); 1036 check_warn_return(ret, "Failed to read ID_REV: %d\n", ret);
1033 val >>= 16; 1037 val >>= 16;
1034 if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9512_)) 1038
1035 pdata->wuff_filter_count = LAN9500A_WUFF_NUM; 1039 if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) ||
1036 else 1040 (val == ID_REV_CHIP_ID_89530_) || (val == ID_REV_CHIP_ID_9730_))
1037 pdata->wuff_filter_count = LAN9500_WUFF_NUM; 1041 pdata->features = (FEATURE_8_WAKEUP_FILTERS |
1042 FEATURE_PHY_NLP_CROSSOVER |
1043 FEATURE_AUTOSUSPEND);
1044 else if (val == ID_REV_CHIP_ID_9512_)
1045 pdata->features = FEATURE_8_WAKEUP_FILTERS;
1038 1046
1039 dev->net->netdev_ops = &smsc95xx_netdev_ops; 1047 dev->net->netdev_ops = &smsc95xx_netdev_ops;
1040 dev->net->ethtool_ops = &smsc95xx_ethtool_ops; 1048 dev->net->ethtool_ops = &smsc95xx_ethtool_ops;
@@ -1109,6 +1117,9 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
1109 u32 command[2]; 1117 u32 command[2];
1110 u32 offset[2]; 1118 u32 offset[2];
1111 u32 crc[4]; 1119 u32 crc[4];
1120 int wuff_filter_count =
1121 (pdata->features & FEATURE_8_WAKEUP_FILTERS) ?
1122 LAN9500A_WUFF_NUM : LAN9500_WUFF_NUM;
1112 int i, filter = 0; 1123 int i, filter = 0;
1113 1124
1114 memset(command, 0, sizeof(command)); 1125 memset(command, 0, sizeof(command));
@@ -1166,7 +1177,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
1166 filter++; 1177 filter++;
1167 } 1178 }
1168 1179
1169 for (i = 0; i < (pdata->wuff_filter_count * 4); i++) { 1180 for (i = 0; i < (wuff_filter_count * 4); i++) {
1170 ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]); 1181 ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]);
1171 if (ret < 0) 1182 if (ret < 0)
1172 kfree(filter_mask); 1183 kfree(filter_mask);
@@ -1174,17 +1185,17 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
1174 } 1185 }
1175 kfree(filter_mask); 1186 kfree(filter_mask);
1176 1187
1177 for (i = 0; i < (pdata->wuff_filter_count / 4); i++) { 1188 for (i = 0; i < (wuff_filter_count / 4); i++) {
1178 ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]); 1189 ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]);
1179 check_warn_return(ret, "Error writing WUFF"); 1190 check_warn_return(ret, "Error writing WUFF");
1180 } 1191 }
1181 1192
1182 for (i = 0; i < (pdata->wuff_filter_count / 4); i++) { 1193 for (i = 0; i < (wuff_filter_count / 4); i++) {
1183 ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]); 1194 ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]);
1184 check_warn_return(ret, "Error writing WUFF"); 1195 check_warn_return(ret, "Error writing WUFF");
1185 } 1196 }
1186 1197
1187 for (i = 0; i < (pdata->wuff_filter_count / 2); i++) { 1198 for (i = 0; i < (wuff_filter_count / 2); i++) {
1188 ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]); 1199 ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]);
1189 check_warn_return(ret, "Error writing WUFF"); 1200 check_warn_return(ret, "Error writing WUFF");
1190 } 1201 }
diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
index 1f862693dd7e..99f04a251a4e 100644
--- a/drivers/net/usb/smsc95xx.h
+++ b/drivers/net/usb/smsc95xx.h
@@ -55,6 +55,9 @@
55#define ID_REV_CHIP_ID_9500_ (0x9500) 55#define ID_REV_CHIP_ID_9500_ (0x9500)
56#define ID_REV_CHIP_ID_9500A_ (0x9E00) 56#define ID_REV_CHIP_ID_9500A_ (0x9E00)
57#define ID_REV_CHIP_ID_9512_ (0xEC00) 57#define ID_REV_CHIP_ID_9512_ (0xEC00)
58#define ID_REV_CHIP_ID_9530_ (0x9530)
59#define ID_REV_CHIP_ID_89530_ (0x9E08)
60#define ID_REV_CHIP_ID_9730_ (0x9730)
58 61
59#define INT_STS (0x08) 62#define INT_STS (0x08)
60#define INT_STS_TX_STOP_ (0x00020000) 63#define INT_STS_TX_STOP_ (0x00020000)