From: Roger Quadros <rogerq@kernel.org>
To: Marek Vasut <marex@denx.de>, Tom Rini <trini@konsulko.com>,
Peter Chen <peter.chen@kernel.org>,
Pawel Laszczak <pawell@cadence.com>,
Julien Panis <jpanis@baylibre.com>
Cc: u-boot@lists.denx.de, tony@atomide.com, r-gunasekaran@ti.com,
vigneshr@ti.com, nm@ti.com
Subject: Re: [PATCH v3 09/12] usb: cdns3: Handle otg mode as peripheral
Date: Sat, 19 Aug 2023 21:14:53 +0300 [thread overview]
Message-ID: <62c5fe13-7f0e-e736-273e-31a8bbddbf13@kernel.org> (raw)
In-Reply-To: <1e7e74f3-b54c-0002-e2a8-e32d0087ed9c@denx.de>
On 19/08/2023 15:20, Marek Vasut wrote:
> On 8/19/23 09:00, Roger Quadros wrote:
>> +Peter & Pawel.
>>
>> On 19/08/2023 02:47, Marek Vasut wrote:
>>> On 8/18/23 21:26, Roger Quadros wrote:
>>>>
>>>>
>>>> On 18/08/2023 21:48, Tom Rini wrote:
>>>>> On Thu, Aug 17, 2023 at 11:15:17AM +0300, Roger Quadros wrote:
>>>>>> Hi Tom,
>>>>>>
>>>>>> On 14/08/2023 20:17, Tom Rini wrote:
>>>>>>> On Thu, Jul 13, 2023 at 03:45:42PM +0200, Julien Panis wrote:
>>>>>>>
>>>>>>>> Override 'otg' to 'peripheral' mode, since 'otg' mode
>>>>>>>> is not yet supported by u-boot.
>>>>>>>>
>>>>>>>> Signed-off-by: Julien Panis <jpanis@baylibre.com>
>>>>>>>> Suggested-by: Roger Quadros <rogerq@kernel.org>
>>>>>>>> ---
>>>>>>>> drivers/usb/cdns3/core.c | 4 ++++
>>>>>>>> 1 file changed, 4 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
>>>>>>>> index 644a9791b9c9..bd763fc593e1 100644
>>>>>>>> --- a/drivers/usb/cdns3/core.c
>>>>>>>> +++ b/drivers/usb/cdns3/core.c
>>>>>>>> @@ -149,6 +149,10 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
>>>>>>>> dr_mode = best_dr_mode;
>>>>>>>> + /* u-boot doesn't yet support OTG so limit to PERIPHERAL */
>>>>>>>> + if (dr_mode == USB_DR_MODE_OTG)
>>>>>>>> + dr_mode = USB_DR_MODE_PERIPHERAL;
>>>>>>>> +
>>>>>>>> #if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD)
>>>>>>>> if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
>>>>>>>> ret = cdns3_host_init(cdns);
>>>>>>>
>>>>>>> Julien, why don't we support otg mode here?
>>>>>>>
>>>>>>
>>>>>> dr_mode will never be OTG at this point as the previous if condition
>>>>>> would have forced it to PERIPHERAL.
>>>>>>
>>>>>> My understanding was that u-boot USB framework doesn't support OTG mode
>>>>>> so we force it to PERIPHERAL.
>>>>>
>>>>> Well, the first part of this series is "make unknown state be OTG" for
>>>>> DWC3, so we do in general (and Marek told me off-list he's used it on
>>>>> DWC2 as well), so it sounds like these (CDNS3, MUSB) drivers need fixing
>>>>> / updating.
>>>>>
>>>>
>>>> CDNS3 does not have an internal OTG state machine. We mostly really care
>>>> about role switching and not the full OTG stack. There needs to be
>>>> some kind of SW framework to do that in u-boot.
>>>>
>>>> Marek could you please advise what can be done here?
>>>
>>> As far as I can tell, MX8MM (CI HDRC), STM32MP1 (DWC2) all can do the host/peripheral switching. Why is that a problem with CDNS3 ? I am not familiar with this controller btw.
>>
>> So for MX8MM and STM32MP1, do we support on the fly host/peripheral switching based on USB plug type?
>> As we don't have interrupts, do you keep polling for ID status change?
>
> Nope, you just plug in one cable or the other and run the matching command -- either 'usb reset' for Host or 'ums/dfu/...' for Peripheral .
OK.
>
>> CDNS3 does support host/peripheral switching. i.e. cdsn3_hw_role_state_machine() and drd.c.
>> What we are missing is the interrupt logic to map ID pin status change to role change.
>
> I don't think you need any interrupt logic for this to work ?
For the use case you described, no.
Julien, I think this can be easily achieved with the current driver.
Would be nice if driver prevents user from setting incorrect role than
what cable is set to.
--
cheers,
-roger
next prev parent reply other threads:[~2023-08-19 18:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 13:45 [PATCH v3 00/12] Remove unnecessary USBx dr_mode configuration Julien Panis
2023-07-13 13:45 ` [PATCH v3 01/12] usb: dwc3: Handle unknown mode as otg Julien Panis
2023-08-14 17:17 ` Tom Rini
2023-07-13 13:45 ` [PATCH v3 02/12] arm: dts: dra7-evm-u-boot: Remove usb1 mode configuration Julien Panis
2023-07-13 13:45 ` [PATCH v3 03/12] arm: dts: dra71-evm-u-boot: " Julien Panis
2023-07-13 13:45 ` [PATCH v3 04/12] arm: dts: dra72-evm-revc-u-boot: " Julien Panis
2023-07-13 13:45 ` [PATCH v3 05/12] arm: dts: dra72-evm-u-boot: " Julien Panis
2023-07-13 13:45 ` [PATCH v3 06/12] arm: dts: dra76-evm-u-boot: " Julien Panis
2023-07-13 13:45 ` [PATCH v3 07/12] arm: dts: keystone-k2e-evm-u-boot: " Julien Panis
2023-07-13 13:45 ` [PATCH v3 08/12] arm: dts: k3-am654-r5-base-board-u-boot: Remove usb " Julien Panis
2023-07-13 13:45 ` [PATCH v3 09/12] usb: cdns3: Handle otg mode as peripheral Julien Panis
2023-08-14 17:17 ` Tom Rini
2023-08-17 8:15 ` Roger Quadros
2023-08-18 18:48 ` Tom Rini
2023-08-18 19:26 ` Roger Quadros
2023-08-18 23:47 ` Marek Vasut
2023-08-19 7:00 ` Roger Quadros
2023-08-19 12:20 ` Marek Vasut
2023-08-19 18:14 ` Roger Quadros [this message]
2023-07-13 13:45 ` [PATCH v3 10/12] arm: dts: k3-am642-evm-u-boot: Remove usb0 mode configuration Julien Panis
2023-07-13 13:45 ` [PATCH v3 11/12] arm: dts: k3-j7200-common-proc-board-u-boot: " Julien Panis
2023-07-13 13:45 ` [PATCH v3 12/12] arm: dts: k3-j721e-common-proc-board-u-boot: " Julien Panis
2023-07-13 17:37 ` [PATCH v3 00/12] Remove unnecessary USBx dr_mode configuration Roger Quadros
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=62c5fe13-7f0e-e736-273e-31a8bbddbf13@kernel.org \
--to=rogerq@kernel.org \
--cc=jpanis@baylibre.com \
--cc=marex@denx.de \
--cc=nm@ti.com \
--cc=pawell@cadence.com \
--cc=peter.chen@kernel.org \
--cc=r-gunasekaran@ti.com \
--cc=tony@atomide.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
/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