smsc75xx: let EEPROM determine GPIO/LED settings
authorSteve Glendinning <steve.glendinning@shawell.net>
Fri, 4 May 2012 00:57:13 +0000 (00:57 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 May 2012 03:43:57 +0000 (23:43 -0400)
This patch allows the GPIO/LED settings to be configured by the
EEPROM if present, and only sets the default values (LED outputs
for link/activity) when an EEPROM is not detected.

Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/smsc75xx.c

index 72b62b51c46f83107d159f1bde629032e8da4688..fb1a087b101d1b61447b7cc580d11f74283428f1 100644 (file)
@@ -903,15 +903,20 @@ static int smsc75xx_reset(struct usbnet *dev)
 
        netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x", buf);
 
-       /* Configure GPIO pins as LED outputs */
-       ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf);
-       check_warn_return(ret, "Failed to read LED_GPIO_CFG: %d", ret);
+       ret = smsc75xx_read_reg(dev, E2P_CMD, &buf);
+       check_warn_return(ret, "Failed to read E2P_CMD: %d", ret);
 
-       buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL);
-       buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL;
+       /* only set default GPIO/LED settings if no EEPROM is detected */
+       if (!(buf & E2P_CMD_LOADED)) {
+               ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf);
+               check_warn_return(ret, "Failed to read LED_GPIO_CFG: %d", ret);
 
-       ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf);
-       check_warn_return(ret, "Failed to write LED_GPIO_CFG: %d", ret);
+               buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL);
+               buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL;
+
+               ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf);
+               check_warn_return(ret, "Failed to write LED_GPIO_CFG: %d", ret);
+       }
 
        ret = smsc75xx_write_reg(dev, FLOW, 0);
        check_warn_return(ret, "Failed to write FLOW: %d", ret);