[PATCH 3/5] usb: dwc3-generic: Relax unsupported dr_mode check

Jonas Karlman jonas at kwiboo.se
Thu Jul 13 11:56:22 CEST 2023


Hi Marek,

Sorry for late reply.
On 2023-06-05 12:14, Marek Vasut wrote:
> On 5/30/23 12:26, Jonas Karlman wrote:
>> When dr_mode is peripheral or otg and U-Boot has not been built with
>> DM_USB_GADGET support, booting such device may end up with:
>>
>>    dwc3_glue_bind_common: subnode name: usb at fcc00000
>>    Error binding driver 'dwc3-generic-wrapper': -6
>>    Some drivers failed to bind
>>    initcall sequence 00000000effbca08 failed at call 0000000000a217c8 (err=-6)
>>    ### ERROR ### Please RESET the board ###
>>
>> Instead fail gracfully with ENODEV to allow board continue booting.
>>
>>    dwc3_glue_bind_common: subnode name: usb at fcc00000
>>    dwc3_glue_bind_common: unsupported dr_mode
>>
>> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
>> ---
>>   drivers/usb/dwc3/dwc3-generic.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
>> index c28ad47bddd8..f7859a530280 100644
>> --- a/drivers/usb/dwc3/dwc3-generic.c
>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>> @@ -422,13 +422,13 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
>>   		dr_mode = usb_get_dr_mode(node);
>>   
>>   	switch (dr_mode) {
>> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
>>   	case USB_DR_MODE_PERIPHERAL:
>>   	case USB_DR_MODE_OTG:
>> -#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> 
> Why not just do
> 
> #else
> return -ENODEV
> #endif
> 
> here ?

The code was changed to closer match how host mode is already handled,
and the default switch case already return -ENODEV.

Regards,
Jonas

> 
>>   		debug("%s: dr_mode: OTG or Peripheral\n", __func__);
>>   		driver = "dwc3-generic-peripheral";
>> -#endif
>>   		break;
>> +#endif
> 
> 



More information about the U-Boot mailing list