Skip to contentSkip to conversation

fsl-udc (USB gadget) anyone?

DISCUSSION Baruch Siach 3 participants 4 messages Aug 16, 2010 – Aug 17, 2010

lore
Share & tools
lore
#0 lore raw

Hi Barebox list,

I see that there are no in-tree fsl-udc driver users. Does anyone here have experience with this driver on an i.MX based system? What pre-probe() initialization does this driver require at the platform code?

TIA,

baruch

Signature · 8 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -

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

Hi Baruch,

Quoted 5 lines · Baruch Siach

Hi Barebox list,

I see that there are no in-tree fsl-udc driver users. Does anyone here have experience with this driver on an i.MX based system? What pre-probe() initialization does this driver require at the platform code?

We are using it on a custom i.MX25 board (which is not in mainline because hardly anyone could make use of the code). Here is the platform initialization code (mixed with ehci host support). It works fine in DFU mode, serial support is probably not working. I have tried serial support, but had problems integrating it properly in barebox.

+static void cm3389_usb_init(void)
+{
+ unsigned int tmp;
+
+ /* Host 2 */
+ tmp = readl(IMX_OTG_BASE + 0x600);
+ tmp &= ~(3 << 21);
+ tmp |= (2 << 21) | (1 << 4) | (1 << 5);
+ 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 + 0x1a8);
+ writel(tmp | 0x3, IMX_OTG_BASE + 0x1a8);
+}
+
+static struct device_d usbh2_dev = {
+ .name = "ehci",
+ .map_base = IMX_OTG_BASE + 0x400,
+ .size = 0x200,
+};
+
+static struct fsl_usb2_platform_data usb_pdata = {
+ .operating_mode = FSL_USB2_DR_DEVICE,
+ .phy_mode = FSL_USB2_PHY_UTMI,
+};
+
+static struct device_d usbotg_dev = {
+ .name = "fsl-udc",
+ .map_base = IMX_OTG_BASE,
+ .size = 0x200,
+ .platform_data = &usb_pdata,
+};

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
#2 lore raw

Hi Sacha, Hi Baruch,

Quoted 8 lines · Sascha Hauer
Quoted 5 lines · Baruch Siach

Hi Barebox list,

I see that there are no in-tree fsl-udc driver users. Does anyone here have experience with this driver on an i.MX based system? What pre-probe() initialization does this driver require at the platform code?

Quoted 5 lines

We are using it on a custom i.MX25 board (which is not in mainline because hardly anyone could make use of the code). Here is the platform initialization code (mixed with ehci host support). It works fine in DFU mode, serial support is probably not working. I have tried serial support, but had problems integrating it properly in barebox.

interesting, I've tested it on an i.MX27 and I had to do the following change to get DFU working fine, else the 1st packet's last bytes were always wrong when flashing data to the NOR (or simply copying data into RAM) :
http://www.spinics.net/lists/u-boot-v2/msg01166.html

Do you think this fix is wrong ?

The init is the following :

static struct fsl_usb2_platform_data udc_info = {
	.operating_mode = FSL_USB2_DR_DEVICE,
	.phy_mode = FSL_USB2_PHY_ULPI,
};
static struct device_d udc_dev = {
	.name     = "fsl-udc",
	.map_base = IMX_OTG_BASE,
	.platform_data	= &udc_info,
};

Eric

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

#3 lore raw
In reply to Sascha Hauer

Hi Sascha,

Quoted 13 lines · Sascha Hauer
Quoted 5 lines · Baruch Siach

Hi Barebox list,

I see that there are no in-tree fsl-udc driver users. Does anyone here have experience with this driver on an i.MX based system? What pre-probe() initialization does this driver require at the platform code?

We are using it on a custom i.MX25 board (which is not in mainline because hardly anyone could make use of the code). Here is the platform initialization code (mixed with ehci host support). It works fine in DFU mode, serial support is probably not working. I have tried serial support, but had problems integrating it properly in barebox.

[snip]

Review

Quoted 11 lines
(quoted diff) +11 -0
+static struct fsl_usb2_platform_data usb_pdata = {
+	.operating_mode	= FSL_USB2_DR_DEVICE,
+	.phy_mode	= FSL_USB2_PHY_UTMI,
+};
+
+static struct device_d usbotg_dev = {
+	.name     = "fsl-udc",
+	.map_base = IMX_OTG_BASE,
+	.size     = 0x200,
+	.platform_data = &usb_pdata,
+};

Thanks for the info. Unfortunately I was not able to get dfu work on both the i.MX25 PDK and our custom board. The board doesn't even get enumerated. The USB PHY wiring is the same on both. After running the 'dfu' command as follows:

barebox:/ dfu -V 0x082d -P 0x2000 test(script)

I connect the board to my host and see the following on the host side:

[113870.024034] usb 2-1: new high speed USB device using ehci_hcd and address 101
[113870.092245] hub 2-0:1.0: unable to enumerate USB device on port 1
[113870.584048] usb 6-1: new full speed USB device using uhci_hcd and address 27
[113870.700071] hub 6-0:1.0: unable to enumerate USB device on port 1
[113871.080062] usb 6-1: new full speed USB device using uhci_hcd and address 28
[113871.200106] usb 6-1: device descriptor read/64, error -71
[113871.424073] usb 6-1: device descriptor read/64, error -71
[113871.640069] usb 6-1: new full speed USB device using uhci_hcd and address 29
[113871.760068] usb 6-1: device descriptor read/64, error -71
[113871.984068] usb 6-1: device descriptor read/64, error -71
[113872.200067] usb 6-1: new full speed USB device using uhci_hcd and address 30
[113872.608070] usb 6-1: device not accepting address 30, error -71
[113872.720073] usb 6-1: new full speed USB device using uhci_hcd and address 31
[113873.128058] usb 6-1: device not accepting address 31, error -71
[113873.128079] hub 6-0:1.0: unable to enumerate USB device on port 1

Sprinkling printfs over the fsl-udc driver code didn't reveal much, except from repeated USB_STS_PORT_CHANGE and USB_STS_RESET interrupts. Before giving up completely I thought I'd just report this failure, maybe someone has a clue.

baruch

Signature · 8 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -

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