public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@kernel.org>
To: Sjoerd Simons <sjoerd@collabora.com>, u-boot@lists.denx.de
Cc: Martyn Welch <martyn.welch@collabora.com>,
	Nishanth Menon <nm@ti.com>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Igor Prusov <ivprusov@salutedevices.com>,
	Marek Vasut <marex@denx.de>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Simon Glass <sjg@chromium.org>,
	Svyatoslav Ryhel <clamor95@gmail.com>
Subject: Re: [PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start
Date: Fri, 12 Jan 2024 14:56:47 +0200	[thread overview]
Message-ID: <1fea7f2d-62af-44f5-bcfd-2a7e3fd33ca6@kernel.org> (raw)
In-Reply-To: <80d49aa7dd463700d98d5b2d74b7df35b6ed1d88.camel@collabora.com>



On 12/01/2024 13:06, Sjoerd Simons wrote:
> On Fri, 2024-01-12 at 12:39 +0200, Roger Quadros wrote:
>>
>>
>> On 12/01/2024 10:52, Sjoerd Simons wrote:
>>> When dr_mode is "otg" the dwc3 is initially configured in _OTG
>>> mode;
>>> However in this mode the gadget functionality doesn't work without
>>> further configuration. To resolve that on gadget start switch to
>>> _DEVICE
>>> mode globally and go back to _OTG on stop again.
>>>
>>> For this the dwc3_set_mode is renamed to dwc3_core_set_mode to
>>> avoid a
>>> conflict with the same function exposed by xhci-dwc3
>>
>> Aren't they both doing the same thing? I'd rather define them at one
>> place
>> i.e. dwc3/core.c.
> 
> They twiddle the same registers afaict indeed; but the way to get there
> is rather different. So having just one for both really needs a bigger
> amount of rework.
> 
>> The driver model design for dwc3 looks really broken in u-boot.
>>
>> "snps,dwc3" is claimed by xhci-dwc3.c instead of being claimed by
>> dwc3/core.c.
>> This is probably because at the time USB host was the more needed use
>> case at u-boot.
>>
>> Ideally dwc3/core.c should claim "snps,dwc3" device and instantiate
>> the respective Host/Device/OTG device based on the provided otg mode.
>>
>> For Host/Device mode it is straight forwa
>> dwc3/core.c does dwc3_set_mode() depending on the mode and:
>> for host mode -> register xhci-usb driver.
>> for device mode -> register UDC device driver.
>>
>> For dual-role mode, the solution is not very clear as I don't think
>> there is a role switch framework present
>>
>> To begin with, we could probably restrict it to just device mode
>> as most platforms were forcing it to device mode in any case as they
>> usually have a 2nd USB port that is host only.
> 
> Right we don't have role switching; And if we had we'd have to add
> support of the Type-C controller on the SK boards which determines the
> roles for this.
> 
> This one more minimal patch was modelled after the discussion last year
> around otg mode[0]. And similar to how the cdns3 driver handles it.
> Essentially letting host/gadget mode be determined by the usage rather
> then the cables plugged, which is not pretty but works.
> 
> While I agree with you this could all be a lot nicer of u-boot did
> "proper" OTG/role-switching; I unfortunately don't have the bandwidth
> to introduce all of that and it seems a shame to block DFU support on
> it. For reference my previous series just set the peripheral role in
> the dts which reflects your suggestion of forcing device mode. I'd be
> wary to do so in the driver because i would hope the OTG handling in
> dwc3 is there for a reason :) 
> 
> 
> 0: https://lists.denx.de/pipermail/u-boot/2023-August/527709.html
> 
> 

In your current series, how does it work?
What happens if user starts both host and device controllers?

e.g.
> usb start
> dfu 0

-- 
cheers,
-roger

  reply	other threads:[~2024-01-12 12:56 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  8:52 [PATCH v4 0/7] Add DFU and usb boot for TI am62x SK and beagleplay Sjoerd Simons
2024-01-12  8:52 ` [PATCH v4 1/7] usb: dwc3: Add dwc3 glue driver for am62 Sjoerd Simons
2024-01-16 10:22   ` Mattijs Korpershoek
2024-05-01 13:56     ` Martyn Welch
2024-05-02  7:03       ` Mattijs Korpershoek
2024-04-12 20:34   ` Sverdlin, Alexander
2024-01-12  8:52 ` [PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start Sjoerd Simons
2024-01-12 10:39   ` Roger Quadros
2024-01-12 11:06     ` Sjoerd Simons
2024-01-12 12:56       ` Roger Quadros [this message]
2024-01-12 14:18         ` Sjoerd Simons
2024-01-15 13:40           ` Roger Quadros
2024-01-12 12:55   ` Caleb Connolly
2024-01-16 10:55     ` Mattijs Korpershoek
2024-01-16 10:46   ` Mattijs Korpershoek
2024-04-12 20:33   ` Sverdlin, Alexander
2024-01-12  8:52 ` [PATCH v4 3/7] board: ti: am62x: am62x: include env for DFU Sjoerd Simons
2024-01-16 10:57   ` Mattijs Korpershoek
2024-04-12 20:31   ` Sverdlin, Alexander
2024-01-12  8:52 ` [PATCH v4 4/7] arm: dts: k3-am625-sk: Enable usb port in u-boot Sjoerd Simons
2024-01-16 11:17   ` Mattijs Korpershoek
2024-01-16 11:21     ` Sjoerd Simons
2024-04-12 20:30   ` Sverdlin, Alexander
2024-01-12  8:52 ` [PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support Sjoerd Simons
2024-01-12  9:58   ` Roger Quadros
2024-01-12 10:44     ` Sjoerd Simons
2024-01-12 10:55       ` Roger Quadros
2024-01-12 12:37   ` Nishanth Menon
2024-01-12 13:09     ` Sjoerd Simons
2024-01-12 13:19       ` Nishanth Menon
2024-01-12 15:06         ` Sjoerd Simons
2024-01-12 15:40           ` Nishanth Menon
2024-01-12 15:58             ` Sjoerd Simons
2024-01-12 16:03               ` Tom Rini
2024-02-08 10:33   ` Mattijs Korpershoek
2024-01-12  8:52 ` [PATCH v4 6/7] beagleplay: Add " Sjoerd Simons
2024-01-12 10:41   ` Roger Quadros
2024-01-12 10:47     ` Sjoerd Simons
2024-01-12 12:34   ` Nishanth Menon
2024-01-12  8:52 ` [PATCH v4 7/7] doc: board: Add document for DFU boot on am62x SoCs Sjoerd Simons
2024-01-12 12:36   ` Nishanth Menon
2024-01-12 12:58     ` Sjoerd Simons
2024-01-12 13:18       ` Mattijs Korpershoek
2024-01-16 11:12   ` Mattijs Korpershoek
2024-01-16 10:09 ` [PATCH v4 0/7] Add DFU and usb boot for TI am62x SK and beagleplay Mattijs Korpershoek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1fea7f2d-62af-44f5-bcfd-2a7e3fd33ca6@kernel.org \
    --to=rogerq@kernel.org \
    --cc=caleb.connolly@linaro.org \
    --cc=clamor95@gmail.com \
    --cc=ivprusov@salutedevices.com \
    --cc=marex@denx.de \
    --cc=martyn.welch@collabora.com \
    --cc=mkorpershoek@baylibre.com \
    --cc=nm@ti.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=sjoerd@collabora.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox