Skip to content
Permalink
Browse files
kernel-3.4.x: backport new Realtek RTL8152/8153 USB 3.0/2.0 Ethernet …
…driver
  • Loading branch information
andy-padavan committed Aug 8, 2015
1 parent c980d8c commit 3806a1efc6a54d002eb78b134a855fc1b684cdb8
@@ -83,8 +83,7 @@ config USB_PEGASUS
module will be called pegasus.

config USB_RTL8150
tristate "USB RTL8150 based ethernet device support (EXPERIMENTAL)"
depends on EXPERIMENTAL
tristate "USB RTL8150 based ethernet device support"
select NET_CORE
select MII
help
@@ -95,6 +94,17 @@ config USB_RTL8150
To compile this driver as a module, choose M here: the
module will be called rtl8150.

config USB_RTL8152
tristate "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
select MII
help
This option adds support for Realtek RTL8152 based USB 2.0
10/100 Ethernet adapters and RTL8153 based USB 3.0 10/100/1000
Ethernet adapters.

To compile this driver as a module, choose M here: the
module will be called r8152.

config USB_USBNET
tristate "Multi-purpose USB Networking Framework"
select NET_CORE
@@ -6,6 +6,7 @@ obj-$(CONFIG_USB_CATC) += catc.o
obj-$(CONFIG_USB_KAWETH) += kaweth.o
obj-$(CONFIG_USB_PEGASUS) += pegasus.o
obj-$(CONFIG_USB_RTL8150) += rtl8150.o
obj-$(CONFIG_USB_RTL8152) += r8152.o
obj-$(CONFIG_USB_HSO) += hso.o
obj-$(CONFIG_USB_NET_AX8817X) += asix.o
obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o
@@ -825,7 +825,8 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
/* Get the MAC address */
ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
if (ret < 0) {
dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n",
ret);
goto out;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@@ -904,7 +905,7 @@ static int ax88772_reset(struct usbnet *dev)

ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
if (ret < 0) {
dbg("Select PHY #1 failed: %d", ret);
netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
goto out;
}

@@ -932,13 +933,13 @@ static int ax88772_reset(struct usbnet *dev)

msleep(150);
rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
ret = asix_write_rx_ctl(dev, 0x0000);
if (ret < 0)
goto out;

rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);

ret = asix_sw_reset(dev, AX_SWRESET_PRL);
if (ret < 0)
@@ -965,7 +966,7 @@ static int ax88772_reset(struct usbnet *dev)
AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
AX88772_IPG2_DEFAULT, 0, NULL);
if (ret < 0) {
dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
goto out;
}

@@ -982,10 +983,13 @@ static int ax88772_reset(struct usbnet *dev)
goto out;

rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
rx_ctl);

rx_ctl = asix_read_medium_status(dev);
dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
netdev_dbg(dev->net,
"Medium Status is 0x%04x after all initializations\n",
rx_ctl);

return 0;

@@ -1020,7 +1024,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
/* Get the MAC address */
ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
if (ret < 0) {
dbg("Failed to read MAC address: %d", ret);
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@@ -1041,7 +1045,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
/* Reset the PHY to normal operation mode */
ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
if (ret < 0) {
dbg("Select PHY #1 failed: %d", ret);
netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
return ret;
}

@@ -1061,7 +1065,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)

/* Read PHYID register *AFTER* the PHY was reset properly */
phyid = asix_get_phyid(dev);
dbg("PHYID=0x%08x", phyid);
netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);

/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
if (dev->driver_info->flags & FLAG_FRAMING_AX) {
@@ -1186,13 +1190,13 @@ static int ax88178_reset(struct usbnet *dev)
u32 phyid;

asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status);
dbg("GPIO Status: 0x%04x", status);
netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status);

asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);

dbg("EEPROM index 0x17 is 0x%04x", eeprom);
netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom);

if (eeprom == cpu_to_le16(0xffff)) {
data->phymode = PHY_MODE_MARVELL;
@@ -1203,7 +1207,7 @@ static int ax88178_reset(struct usbnet *dev)
data->ledmode = le16_to_cpu(eeprom) >> 8;
gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1;
}
dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode);

/* Power up external GigaPHY through AX88178 GPIO pin */
asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
@@ -1212,14 +1216,14 @@ static int ax88178_reset(struct usbnet *dev)
asix_write_gpio(dev, 0x001c, 300);
asix_write_gpio(dev, 0x003c, 30);
} else {
dbg("gpio phymode == 1 path");
netdev_dbg(dev->net, "gpio phymode == 1 path\n");
asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
}

/* Read PHYID register *AFTER* powering up PHY */
phyid = asix_get_phyid(dev);
dbg("PHYID=0x%08x", phyid);
netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);

/* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */
asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL);
@@ -1387,7 +1391,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
/* Get the MAC address */
ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
if (ret < 0) {
dbg("Failed to read MAC address: %d", ret);
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);

0 comments on commit 3806a1e

Please sign in to comment.