The SMSC95XX is a USB hub with a built-in Ethernet adapter. This adds support
for this, using the USB host network framework.
Changes for v2:
- Coding style cleanup
- Changed some comments as suggested
Changes for v3:
- Change turbo_mode to #define
Changes for v4:
- Dropped Tegra2 specific bit
- Fixed a few broken bits in SMSC from my testing
Changes for v5:
- Code style clean-ups in SMSC
- Cleaned up debugging of errors in SMSC driver
Changes for v6:
- Set NET_IP_ALIGN to 0 always
Changes for v8:
- Add setup of SMSC write_hwaddr function
Signed-off-by: Simon Glass
Tested-by: Eric Bénard
---
drivers/usb/eth/Makefile|1 +
drivers/usb/eth/smsc95xx.c | 879 +++
drivers/usb/eth/usb_ether.c |7 +
include/usb_ether.h | 13 +
4 files changed, 900 insertions(+), 0 deletions(-)
create mode 100644 drivers/usb/eth/smsc95xx.c
diff --git a/drivers/usb/eth/Makefile b/drivers/usb/eth/Makefile
index 6a5f25a..e28793d 100644
--- a/drivers/usb/eth/Makefile
+++ b/drivers/usb/eth/Makefile
@@ -28,6 +28,7 @@ COBJS-$(CONFIG_USB_HOST_ETHER) += usb_ether.o
ifdef CONFIG_USB_ETHER_ASIX
COBJS-y += asix.o
endif
+COBJS-$(CONFIG_USB_ETHER_SMSC95XX) += smsc95xx.o
COBJS := $(COBJS-y)
SRCS := $(COBJS:.o=.c)
diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
new file mode 100644
index 000..97f2729
--- /dev/null
+++ b/drivers/usb/eth/smsc95xx.c
@@ -0,0 +1,879 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * Copyright (C) 2009 NVIDIA, Corporation
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include
+#include
+#include
+#include "usb_ether.h"
+
+/* SMSC LAN95xx based USB 2.0 Ethernet Devices */
+
+/* Tx command words */
+#define TX_CMD_A_FIRST_SEG_0x2000
+#define TX_CMD_A_LAST_SEG_ 0x1000
+
+/* Rx status word */
+#define RX_STS_FL_ 0x3FFF /* Frame Length */
+#define RX_STS_ES_ 0x8000 /* Error Summary */
+
+/* SCSRs */
+#define ID_REV 0x00
+
+#define INT_STS0x08
+
+#define TX_CFG 0x10
+#define TX_CFG_ON_ 0x0004
+
+#define HW_CFG 0x14
+#define HW_CFG_BIR_0x1000
+#define HW_CFG_RXDOFF_ 0x0600
+#define HW_CFG_MEF_0x0020
+#define HW_CFG_BCE_0x0002
+#define HW_CFG_LRST_ 0x0008
+
+#define PM_CTRL0x20
+#define PM_CTL_PHY_RST_0x0010
+
+#define AFC_CFG0x2C
+
+/*
+ * Hi watermark = 15.5Kb (~10 mtu pkts)
+ * low watermark = 3k (~2 mtu pkts)
+ * backpressure duration = ~ 350us
+ * Apply FC on any frame.
+ */
+#define AFC_CFG_DEFAULT0x00F830A1
+
+#define E2P_CMD0x30
+#define E2P_CMD_BUSY_ 0x8000
+#define E2P_CMD_READ_ 0x
+#define E2P_CMD_TIMEOUT_ 0x0400
+#define E2P_CMD_LOADED_0x0200
+#define E2P_CMD_ADDR_ 0x01FF
+
+#define E2P_DATA 0x34
+
+#define BURST_CAP 0x38
+
+#define INT_EP_CTL 0x68
+#define INT_EP_CTL_PHY_INT_0x8000
+
+#define BULK_IN_DLY0x6C
+
+/* MAC CSRs */
+#define MAC_CR 0x100
+#define MAC_CR_MCPAS_ 0x0008
+#define MAC_CR_PRMS_ 0x0004
+#define MAC_CR_HPFILT_ 0x2000
+#define MAC_CR_TXEN_ 0x0008
+#define MAC_CR_RXEN_ 0x0004
+
+#define ADDRH 0x104
+
+#define ADDRL 0x108
+
+#define MII_ADDR 0x114
+#define MII_WRITE_ 0x02
+#define MII_BUSY_ 0x01
+#define MII_READ_ 0x00 /* ~of MII Write bit */
+
+#define MII_DATA 0x118
+
+#define FLOW 0x11C
+
+#define VLAN1 0x120
+