[U-Boot] [PATCH 08/10] am43xx: Add USB device boot support to SPL

Mugunthan V N mugunthanvnm at ti.com
Tue Mar 15 13:14:17 CET 2016


From: Tom Rini <trini at ti.com>

Add in code to initialize the DWC3 gadget controller so that we can do
RNDIS in SPL on these platforms.

Signed-off-by: Tom Rini <trini at ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon at ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
---
 board/ti/am43xx/board.c           | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/Makefile                  |  2 ++
 drivers/usb/gadget/gadget_chips.h |  2 ++
 include/configs/am43xx_evm.h      | 12 ++++++++++++
 4 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index c75ef53..e71d86e 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -766,8 +766,8 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#ifdef CONFIG_DRIVER_TI_CPSW
-
+#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
+	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
 static void cpsw_control(int enabled)
 {
 	/* Additional controls can be added here */
@@ -805,7 +805,24 @@ static struct cpsw_platform_data cpsw_data = {
 	.host_port_num		= 0,
 	.version		= CPSW_CTRL_VERSION_2,
 };
+#endif
 
+/*
+ * This function will:
+ * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr
+ * in the environment
+ * Perform fixups to the PHY present on certain boards.  We only need this
+ * function in:
+ * - SPL with either CPSW or USB ethernet support
+ * - Full U-Boot, with either CPSW or USB ethernet
+ * Build in only these cases to avoid warnings about unused variables
+ * when we build an SPL that has neither option but full U-Boot will.
+ */
+#if ((defined(CONFIG_SPL_ETH_SUPPORT) || \
+	defined(CONFIG_SPL_USBETH_SUPPORT)) && \
+	defined(CONFIG_SPL_BUILD)) || \
+	((defined(CONFIG_DRIVER_TI_CPSW) || \
+	  defined(CONFIG_USB_ETHER)) && !defined(CONFIG_SPL_BUILD))
 int board_eth_init(bd_t *bis)
 {
 	int rv;
@@ -822,12 +839,15 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
+#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
+	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
 	if (!getenv("ethaddr")) {
 		puts("<ethaddr> not set. Validating first E-fuse MAC\n");
 		if (is_valid_ethaddr(mac_addr))
 			eth_setenv_enetaddr("ethaddr", mac_addr);
 	}
 
+#ifndef CONFIG_SPL_BUILD
 	mac_lo = readl(&cdev->macid1l);
 	mac_hi = readl(&cdev->macid1h);
 	mac_addr[0] = mac_hi & 0xFF;
@@ -841,6 +861,7 @@ int board_eth_init(bd_t *bis)
 		if (is_valid_ethaddr(mac_addr))
 			eth_setenv_enetaddr("eth1addr", mac_addr);
 	}
+#endif
 
 	if (board_is_eposevm()) {
 		writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel);
@@ -862,8 +883,20 @@ int board_eth_init(bd_t *bis)
 	}
 
 	rv = cpsw_register(&cpsw_data);
-	if (rv < 0)
+	if (rv < 0) {
 		printf("Error %d registering CPSW switch\n", rv);
+		return rv;
+	}
+#endif
+#if defined(CONFIG_USB_ETHER) && \
+	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
+	if (is_valid_ethaddr(mac_addr))
+		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+
+	rv = usb_eth_initialize(bis);
+	if (rv < 0)
+		printf("Error %d registering USB_ETHER\n", rv);
+#endif
 
 	return rv;
 }
diff --git a/drivers/Makefile b/drivers/Makefile
index e7eab66..35319b5 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -31,6 +31,8 @@ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/
+obj-$(CONFIG_USB_DWC3_GADGET) += usb/dwc3/
+obj-$(CONFIG_USB_DWC3_GADGET) += usb/gadget/udc/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += usb/gadget/
 obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/
 obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += usb/host/
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index 973cd97..c09d30e 100644
--- a/drivers/usb/gadget/gadget_chips.h
+++ b/drivers/usb/gadget/gadget_chips.h
@@ -231,5 +231,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
 		return 0x21;
 	else if (gadget_is_fotg210(gadget))
 		return 0x22;
+	else if (gadget_is_dwc3(gadget))
+		return 0x23;
 	return -ENOENT;
 }
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 7d2a93e..546cc09 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -129,6 +129,9 @@
 #define CONFIG_USB_DWC3_GADGET
 
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00"
 #define CONFIG_USB_GADGET_DOWNLOAD
 #define CONFIG_USB_GADGET_VBUS_DRAW 2
 #define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
@@ -148,6 +151,15 @@
 #undef CONFIG_TIMER
 #endif
 
+#if (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT))
+#undef CONFIG_ENV_IS_IN_FAT
+#define CONFIG_ENV_IS_NOWHERE
+#endif
+
+#if defined(CONFIG_SPL_USBETH_SUPPORT) || defined(CONFIG_SPL_ETH_SUPPORT)
+#define CONFIG_SPL_NET_SUPPORT
+#endif
+
 #ifndef CONFIG_SPL_BUILD
 /* USB Device Firmware Update support */
 #define CONFIG_USB_FUNCTION_DFU
-- 
2.7.2.333.g70bd996



More information about the U-Boot mailing list