ARM: socfpga: gen5: release reset before using USB as device with ums

Wolfgang Grandegger wg at aries-embedded.de
Mon Mar 14 11:57:28 CET 2022


Hello,

Am 28.02.22 um 16:22 schrieb Marek Vasut:
> On 2/28/22 16:18, Wolfgang Grandegger wrote:
> 
> Hi,
> 
> [...]
> 
>>>> diff --git a/arch/arm/mach-socfpga/board.c
>>>> b/arch/arm/mach-socfpga/board.c
>>>> index 7267163222..a2eed73fe9 100644
>>>> --- a/arch/arm/mach-socfpga/board.c
>>>> +++ b/arch/arm/mach-socfpga/board.c
>>>> @@ -83,6 +83,14 @@ int board_usb_init(int index, enum usb_init_type
>>>> init)
>>>>        /* Patch the address from OF into the controller pdata. */
>>>>        socfpga_otg_data.regs_otg = addr;
>>>>    +#ifdef CONFIG_TARGET_SOCFPGA_GEN5
>>>> +    /* First release reset of the USB port */
>>>> +    if (addr == SOCFPGA_USB0_ADDRESS)
>>>> +        socfpga_per_reset(SOCFPGA_RESET(USB0), 0);
>>>> +    else if (addr == SOCFPGA_USB1_ADDRESS)
>>>> +        socfpga_per_reset(SOCFPGA_RESET(USB1), 0);
>>>> +#endif
>>>
>>> Is this really needed at all ?
>>
>> Yes, it's needed, otherwise "ums 0 mmc 0" does not work. It was working
>> some time ago but commit 430b42f76a4e50ffef7cc2b3c195ff645a438433 did
>> remove the ad-hoc reset code. I realize the issue an on Aries MCVEVP
>> board, but I'm quite sure that it's present on all Cyclone5 boards.
> 
> Can you investigate why the reset-socfpga.c does not release the USB
> from reset instead ? That would be the right approach.

The attached patch works. It enables CONFIG_DM_USB_GADGET and adds
"dr_mode = otg" to the USB device tree node. "ums 0 mmc 0" deasserts the
reset for USB1 and re-assert it when done. All ok with that!

But then "usb start" is broken:

  => usb start
  starting USB...
  USB: drv id 110 name usb
  USB: drv id 90 name serial
  USB: drv id 101 name sysreset
  USB: drv id 85 name reset
  USB: drv id 22 name blk
  USB: drv id 59 name mmc
  USB: drv id 99 name syscon
  USB: drv id 25 name cache
  USB: drv id 43 name i2c
  USB: drv id 40 name gpio
  USB: drv id 36 name ethernet
  USB: drv id 91 name simple_bus
  USB: drv id 0 name root
  No working controllers found


The function "uclass_find()" does no longer find the USB host device
(UCLASS_USB). The debug ouput is with:

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 2578803b7a..b59a5dcdad 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -35,6 +35,9 @@ struct uclass *uclass_find(enum uclass_id key)
         * id to node.
         */
        list_for_each_entry(uc, gd->uclass_root, sibling_node) {
+               if (key == UCLASS_USB)
+                       printf("USB: drv id %d name %s\n", 
+                              uc->uc_drv->id, uc->uc_drv->name);
                if (uc->uc_drv->id == key)
                        return uc;
        }

Id 110 is UCLASS_USB_GADGET_GENERIC, but UCLASS_USB is gone. There is
some magic with usb device scanning. Any idea what could cause that
problem?

Wolfgang

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-socfpga-mcvevk-fix-reset-handling-to-make-ums-0-mmc-.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20220314/647796e8/attachment.bin>


More information about the U-Boot mailing list