UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor gwowen
Visitor
2,664 Views
Registered: ‎06-09-2014

USB OTG in device mode - ULPI3320 chip

We are having a lot of difficulty getting our custom board to enumerate in device mode (using g_webcam or g_zero) modules, on Petalinux Kernel v2015.3. The module loads OK, and everything seems fine, but the device never enumerates. Inspecting the USB3320's ULPI registers during set-up - through the viewport - it seems that the DPPULLDOWN and DMPULLDOWN registers are always set, so the Phy always expects to act as a host.

Testing with both the ULPI Phy driver and the Passthrough driver, there's nowhere in the Linux Kernel code where these registers are modified - is the controller expected to do this automatically when the controller is put into device mode?

Does someone have a working kernel-config/device-tree setup that we can use a base for our tests? Any kernel version will do.

0 Kudos
8 Replies
Visitor msteveb0
Visitor
2,632 Views
Registered: ‎05-07-2014

Re: USB OTG in device mode - ULPI3320 chip

Where are you looking?

Look in drivers/usb/phy/phy-ulpi.c and you will see something like this:

 

 

static int ulpi_set_otg_flags(struct usb_phy *phy)
{
    unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN |
                 ULPI_OTG_CTRL_DM_PULLDOWN;

    if (phy->flags & ULPI_OTG_ID_PULLUP)
        flags |= ULPI_OTG_CTRL_ID_PULLUP;

    /*
     * ULPI Specification rev.1.1 default
     * for Dp/DmPulldown is enabled.
     */
    if (phy->flags & ULPI_OTG_DP_PULLDOWN_DIS)
        flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN;

    if (phy->flags & ULPI_OTG_DM_PULLDOWN_DIS)
        flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN;

    if (phy->flags & ULPI_OTG_EXTVBUSIND)
        flags |= ULPI_OTG_CTRL_EXTVBUSIND;

    return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL);
}

As long as your ulpi phy is hooked up correctly in the device tree it should be correctly.

0 Kudos
Visitor gwowen
Visitor
2,626 Views
Registered: ‎06-09-2014

Re: USB OTG in device mode - ULPI3320 chip

Right, I've found that code, but if you grep the source tree, you find that that line is the only place in the source where ULPI_OTG_DP_PULLDOWN_DIS and ULPI_OTG_DM_PULLDOWN_DIS are referenced (besides their definitions in the ulpi.h header file). So the code exists to set those registers *if* the flags are set - but no code exists to actually set the flags.
0 Kudos
Voyager
Voyager
2,609 Views
Registered: ‎09-14-2016

Re: USB OTG in device mode - ULPI3320 chip

Hi,

 

Are you sure about the schematic? We have successfully used ULPI3320 in host and peripheral but not otg mode :S

 

All troubles came from hardware issue ... Could you share your schematic ?

 

For info our device-tree for both parts:

 

    /* USB PHY DEVICE*/
    usb_phy0: phy0 {
        compatible = "usb-nop-xceiv";
        #phy-cells = <0>;
        reset-gpios = <&gpio0 52 1>;   // you have to check this part with your schematic
    };

    /* USB PHY HOST */
    usb_phy1: phy1 {
        compatible = "ulpi-phy";
        #phy-cells = <0>;
        reset-gpios = <&gpio0 53 1>; // you have to check this part with your schematic
        reg = <0xe0002000 0x1000>;
        view-port = <0x170>;
        drv-vbus;
    };

 

 

&usb0 {
    status = "okay";
    dr_mode = "peripheral";
    usb-phy = <&usb_phy0>;
};

&usb1 {
    status = "okay";
    dr_mode = "host";
    usb-phy = <&usb_phy1>;
};

 

Cheers,

Trigger

Visitor gwowen
Visitor
2,598 Views
Registered: ‎06-09-2014

Re: USB OTG in device mode - ULPI3320 chip

Thanks for that device tree. I notice that on the peripheral and host USB phys use different drivers - the passthrough for the peripheral and the ULPI for the host. We're trying to use the ULPI for both (as we want to do OTG - eventually) but I think I'll take I will look into uploading the appropriate bits of the schematic.

Thanks

0 Kudos
Voyager
Voyager
2,585 Views
Registered: ‎09-14-2016

Re: USB OTG in device mode - ULPI3320 chip

Yes, you're right, we don't use the driver because we had a lot of trouble with and we didn't want to waste our time on it.

 

For info we use linux-xlnx 4.6, maybe you could try to upgrade your Petalinux (v2015.3 is a little bit old) in order to get some fix like:

 

https://patchwork.kernel.org/patch/10054387/

https://patchwork.kernel.org/patch/10055483/

 

You can also take a look here:

https://forums.xilinx.com/t5/Zynq-All-Programmable-SoC/zedboard-USB-issue-with-ULPI-timeout/m-p/659226

 

Cheers,

Trigger

0 Kudos
Visitor gwowen
Visitor
2,568 Views
Registered: ‎06-09-2014

Re: USB OTG in device mode - ULPI3320 chip

Hi,

Here are (what I believe to be all) the relevant parts of the schematic.

Thanks for helping out.

transceiver.png
zynq.png
0 Kudos
Highlighted
Visitor msteveb0
Visitor
2,549 Views
Registered: ‎05-07-2014

Re: USB OTG in device mode - ULPI3320 chip

Well, you are right that nothing ever sets those flags.

 

If that's really what you want you can try this patch:

From bf404c0e8f2d379ddc6603cf36c6a3d0f9fa58dd Mon Sep 17 00:00:00 2001
From: Steve Bennett <steveb@workware.net.au>
Date: Sat, 2 Dec 2017 10:25:32 +1000
Subject: [PATCH] drivers/usb/phy: Allow disable-pulldowns for ulpi-phy

---
 drivers/usb/phy/phy-ulpi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c
index d4e848c..72df85f 100644
--- a/drivers/usb/phy/phy-ulpi.c
+++ b/drivers/usb/phy/phy-ulpi.c
@@ -343,6 +343,10 @@ static int ulpi_phy_probe(struct platform_device *pdev)
 	if (flag)
 		uphy->flags |= ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT;

+	flag = of_property_read_bool(np, "disable-pulldowns");
+	if (flag)
+		uphy->flags |= ULPI_OTG_DP_PULLDOWN_DIS | ULPI_OTG_CTRL_DP_PULLDOWN;
+
 	uphy->usb_phy = otg_ulpi_create(&ulpi_viewport_access_ops, uphy->flags);

 	uphy->usb_phy->dev = &pdev->dev;
--
1.9.1

And set the property in your device tree:

 

&usb_phy0 {
    disable-pulldowns;
};
0 Kudos
Adventurer
Adventurer
2,472 Views
Registered: ‎05-07-2008

Re: USB OTG in device mode - ULPI3320 chip

1) Might take a look at your Y1 load caps. Cload = 18pF does not mean that the external caps are 18pF.

As an example: https://community.nxp.com/thread/388856

 

2) Ensure you are getting VBUS when in device mode. PHY must see that.

 

3) Ensure you are providing a reset pulse to the reset pin on the PHY.

0 Kudos