All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot]  [RFC 0/6] Odroid U3 usb initialization
@ 2019-04-01 11:52 Anand Moon
  2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
                   ` (5 more replies)
  0 siblings, 6 replies; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

Odroid u3 had the issue like ethernet would not get initialize
from the u-boot with "usb start" command.

These changes are based on following work done by Tobias Jakobi

[0] https://github.com/tobiasjakobi/u-boot/commit/77a1142eb0aac08464398ef053d66dbf42b42486

These changes tried to address the issue of initialization
of usb devices.

Below is the command I have used for testing.

Tested on Odroid U3+ 
Other board need to tested as I dnot have them.

----------------------------------------------
U-Boot 2019.04-rc4-00089-ga5515f5f60 (Apr 01 2019 - 11:11:59 +0000)

CPU:   Exynos4412 @ 1 GHz
Model: Odroid based on Exynos4412
Type:  u3
DRAM:  2 GiB
LDO20 at VDDQ_EMMC_1.8V: set 1800000 uV; enabling
LDO22 at VDDQ_EMMC_2.8V: set 2800000 uV; enabling
LDO21 at TFLASH_2.8V: set 2800000 uV; enabling
MMC:   SAMSUNG SDHCI: 1, EXYNOS DWMMC: 0
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment

Net:   No ethernet found.
Hit any key to stop autoboot:  0
Odroid #
Odroid # usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 1 Ethernet Device(s) found
Odroid # usb  reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 1 Ethernet Device(s) found
Odroid # usb info
1: Hub,  USB Revision 2.0
 - u-boot EHCI Host Controller
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

2: Vendor specific,  USB Revision 2.0
 - Class: Vendor specific
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0424  Product 0x9730 Version 1.0
   Configuration: 1
   - Interfaces: 1 Bus Powered 500mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 3
     - Class Vendor specific
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512
     - Endpoint 3 In Interrupt MaxPacket 16 Interval 4ms

3: Hub,  USB Revision 2.0
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0424  Product 0x3503 Version 161.160
   Configuration: 1
   - Interfaces: 1 Self Powered Remote Wakeup 2mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 1 Interval 12ms
     - Endpoint 1 In Interrupt MaxPacket 1 Interval 12ms

4: Mass Storage,  USB Revision 2.10
 - JMicron JMS567 DB12345678A3
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x152d  Product 0x0578 Version 99.1
   Configuration: 1
   - Interfaces: 1 Self Powered 30mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 2
     - Class Mass Storage, Transp. SCSI, Bulk only
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512
     - Endpoint 1 Out Bulk MaxPacket 512
     - Endpoint 2 In Bulk MaxPacket 512
     - Endpoint 3 In Bulk MaxPacket 512
     - Endpoint 4 Out Bulk MaxPacket 512

Odroid # reset
resetting ...


U-Boot 2019.04-rc4-00089-ga5515f5f60 (Apr 01 2019 - 11:11:59 +0000)

----------------------

Anand Moon (6):
  odroid: exynos: USB initialization on the U3/X2
  odroid: exynos: usb clean up for U3/X2
  usb: exynos: add init_after_reset for usb reset
  configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  arm: exynos: odroid: fix the confict scripaddr extra env setting
  arm: exynos: add usbnet_devaddr setting to env

 board/samsung/common/board.c   |  4 ++--
 board/samsung/odroid/Kconfig   |  3 +++
 board/samsung/odroid/odroid.c  | 19 ++++++++++++++-----
 drivers/usb/host/ehci-exynos.c | 33 ++++++++++++++++++++++++++++++++-
 include/configs/odroid.h       |  6 +++++-
 5 files changed, 56 insertions(+), 9 deletions(-)

-- 
2.21.0

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
@ 2019-04-01 11:52 ` Anand Moon
  2019-04-01 12:48   ` Krzysztof Kozlowski
                     ` (2 more replies)
  2019-04-01 11:52 ` [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2 Anand Moon
                   ` (4 subsequent siblings)
  5 siblings, 3 replies; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>

Rename board_usb_init() to exynos_usb_init() and call it
early in the Exynos EHCI driver when probing.

This kind of works. After a 'usb start; usb stop; usb start'
cycle the attached devices are recognized.

Add small delay between gpio_direction_output to stable
initialization of usb gpio pins.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
Reoder the exynos_usb_init so that "usb start" command initialization
correcly.
---
---
 board/samsung/odroid/odroid.c  | 14 +++++++++-----
 drivers/usb/host/ehci-exynos.c |  7 +++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index 3e594fd850..79d14ead01 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
 };
 #endif
 
-#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
-
 static void set_usb3503_ref_clk(void)
 {
 #ifdef CONFIG_BOARD_TYPES
@@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
 #endif /* CONFIG_BOARD_TYPES */
 }
 
-int board_usb_init(int index, enum usb_init_type init)
+int exynos_usb_init(void)
 {
-#ifdef CONFIG_CMD_USB
 	struct udevice *dev;
 	int ret;
 
@@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
 	/* Disconnect, Reset, Connect */
 	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
 	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
+	sdelay(200000);
 	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
 	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
 
@@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
 		pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
 		return ret;
 	}
-#endif
+
+	return 0;
+}
+
+#ifdef CONFIG_USB_GADGET
+int board_usb_init(int index, enum usb_init_type init)
+{
 	debug("USB_udc_probe\n");
 	return dwc2_udc_probe(&s5pc210_otg_data);
 }
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index fabc662eb6..b0f7bd4936 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
 	struct gpio_desc vbus_gpio;
 };
 
+extern int exynos_usb_init(void);
+
 /**
  * Contains pointers to register base addresses
  * for the usb controller.
@@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
 	setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
 	udelay(10);
 	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
+
+	/*
+	 * "usb start" initialize the usb driver
+	 */
+	exynos_usb_init();
 }
 
 static void setup_usb_phy(struct exynos_usb_phy *usb)
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [U-Boot]  [RFC 2/6] odroid: exynos: usb clean up for U3/X2
  2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
  2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
@ 2019-04-01 11:52 ` Anand Moon
  2019-04-01 12:51   ` Krzysztof Kozlowski
  2019-04-01 11:52 ` [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset Anand Moon
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

Add board_usb_cleanup routine to cleanup after
de-registering it usb devices. Also fixed the
compilation error for other board.

Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
 board/samsung/common/board.c  | 4 ++--
 board/samsung/odroid/odroid.c | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index 9adbd1e2cf..c74aca9b0a 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -351,10 +351,10 @@ void reset_misc(void)
 	}
 }
 
+#ifdef CONFIG_USB_DWC3
 int board_usb_cleanup(int index, enum usb_init_type init)
 {
-#ifdef CONFIG_USB_DWC3
 	dwc3_uboot_exit(index);
-#endif
 	return 0;
 }
+#endif
diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index 79d14ead01..547ae698cf 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -538,4 +538,9 @@ int board_usb_init(int index, enum usb_init_type init)
 	debug("USB_udc_probe\n");
 	return dwc2_udc_probe(&s5pc210_otg_data);
 }
+
+int board_usb_cleanup(int index, enum usb_init_type init)
+{
+	return s5pc210_phy_control(index);
+}
 #endif
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset
  2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
  2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
  2019-04-01 11:52 ` [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2 Anand Moon
@ 2019-04-01 11:52 ` Anand Moon
  2019-04-01 12:55   ` Krzysztof Kozlowski
  2019-04-01 11:52 ` [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option Anand Moon
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

Some host controllers need addidional re-initialization
after ehci_reset() so we add .init_after_reset callback
which is requires to reinit the phy after controller reset.

Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
 drivers/usb/host/ehci-exynos.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index b0f7bd4936..e6a542e092 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -143,6 +143,23 @@ static void exynos5_setup_usb_phy(struct exynos_usb_phy *usb)
 			EHCICTRL_ENAINCR16);
 }
 
+static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
+{
+	if (cpu_is_exynos4()) {
+		if (proid_is_exynos4412()) {
+			/*
+			 * "usb reset" cmd: restart re-initialize the usb driver
+			 */
+			exynos_usb_init();
+		}
+	}
+	return 0;
+}
+
+static const struct ehci_ops exynos_ehci_ops = {
+	.init_after_reset = ehci_exynos_init_after_reset,
+};
+
 static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
 {
 	writel(CLK_24MHZ, &usb->usbphyclk);
@@ -234,7 +251,8 @@ static int ehci_usb_probe(struct udevice *dev)
 	hcor = (struct ehci_hcor *)((uint32_t)ctx->hcd +
 			HC_LENGTH(ehci_readl(&ctx->hcd->cr_capbase)));
 
-	return ehci_register(dev, ctx->hcd, hcor, NULL, 0, USB_INIT_HOST);
+	return ehci_register(dev, ctx->hcd, hcor, &exynos_ehci_ops,
+			0, USB_INIT_HOST);
 }
 
 static int ehci_usb_remove(struct udevice *dev)
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
                   ` (2 preceding siblings ...)
  2019-04-01 11:52 ` [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset Anand Moon
@ 2019-04-01 11:52 ` Anand Moon
  2019-04-01 12:57   ` Krzysztof Kozlowski
  2019-04-01 11:52 ` [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting Anand Moon
  2019-04-01 11:52 ` [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env Anand Moon
  5 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
error on other development boards.

Fix below compilation error:
Error: You must add new CONFIG options using Kconfig
The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_ODROID_USB

Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
 board/samsung/odroid/Kconfig   | 3 +++
 drivers/usb/host/ehci-exynos.c | 6 ++++++
 include/configs/odroid.h       | 1 +
 3 files changed, 10 insertions(+)

diff --git a/board/samsung/odroid/Kconfig b/board/samsung/odroid/Kconfig
index 8b52a0d589..c5fbffabad 100644
--- a/board/samsung/odroid/Kconfig
+++ b/board/samsung/odroid/Kconfig
@@ -9,4 +9,7 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
 	default "odroid"
 
+config SYS_ODROID_USB
+	bool "Exynos4412 Odroid USB"
+
 endif
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index e6a542e092..3f62eba486 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -31,7 +31,9 @@ struct exynos_ehci_platdata {
 	struct gpio_desc vbus_gpio;
 };
 
+#ifdef CONFIG_SYS_ODROID_USB
 extern int exynos_usb_init(void);
+#endif
 
 /**
  * Contains pointers to register base addresses
@@ -145,6 +147,7 @@ static void exynos5_setup_usb_phy(struct exynos_usb_phy *usb)
 
 static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
 {
+#ifdef CONFIG_SYS_ODROID_USB
 	if (cpu_is_exynos4()) {
 		if (proid_is_exynos4412()) {
 			/*
@@ -153,6 +156,7 @@ static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
 			exynos_usb_init();
 		}
 	}
+#endif
 	return 0;
 }
 
@@ -172,10 +176,12 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
 	udelay(10);
 	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
 
+#ifdef CONFIG_SYS_ODROID_USB
 	/*
 	 * "usb start" initialize the usb driver
 	 */
 	exynos_usb_init();
+#endif
 }
 
 static void setup_usb_phy(struct exynos_usb_phy *usb)
diff --git a/include/configs/odroid.h b/include/configs/odroid.h
index 9f2d43e3fa..d8d30c0f62 100644
--- a/include/configs/odroid.h
+++ b/include/configs/odroid.h
@@ -32,6 +32,7 @@
 #define CONFIG_SYS_MEMTEST_START	CONFIG_SYS_SDRAM_BASE
 #define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_SDRAM_BASE + 0x5E00000)
 #define CONFIG_SYS_LOAD_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x3E00000)
+#define CONFIG_SYS_ODROID_USB
 
 #include <linux/sizes.h>
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting
  2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
                   ` (3 preceding siblings ...)
  2019-04-01 11:52 ` [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option Anand Moon
@ 2019-04-01 11:52 ` Anand Moon
  2019-04-01 13:00   ` Krzysztof Kozlowski
  2019-04-01 11:52 ` [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env Anand Moon
  5 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

fix the confict of scriptaddr address with ramdisk_addr_r
also add missing pxefile_addr_r u-boot extras env setting.

Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
 include/configs/odroid.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/configs/odroid.h b/include/configs/odroid.h
index d8d30c0f62..64819cf81c 100644
--- a/include/configs/odroid.h
+++ b/include/configs/odroid.h
@@ -169,9 +169,10 @@
 	"consoleoff=set console console=ram; save; reset\0" \
 	"initrdname=uInitrd\0" \
 	"ramdisk_addr_r=0x42000000\0" \
-	"scriptaddr=0x42000000\0" \
 	"fdt_addr_r=0x40800000\0" \
 	"kernel_addr_r=0x41000000\0" \
+	"scriptaddr=0x50000000\0" \
+	"pxefile_addr_r=0x51000000\0" \
 	BOOTENV
 
 /* GPT */
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env
  2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
                   ` (4 preceding siblings ...)
  2019-04-01 11:52 ` [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting Anand Moon
@ 2019-04-01 11:52 ` Anand Moon
  2019-04-01 13:04   ` Krzysztof Kozlowski
  5 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 11:52 UTC (permalink / raw)
  To: u-boot

Add usbnet_devaddr mac address to extra env setting
to avoid failure of ethernet driver while usb start.

Odroid # usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices...
Error: sms0 address not set.
Warning: failed to set MAC address
1 Ethernet Device(s) found

Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
 include/configs/odroid.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/odroid.h b/include/configs/odroid.h
index 64819cf81c..b0402e8d49 100644
--- a/include/configs/odroid.h
+++ b/include/configs/odroid.h
@@ -33,6 +33,7 @@
 #define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_SDRAM_BASE + 0x5E00000)
 #define CONFIG_SYS_LOAD_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x3E00000)
 #define CONFIG_SYS_ODROID_USB
+#define CONFIG_USBNET_DEV_ADDR          "02:DE:AD:BE:EF:FF"
 
 #include <linux/sizes.h>
 
@@ -173,6 +174,7 @@
 	"kernel_addr_r=0x41000000\0" \
 	"scriptaddr=0x50000000\0" \
 	"pxefile_addr_r=0x51000000\0" \
+	"usbethaddr=" __stringify(CONFIG_USBNET_DEV_ADDR) "\0" \
 	BOOTENV
 
 /* GPT */
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
@ 2019-04-01 12:48   ` Krzysztof Kozlowski
  2019-04-01 16:20     ` Anand Moon
  2019-04-01 12:57   ` Lukasz Majewski
  2019-04-03 19:58   ` Tobias Jakobi
  2 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 12:48 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
>
> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
>
> Rename board_usb_init() to exynos_usb_init() and call it
> early in the Exynos EHCI driver when probing.
>
> This kind of works. After a 'usb start; usb stop; usb start'
> cycle the attached devices are recognized.
>
> Add small delay between gpio_direction_output to stable
> initialization of usb gpio pins.
>
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Reoder the exynos_usb_init so that "usb start" command initialization
> correcly.
> ---
> ---
>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> index 3e594fd850..79d14ead01 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>  };
>  #endif
>
> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> -
>  static void set_usb3503_ref_clk(void)
>  {
>  #ifdef CONFIG_BOARD_TYPES
> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>  #endif /* CONFIG_BOARD_TYPES */
>  }
>
> -int board_usb_init(int index, enum usb_init_type init)
> +int exynos_usb_init(void)
>  {
> -#ifdef CONFIG_CMD_USB
>         struct udevice *dev;
>         int ret;
>
> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
>         /* Disconnect, Reset, Connect */
>         gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>         gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> +       sdelay(200000);

This should be a separate patch with its own explanation.

>         gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>         gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>
> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
>                 pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
>                 return ret;
>         }
> -#endif
> +
> +       return 0;
> +}
> +
> +#ifdef CONFIG_USB_GADGET
> +int board_usb_init(int index, enum usb_init_type init)
> +{
>         debug("USB_udc_probe\n");
>         return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index fabc662eb6..b0f7bd4936 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>         struct gpio_desc vbus_gpio;
>  };
>
> +extern int exynos_usb_init(void);
> +
>  /**
>   * Contains pointers to register base addresses
>   * for the usb controller.
> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
>         setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
>         udelay(10);
>         clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> +
> +       /*
> +        * "usb start" initialize the usb driver
> +        */
> +       exynos_usb_init();

It should be something more generic like
CONFIG_SYS_USB_OHCI_BOARD_INIT which calls board_usb_init()... but it
still will be calling board code from the driver. Why do you need this
in the first place?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2
  2019-04-01 11:52 ` [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2 Anand Moon
@ 2019-04-01 12:51   ` Krzysztof Kozlowski
  2019-04-01 15:57     ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 12:51 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Add board_usb_cleanup routine to cleanup after
> de-registering it usb devices. Also fixed the
> compilation error for other board.

Fix for build error should be in separate commit. Please also quote
the error you are fixing... because the code compiles fine in my case.

> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
>  board/samsung/common/board.c  | 4 ++--
>  board/samsung/odroid/odroid.c | 5 +++++
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
> index 9adbd1e2cf..c74aca9b0a 100644
> --- a/board/samsung/common/board.c
> +++ b/board/samsung/common/board.c
> @@ -351,10 +351,10 @@ void reset_misc(void)
>         }
>  }
>
> +#ifdef CONFIG_USB_DWC3
>  int board_usb_cleanup(int index, enum usb_init_type init)
>  {
> -#ifdef CONFIG_USB_DWC3
>         dwc3_uboot_exit(index);
> -#endif
>         return 0;
>  }
> +#endif
> diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> index 79d14ead01..547ae698cf 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -538,4 +538,9 @@ int board_usb_init(int index, enum usb_init_type init)
>         debug("USB_udc_probe\n");
>         return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> +
> +int board_usb_cleanup(int index, enum usb_init_type init)
> +{
> +       return s5pc210_phy_control(index);

Why you pass index of USB controller as argument "int on"? Index != on...

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset
  2019-04-01 11:52 ` [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset Anand Moon
@ 2019-04-01 12:55   ` Krzysztof Kozlowski
  2019-04-01 16:05     ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 12:55 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Some host controllers need addidional re-initialization

Please run spell-check.

> after ehci_reset() so we add .init_after_reset callback
> which is requires to reinit the phy after controller reset.

s/requires/required/
.... but you do not re-init the phy. The exynos_usb_init() performs
the reset of usb3503 USB hub!

>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
>  drivers/usb/host/ehci-exynos.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index b0f7bd4936..e6a542e092 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -143,6 +143,23 @@ static void exynos5_setup_usb_phy(struct exynos_usb_phy *usb)
>                         EHCICTRL_ENAINCR16);
>  }
>
> +static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
> +{
> +       if (cpu_is_exynos4()) {
> +               if (proid_is_exynos4412()) {

No need for double indentation.

> +                       /*
> +                        * "usb reset" cmd: restart re-initialize the usb driver

Just "reinitialize", not restart reinitialize.

Best regards,
Krzysztof

> +                        */
> +                       exynos_usb_init();
> +               }
> +       }
> +       return 0;
> +}
> +
> +static const struct ehci_ops exynos_ehci_ops = {
> +       .init_after_reset = ehci_exynos_init_after_reset,
> +};
> +
>  static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
>  {
>         writel(CLK_24MHZ, &usb->usbphyclk);
> @@ -234,7 +251,8 @@ static int ehci_usb_probe(struct udevice *dev)
>         hcor = (struct ehci_hcor *)((uint32_t)ctx->hcd +
>                         HC_LENGTH(ehci_readl(&ctx->hcd->cr_capbase)));
>
> -       return ehci_register(dev, ctx->hcd, hcor, NULL, 0, USB_INIT_HOST);
> +       return ehci_register(dev, ctx->hcd, hcor, &exynos_ehci_ops,
> +                       0, USB_INIT_HOST);
>  }
>
>  static int ehci_usb_remove(struct udevice *dev)
> --
> 2.21.0
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
  2019-04-01 12:48   ` Krzysztof Kozlowski
@ 2019-04-01 12:57   ` Lukasz Majewski
  2019-04-01 13:22     ` Jack Mitchell
  2019-04-03 19:58   ` Tobias Jakobi
  2 siblings, 1 reply; 30+ messages in thread
From: Lukasz Majewski @ 2019-04-01 12:57 UTC (permalink / raw)
  To: u-boot

Hi Anand,

> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> 
> Rename board_usb_init() to exynos_usb_init() and call it
> early in the Exynos EHCI driver when probing.
> 
> This kind of works. After a 'usb start; usb stop; usb start'
> cycle the attached devices are recognized.
> 
> Add small delay between gpio_direction_output to stable
> initialization of usb gpio pins.
> 
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Reoder the exynos_usb_init so that "usb start" command initialization
> correcly.
> ---
> ---
>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/board/samsung/odroid/odroid.c
> b/board/samsung/odroid/odroid.c index 3e594fd850..79d14ead01 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>  };
>  #endif
>  
> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> -
>  static void set_usb3503_ref_clk(void)
>  {
>  #ifdef CONFIG_BOARD_TYPES
> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>  #endif /* CONFIG_BOARD_TYPES */
>  }
>  
> -int board_usb_init(int index, enum usb_init_type init)
> +int exynos_usb_init(void)
>  {
> -#ifdef CONFIG_CMD_USB
>  	struct udevice *dev;
>  	int ret;
>  
> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type
> init) /* Disconnect, Reset, Connect */
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> +	sdelay(200000);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>  
> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type
> init) pr_err("Regulator %s value setting error: %d\n", dev->name,
> ret); return ret;
>  	}
> -#endif
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_USB_GADGET
> +int board_usb_init(int index, enum usb_init_type init)

We are not allowed to add board_usb_* code anymore. The _only_ way to
update/fix the USB gadget code is to convert it to driver model [DM] and
describe it via DTS.

Please consider converting this code to DM/DTS.

> +{
>  	debug("USB_udc_probe\n");
>  	return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> diff --git a/drivers/usb/host/ehci-exynos.c
> b/drivers/usb/host/ehci-exynos.c index fabc662eb6..b0f7bd4936 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>  	struct gpio_desc vbus_gpio;
>  };
>  
> +extern int exynos_usb_init(void);
> +
>  /**
>   * Contains pointers to register base addresses
>   * for the usb controller.
> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct
> exynos4412_usb_phy *usb) setbits_le32(&usb->usbphyrstcon,
> (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST)); udelay(10);
>  	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST |
> RSTCON_SWRST)); +
> +	/*
> +	 * "usb start" initialize the usb driver
> +	 */
> +	exynos_usb_init();
>  }
>  
>  static void setup_usb_phy(struct exynos_usb_phy *usb)




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190401/9935a596/attachment.sig>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-01 11:52 ` [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option Anand Moon
@ 2019-04-01 12:57   ` Krzysztof Kozlowski
  2019-04-01 15:50     ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 12:57 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> error on other development boards.
>
> Fix below compilation error:
> Error: You must add new CONFIG options using Kconfig
> The following new ad-hoc CONFIG options were detected:
> CONFIG_SYS_ODROID_USB

There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.

This is something wrong... Are you sure that you are compiling master branch?

Best regards,
Krzysztof

>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
>  board/samsung/odroid/Kconfig   | 3 +++
>  drivers/usb/host/ehci-exynos.c | 6 ++++++
>  include/configs/odroid.h       | 1 +
>  3 files changed, 10 insertions(+)
>
> diff --git a/board/samsung/odroid/Kconfig b/board/samsung/odroid/Kconfig
> index 8b52a0d589..c5fbffabad 100644
> --- a/board/samsung/odroid/Kconfig
> +++ b/board/samsung/odroid/Kconfig
> @@ -9,4 +9,7 @@ config SYS_VENDOR
>  config SYS_CONFIG_NAME
>         default "odroid"
>
> +config SYS_ODROID_USB
> +       bool "Exynos4412 Odroid USB"
> +
>  endif
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index e6a542e092..3f62eba486 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,7 +31,9 @@ struct exynos_ehci_platdata {
>         struct gpio_desc vbus_gpio;
>  };
>
> +#ifdef CONFIG_SYS_ODROID_USB
>  extern int exynos_usb_init(void);
> +#endif
>
>  /**
>   * Contains pointers to register base addresses
> @@ -145,6 +147,7 @@ static void exynos5_setup_usb_phy(struct exynos_usb_phy *usb)
>
>  static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
>  {
> +#ifdef CONFIG_SYS_ODROID_USB
>         if (cpu_is_exynos4()) {
>                 if (proid_is_exynos4412()) {
>                         /*
> @@ -153,6 +156,7 @@ static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
>                         exynos_usb_init();
>                 }
>         }
> +#endif
>         return 0;
>  }
>
> @@ -172,10 +176,12 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
>         udelay(10);
>         clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
>
> +#ifdef CONFIG_SYS_ODROID_USB
>         /*
>          * "usb start" initialize the usb driver
>          */
>         exynos_usb_init();
> +#endif
>  }
>
>  static void setup_usb_phy(struct exynos_usb_phy *usb)
> diff --git a/include/configs/odroid.h b/include/configs/odroid.h
> index 9f2d43e3fa..d8d30c0f62 100644
> --- a/include/configs/odroid.h
> +++ b/include/configs/odroid.h
> @@ -32,6 +32,7 @@
>  #define CONFIG_SYS_MEMTEST_START       CONFIG_SYS_SDRAM_BASE
>  #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x5E00000)
>  #define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x3E00000)
> +#define CONFIG_SYS_ODROID_USB
>
>  #include <linux/sizes.h>
>
> --
> 2.21.0
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting
  2019-04-01 11:52 ` [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting Anand Moon
@ 2019-04-01 13:00   ` Krzysztof Kozlowski
  2019-04-01 15:43     ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 13:00 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
>
> fix the confict of scriptaddr address with ramdisk_addr_r

Start with capital letter, so s/fix/Fix. End with a full-stop.

> also add missing pxefile_addr_r u-boot extras env setting.

s/also/Also/

... but there is no conflict in the first place. These addresses are
not used in the same time.

Best regards,
Krzysztof

>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
>  include/configs/odroid.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/configs/odroid.h b/include/configs/odroid.h
> index d8d30c0f62..64819cf81c 100644
> --- a/include/configs/odroid.h
> +++ b/include/configs/odroid.h
> @@ -169,9 +169,10 @@
>         "consoleoff=set console console=ram; save; reset\0" \
>         "initrdname=uInitrd\0" \
>         "ramdisk_addr_r=0x42000000\0" \
> -       "scriptaddr=0x42000000\0" \
>         "fdt_addr_r=0x40800000\0" \
>         "kernel_addr_r=0x41000000\0" \
> +       "scriptaddr=0x50000000\0" \
> +       "pxefile_addr_r=0x51000000\0" \
>         BOOTENV
>
>  /* GPT */
> --
> 2.21.0
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env
  2019-04-01 11:52 ` [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env Anand Moon
@ 2019-04-01 13:04   ` Krzysztof Kozlowski
  2019-04-01 16:42     ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 13:04 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Add usbnet_devaddr mac address to extra env setting
> to avoid failure of ethernet driver while usb start.
>
> Odroid # usb start
> starting USB...
> USB0:   USB EHCI 1.00
> scanning bus 0 for devices... 3 USB Device(s) found
>        scanning usb for storage devices... 0 Storage Device(s) found
>        scanning usb for ethernet devices...
> Error: sms0 address not set.
> Warning: failed to set MAC address
> 1 Ethernet Device(s) found
>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
>  include/configs/odroid.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/configs/odroid.h b/include/configs/odroid.h
> index 64819cf81c..b0402e8d49 100644
> --- a/include/configs/odroid.h
> +++ b/include/configs/odroid.h
> @@ -33,6 +33,7 @@
>  #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x5E00000)
>  #define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x3E00000)
>  #define CONFIG_SYS_ODROID_USB
> +#define CONFIG_USBNET_DEV_ADDR          "02:DE:AD:BE:EF:FF"
>
>  #include <linux/sizes.h>
>
> @@ -173,6 +174,7 @@
>         "kernel_addr_r=0x41000000\0" \
>         "scriptaddr=0x50000000\0" \
>         "pxefile_addr_r=0x51000000\0" \
> +       "usbethaddr=" __stringify(CONFIG_USBNET_DEV_ADDR) "\0" \

No. Either the user should set it or manufacturer (e.g. in EEPROM).

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-01 12:57   ` Lukasz Majewski
@ 2019-04-01 13:22     ` Jack Mitchell
  0 siblings, 0 replies; 30+ messages in thread
From: Jack Mitchell @ 2019-04-01 13:22 UTC (permalink / raw)
  To: u-boot



On 01/04/2019 13:57, Lukasz Majewski wrote:
> Hi Anand,
> 
>> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
>>
>> Rename board_usb_init() to exynos_usb_init() and call it
>> early in the Exynos EHCI driver when probing.
>>
>> This kind of works. After a 'usb start; usb stop; usb start'
>> cycle the attached devices are recognized.
>>
>> Add small delay between gpio_direction_output to stable
>> initialization of usb gpio pins.
>>
>> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
>> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
>> ---
>> Reoder the exynos_usb_init so that "usb start" command initialization
>> correcly.
>> ---
>> ---
>>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>>  2 files changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/board/samsung/odroid/odroid.c
>> b/board/samsung/odroid/odroid.c index 3e594fd850..79d14ead01 100644
>> --- a/board/samsung/odroid/odroid.c
>> +++ b/board/samsung/odroid/odroid.c
>> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>>  };
>>  #endif
>>  
>> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
>> -
>>  static void set_usb3503_ref_clk(void)
>>  {
>>  #ifdef CONFIG_BOARD_TYPES
>> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>>  #endif /* CONFIG_BOARD_TYPES */
>>  }
>>  
>> -int board_usb_init(int index, enum usb_init_type init)
>> +int exynos_usb_init(void)
>>  {
>> -#ifdef CONFIG_CMD_USB
>>  	struct udevice *dev;
>>  	int ret;
>>  
>> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type
>> init) /* Disconnect, Reset, Connect */
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
>> +	sdelay(200000);
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>>  
>> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type
>> init) pr_err("Regulator %s value setting error: %d\n", dev->name,
>> ret); return ret;
>>  	}
>> -#endif
>> +
>> +	return 0;
>> +}
>> +
>> +#ifdef CONFIG_USB_GADGET
>> +int board_usb_init(int index, enum usb_init_type init)
> 
> We are not allowed to add board_usb_* code anymore. The _only_ way to
> update/fix the USB gadget code is to convert it to driver model [DM] and
> describe it via DTS.
> 
> Please consider converting this code to DM/DTS.

Patrick currently has a series enabling DWC2 OTG DM support which I'm
attempting to switch the rk3288 over too. A branch can be found at
https://github.com/patrickdelaunay/u-boot/tree/v2019.04-stm32mp for testing.

> 
>> +{
>>  	debug("USB_udc_probe\n");
>>  	return dwc2_udc_probe(&s5pc210_otg_data);
>>  }
>> diff --git a/drivers/usb/host/ehci-exynos.c
>> b/drivers/usb/host/ehci-exynos.c index fabc662eb6..b0f7bd4936 100644
>> --- a/drivers/usb/host/ehci-exynos.c
>> +++ b/drivers/usb/host/ehci-exynos.c
>> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>>  	struct gpio_desc vbus_gpio;
>>  };
>>  
>> +extern int exynos_usb_init(void);
>> +
>>  /**
>>   * Contains pointers to register base addresses
>>   * for the usb controller.
>> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct
>> exynos4412_usb_phy *usb) setbits_le32(&usb->usbphyrstcon,
>> (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST)); udelay(10);
>>  	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST |
>> RSTCON_SWRST)); +
>> +	/*
>> +	 * "usb start" initialize the usb driver
>> +	 */
>> +	exynos_usb_init();
>>  }
>>  
>>  static void setup_usb_phy(struct exynos_usb_phy *usb)
> 
> 
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
> 
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting
  2019-04-01 13:00   ` Krzysztof Kozlowski
@ 2019-04-01 15:43     ` Anand Moon
  0 siblings, 0 replies; 30+ messages in thread
From: Anand Moon @ 2019-04-01 15:43 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:30, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > fix the confict of scriptaddr address with ramdisk_addr_r
>
> Start with capital letter, so s/fix/Fix. End with a full-stop.
>
> > also add missing pxefile_addr_r u-boot extras env setting.
>
> s/also/Also/
>
> ... but there is no conflict in the first place. These addresses are
> not used in the same time.
>
> Best regards,
> Krzysztof
>

Thanks for your review comments. I will try to improve on this.
While investigating my earlier failure to load kernel some time ago.
I discover this inputs after study Arch linux u-boot changes.

Below is loot log on ArchLinux and the boot.scr script is loaded
50000000 address
which do not conflict with rest of the settings.

U-Boot 2019.04-rc4-00089-ga5515f5f60 (Apr 01 2019 - 11:11:59 +0000)

CPU:   Exynos4412 @ 1 GHz
Model: Odroid based on Exynos4412
Type:  u3
DRAM:  2 GiB
LDO20 at VDDQ_EMMC_1.8V: set 1800000 uV; enabling
LDO22 at VDDQ_EMMC_2.8V: set 2800000 uV; enabling
LDO21 at TFLASH_2.8V: set 2800000 uV; enabling
MMC:   SAMSUNG SDHCI: 1, EXYNOS DWMMC: 0
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment

Net:   No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found U-Boot script /boot/boot.scr
932 bytes read in 6 ms (151.4 KiB/s)
## Executing script at 50000000
6625664 bytes read in 243 ms (26 MiB/s)
72657 bytes read in 20 ms (3.5 MiB/s)
6593459 bytes read in 241 ms (26.1 MiB/s)
Kernel image @ 0x41000000 [ 0x000000 - 0x651980 ]
## Flattened Device Tree blob at 40800000
   Booting using the fdt blob at 0x40800000
   Loading Ramdisk to 4f9b6000, end 4ffffbb3 ... OK
   Loading Device Tree to 4f9a1000, end 4f9b5bd0 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0xa00
[    0.000000] Linux version 5.0.5-1-ARCH (builduser at leming) (gcc
version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Sat Mar 30 00:25:25 UTC
2019
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing
instruction cache
[    0.000000] OF: fdt: Machine model: Hardkernel ODROID-U3 board
based on Exynos4412

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-01 12:57   ` Krzysztof Kozlowski
@ 2019-04-01 15:50     ` Anand Moon
  2019-04-01 16:16       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 15:50 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:27, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> > error on other development boards.
> >
> > Fix below compilation error:
> > Error: You must add new CONFIG options using Kconfig
> > The following new ad-hoc CONFIG options were detected:
> > CONFIG_SYS_ODROID_USB
>
> There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.
>
> This is something wrong... Are you sure that you are compiling master branch?
>
> Best regards,
> Krzysztof
>

[snip]

CONFIG_SYS_ODROID_USB is adder to fix compilation error other development board.
so this code is specific to the Odroid U3 and Odroid X2 boards.

I have compiled both XU3 and U3 build with no problem.

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2
  2019-04-01 12:51   ` Krzysztof Kozlowski
@ 2019-04-01 15:57     ` Anand Moon
  2019-04-01 16:12       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 15:57 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:21, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Add board_usb_cleanup routine to cleanup after
> > de-registering it usb devices. Also fixed the
> > compilation error for other board.
>
> Fix for build error should be in separate commit. Please also quote
> the error you are fixing... because the code compiles fine in my case.
>

Compilation error happens on other target boards. like Odroid-XU3

> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> >  board/samsung/common/board.c  | 4 ++--
> >  board/samsung/odroid/odroid.c | 5 +++++
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
> > index 9adbd1e2cf..c74aca9b0a 100644
> > --- a/board/samsung/common/board.c
> > +++ b/board/samsung/common/board.c
> > @@ -351,10 +351,10 @@ void reset_misc(void)
> >         }
> >  }
> >
> > +#ifdef CONFIG_USB_DWC3
> >  int board_usb_cleanup(int index, enum usb_init_type init)
> >  {
> > -#ifdef CONFIG_USB_DWC3
> >         dwc3_uboot_exit(index);
> > -#endif
> >         return 0;
> >  }
> > +#endif
> > diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> > index 79d14ead01..547ae698cf 100644
> > --- a/board/samsung/odroid/odroid.c
> > +++ b/board/samsung/odroid/odroid.c
> > @@ -538,4 +538,9 @@ int board_usb_init(int index, enum usb_init_type init)
> >         debug("USB_udc_probe\n");
> >         return dwc2_udc_probe(&s5pc210_otg_data);
> >  }
> > +
> > +int board_usb_cleanup(int index, enum usb_init_type init)
> > +{
> > +       return s5pc210_phy_control(index);
>
> Why you pass index of USB controller as argument "int on"? Index != on...
>

Generally board_usb_cleanup do cleanup the index of the board_usb_init,
so I use this naturally. I will check and update this if needed.

> Best regards,
> Krzysztof

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset
  2019-04-01 12:55   ` Krzysztof Kozlowski
@ 2019-04-01 16:05     ` Anand Moon
  2019-04-01 16:14       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 16:05 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:25, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Some host controllers need addidional re-initialization
>
> Please run spell-check.
>
> > after ehci_reset() so we add .init_after_reset callback
> > which is requires to reinit the phy after controller reset.
>
> s/requires/required/

I did run checkpatch before on this, It did not spotted and error or warning.

> .... but you do not re-init the phy. The exynos_usb_init() performs
> the reset of usb3503 USB hub!
>

Yes that is needed as we do not get the usb back after "usb reset" command.

> >
> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> >  drivers/usb/host/ehci-exynos.c | 20 +++++++++++++++++++-
> >  1 file changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> > index b0f7bd4936..e6a542e092 100644
> > --- a/drivers/usb/host/ehci-exynos.c
> > +++ b/drivers/usb/host/ehci-exynos.c
> > @@ -143,6 +143,23 @@ static void exynos5_setup_usb_phy(struct exynos_usb_phy *usb)
> >                         EHCICTRL_ENAINCR16);
> >  }
> >
> > +static int ehci_exynos_init_after_reset(struct ehci_ctrl *ehcntl)
> > +{
> > +       if (cpu_is_exynos4()) {
> > +               if (proid_is_exynos4412()) {
>
> No need for double indentation.
>
> > +                       /*
> > +                        * "usb reset" cmd: restart re-initialize the usb driver
>
> Just "reinitialize", not restart reinitialize.
>

Ok.

> Best regards,
> Krzysztof
>
> > +                        */
> > +                       exynos_usb_init();
> > +               }
> > +       }
> > +       return 0;
> > +}
> > +
> > +static const struct ehci_ops exynos_ehci_ops = {
> > +       .init_after_reset = ehci_exynos_init_after_reset,
> > +};
> > +
> >  static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
> >  {
> >         writel(CLK_24MHZ, &usb->usbphyclk);
> > @@ -234,7 +251,8 @@ static int ehci_usb_probe(struct udevice *dev)
> >         hcor = (struct ehci_hcor *)((uint32_t)ctx->hcd +
> >                         HC_LENGTH(ehci_readl(&ctx->hcd->cr_capbase)));
> >
> > -       return ehci_register(dev, ctx->hcd, hcor, NULL, 0, USB_INIT_HOST);
> > +       return ehci_register(dev, ctx->hcd, hcor, &exynos_ehci_ops,
> > +                       0, USB_INIT_HOST);
> >  }
> >
> >  static int ehci_usb_remove(struct udevice *dev)
> > --
> > 2.21.0
> >

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2
  2019-04-01 15:57     ` Anand Moon
@ 2019-04-01 16:12       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 16:12 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 17:57, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Hi Krzysztof,
>
> On Mon, 1 Apr 2019 at 18:21, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
> > >
> > > Add board_usb_cleanup routine to cleanup after
> > > de-registering it usb devices. Also fixed the
> > > compilation error for other board.
> >
> > Fix for build error should be in separate commit. Please also quote
> > the error you are fixing... because the code compiles fine in my case.
> >
>
> Compilation error happens on other target boards. like Odroid-XU3

OK, please quote it and fix the error in separate commit.

>
> > > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > > ---
> > >  board/samsung/common/board.c  | 4 ++--
> > >  board/samsung/odroid/odroid.c | 5 +++++
> > >  2 files changed, 7 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
> > > index 9adbd1e2cf..c74aca9b0a 100644
> > > --- a/board/samsung/common/board.c
> > > +++ b/board/samsung/common/board.c
> > > @@ -351,10 +351,10 @@ void reset_misc(void)
> > >         }
> > >  }
> > >
> > > +#ifdef CONFIG_USB_DWC3
> > >  int board_usb_cleanup(int index, enum usb_init_type init)
> > >  {
> > > -#ifdef CONFIG_USB_DWC3
> > >         dwc3_uboot_exit(index);
> > > -#endif
> > >         return 0;
> > >  }
> > > +#endif
> > > diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> > > index 79d14ead01..547ae698cf 100644
> > > --- a/board/samsung/odroid/odroid.c
> > > +++ b/board/samsung/odroid/odroid.c
> > > @@ -538,4 +538,9 @@ int board_usb_init(int index, enum usb_init_type init)
> > >         debug("USB_udc_probe\n");
> > >         return dwc2_udc_probe(&s5pc210_otg_data);
> > >  }
> > > +
> > > +int board_usb_cleanup(int index, enum usb_init_type init)
> > > +{
> > > +       return s5pc210_phy_control(index);
> >
> > Why you pass index of USB controller as argument "int on"? Index != on...
> >
>
> Generally board_usb_cleanup do cleanup the index of the board_usb_init,
> so I use this naturally. I will check and update this if needed.

But s5pc210_phy_control not. Your comment does not really address my concerns...

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset
  2019-04-01 16:05     ` Anand Moon
@ 2019-04-01 16:14       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 16:14 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 18:05, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Hi Krzysztof,
>
> On Mon, 1 Apr 2019 at 18:25, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> > >
> > > Some host controllers need addidional re-initialization
> >
> > Please run spell-check.
> >
> > > after ehci_reset() so we add .init_after_reset callback
> > > which is requires to reinit the phy after controller reset.
> >
> > s/requires/required/
>
> I did run checkpatch before on this, It did not spotted and error or warning.
>
> > .... but you do not re-init the phy. The exynos_usb_init() performs
> > the reset of usb3503 USB hub!
> >
>
> Yes that is needed as we do not get the usb back after "usb reset" command.

Then please update the commit message to describe what exactly you are
doing and what you want to achieve. Someone might think that you are
doing initialization in init-after-reset... but you want to perform
different reset after reset of ehci... and while writing it maybe you
will notice that it is a hack and probably not the best way to do it.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-01 15:50     ` Anand Moon
@ 2019-04-01 16:16       ` Krzysztof Kozlowski
  2019-04-01 17:16         ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-01 16:16 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 17:50, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Hi Krzysztof,
>
> On Mon, 1 Apr 2019 at 18:27, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> > >
> > > Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> > > error on other development boards.
> > >
> > > Fix below compilation error:
> > > Error: You must add new CONFIG options using Kconfig
> > > The following new ad-hoc CONFIG options were detected:
> > > CONFIG_SYS_ODROID_USB
> >
> > There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.
> >
> > This is something wrong... Are you sure that you are compiling master branch?
> >
> > Best regards,
> > Krzysztof
> >
>
> [snip]
>
> CONFIG_SYS_ODROID_USB is adder to fix compilation error other development board.
> so this code is specific to the Odroid U3 and Odroid X2 boards.
>
> I have compiled both XU3 and U3 build with no problem.

You quoted the error message saying that ad-hoc option
CONFIG_SYS_ODROID_USB was added. But such ad-hoc option does not
exist. Now you say that you add this to fix build problem... I really
do not understand. So let's simplify it - please tell me how I can
reproduce the problem and what is expected.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-01 12:48   ` Krzysztof Kozlowski
@ 2019-04-01 16:20     ` Anand Moon
  0 siblings, 0 replies; 30+ messages in thread
From: Anand Moon @ 2019-04-01 16:20 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:18, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> >
> > Rename board_usb_init() to exynos_usb_init() and call it
> > early in the Exynos EHCI driver when probing.
> >
> > This kind of works. After a 'usb start; usb stop; usb start'
> > cycle the attached devices are recognized.
> >
> > Add small delay between gpio_direction_output to stable
> > initialization of usb gpio pins.
> >
> > Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> > Reoder the exynos_usb_init so that "usb start" command initialization
> > correcly.
> > ---
> > ---
> >  board/samsung/odroid/odroid.c  | 14 +++++++++-----
> >  drivers/usb/host/ehci-exynos.c |  7 +++++++
> >  2 files changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> > index 3e594fd850..79d14ead01 100644
> > --- a/board/samsung/odroid/odroid.c
> > +++ b/board/samsung/odroid/odroid.c
> > @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
> >  };
> >  #endif
> >
> > -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> > -
> >  static void set_usb3503_ref_clk(void)
> >  {
> >  #ifdef CONFIG_BOARD_TYPES
> > @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
> >  #endif /* CONFIG_BOARD_TYPES */
> >  }
> >
> > -int board_usb_init(int index, enum usb_init_type init)
> > +int exynos_usb_init(void)
> >  {
> > -#ifdef CONFIG_CMD_USB
> >         struct udevice *dev;
> >         int ret;
> >
> > @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
> >         /* Disconnect, Reset, Connect */
> >         gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
> >         gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> > +       sdelay(200000);
>
> This should be a separate patch with its own explanation.
>
> >         gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
> >         gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
> >
> > @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
> >                 pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
> >                 return ret;
> >         }
> > -#endif
> > +
> > +       return 0;
> > +}
> > +
> > +#ifdef CONFIG_USB_GADGET
> > +int board_usb_init(int index, enum usb_init_type init)
> > +{
> >         debug("USB_udc_probe\n");
> >         return dwc2_udc_probe(&s5pc210_otg_data);
> >  }
> > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> > index fabc662eb6..b0f7bd4936 100644
> > --- a/drivers/usb/host/ehci-exynos.c
> > +++ b/drivers/usb/host/ehci-exynos.c
> > @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
> >         struct gpio_desc vbus_gpio;
> >  };
> >
> > +extern int exynos_usb_init(void);
> > +
> >  /**
> >   * Contains pointers to register base addresses
> >   * for the usb controller.
> > @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
> >         setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> >         udelay(10);
> >         clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> > +
> > +       /*
> > +        * "usb start" initialize the usb driver
> > +        */
> > +       exynos_usb_init();
>
> It should be something more generic like
> CONFIG_SYS_USB_OHCI_BOARD_INIT which calls board_usb_init()... but it
> still will be calling board code from the driver. Why do you need this
> in the first place?

Ideally usb start should be invoked while loading of the u-boot.
but some how this is missing I could not figure out this.

I have tried following in odroid.c but still no sign of usb to get
initialize usb,

int board_eth_init(bd_t *bis)
{
        printf("Registered USB_ETHER\n");
        exynos_usb_init();
        return 0;
}

Here is the debugging I tried to under stand before I tried to modify the code.
Before usb start is called.

Odroid # dm help
dm - Driver model low level access
...
 gpio        44  [   ]   gpio_exynos           |   |-- gpv3
 gpio        45  [   ]   gpio_exynos           |   `-- gpv4
 usb          0  [   ]   ehci_exynos           `-- ehci at 12580000

After usb start
Odroid # usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 1 Ethernet Device(s) found
Odroid # dm tree

 gpio        45  [   ]   gpio_exynos           |   `-- gpv4
 usb          0  [ + ]   ehci_exynos           `-- ehci at 12580000
 usb_hub      0  [ + ]   usb_hub                   `-- usb_hub
 usb_dev_ge   0  [ + ]   usb_dev_generic_drv           |-- generic_bus_0_dev_2
 usb_hub      1  [ + ]   usb_hub                       `-- usb_hub
 usb_mass_s   0  [ + ]   usb_mass_storage                  `-- usb_mass_storage
 blk          2  [   ]   usb_storage_blk                       `--
usb_mass_storage.lun0

After the dm node register we can perform usb and ethernet operation on u-boot.

Any other input's I can try this out.

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env
  2019-04-01 13:04   ` Krzysztof Kozlowski
@ 2019-04-01 16:42     ` Anand Moon
  0 siblings, 0 replies; 30+ messages in thread
From: Anand Moon @ 2019-04-01 16:42 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:34, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Add usbnet_devaddr mac address to extra env setting
> > to avoid failure of ethernet driver while usb start.
> >
> > Odroid # usb start
> > starting USB...
> > USB0:   USB EHCI 1.00
> > scanning bus 0 for devices... 3 USB Device(s) found
> >        scanning usb for storage devices... 0 Storage Device(s) found
> >        scanning usb for ethernet devices...
> > Error: sms0 address not set.
> > Warning: failed to set MAC address
> > 1 Ethernet Device(s) found
> >
> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> >  include/configs/odroid.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/include/configs/odroid.h b/include/configs/odroid.h
> > index 64819cf81c..b0402e8d49 100644
> > --- a/include/configs/odroid.h
> > +++ b/include/configs/odroid.h
> > @@ -33,6 +33,7 @@
> >  #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x5E00000)
> >  #define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x3E00000)
> >  #define CONFIG_SYS_ODROID_USB
> > +#define CONFIG_USBNET_DEV_ADDR          "02:DE:AD:BE:EF:FF"
> >
> >  #include <linux/sizes.h>
> >
> > @@ -173,6 +174,7 @@
> >         "kernel_addr_r=0x41000000\0" \
> >         "scriptaddr=0x50000000\0" \
> >         "pxefile_addr_r=0x51000000\0" \
> > +       "usbethaddr=" __stringify(CONFIG_USBNET_DEV_ADDR) "\0" \
>
> No. Either the user should set it or manufacturer (e.g. in EEPROM).
>
Ok,

This usb Ethernet do not support reading mac addressed from EEPROM.
some user need to pass this mac address via boot command can used is approach.

But I could not perform "saveenv" after setting the mac address. see below.

Odroid #
Odroid # setenv usbethaddr C2:22:09:F2:5F:E8
Odroid #
Odroid # saveenv
Saving Environment to MMC... Card did not respond to voltage select!
No block device
Failed (1)
Odroid #

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-01 16:16       ` Krzysztof Kozlowski
@ 2019-04-01 17:16         ` Anand Moon
  2019-04-02  7:02           ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-01 17:16 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Mon, 1 Apr 2019 at 21:46, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 17:50, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Hi Krzysztof,
> >
> > On Mon, 1 Apr 2019 at 18:27, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > >
> > > On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> > > >
> > > > Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> > > > error on other development boards.
> > > >
> > > > Fix below compilation error:
> > > > Error: You must add new CONFIG options using Kconfig
> > > > The following new ad-hoc CONFIG options were detected:
> > > > CONFIG_SYS_ODROID_USB
> > >
> > > There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.
> > >
> > > This is something wrong... Are you sure that you are compiling master branch?
> > >
> > > Best regards,
> > > Krzysztof
> > >
> >
> > [snip]
> >
> > CONFIG_SYS_ODROID_USB is adder to fix compilation error other development board.
> > so this code is specific to the Odroid U3 and Odroid X2 boards.
> >
> > I have compiled both XU3 and U3 build with no problem.
>
> You quoted the error message saying that ad-hoc option
> CONFIG_SYS_ODROID_USB was added. But such ad-hoc option does not
> exist. Now you say that you add this to fix build problem... I really
> do not understand. So let's simplify it - please tell me how I can
> reproduce the problem and what is expected.
>
> Best regards,
> Krzysztof

This CONFIG_SYS_ODROID_USB options is more like and compile time flag
defined in odroid.h and not on any other boards, so this flags add
guard to the code.

At the end of  u-boot compilation it would prompt that new config
option is added
please add this to some Kconfig so that it could be selected via make menuconfig

See the link below, why I chose this options.

[0] https://github.com/Xilinx/u-boot-xlnx/blob/master/doc/README.kconfig

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-01 17:16         ` Anand Moon
@ 2019-04-02  7:02           ` Krzysztof Kozlowski
  2019-04-02  7:52             ` Anand Moon
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-02  7:02 UTC (permalink / raw)
  To: u-boot

On Mon, 1 Apr 2019 at 19:17, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Hi Krzysztof,
>
> On Mon, 1 Apr 2019 at 21:46, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > On Mon, 1 Apr 2019 at 17:50, Anand Moon <linux.amoon@gmail.com> wrote:
> > >
> > > Hi Krzysztof,
> > >
> > > On Mon, 1 Apr 2019 at 18:27, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > > >
> > > > On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> > > > >
> > > > > Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> > > > > error on other development boards.
> > > > >
> > > > > Fix below compilation error:
> > > > > Error: You must add new CONFIG options using Kconfig
> > > > > The following new ad-hoc CONFIG options were detected:
> > > > > CONFIG_SYS_ODROID_USB
> > > >
> > > > There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.
> > > >
> > > > This is something wrong... Are you sure that you are compiling master branch?
> > > >
> > > > Best regards,
> > > > Krzysztof
> > > >
> > >
> > > [snip]
> > >
> > > CONFIG_SYS_ODROID_USB is adder to fix compilation error other development board.
> > > so this code is specific to the Odroid U3 and Odroid X2 boards.
> > >
> > > I have compiled both XU3 and U3 build with no problem.
> >
> > You quoted the error message saying that ad-hoc option
> > CONFIG_SYS_ODROID_USB was added. But such ad-hoc option does not
> > exist. Now you say that you add this to fix build problem... I really
> > do not understand. So let's simplify it - please tell me how I can
> > reproduce the problem and what is expected.
> >
> > Best regards,
> > Krzysztof
>
> This CONFIG_SYS_ODROID_USB options is more like and compile time flag
> defined in odroid.h and not on any other boards, so this flags add
> guard to the code.
>
> At the end of  u-boot compilation it would prompt that new config
> option is added
> please add this to some Kconfig so that it could be selected via make menuconfig
>
> See the link below, why I chose this options.
>
> [0] https://github.com/Xilinx/u-boot-xlnx/blob/master/doc/README.kconfig

Can you provide answer to this:
"So let's simplify it - please tell me how I can reproduce the problem
and what is expected."
?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-02  7:02           ` Krzysztof Kozlowski
@ 2019-04-02  7:52             ` Anand Moon
  2019-04-02  7:56               ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Anand Moon @ 2019-04-02  7:52 UTC (permalink / raw)
  To: u-boot

Hi Krzysztof,

On Tue, 2 Apr 2019 at 12:32, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 19:17, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Hi Krzysztof,
> >
> > On Mon, 1 Apr 2019 at 21:46, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > >
> > > On Mon, 1 Apr 2019 at 17:50, Anand Moon <linux.amoon@gmail.com> wrote:
> > > >
> > > > Hi Krzysztof,
> > > >
> > > > On Mon, 1 Apr 2019 at 18:27, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > > > >
> > > > > On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> > > > > >
> > > > > > Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> > > > > > error on other development boards.
> > > > > >
> > > > > > Fix below compilation error:
> > > > > > Error: You must add new CONFIG options using Kconfig
> > > > > > The following new ad-hoc CONFIG options were detected:
> > > > > > CONFIG_SYS_ODROID_USB
> > > > >
> > > > > There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.
> > > > >
> > > > > This is something wrong... Are you sure that you are compiling master branch?
> > > > >
> > > > > Best regards,
> > > > > Krzysztof
> > > > >
> > > >
> > > > [snip]
> > > >
> > > > CONFIG_SYS_ODROID_USB is adder to fix compilation error other development board.
> > > > so this code is specific to the Odroid U3 and Odroid X2 boards.
> > > >
> > > > I have compiled both XU3 and U3 build with no problem.
> > >
> > > You quoted the error message saying that ad-hoc option
> > > CONFIG_SYS_ODROID_USB was added. But such ad-hoc option does not
> > > exist. Now you say that you add this to fix build problem... I really
> > > do not understand. So let's simplify it - please tell me how I can
> > > reproduce the problem and what is expected.
> > >
> > > Best regards,
> > > Krzysztof
> >
> > This CONFIG_SYS_ODROID_USB options is more like and compile time flag
> > defined in odroid.h and not on any other boards, so this flags add
> > guard to the code.
> >
> > At the end of  u-boot compilation it would prompt that new config
> > option is added
> > please add this to some Kconfig so that it could be selected via make menuconfig
> >
> > See the link below, why I chose this options.
> >
> > [0] https://github.com/Xilinx/u-boot-xlnx/blob/master/doc/README.kconfig
>
> Can you provide answer to this:
> "So let's simplify it - please tell me how I can reproduce the problem
> and what is expected."
> ?
>

Since I would like to keep the code specific to Odroid U3 and Odroid X2.
I have introduce CONFIG_SYS_ODROID_USB this flag in "include/configs/odroid.h"

If your remove the entry from board/samsung/odroid/Kconfig you will
hit above error
at the end of the build process.

At the end of the compilation it suggest to add this entry into Kconfig option
so that this flag could be select and build flag in boards/config file.

  OBJCOPY u-boot.srec
  OBJCOPY u-boot-nodtb.bin
  CAT     u-boot-dtb.bin
  COPY    u-boot.bin
  SYM     u-boot.sym
  CFGCHK  u-boot.cfg
Error: You must add new CONFIG options using Kconfig
The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_ODROID_USB

Please add these via Kconfig instead. Find a suitable Kconfig
file and add a 'config' or 'menuconfig' option.
make: *** [Makefile:1003: all] Error 1

This flag is mostly used as a guard to avoid compilation error on other boards.

I could not find any other option to fix this issue.
If possible plz let me know.

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option
  2019-04-02  7:52             ` Anand Moon
@ 2019-04-02  7:56               ` Krzysztof Kozlowski
  0 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2019-04-02  7:56 UTC (permalink / raw)
  To: u-boot

On Tue, 2 Apr 2019 at 09:52, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Hi Krzysztof,
>
> On Tue, 2 Apr 2019 at 12:32, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > On Mon, 1 Apr 2019 at 19:17, Anand Moon <linux.amoon@gmail.com> wrote:
> > >
> > > Hi Krzysztof,
> > >
> > > On Mon, 1 Apr 2019 at 21:46, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > > >
> > > > On Mon, 1 Apr 2019 at 17:50, Anand Moon <linux.amoon@gmail.com> wrote:
> > > > >
> > > > > Hi Krzysztof,
> > > > >
> > > > > On Mon, 1 Apr 2019 at 18:27, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> > > > > >
> > > > > > On Mon, 1 Apr 2019 at 13:53, Anand Moon <linux.amoon@gmail.com> wrote:
> > > > > > >
> > > > > > > Add new CONFIG_SYS_ODROID_USB flag to avoid compliation
> > > > > > > error on other development boards.
> > > > > > >
> > > > > > > Fix below compilation error:
> > > > > > > Error: You must add new CONFIG options using Kconfig
> > > > > > > The following new ad-hoc CONFIG options were detected:
> > > > > > > CONFIG_SYS_ODROID_USB
> > > > > >
> > > > > > There is no ad-hoc option "SYS_ODROID_USB" so it cannot cause build error.
> > > > > >
> > > > > > This is something wrong... Are you sure that you are compiling master branch?
> > > > > >
> > > > > > Best regards,
> > > > > > Krzysztof
> > > > > >
> > > > >
> > > > > [snip]
> > > > >
> > > > > CONFIG_SYS_ODROID_USB is adder to fix compilation error other development board.
> > > > > so this code is specific to the Odroid U3 and Odroid X2 boards.
> > > > >
> > > > > I have compiled both XU3 and U3 build with no problem.
> > > >
> > > > You quoted the error message saying that ad-hoc option
> > > > CONFIG_SYS_ODROID_USB was added. But such ad-hoc option does not
> > > > exist. Now you say that you add this to fix build problem... I really
> > > > do not understand. So let's simplify it - please tell me how I can
> > > > reproduce the problem and what is expected.
> > > >
> > > > Best regards,
> > > > Krzysztof
> > >
> > > This CONFIG_SYS_ODROID_USB options is more like and compile time flag
> > > defined in odroid.h and not on any other boards, so this flags add
> > > guard to the code.
> > >
> > > At the end of  u-boot compilation it would prompt that new config
> > > option is added
> > > please add this to some Kconfig so that it could be selected via make menuconfig
> > >
> > > See the link below, why I chose this options.
> > >
> > > [0] https://github.com/Xilinx/u-boot-xlnx/blob/master/doc/README.kconfig
> >
> > Can you provide answer to this:
> > "So let's simplify it - please tell me how I can reproduce the problem
> > and what is expected."
> > ?
> >
>
> Since I would like to keep the code specific to Odroid U3 and Odroid X2.
> I have introduce CONFIG_SYS_ODROID_USB this flag in "include/configs/odroid.h"

So you added it? And broke build? And then add new commit to fix it?

> If your remove the entry from board/samsung/odroid/Kconfig you will
> hit above error
> at the end of the build process.

In board/samsung/odroid/Kconfig  there is no such option like
CONFIG_SYS_ODROID_USB.

It looks like this commit is not fixing anything in existing U-Boot
sources, which you claim in commit message. If you break the building
in one commit, do not fix it in second commit. Just do not break it at
first place.

Best regards,
Krzysztof

> At the end of the compilation it suggest to add this entry into Kconfig option
> so that this flag could be select and build flag in boards/config file.
>
>   OBJCOPY u-boot.srec
>   OBJCOPY u-boot-nodtb.bin
>   CAT     u-boot-dtb.bin
>   COPY    u-boot.bin
>   SYM     u-boot.sym
>   CFGCHK  u-boot.cfg
> Error: You must add new CONFIG options using Kconfig
> The following new ad-hoc CONFIG options were detected:
> CONFIG_SYS_ODROID_USB
>
> Please add these via Kconfig instead. Find a suitable Kconfig
> file and add a 'config' or 'menuconfig' option.
> make: *** [Makefile:1003: all] Error 1
>
> This flag is mostly used as a guard to avoid compilation error on other boards.
>
> I could not find any other option to fix this issue.
> If possible plz let me know.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
  2019-04-01 12:48   ` Krzysztof Kozlowski
  2019-04-01 12:57   ` Lukasz Majewski
@ 2019-04-03 19:58   ` Tobias Jakobi
  2019-04-04  3:01     ` Anand Moon
  2 siblings, 1 reply; 30+ messages in thread
From: Tobias Jakobi @ 2019-04-03 19:58 UTC (permalink / raw)
  To: u-boot

Hello,

in case this isn't totally obvious, I want to state it here again: THIS IS A HACK!

This patch of mine was never meant for upstream submission. Note that the
original commit has a TODO included, which again makes clear: This is not the
proper way to do it. It's a quick&dirty solution because I needed booting via
tftp. Nothing more.

I have seen this plently of times now. Anand Moon takes some code, tinkers
around with it and then presents it for review. The problem is that he doesn't
even bother to understand what he's doing and when he arrives at something
semi-working, it is more by chance than anything else. I feel sorry for
Krzysztof (and others), who, with the patience of a monk to say the least, has
to deal with this time and time again.

- Tobias



Anand Moon wrote:
> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> 
> Rename board_usb_init() to exynos_usb_init() and call it
> early in the Exynos EHCI driver when probing.
> 
> This kind of works. After a 'usb start; usb stop; usb start'
> cycle the attached devices are recognized.
> 
> Add small delay between gpio_direction_output to stable
> initialization of usb gpio pins.
> 
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Reoder the exynos_usb_init so that "usb start" command initialization
> correcly.
> ---
> ---
>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> index 3e594fd850..79d14ead01 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>  };
>  #endif
>  
> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> -
>  static void set_usb3503_ref_clk(void)
>  {
>  #ifdef CONFIG_BOARD_TYPES
> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>  #endif /* CONFIG_BOARD_TYPES */
>  }
>  
> -int board_usb_init(int index, enum usb_init_type init)
> +int exynos_usb_init(void)
>  {
> -#ifdef CONFIG_CMD_USB
>  	struct udevice *dev;
>  	int ret;
>  
> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
>  	/* Disconnect, Reset, Connect */
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> +	sdelay(200000);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>  
> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
>  		pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
>  		return ret;
>  	}
> -#endif
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_USB_GADGET
> +int board_usb_init(int index, enum usb_init_type init)
> +{
>  	debug("USB_udc_probe\n");
>  	return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index fabc662eb6..b0f7bd4936 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>  	struct gpio_desc vbus_gpio;
>  };
>  
> +extern int exynos_usb_init(void);
> +
>  /**
>   * Contains pointers to register base addresses
>   * for the usb controller.
> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
>  	setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
>  	udelay(10);
>  	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> +
> +	/*
> +	 * "usb start" initialize the usb driver
> +	 */
> +	exynos_usb_init();
>  }
>  
>  static void setup_usb_phy(struct exynos_usb_phy *usb)
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2
  2019-04-03 19:58   ` Tobias Jakobi
@ 2019-04-04  3:01     ` Anand Moon
  0 siblings, 0 replies; 30+ messages in thread
From: Anand Moon @ 2019-04-04  3:01 UTC (permalink / raw)
  To: u-boot

Hi Tobias,

On Thu, 4 Apr 2019 at 01:28, Tobias Jakobi
<tjakobi@math.uni-bielefeld.de> wrote:
>
> Hello,
>
> in case this isn't totally obvious, I want to state it here again: THIS IS A HACK!
>
> This patch of mine was never meant for upstream submission. Note that the
> original commit has a TODO included, which again makes clear: This is not the
> proper way to do it. It's a quick&dirty solution because I needed booting via
> tftp. Nothing more.
>
> I have seen this plently of times now. Anand Moon takes some code, tinkers
> around with it and then presents it for review. The problem is that he doesn't
> even bother to understand what he's doing and when he arrives at something
> semi-working, it is more by chance than anything else. I feel sorry for
> Krzysztof (and others), who, with the patience of a monk to say the least, has
> to deal with this time and time again.
>
> - Tobias
>

Yes I completely understand you point,  their could be other way to
fix this issue
which I over looked, sorry for the trouble. Let discard this for now.

Best Regards
-Anand

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2019-04-04  3:01 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01 11:52 [U-Boot] [RFC 0/6] Odroid U3 usb initialization Anand Moon
2019-04-01 11:52 ` [U-Boot] [RFC 1/6] odroid: exynos: USB initialization on the U3/X2 Anand Moon
2019-04-01 12:48   ` Krzysztof Kozlowski
2019-04-01 16:20     ` Anand Moon
2019-04-01 12:57   ` Lukasz Majewski
2019-04-01 13:22     ` Jack Mitchell
2019-04-03 19:58   ` Tobias Jakobi
2019-04-04  3:01     ` Anand Moon
2019-04-01 11:52 ` [U-Boot] [RFC 2/6] odroid: exynos: usb clean up for U3/X2 Anand Moon
2019-04-01 12:51   ` Krzysztof Kozlowski
2019-04-01 15:57     ` Anand Moon
2019-04-01 16:12       ` Krzysztof Kozlowski
2019-04-01 11:52 ` [U-Boot] [RFC 3/6] usb: exynos: add init_after_reset for usb reset Anand Moon
2019-04-01 12:55   ` Krzysztof Kozlowski
2019-04-01 16:05     ` Anand Moon
2019-04-01 16:14       ` Krzysztof Kozlowski
2019-04-01 11:52 ` [U-Boot] [RFC 4/6] configs: exynos: Add new CONFIG_SYS_ODROID_USB config option Anand Moon
2019-04-01 12:57   ` Krzysztof Kozlowski
2019-04-01 15:50     ` Anand Moon
2019-04-01 16:16       ` Krzysztof Kozlowski
2019-04-01 17:16         ` Anand Moon
2019-04-02  7:02           ` Krzysztof Kozlowski
2019-04-02  7:52             ` Anand Moon
2019-04-02  7:56               ` Krzysztof Kozlowski
2019-04-01 11:52 ` [U-Boot] [RFC 5/6] arm: exynos: odroid: fix the confict scripaddr extra env setting Anand Moon
2019-04-01 13:00   ` Krzysztof Kozlowski
2019-04-01 15:43     ` Anand Moon
2019-04-01 11:52 ` [U-Boot] [RFC 6/6] arm: exynos: add usbnet_devaddr setting to env Anand Moon
2019-04-01 13:04   ` Krzysztof Kozlowski
2019-04-01 16:42     ` Anand Moon

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.