Skip to contentSkip to conversation

USB On PCM043?

RFC PATCH In review Jerry Kirk 5 participants 11 messages Jul 19, 2012 – Nov 6, 2012

Subsystems (2)
lore
Share & tools
lore

Jerry Kirk

author
#0 lore raw

We have been attempting to get USB Host mode working under Barebox(2012-07-0) on a PCM043 platform (i.mx35), but we are having a bit of trouble.

We have merged the CONFIG_USB specific code for "imx35_devices_init" and "imx35_usb_init" from the Eukrea platform into pcm043.c, added the "MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR" and "MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC" pad definitions (as per the main kernel pcm043.c file), added the "tmp |= 0x3 << CCM_CGR2_USB_SHIFT" to enable the USB clock to "pcm043_core_setup", built everything with the "usb" command enabled, and then loaded the new Barebox image into our pcm043 board. We have USB_EHCI and USB_STORAGE enabled in the Barebox config.

If I execute the "usb" command then it returns that it has found 1 EHCI controller. If I plug in any device, the only one it has EVER detected has been a USB mouse. It will be detected most of the time following a reset and after unplugging/replugging the mouse -- but will never be detected again after this unless I do a reset/replug operation (and never on a "usb -f" forced redetect).

Basically, our goal is to get USB flash drives working for use as a means of upgrading our Linux kernel in the field -- but right now it won't even EVER recognize a USB flash drive when it is plugged into the unit. We also know it is not a hardware problem as all USB devices work just fine once the full kernel finishes booting.

From what we have read, it looks like the Eukrea platform had USB working in it, and we have attempted to use it as a guide, but we still aren't having any luck.

Does anyone know of any steps we might be missing? Or of anyone who has gotten USB host mode working on a pcm043 under Barebox before?

I think we are close, but something (obviously) still isn't right.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw
Quoted 24 lines · Jerry Kirk

We have been attempting to get USB Host mode working under Barebox(2012-07-0) on a PCM043 platform (i.mx35), but we are having a bit of trouble.

We have merged the CONFIG_USB specific code for "imx35_devices_init" and "imx35_usb_init" from the Eukrea platform into pcm043.c, added the "MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR" and "MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC" pad definitions (as per the main kernel pcm043.c file), added the "tmp |= 0x3 << CCM_CGR2_USB_SHIFT" to enable the USB clock to "pcm043_core_setup", built everything with the "usb" command enabled, and then loaded the new Barebox image into our pcm043 board. We have USB_EHCI and USB_STORAGE enabled in the Barebox config.

If I execute the "usb" command then it returns that it has found 1 EHCI controller. If I plug in any device, the only one it has EVER detected has been a USB mouse. It will be detected most of the time following a reset and after unplugging/replugging the mouse -- but will never be detected again after this unless I do a reset/replug operation (and never on a "usb -f" forced redetect).

Basically, our goal is to get USB flash drives working for use as a means of upgrading our Linux kernel in the field -- but right now it won't even EVER recognize a USB flash drive when it is plugged into the unit. We also know it is not a hardware problem as all USB devices work just fine once the full kernel finishes booting.

Quoted 7 lines

From what we have read, it looks like the Eukrea platform had USB working in it, and we have attempted to use it as a guide, but we still aren't having any luck.

Does anyone know of any steps we might be missing? Or of anyone who has gotten USB host mode working on a pcm043 under Barebox before?

I think we are close, but something (obviously) still isn't right.

Could it be that the USB clock operates at the wrong rate? I think it should be 60MHz.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#2 lore raw
Quoted 5 lines
Quoted 2 lines

We have been attempting to get USB Host mode working under Barebox(2012-07-0) a PCM043 platform (i.mx35), but we are having a bit of trouble.

Could it be that the USB clock operates at the wrong rate? I think it should be 60MHz.

We're not certain how to verify the clock setting for USB in Barebox. We have used "dump_clocks" but are not certain which of these clocks the USB clock is derived from. We think we have it set to the same settings as the Eukrea board.

Do you know of anyone that has used USB on the pcm043 board?

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 10 lines · Jerry Kirk
Quoted 5 lines
Quoted 2 lines

We have been attempting to get USB Host mode working under Barebox(2012-07-0) a PCM043 platform (i.mx35), but we are having a bit of trouble.

Could it be that the USB clock operates at the wrong rate? I think it should be 60MHz.

We're not certain how to verify the clock setting for USB in Barebox. We have used "dump_clocks" but are not certain which of these clocks the USB clock is derived from. We think we have it set to the same settings as the Eukrea board.

The i.MX SoCs have a clko pin which can be muxed to different clocks. I don't know if this is accessible on the pcm043, but if yes, you could switch it to the USB clock and measure the clock.
Otherwise it might be good to run a current -rc kernel, you can then see the complete clock tree in debugfs

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

RFC PATCH 1/1 pcm043: usb support --not working--

Hi,

with the patch below I get the same behavior as Jerry: Only once after
reset command "usb" shows HI-Devices (Joystick, Mouse, ...). Jerry, do you have made any progress on this?

The clock settings seems to be the same as for eukrea_cpuimx35. Eric:
Does USB work for you on your board?

Sascha, I currently have no working config for kernel >=3.5 to check for clocks in debugfs.

Any thoughts on this?

Thanks
-- Christoph

From 2cec5266d1ae9ea141c6743accab9d1cb0ced7fc Mon Sep 17 00:00:00 2001
From: Christoph Fritz <[email protected]>
Date: Wed, 1 Aug 2012 11:32:17 +0200
Subject: [PATCH] pcm043: usb support --not working--

---
 arch/arm/boards/pcm043/lowlevel.c |    6 ++++++
 arch/arm/boards/pcm043/pcm043.c   |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)
arch/arm/boards/pcm043/lowlevel.c +6 -0
index efb5441..cec25b2 100644
@@ -196,6 +196,12 @@ void __bare_init __naked board_init_lowlevel(void)
 	r |= 0x00000003;
 	writel(r, ccm_base + CCM_CGR1);
 
+	/* enable USBOTG clock */
+	r = readl(ccm_base + CCM_CGR2);
+	r |= 0x3 << CCM_CGR2_USB_SHIFT;
+	r |= 0x3 << 26;
+	writel(r, ccm_base + CCM_CGR2);
+
 	r = readl(IMX_L2CC_BASE + L2X0_AUX_CTRL);
 	r |= 0x1000;
 	writel(r, IMX_L2CC_BASE + L2X0_AUX_CTRL);
arch/arm/boards/pcm043/pcm043.c +33 -0
index 9136bb3..06bf36b 100644
@@ -46,6 +46,7 @@
 #include <mach/imx-pll.h>
 #include <mach/iomux-mx35.h>
 #include <mach/devices-imx35.h>
+#include <mach/usb.h>
 
 static struct fec_platform_data fec_info = {
 	.xcv_type = MII100,
@@ -94,6 +95,30 @@ static struct fb_videomode pcm043_fb_mode[] = {
 	}
 };
 
+#ifdef CONFIG_USB
+static void imx35_usb_init(void)
+{
+	unsigned int tmp;
+
+	/* Host 1 */
+	tmp = readl(IMX_OTG_BASE + 0x600);
+	tmp &= ~(MX35_H1_SIC_MASK | MX35_H1_PM_BIT | MX35_H1_TLL_BIT |
+		MX35_H1_USBTE_BIT | MX35_H1_IPPUE_DOWN_BIT | MX35_H1_IPPUE_UP_BIT);
+	tmp |= (MXC_EHCI_INTERFACE_SINGLE_UNI) << MX35_H1_SIC_SHIFT;
+	tmp |= MX35_H1_USBTE_BIT;
+	tmp |= MX35_H1_IPPUE_DOWN_BIT;
+	writel(tmp, IMX_OTG_BASE + 0x600);
+
+	tmp = readl(IMX_OTG_BASE + 0x584);
+	tmp |= 3 << 30;
+	writel(tmp, IMX_OTG_BASE + 0x584);
+
+	/* Set to Host mode */
+	tmp = readl(IMX_OTG_BASE + 0x5a8);
+	writel(tmp | 0x3, IMX_OTG_BASE + 0x5a8);
+}
+#endif
+
 static struct imx_ipu_fb_platform_data ipu_fb_data = {
 	.mode			= pcm043_fb_mode,
 	.num_modes		= ARRAY_SIZE(pcm043_fb_mode),
@@ -101,6 +126,7 @@ static struct imx_ipu_fb_platform_data ipu_fb_data = {
 	.bpp			= 16,
 };
 
+
 static int pcm043_mem_init(void)
 {
 	arm_add_mem_device("ram0", IMX_SDRAM_CS0, SZ_128M);
@@ -173,6 +199,11 @@ static int imx35_devices_init(void)
 
 	imx35_add_fb(&ipu_fb_data);
 
+#ifdef CONFIG_USB
+	imx35_usb_init();
+	add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_OTG_BASE + 0x400, NULL);
+#endif
+
 	armlinux_set_bootparams((void *)0x80000100);
 	armlinux_set_architecture(MACH_TYPE_PCM043);
 
@@ -209,6 +240,8 @@ static iomux_v3_cfg_t pcm043_pads[] = {
 	MX35_PAD_I2C1_CLK__I2C1_SCL,
 	MX35_PAD_I2C1_DAT__I2C1_SDA,
 	MX35_PAD_ATA_CS0__GPIO2_6, /* LED */
+	MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR,
+	MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC,
 };
 
 static int imx35_console_init(void)
Signature · 9 lines
1.7.2.5




_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

Re: [RFC][PATCH] pcm043: usb support --not working--

Hi Christoph,

Quoted 9 lines · Christoph Fritz

Hi,

with the patch below I get the same behavior as Jerry: Only once after
reset command "usb" shows HI-Devices (Joystick, Mouse, ...). Jerry, do you have made any progress on this?

The clock settings seems to be the same as for eukrea_cpuimx35. Eric:
Does USB work for you on your board?

thanks for the heads up : now it works.

Quoted 5 lines

Sascha, I currently have no working config for kernel >=3.5 to check for clocks in debugfs.

Any thoughts on this?

try to copy the config in that patch I just sent ;-)

Eric

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw

Re: [RFC][PATCH] pcm043: usb support --not working--

Quoted 4 lines · Eric Bénard
Quoted 3 lines

The clock settings seems to be the same as for eukrea_cpuimx35. Eric:
Does USB work for you on your board?

thanks for the heads up : now it works.

great :-)

Quoted 6 lines
Quoted 5 lines

Sascha, I currently have no working config for kernel >=3.5 to check for clocks in debugfs.

Any thoughts on this?

try to copy the config in that patch I just sent ;-)

I did - without success. I suppose the external phy needs to be configured properly.

When you type the command "usb", you are getting a list of connected devices. Can you execute command "usb" a second and third time with the same result?

If yes, I think the clocks on pcm043 aren't set properly.

Thanks,
-- Christoph

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#7 lore raw

Re: [RFC][PATCH] pcm043: usb support --not working--

Hi Christoph,

Quoted 3 lines · Christoph Fritz

I did - without success. I suppose the external phy needs to be configured properly.

I'm using the internal PHY.

Quoted 4 lines

When you type the command "usb", you are getting a list of connected devices. Can you execute command "usb" a second and third time with the same result?

didn't try but at least the 1st time the USB storage was detected and I could mount it and list the files it contains.

Eric

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#8 lore raw

Re: [RFC][PATCH] pcm043: usb support --not working--

In reply to Christoph Fritz
Quoted 13 lines · Christoph Fritz
Quoted 4 lines · Eric Bénard
Quoted 3 lines

The clock settings seems to be the same as for eukrea_cpuimx35. Eric:
Does USB work for you on your board?

thanks for the heads up : now it works.

great :-)

Quoted 5 lines
Quoted 5 lines

Sascha, I currently have no working config for kernel >=3.5 to check for clocks in debugfs.

Any thoughts on this?

Quoted 8 lines
Quoted 1 line

try to copy the config in that patch I just sent ;-)

I did - without success. I suppose the external phy needs to be configured properly.

When you type the command "usb", you are getting a list of connected devices. Can you execute command "usb" a second and third time with the same result?

By default 'usb' now only probes once. That is because the USB stack is too silly to just keep already enumarated devices, but instead just removes all devices and reenumarates them. Bad things happen if one of your devices was a mounted USB mass storage device for example. If you want to probe multiple times try the -f aka force aka I know what I'm doing option.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#9 lore raw

Re: [RFC][PATCH] pcm043: usb support --not working--

Quoted 6 lines · Sascha Hauer

By default 'usb' now only probes once. That is because the USB stack is too silly to just keep already enumarated devices, but instead just removes all devices and reenumarates them. Bad things happen if one of your devices was a mounted USB mass storage device for example. If you want to probe multiple times try the -f aka force aka I know what I'm doing option.

In our case, we have been using the "usb -f" command but it still only finds HID type devices on the first probe after reset. On later "usb -f" it only finds the hub. We are using the external Phy module which is likely the problem. We have verified the clocks are at 60 mhz. We plan to readdress this issue in a couple of weeks when our final hardware arrives.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#10 lore raw

Re: [RFC][PATCH] pcm043: usb support --not working--

In reply to Sascha Hauer
Quoted 24 lines · Sascha Hauer
Quoted 13 lines · Christoph Fritz
Quoted 4 lines · Eric Bénard
Quoted 3 lines

The clock settings seems to be the same as for eukrea_cpuimx35. Eric:
Does USB work for you on your board?

thanks for the heads up : now it works.

great

Quoted 5 lines
Quoted 5 lines

Sascha, I currently have no working config for kernel >=3.5 to check for clocks in debugfs.

Any thoughts on this?

Quoted 8 lines
Quoted 1 line

try to copy the config in that patch I just sent

I did - without success. I suppose the external phy needs to be configured properly.

When you type the command "usb", you are getting a list of connected devices. Can you execute command "usb" a second and third time with the same result?

Quoted 9 lines

By default 'usb' now only probes once. That is because the USB stack is too silly to just keep already enumarated devices, but instead just removes all devices and reenumarates them. Bad things happen if one of your devices was a mounted USB mass storage device for example. If you want to probe multiple times try the -f aka force aka I know what I'm doing option.

Sascha

Sascha,

I work with Jerry and I've been doing a lot more testing with USB lately and we are still having issues under Barebox. We are on new hardware that now uses the internal Phy and everything seems to work find under Linux itself. However,under Barebox I am still seeing the following behaviour:

1) The first time after reset, when I do the "USB" command it detects the built-in hub device and any HID devices I have tested without issue.
2) Any additional times I do "USB -F" after that it ONLY detects the internal hub.
3) USB Mass Storage devices (flash drives, hard drives, et al) are NEVER detected -- and I've tried a LOT of different ones. The vast majority are never even detected at all, but I have one really old one that it will at least say "2 devices detected" on the probe but never shows any description of the device.

We are using a PCM043 SOM on a custom carrier board -- and to the best of my knowledge everything is setup properly. I've also checked the USB clock and it is correct. I have so far tried this with both Barebox 9 and Barebox 10, with no success. I have made sure that USB support is compiled in, as well as mass storage support and FAT support.

Do you have any ideas as to what might be going on or what we should be looking at?

Thanks,
Michael Burkey

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox