Linux USB
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@kernel.org>
To: "tomer.maimon@nuvoton.com" <tomer.maimon@nuvoton.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: Advise for adding Nuvoton BMC Synopsys USB 2.0 device controllers to Linux kernel USB Chipidea driver
Date: Fri, 8 Sep 2023 18:26:18 +0800	[thread overview]
Message-ID: <20230908102618.GA1134975@nchen-desktop> (raw)
In-Reply-To: <TY0PR03MB627615C146DF1CCED0BCAA2C84EEA@TY0PR03MB6276.apcprd03.prod.outlook.com>

On 23-09-07 14:33:29, tomer.maimon@nuvoton.com wrote:
> Hi Peter
> 
> My name is Tomer I am working in Nuvoton system in the Linux kernel, our project developing BMC SoC for servers.
> In Nuvoton BMC (NPCM) there are ten identical Synopsys USB 2.0 device controllers called NPCM UDC.
> 
> Lately we started to work with USB Chipidea driver to add NPCM UDC as well.
> The NPCM BMC using only the UDC and not the USB host.
> 
> Using the default compatible<https://elixir.bootlin.com/linux/v5.15.130/C/ident/compatible> = "chipidea,usb2<https://elixir.bootlin.com/linux/v5.15.130/B/ident/chipidea%2Cusb2>" didn't work for us since:
> 
> 1.       The USB_MODE should be set at boot or after reset since the reset The USB_MODE is incorrect (0x15002)
> 
> [cid:image002.jpg@01D9E1B1.691030B0]
> 
> 
> It solved by setting USB_MODE during NPCM reset ci_hdrc_npcm_notify_event, now using unique npcm-udc compatible :)
> 
> 
> 
> 2.      vbus_active parameter don't change, stay 0.
> 
> The Device Control Capability Parameters Register (DCCPARAMS) is a read only register that indicate the module is only DC (Device Capable)
> 
> This is why the driver didn't indicate the driver is OTG
> 
> https://elixir.bootlin.com/linux/v6.5.2/source/drivers/usb/chipidea/core.c#L948
> 
>               ci<https://elixir.bootlin.com/linux/v6.5.2/C/ident/ci>->is_otg<https://elixir.bootlin.com/linux/v6.5.2/C/ident/is_otg> = (hw_read<https://elixir.bootlin.com/linux/v6.5.2/C/ident/hw_read>(ci<https://elixir.bootlin.com/linux/v6.5.2/C/ident/ci>, CAP_DCCPARAMS<https://elixir.bootlin.com/linux/v6.5.2/C/ident/CAP_DCCPARAMS>,
> 
>                            DCCPARAMS_DC<https://elixir.bootlin.com/linux/v6.5.2/C/ident/DCCPARAMS_DC> | DCCPARAMS_HC<https://elixir.bootlin.com/linux/v6.5.2/C/ident/DCCPARAMS_HC>)
> 
>                                   == (DCCPARAMS_DC<https://elixir.bootlin.com/linux/v6.5.2/C/ident/DCCPARAMS_DC> | DCCPARAMS_HC<https://elixir.bootlin.com/linux/v6.5.2/C/ident/DCCPARAMS_HC>));
> 
> Why otg is set only when DC and HC is set?
> 
> By enabling ci<https://elixir.bootlin.com/linux/v6.5.2/C/ident/ci>->is_otg<https://elixir.bootlin.com/linux/v6.5.2/C/ident/is_otg> = true we see we need to set the extcon in the device tree, why we need extcon to handle the vbus? Can the vbus be permanent?
> 
> 
> 
> Even after setting extcon vbus to dummy GPIO we succeed to modify the vbus_active parameter to is_active but it didn't worked in the end because it a dummy GPIO that not related to the USB vbus.
> 
> 
> 
> BTW,
> 
> If we adding ci->vbus_active = true at probe stage the UDC Chipidea driver works fine.
> 
> https://elixir.bootlin.com/linux/v6.5.2/source/drivers/usb/chipidea/core.c#L1123
> 
> 
> 
> Appreciate if you could you advise how should we overcome this issue

After loading the gadget driver, try to force "connect" udc using /sys
entry. See the below code at file: drivers/usb/gadget/udc/core.c

static ssize_t soft_connect_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t n)


Your issue is probably due to the UDC don't know it is connected, so DP
is not pulled up.

-- 

Thanks,
Peter Chen

       reply	other threads:[~2023-09-08 10:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <TY0PR03MB627615C146DF1CCED0BCAA2C84EEA@TY0PR03MB6276.apcprd03.prod.outlook.com>
2023-09-08 10:26 ` Peter Chen [this message]
     [not found]   ` <TY0PR03MB62768499A37E53AEB9E1306284F3A@TY0PR03MB6276.apcprd03.prod.outlook.com>
2023-09-11 12:16     ` Advise for adding Nuvoton BMC Synopsys USB 2.0 device controllers to Linux kernel USB Chipidea driver Peter Chen
2023-09-11 15:24       ` tomer.maimon

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=20230908102618.GA1134975@nchen-desktop \
    --to=peter.chen@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tomer.maimon@nuvoton.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