mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* usbotg: otg_set_mode() can only be called once
@ 2023-08-24 11:30 Christian Eggers
  2023-08-24 12:04 ` Christian Eggers
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Eggers @ 2023-08-24 11:30 UTC (permalink / raw)
  To: barebox

Application:

1. Try to boot via fastboot (usb device)
2. Try to boot via usb drive (usb host)

Problem:

barebox@i.MX6ULL:/ setenv otg.mode=host
imx-usb 2184000.usb@2184000.of: USB EHCI 1.00
barebox@i.MX6ULL:/ setenv otg.mode=peripheral
Cannot set parameter otg.mode: Device or resource busy

Analysis:

The otgdev core maintains one `struct otg_mode` per device.  The function
checks whether the current mode is equal to USB_DR_MODE_OTG.  If not, it
returns -EBUSY.  There is currently no way to reset the current mode back to
USB_DR_MODE_OTG after it has been set to peripheral or host mode once.







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: usbotg: otg_set_mode() can only be called once
  2023-08-24 11:30 usbotg: otg_set_mode() can only be called once Christian Eggers
@ 2023-08-24 12:04 ` Christian Eggers
  2023-08-24 13:23   ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Eggers @ 2023-08-24 12:04 UTC (permalink / raw)
  To: barebox

ok, I should better read the manuals ...

"Once a specific mode has been selected it can't be changed later anymore."

In the past I used two OTG cores, one as device and one as host. So both
OTGs were set to a fixed drmode in the device tree.

No I need to implement both features via a single OTG.  But probably
I can use another criteria for choosing the correct boot methods instead of
trying both.


On Thursday, 24 August 2023, 13:30:46 CEST, Christian Eggers wrote:
> Application:
> 
> 1. Try to boot via fastboot (usb device)
> 2. Try to boot via usb drive (usb host)
> 
> Problem:
> 
> barebox@i.MX6ULL:/ setenv otg.mode=host
> imx-usb 2184000.usb@2184000.of: USB EHCI 1.00
> barebox@i.MX6ULL:/ setenv otg.mode=peripheral
> Cannot set parameter otg.mode: Device or resource busy
> 
> Analysis:
> 
> The otgdev core maintains one `struct otg_mode` per device.  The function
> checks whether the current mode is equal to USB_DR_MODE_OTG.  If not, it
> returns -EBUSY.  There is currently no way to reset the current mode back to
> USB_DR_MODE_OTG after it has been set to peripheral or host mode once.
> 
> 







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: usbotg: otg_set_mode() can only be called once
  2023-08-24 12:04 ` Christian Eggers
@ 2023-08-24 13:23   ` Ahmad Fatoum
  2023-08-24 13:35     ` Christian Eggers
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2023-08-24 13:23 UTC (permalink / raw)
  To: Christian Eggers, barebox

Hello Christian,

On 24.08.23 14:04, Christian Eggers wrote:
> ok, I should better read the manuals ...
> 
> "Once a specific mode has been selected it can't be changed later anymore."
> 
> In the past I used two OTG cores, one as device and one as host. So both
> OTGs were set to a fixed drmode in the device tree.
> 
> No I need to implement both features via a single OTG.  But probably
> I can use another criteria for choosing the correct boot methods instead of
> trying both.

Obvious choices is checking [ "$bootsource" = serial ] or checking if device
is gadget through ID pin or Type C controller.

Is that possible in your case?

Cheers,
Ahmad

> 
> 
> On Thursday, 24 August 2023, 13:30:46 CEST, Christian Eggers wrote:
>> Application:
>>
>> 1. Try to boot via fastboot (usb device)
>> 2. Try to boot via usb drive (usb host)
>>
>> Problem:
>>
>> barebox@i.MX6ULL:/ setenv otg.mode=host
>> imx-usb 2184000.usb@2184000.of: USB EHCI 1.00
>> barebox@i.MX6ULL:/ setenv otg.mode=peripheral
>> Cannot set parameter otg.mode: Device or resource busy
>>
>> Analysis:
>>
>> The otgdev core maintains one `struct otg_mode` per device.  The function
>> checks whether the current mode is equal to USB_DR_MODE_OTG.  If not, it
>> returns -EBUSY.  There is currently no way to reset the current mode back to
>> USB_DR_MODE_OTG after it has been set to peripheral or host mode once.
>>
>>
> 
> 
> 
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: usbotg: otg_set_mode() can only be called once
  2023-08-24 13:23   ` Ahmad Fatoum
@ 2023-08-24 13:35     ` Christian Eggers
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Eggers @ 2023-08-24 13:35 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum

Hello Ahmad,

On Thursday, 24 August 2023, 15:23:17 CEST, Ahmad Fatoum wrote:
> Hello Christian,
> 
> On 24.08.23 14:04, Christian Eggers wrote:
> > ok, I should better read the manuals ...
> > 
> > "Once a specific mode has been selected it can't be changed later anymore."
> > 
> > In the past I used two OTG cores, one as device and one as host. So both
> > OTGs were set to a fixed drmode in the device tree.
> > 
> > No I need to implement both features via a single OTG.  But probably
> > I can use another criteria for choosing the correct boot methods instead of
> > trying both.
> 
> Obvious choices is checking [ "$bootsource" = serial ] or checking if device
> is gadget through ID pin or Type C controller.
> 
> Is that possible in your case?
I currently check for $bootsource which is sufficient. But using the USB-C CC
lines (that's why I am working on the ADC driver) sounds event better.  Currently
I use the ADC only for checking whether a device is connected (I am allowed to 
enable VBUS), but not for determining whether a host is connected (activate USB gadget).

regards,
Christian


> 
> Cheers,
> Ahmad
> 
> > 
> > 
> > On Thursday, 24 August 2023, 13:30:46 CEST, Christian Eggers wrote:
> >> Application:
> >>
> >> 1. Try to boot via fastboot (usb device)
> >> 2. Try to boot via usb drive (usb host)
> >>
> >> Problem:
> >>
> >> barebox@i.MX6ULL:/ setenv otg.mode=host
> >> imx-usb 2184000.usb@2184000.of: USB EHCI 1.00
> >> barebox@i.MX6ULL:/ setenv otg.mode=peripheral
> >> Cannot set parameter otg.mode: Device or resource busy
> >>
> >> Analysis:
> >>
> >> The otgdev core maintains one `struct otg_mode` per device.  The function
> >> checks whether the current mode is equal to USB_DR_MODE_OTG.  If not, it
> >> returns -EBUSY.  There is currently no way to reset the current mode back to
> >> USB_DR_MODE_OTG after it has been set to peripheral or host mode once.
> >>
> >>
> > 
> > 
> > 
> > 
> > 
> > 
> 
> 







^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-24 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 11:30 usbotg: otg_set_mode() can only be called once Christian Eggers
2023-08-24 12:04 ` Christian Eggers
2023-08-24 13:23   ` Ahmad Fatoum
2023-08-24 13:35     ` Christian Eggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox