Cc netdev and usb lists.
On Fri, Jan 11, 2013 at 9:17 AM, <freddy@xxxxxxxxxxx> wrote:From: Freddy Xin <freddy@xxxxxxxxxxx>
This patch adds a driver for ASIX's AX88179 family of USB 3.0/2.0
to gigabit ethernet adapters. It's based on the AX88xxx driver but
the usb commands used to access registers for AX88179 are completely different.
This driver had been verified on x86 system with AX88179/AX88178A and
Sitcomm LN-032 USB dongles.
Signed-off-by: Freddy Xin <freddy@xxxxxxxxxxx>
---
drivers/net/usb/Kconfig | 18 +
drivers/net/usb/Makefile | 1 +
drivers/net/usb/ax88179_178a.c | 1457 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 1476 insertions(+)
create mode 100644 drivers/net/usb/ax88179_178a.c
[...]diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 0000000..47504ea
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
+static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+ u16 size, void *data)
+{
+ int ret;
+ ret = usbnet_read_cmd(dev, cmd,
+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ value, index, data, size);
+
+ if (ret != size && ret >= 0)
+ return -EINVAL;
+ return ret;
+}
+
+static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+ u16 size, void *data)
+{
+ return usbnet_write_cmd(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR
+ | USB_RECIP_DEVICE, value, index, data, size);
+}
+
+static void
+ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
+ u16 size, void *data)
+{
+ usbnet_write_cmd_async(dev, cmd,
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ value, index, data, size);
+}
+
+static int ax88179_get_eeprom(struct net_device *net,
+ struct ethtool_eeprom *eeprom, u8 *data)
+{
+ struct usbnet *dev = netdev_priv(net);
+ u16 *ebuf = (u16 *)data;
+ int i;
+
+ /* Crude hack to ensure that we don't overwrite memory
+ * if an odd length is supplied
+ */
+ if (eeprom->len % 2)
+ return -EINVAL;
+
+ /* ax8817x returns 2 bytes from eeprom on read */
+ for (i = 0; i < eeprom->len / 2; i++) {
+ if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM,
+ eeprom->offset + i, 1, 2, &ebuf[i]) < 0)
+ return -EINVAL;
+ }
+ return 0;
+}
+