i.MX51 Linux USB

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX51 Linux USB

Jump to solution
3,839 Views
eahlen
Contributor I

Hi,

I have a custom i.MX51 board heavily based on the babbage board. I'm trying to get USB to work on it without success. I'm using Linux kernel 3.11 and Device Tree (I have an old system running on the board with kernel 2.6.31). The first problem was that the "compatible" value for usbmisc was "fsl,imx51-usbmisc" which doesn't even have a mapping. If I've understood it correctly I should be able to use "fsl,imx53-usbmisc" here if I'm not disabling over current detection? I've also made a patch for imx51-usbmisc which I plan on submitting if I can get it tested. But this makes me suspect that USB has never been tested on i.MX51? The funny thing is that I actually got it working once when debugging the kernel over JTAG and had a breakpoint set in ci_hdrc_imx_probe, but haven't been able to reproduce.

Any ideas are much appreciated!

Labels (3)
Tags (1)
0 Kudos
1 Solution
1,961 Views
erikahlén
Contributor II

If someone else have the same problem I wanted to write that I found a patch that solved my problems with USB OTG.

[PATCH] ARM: dts: i.MX51: Fix OTG PHY clock

View solution in original post

0 Kudos
23 Replies
1,962 Views
erikahlén
Contributor II

If someone else have the same problem I wanted to write that I found a patch that solved my problems with USB OTG.

[PATCH] ARM: dts: i.MX51: Fix OTG PHY clock

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Cool, does USB Host1 also work for you?

0 Kudos
1,817 Views
erikahlén
Contributor II

Yes, USB Host1 is also working =)

And just to be clear, I needed another patch for USB to work.

[PATCH] chipidea: core: Move hw_phymode_configure() into probe -- Linux USB

Thank you for that one :smileywink:

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Erik,

This is great news!

Could you please share your patches to get USBH1 host working with mainline?

I would like to add USBH1 support for mx51evk board, which has a USB3317 PHY and a USB2517 hub.

Thanks,

Fabio Estevam

0 Kudos
1,817 Views
daveebright
Contributor III

Hi Fabio,

Did anyone ever determine the proper contents of the imx51.dts and imx51-babbage.dtsi files to get the USB functionality working in later kernels that use the device tree for the i.MX51 EVK?  I have investigated/built the latest stable kernel 3.14-rc6 and the latest linaro kernel without any luck.  The USB definitions are in the imx51.dtsi file as status disabled and the imx51-babbage.dts file has no USB references in it at all.  I believe there needs to be USB nodes in the imx51-babbage.dts file which further define/override the generic definitions in the imx51.dtsi file for the i.MX51 EVK.  If you have gotten a working version of this I would appreciate you sharing the information.

Thanks,

Dave

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Dave,

You have to do something like Erik Ahlen showed on his last post and adapt it to imx51-babbage.dts.

I haven't had a chance to try it on this board yet.

imx53-qsb has USB host1 and gadget functional.

Let me know how you go with this implementation.

Regards,

Fabio Estevam

0 Kudos
1,817 Views
daveebright
Contributor III

Fabio,

I got the USB host1 port working on the i.MX51 EVK, but the USB OTG port is not functional.  I added the following to the imx51-babbage.dtsi file (kernel 3.14-rc6):

These nodes are inside the first section:

        regulators {

                compatible = "simple-bus";

                reg_usb_vbus: usb_vbus {

                        compatible = "regulator-fixed";

                        regulator-name = "usb_vbus";

                        regulator-min-microvolt = <3300000>;

                        regulator-max-microvolt = <3300000>;

                        gpio = <&gpio2 5 0>;

                        enable-active-high;

                };

        };

        usbphy1: usbphy@1 {

                compatible = "usb-nop-xceiv";

                clocks = <&clks 75>;

                clocks-name = "main_clk";

                status = "okay";

        };

};

These nodes are at the end of the file:

&usbh1 {

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_usbh1_1>;

        fsl,usbphy = <&usbphy1>;

        vbus-supply = <&reg_usb_vbus>;

        phy_type = "ulpi";

        status = "okay";

};

&usbotg {

        dr_mode = "otg";

        status = "okay";

};

I'll keep working on the USB OTG next week.  I have the "[PATCH] ARM: dts: i.MX51: Fix OTG PHY clock" mentioned by Erik, so that is not it.  If you have any ideas let me know.  I plan on turning on debug inside the Chip Idea UDC driver to get a better understanding what is going on.

Additionally lsusb shows:

Bus 002 Device 002: ID 0424:2517 Standard Microsystems Corp. Hub

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 003: ID 05e3:0718 Genesys Logic, Inc. IDE/SATA Adapter

So I can see the root hub for the USB OTG.  I'm attempting to use the port as a device port (g_ether or g_zero drivers) and when I plug it into another computer nothing happens.  If I run on my old 2.6.35 kernel load, the gadget drivers g_ether and g_zero work fine.

Thanks,

Dave

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Dave,

I implemented your suggestions and came up with this patch that I plan to submitting to the linux-arm-kernel list:

http://pastebin.com/Z2FYSW8m

This patches makes USBHost functional on my mx51evk.

If you agree, I would like to put your Signed-off-by line in this patch in order to give you credit for this work.

Please reply to me with your email address so that I can include it.

I will also check/debug the USB OTG functionality later.

Regards,

Fabio Estevam

0 Kudos
1,816 Views
daveebright
Contributor III

Fabio,

I agree with your USB host patch for the i.MX51 EVK based on my suggestions.  I have no problem with you submitting the patch and taking credit.

Thanks,

Dave

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Dave,

Regarding USB OTG, this is what I observe on mx51evk:

root@freescale /$ modprobe g_ether

using random self ethernet address

using random host ethernet address

usb0: HOST MAC 92:26:a4:e1:8a:2c

usb0: MAC 56:77:ac:d0:2a:cd

g_ether gadget: Ethernet Gadget, version: Memorial Day 2008

g_ether gadget: g_ether ready

,but when I insert the cable in the PC I don't get any response that CDC / g_ether has been loaded. I tested the same kernel on a mx6q-wandboard and g_ether is working fine, so the kernel version I am using is fine.

I have also started a thread in linux-arm-kernel about USB OTG on mx51.

Regards,

Fabio Estevam

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Dave,

I have g_ether working fine now :-)

This is what I changed in usbmisc_imx.c:

http://pastebin.com/jmwY4hvL

And I used the same usbotg node that you mentioned before.

Test procedure:

1. Do a full power cycle

2. Load the g_ether module on the mx51evk:

$ modprobe g_ether

using random self ethernet address

using random host ethernet address

usb0: HOST MAC 22:81:c3:54:bb:20

usb0: MAC 62:f7:11:de:af:d3

g_ether gadget: Ethernet Gadget, version: Memorial Day 2008

g_ether gadget: g_ether ready

3. Insert the USB cable between the mx51evk USB OTG port and the PC

You should see the following message pop up: "g_ether gadget: high-speed config #1: CDC Ethernet (EEM)"

4. On the mx51evk console:

$ ifconfig usb0 up

$ ifconfig usb0 10.0.0.2

5. On the host PC terminal:

# sudo ifconfig usb0 10.0.0.1

# ping 10.0.0.2

PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.

64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=1.62 ms

64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.502 ms

64 bytes from 10.0.0.2: icmp_req=3 ttl=64 time=0.501 ms

64 bytes from 10.0.0.2: icmp_req=4 ttl=64 time=0.295 ms

64 bytes from 10.0.0.2: icmp_req=5 ttl=64 time=0.345 ms

64 bytes from 10.0.0.2: icmp_req=6 ttl=64 time=0.361 ms

64 bytes from 10.0.0.2: icmp_req=7 ttl=64 time=0.322 ms

64 bytes from 10.0.0.2: icmp_req=8 ttl=64 time=0.531 ms

64 bytes from 10.0.0.2: icmp_req=9 ttl=64 time=0.543 ms

64 bytes from 10.0.0.2: icmp_req=10 ttl=64 time=0.492 ms

64 bytes from 10.0.0.2: icmp_req=11 ttl=64 time=0.401 ms

64 bytes from 10.0.0.2: icmp_req=12 ttl=64 time=0.301 ms

64 bytes from 10.0.0.2: icmp_req=13 ttl=64 time=0.506 ms

64 bytes from 10.0.0.2: icmp_req=14 ttl=64 time=0.510 ms

64 bytes from 10.0.0.2: icmp_req=15 ttl=64 time=0.552 ms

6. If you notice that the ping stops, do a CTRL + C and inspect 'ifconfig usb0'. Probably it lost its IP, then just do number 5 again.

Regards,

Fabio Estevam

0 Kudos
1,816 Views
fabio_estevam
NXP Employee
NXP Employee
0 Kudos
1,816 Views
daveebright
Contributor III

Fabio,

I applied this patch and tested it for the USB OTG on the i.MX51 EVK and so far it works for me.  Both the g_ether and g_mass_storage gadget drivers now function properly.  Thanks a lot!!!  I appreciate your help!!!

Dave

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Dave,

Good to know that USBH1 is working!

For the USB OTG: please try passing dr_mode = "peripheral".

Also, I haven't seen where you added the USB OTG phy node in the device tree.

I will try to get access to a mx51evk next week.

Regards,

Fabio Estevam

0 Kudos
1,817 Views
daveebright
Contributor III

Fabio,

The USB OTG phy node is included in the imx51.dtsi device tree file.  It looks as follows:

                        usbphy0: usbphy@0 {

                                compatible = "usb-nop-xceiv";

                                clocks = <&clks 75>;

                                clock-names = "main_clk";

                                status = "okay";

                        };

Last week I also had already tried with dr_mode = "peripheral" with no luck.  I hope to have some time to work on this further today.

Thanks,

Dave Ebright

0 Kudos
1,817 Views
daveebright
Contributor III

Fabio,

I got a little more time to work on this today.  I found that if I added phy_type = "utmi" or phy_type = "utmi_wide" to the usbotg entry in the imx51-babbage.dts file that the USB OTG gadget functionality almost works.  That is the usbotg entry now looks like:

&usbotg {

        dr_mode = "otg";

        phy_type = "utmi";

        disable-over-current;

        status = "okay";

};

So then I loaded the g_ether driver, plugged the USB cable into my PC running Ubuntu and a connection is established.  I gave each end a static IP in the same subnet, but I could not ping or ssh successfully in either direction.  Next I tried the g_mass_storage driver, but I cannot get my file system partition to mount on the remote host (messages on the remote end indicating it attached with the right file system type of EXT4, but then there is a message saying sdc: detected capacity change from 31914983424 to 0).  On the i.MX51 EVK it rolls in the log message: "g_mass_storage gadget: full-speed config #1: Linux File-Backed Storage".  Generally when this works of course you only get one of these messages.  I also tried this with dr_mode = "peripheral", but the results are the same.

Anyway I will keep debugging this...

Dave

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Dave,

Looks like you are almost there.

Maybe we are missing this setting?

/* Set the PHY clock to 19.2MHz */

    v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);

    v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;

    v |= MX51_USB_PLL_DIV_19_2_MHZ;

    __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);

    iounmap(usb_base);

,which can be found at the non-dt version of the mx51 evk support at:

arch/arm/mach-imx/mach-mx51_babbage.c

A quick way to test this is to start by setting and clearing these bits from the bootloader.

If it works, then we need to figure out a proper way to do these settings in the kernel.

Regards,

Fabio Estevam

0 Kudos
1,817 Views
erikahlén
Contributor II

Hi Fabio,

Our board has a USB3340 PHY and a USB2512Bi hub.

I added this to our device tree.

usbh1_reset: usbh1_reset_reg {

  compatible = "regulator-fixed";

  regulator-name = "usbh1_reset";

  regulator-min-microvolt = <3300000>;

  regulator-max-microvolt = <3300000>;

  gpio = <&gpio3 8 0>;

  startup-delay-us = <7000>;

};

usbphy1: usbphy@1 {

  compatible = "usb-nop-xceiv";

  clocks = <&clks 75>;

  clock-names = "main_clk";

  status = "okay";

};

</quote>

And then the node for h1 looks like this.

&usbh1 {

  pinctrl-names = "default";

  pinctrl-0 = <&pinctrl_usbh1_1>;

  fsl,usbphy = <&usbphy1>;

  phy_type = "ulpi";

  dr_mode = "host";

  status = "okay";

};

Looking at the code for the non device tree babbage it looks like there needs to be some handling of resetting the PHY and hub.

Regards,

0 Kudos
1,817 Views
erikahlén
Contributor II

Haven't had time to test it yet, hopefully tomorrow. It's a bit more problematic with a hub that also needs configuring though.

0 Kudos
1,817 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Erik,

We do have USB support for mx53, but not for mx51 yet in the mainline kernel.

Alexander sent some mx51 related patches: http://www.spinics.net/lists/arm-kernel/msg285376.html

Do you have USB functional on mx51 now?

It would be great if you could test Alexander's patch or share some of your patches in the linux-arm-kernel and linux-usb mailing lists.

Regards,

Fabio Estevam