Skip to contentSkip to conversation

AM335x: Add USB support in u-boot.

PATCH Superseded Harman Sohanpal 5 participants 9 messages Jun 26, 2012 – Jul 4, 2012

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover AM335x: Add USB support in u-boot.

These patches add USB support in u-boot for AM335x. I have tested this code on AM335x evm and beaglebone in the host mode using mass storage class.
For device mode, I have tested this on beaglebone using usbtty. CONFIG_MUSB_HCD has been enabled by default to make USB work in host mode.

Gene Zarkhin (1):
AM335x : Add USB support for AM335x in u-boot

Harman Sohanpal (2):
AM335x : Configs to add USB host support. musb_udc : Fix compile warning.

 drivers/usb/musb/Makefile    |    1 +
 drivers/usb/musb/am335x.c    |  121 ++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/musb/am335x.h    |  113 +++++++++++++++++++++++++++++++++++++++
 drivers/usb/musb/musb_core.h |    2 +
 drivers/usb/musb/musb_hcd.h  |    3 -
 include/configs/am335x_evm.h |   41 ++++++++++++++
 include/usb.h                |    3 +-
 7 files changed, 280 insertions(+), 4 deletions(-)
 create mode 100644 drivers/usb/musb/am335x.c
 create mode 100644 drivers/usb/musb/am335x.h
#1 lore raw

PATCH v3 1/3 AM335x : Add USB support for AM335x in u-boot

From: Gene Zarkhin <[email protected]>

Adds USB support in uboot for AM335x.
By default the USB 1 module is enabled.
The support for USB 0 can be enabled by changing the USB base address and the phy control register address in the header file am335x.h.
USB 1 has a full size connector so acts in host mode and USB 0 has a mini connector so used in device mode. By default, the support is added for host mode hence USB 1 has been enabled by default.

---
Changes for v2:
- none
Changes for v3:
- Changed commit message to specify why USB 1 has been enabled by default.

 drivers/usb/musb/Makefile |    1 +
 drivers/usb/musb/am335x.c |  121 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/musb/am335x.h |  113 ++++++++++++++++++++++++++++++++++++++++++
 include/usb.h             |    3 +-
 4 files changed, 237 insertions(+), 1 deletions(-)
 create mode 100644 drivers/usb/musb/am335x.c
 create mode 100644 drivers/usb/musb/am335x.h
drivers/usb/musb/Makefile +1 -0
index 20b5503..d00ec40 100644
@@ -32,6 +32,7 @@ COBJS-$(CONFIG_USB_DAVINCI) += davinci.o
 COBJS-$(CONFIG_USB_OMAP3) += omap3.o
 COBJS-$(CONFIG_USB_DA8XX) += da8xx.o
 COBJS-$(CONFIG_USB_AM35X) += am35x.o
+COBJS-$(CONFIG_USB_AM335X) += am335x.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/usb/musb/am335x.c new file +121 -0

121 lines not on this page · raw message

drivers/usb/musb/am335x.h new file +113 -0

113 lines not on this page · raw message

include/usb.h +2 -1
index 6da91e7..13f5434 100644
@@ -141,7 +141,8 @@ struct usb_device {
 	defined(CONFIG_USB_SL811HS) || defined(CONFIG_USB_ISP116X_HCD) || \
 	defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI) || \
 	defined(CONFIG_USB_OMAP3) || defined(CONFIG_USB_DA8XX) || \
-	defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X)
+	defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X) || \
+	defined(CONFIG_USB_AM335X)
 
 int usb_lowlevel_init(void);
 int usb_lowlevel_stop(void);
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v3 1/3 AM335x : Add USB support for AM335x in u-boot

Quoted 12 lines · Harman Sohanpal

From: Gene Zarkhin <[email protected]>

Adds USB support in uboot for AM335x.
By default the USB 1 module is enabled.
The support for USB 0 can be enabled by changing the USB base address and the phy control register address in the header file am335x.h.
USB 1 has a full size connector so acts in host mode and USB 0 has a mini connector so used in device mode. By default, the support is added for host mode hence USB 1 has been enabled by default.

Quoted 2 lines

What I was saying was that we want to make am335x.h do:
#define AM335X_USB0_BASE 0x47401000
#define AM335X_USB1_BASE 0x47401800

Then:
#ifdef CONFIG_AM335X_USB0
#define AM335X_USB_OTG_BASE AM335X_USB0_BASE
#elif defined(CONFIG_AM335X_USB1)
#define AM335X_USB_OTG_BASE AM335X_USB1_BASE
#endif
#define AM335X_USB_OTG_CORE_BASE (AM335X_USB_OTG_BASE + 0x400)

So that in boards.cfg we could add an entry for am335x_evm_usb1 and set CONFIG_AM335X_USB1 dynamically. Then in am335x_evm.h set either MUSB_HCD or MUSB_UDC based on if CONFIG_AM335X_USB0 or CONFIG_AM335X_USB1 is set (and have boards.cfg set CONFIG_AM335X_USB0 for 'am335x_evm).

Then you can test device mode on the evm :) And how did you test device mode on the beaglebone? I couldn't since I don't have the rest set of adapters here.

Also:

Quoted 1 line

+++ b/drivers/usb/musb/am335x.h

[snip]

drivers/usb/musb/am335x.h line 40

Quoted 4 lines
drivers/usb/musb/am335x.h new file +4 -0
+/* Control Module Registers */
+#define CM_REGISTERS			CTRL_BASE
+#define USB_CTRL0_REG_OFFSET	(0x628)
+#define USB_CTRL1_REG_OFFSET	(0x680)

Please get all indentation out to a consistent level

drivers/usb/musb/am335x.h line 43

Quoted 2 lines
drivers/usb/musb/am335x.h new file +2 -0
+#define PRCM_IDLEST                             0x30000
+#define DPLL_CLKDCOLDO_GATE_CTRL                0x300

And always use tabs :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120627/d05edaef/attachment.pgp>
#3 lore raw

PATCH v3 1/3 AM335x : Add USB support for AM335x in u-boot

Quoted 60 lines

-----Original Message-----
From: Tom Rini [mailto:tom.rini at gmail.com] On Behalf Of Rini, Tom
Sent: Wednesday, June 27, 2012 10:50 PM
To: Sohanpal, Harman
Cc: u-boot at lists.denx.de; Gene Zarkhin
Subject: Re: [U-Boot] [PATCH v3 1/3] AM335x : Add USB support for AM335x in u-boot

Quoted 12 lines · Harman Sohanpal

From: Gene Zarkhin <[email protected]>

Adds USB support in uboot for AM335x.
By default the USB 1 module is enabled.
The support for USB 0 can be enabled by changing the USB base address and the phy control register address in the header file am335x.h.
USB 1 has a full size connector so acts in host mode and USB 0 has a mini connector so used in device mode. By default, the support is added for host mode hence USB 1 has been enabled by default.

Quoted 2 lines

What I was saying was that we want to make am335x.h do:
#define AM335X_USB0_BASE 0x47401000
#define AM335X_USB1_BASE 0x47401800

Then:
#ifdef CONFIG_AM335X_USB0
#define AM335X_USB_OTG_BASE AM335X_USB0_BASE
#elif defined(CONFIG_AM335X_USB1)
#define AM335X_USB_OTG_BASE AM335X_USB1_BASE
#endif
#define AM335X_USB_OTG_CORE_BASE (AM335X_USB_OTG_BASE + 0x400)

So that in boards.cfg we could add an entry for am335x_evm_usb1 and set CONFIG_AM335X_USB1 dynamically. Then in am335x_evm.h set either MUSB_HCD or MUSB_UDC based on if CONFIG_AM335X_USB0 or CONFIG_AM335X_USB1 is set (and have boards.cfg set CONFIG_AM335X_USB0 for 'am335x_evm).

Then you can test device mode on the evm :) And how did you test device mode on the beaglebone? I couldn't since I don't have the rest set of adapters here.

Also:

Quoted 1 line

+++ b/drivers/usb/musb/am335x.h

[snip]

drivers/usb/musb/am335x.h line 40

Quoted 4 lines
drivers/usb/musb/am335x.h new file +4 -0
+/* Control Module Registers */
+#define CM_REGISTERS			CTRL_BASE
+#define USB_CTRL0_REG_OFFSET	(0x628)
+#define USB_CTRL1_REG_OFFSET	(0x680)

Please get all indentation out to a consistent level

Quoted 5 lines

drivers/usb/musb/am335x.h line 43

Quoted 2 lines
drivers/usb/musb/am335x.h new file +2 -0
+#define PRCM_IDLEST                             0x30000
+#define DPLL_CLKDCOLDO_GATE_CTRL                0x300

And always use tabs :)

Hi Tom,
Thanks for the review.
I will send the patches doing
all the modifications you have mentioned.
Also there was some confusion regarding testing in the device mode. A new node /dev/ttyUSB0 was seen when beagle bone was connected to a linux machine, but it is not using USB as serial using usbtty. It was using the USB to serial chip in the beagle bone. Sorry for that. So I am still to confirm whether the device mode works with usbtty. But previously I have tested the device mode on both evm
and beagle bone using some local DFU patches and it worked fine. Thanks,
Harman

#4 lore raw

PATCH v3 1/3 AM335x : Add USB support for AM335x in u-boot

In reply to Harman Sohanpal

Hi,

drivers/usb/musb/am335x.h line 40

Quoted 4 lines · Harman Sohanpal <harman_sohanpal <at> ti.com> writes:
drivers/usb/musb/am335x.h new file +4 -0
+/* Control Module Registers */
+#define CM_REGISTERS			CTRL_BASE
+#define USB_CTRL0_REG_OFFSET	(0x628)
+#define USB_CTRL1_REG_OFFSET	(0x680)

USB_CTRL1 seems to be unused. Furthermore, both values seems to be incorrect:
according to the RM USB_CTRL0 offset should be 0x628 and USB_CTRL1 should be 0x628. I understand that's cause you use USB1 by default but that's kind of misguiding. Could you please use the approach Tom suggested for base address here too? Define USB_CRTL* to correct values but use USB_CONTROL_REG_OFFSET (defined conditionally) in code?

Regards, Ilya.

#5 lore raw

PATCH v3 1/3 AM335x : Add USB support for AM335x in u-boot

Quoted 7 lines · Ilya Yanok

Hi,

drivers/usb/musb/am335x.h line 40

Quoted 4 lines · Harman Sohanpal <harman_sohanpal <at> ti.com> writes:
drivers/usb/musb/am335x.h new file +4 -0
+/* Control Module Registers */
+#define CM_REGISTERS                 CTRL_BASE
+#define USB_CTRL0_REG_OFFSET (0x628)
+#define USB_CTRL1_REG_OFFSET (0x680)

Hi llya,
Thanks for your review.
But I believe you are talking of version 3 of the patches. Kindly have a look at the version 4 I have sent. I have used the same approach which Tom has mentioned for control register offset also.
Thanks,
Harman

Quoted 14 lines

USB_CTRL1 seems to be unused. Furthermore, both values seems to be incorrect:
according to the RM USB_CTRL0 offset should be 0x628 and USB_CTRL1 should be 0x628. I understand that's cause you use USB1 by default but that's kind of misguiding. Could you please use the approach Tom suggested for base address here too? Define USB_CRTL* to correct values but use USB_CONTROL_REG_OFFSET (defined conditionally) in code?

Regards, Ilya.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#6 lore raw

PATCH v3 1/3 AM335x : Add USB support for AM335x in u-boot

Hi,

Quoted 5 lines · Harman Sohanpal

Thanks for your review.
But I believe you are talking of version 3 of the patches. Kindly have a look at the version 4 I have sent.

Yes, my bad. I've seen your fourth version just after sending my comment.

Quoted 3 lines

I have used the same approach which Tom has mentioned for control register offset also.

Yes, I've seen. I still think that it's a bit misguiding to conditionally define USB_CTRL0 but the general approach is ok.
Other than that I think it's good to have boards.cfg entries for both options.

And how much have you tested these patches? I tried them on my beaglebone and have issues both with host and device modes.

In device mode I tried to use CDC ACM. My Linux host sees the device and /dev/ttyACM0 node shows up. I can put stdout in U-Boot to usbtty and this works nice too. But once I try to reassign stdin also I got my picocom hanged (only killable with kill -9).

I host mode I tried with two flashdisks (512MB and 4GB) and card-reader (32MB SD and 8GB microSD cards). Only 512MB stick works as expected. With others I got:
1. 4GB flashdisk -- 0 device found, second "usb start" command seems to
wedge the board
2. 8GB card -- scanning bus for storage devices... Device NOT ready Request Sense returned 00 00 00. Second "usb start" is lethal too.
3. 32MB card -- scanning bus for storage devices... READ_CAP ERROR

Regards, Ilya.

#7 lore raw

PATCH v3 2/3 AM335x : Configs to add USB host support.

In reply to Harman Sohanpal

Adds required configs in config file for am335x_evm to add support for usb host mode. To enable USB device mode, add CONFIG_MUSB_UDC in place of CONFIG_MUSB_HCD.
Tested using usbtty for device mode and mass storage for host mode.

---
Changes for v2:
- #define cleanups.
Changes for v3:
- remove configs for usb as keyboard in host mode.
- removed extra test of CONFIG_USB_AM335X.
- changed commit messgae.

 include/configs/am335x_evm.h |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
include/configs/am335x_evm.h +32 -0
index d0fbc88..a1e16cc 100644
@@ -165,6 +165,38 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #endif
 
+
+/*
+ * USB configuration
+ * Enable CONFIG_MUSB_HCD for Host functionalities MSC
+ * Enable CONFIG_MUSB_UDC for Device functionalities.
+ */
+#define CONFIG_USB_AM335X
+#define CONFIG_MUSB_HCD
+
+#ifdef CONFIG_MUSB_HCD
+#define CONFIG_CMD_USB
+
+#define CONFIG_USB_STORAGE
+#define CONGIG_CMD_STORAGE
+#define CONFIG_CMD_FAT
+
+#endif /* CONFIG_MUSB_HCD */
+
+#ifdef CONFIG_MUSB_UDC
+/* USB device configuration */
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_USB_DEVICE
+#define CONFIG_USB_TTY
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#endif	/* CONFIG_SPL_BUILD */
+/* Change these to suit your needs */
+#define CONFIG_USBD_VENDORID            0x0451
+#define CONFIG_USBD_PRODUCTID           0x5678
+#define CONFIG_USBD_MANUFACTURER        "Texas Instruments"
+#define CONFIG_USBD_PRODUCT_NAME        "AM335xEVM"
+#endif /* CONFIG_MUSB_UDC */
+
 /* Unsupported features */
 #undef CONFIG_USE_IRQ
 
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH v3 3/3 musb_udc : Fix compile warning.

In reply to Harman Sohanpal

Fix the compile warning :
implicit declaration of musb_platform_init
when CONFIG_MUSB_UDC is defined.
The extern musb_platform_init was declared in musb_hcd.h but no such extern function was declared for musb_udc. So a common function has been declared in musb_core.h which can be used for both host mode and device mode.

---
Changes for v2:
- none.
Changes for v3:
- none.

 drivers/usb/musb/musb_core.h |    2 ++
 drivers/usb/musb/musb_hcd.h  |    3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_core.h +2 -0
index a8adcce..14253f0 100644
@@ -360,6 +360,8 @@ extern void musb_start(void);
 extern void musb_configure_ep(const struct musb_epinfo *epinfo, u8 cnt);
 extern void write_fifo(u8 ep, u32 length, void *fifo_data);
 extern void read_fifo(u8 ep, u32 length, void *fifo_data);
+extern int musb_platform_init(void);
+extern void musb_platform_deinit(void);
 
 #if defined(CONFIG_USB_BLACKFIN)
 /* Every USB register is accessed as a 16-bit even if the value itself
drivers/usb/musb/musb_hcd.h +0 -3
index dde7d37..5621f7e 100644
@@ -105,8 +105,5 @@ extern unsigned char new[];
 #define RH_REQ_ERR		   -1
 #define RH_NACK			   0x00
 
-/* extern functions */
-extern int musb_platform_init(void);
-extern void musb_platform_deinit(void);
 
 #endif	/* __MUSB_HCD_H__ */
Signature · 1 line
1.7.0.4