All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 08/10] am43xx: Add USB device boot support to SPL
Date: Tue, 15 Mar 2016 17:44:17 +0530	[thread overview]
Message-ID: <1458044059-18363-9-git-send-email-mugunthanvnm@ti.com> (raw)
In-Reply-To: <1458044059-18363-1-git-send-email-mugunthanvnm@ti.com>

From: Tom Rini <trini@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@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@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

  parent reply	other threads:[~2016-03-15 12:14 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 12:14 [U-Boot] [PATCH 00/10] driver model bring-up of dwc3 usb peripheral Mugunthan V N
2016-03-15 12:14 ` [U-Boot] [PATCH 01/10] drivers: usb: dwc3: remove devm_zalloc from linux_compact Mugunthan V N
2016-03-15 13:59   ` Tom Rini
2016-04-15 14:13     ` Simon Glass
2016-04-18  6:36       ` Mugunthan V N
2016-04-18 14:38         ` Simon Glass
2016-03-15 12:14 ` [U-Boot] [PATCH 02/10] drivers: usb: dwc3-omap: move usb_gadget_handle_interrupts from board files to drivers Mugunthan V N
2016-03-15 14:00   ` Tom Rini
2016-03-15 12:14 ` [U-Boot] [PATCH 03/10] am437x: board: do not register usb devices when CONFIG_DM_USB is defined Mugunthan V N
2016-03-15 14:00   ` Tom Rini
2016-03-15 12:14 ` [U-Boot] [PATCH 04/10] dra7xx: " Mugunthan V N
2016-03-15 14:00   ` Tom Rini
2016-03-15 12:14 ` [U-Boot] [PATCH 05/10] drivers: usb: dwc3: add ti dwc3 misc driver for wrapper Mugunthan V N
2016-03-15 14:01   ` Tom Rini
2016-03-15 12:14 ` [U-Boot] [PATCH 06/10] drivers: usb: common: add support to get maximum speed from dt Mugunthan V N
2016-03-15 14:01   ` Tom Rini
2016-04-09 18:34   ` Simon Glass
2016-03-15 12:14 ` [U-Boot] [PATCH 07/10] drivers: usb: dwc3: add ti dwc3 peripheral driver with driver model support Mugunthan V N
2016-03-15 14:02   ` Tom Rini
2016-03-15 12:14 ` Mugunthan V N [this message]
2016-03-15 14:04   ` [U-Boot] [PATCH 08/10] am43xx: Add USB device boot support to SPL Tom Rini
2016-03-15 12:14 ` [U-Boot] [PATCH 09/10] configs: am43xx: Add am43xx_evm_usbspl_defconfig Mugunthan V N
2016-03-15 14:05   ` Tom Rini
2016-03-15 12:14 ` [U-Boot] [PATCH 10/10] defconfig: am437x_sk_evm: enable usb driver model Mugunthan V N
2016-03-15 14:05   ` Tom Rini
2016-03-31 14:10 ` [U-Boot] [PATCH 00/10] driver model bring-up of dwc3 usb peripheral Michal Simek
2016-03-31 15:11   ` Tom Rini
2016-03-31 15:24     ` Marek Vasut
2016-04-06 23:16       ` Simon Glass
2016-04-08 19:45         ` Tom Rini
2016-04-11 12:20           ` Simon Glass
2016-04-11 14:52             ` Mugunthan V N
2016-04-11 14:57               ` Simon Glass
2016-04-12 10:34                 ` Mugunthan V N
2016-12-20 14:04                   ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458044059-18363-9-git-send-email-mugunthanvnm@ti.com \
    --to=mugunthanvnm@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.