On 23-09-10 12:47:06, tomer.maimon@xxxxxxxxxxx wrote: > Hi Peter, > > > > Thanks for your prompt response. > > > > Unfortunately soft connect didn't solve the problem, because the vbus_active is not active > > And this is why the ci_hdrc_gadget_connect<https://elixir.bootlin.com/linux/v6.5.2/C/ident/ci_hdrc_gadget_connect>(gadget<https://elixir.bootlin.com/linux/v6.5.2/C/ident/gadget>, 1) is not called. > > https://elixir.bootlin.com/linux/v6.5.2/source/drivers/usb/chipidea/udc.c#L1950 > Please use plain text for upstream email. So, for your soc, the usb role is device-only, and there is no otgsc register. You may try to introduce a flag like CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS, and using it at ci_handle_vbus_change for (!ci->is_otg condition), when both conditions are satisfied, call usb_gadget_vbus_connect(&ci->gadget); Thanks, Peter > > > In the log below we added debug print of the vbus_active status: > > # insmod usb_f_mass_storage.ko > > # insmod g_mass_storage.ko file=/tmp/backing_file removable=1 > > Mass Storage Function, version: 2009/09/11 > > LUN: removable file: (no medium) > > LUN: removable file: /tmp/backing_file > > Number of LUNs=1 > > g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11 > > g_mass_storage gadget: userspace failed to provide iSerialNumber > > g_mass_storage gadget: g_mass_storage ready > > usb_gadget_udc_start > > ci_udc_start > > ci_udc_start ci->vbus_active 0 > > # cd /sys/class/udc/ci_hdrc.0/ > > # echo connect > soft_connect > > udc ci_hdrc.0: UDC had already started > > # echo disconnect > soft_connect > > ci_udc_stop ci->vbus_active 0 > > # echo connect > soft_connect > > usb_gadget_udc_start > > ci_udc_start > > ci_udc_start ci->vbus_active 0 > > > > How can I active the vbus_active parameter? > > > > Thanks, > > > > Tomer > > > > -----Original Message----- > From: Peter Chen <peter.chen@xxxxxxxxxx> > Sent: Friday, 8 September 2023 13:26 > To: IS20 Tomer Maimon <tomer.maimon@xxxxxxxxxxx> > Cc: linux-usb@xxxxxxxxxxxxxxx > Subject: Re: Advise for adding Nuvoton BMC Synopsys USB 2.0 device controllers to Linux kernel USB Chipidea driver > > > > CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content. > > > > > > On 23-09-07 14:33:29, tomer.maimon@xxxxxxxxxxx<mailto:tomer.maimon@xxxxxxxxxxx> 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://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.15.130%2FC%2Fident%2Fcompatible&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985252717%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PLwJbYcd%2Fs2F2x7yXL7wp3g4AxDJ8JyJIZ2TTBGFGWw%3D&reserved=0<https://elixir.bootlin.com/linux/v5.15.130/C/ident/compatible>> = "chipidea,usb2<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.15.130%2FB%2Fident%2Fchipidea%252Cusb2&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=uZQemtQLmMuVP8ifpczSYtHw2Z4drLLn%2Fm2ObnpJW0Q%3D&reserved=0<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://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felix<https://elix/> > > > ir.bootlin.com%2Flinux%2Fv6.5.2%2Fsource%2Fdrivers%2Fusb%2Fchipidea%2F > > > core.c%23L948&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba4 > > > 4903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C6382 > > > 97655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l > > > uMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2B5yqPLl4FS > > > YUF2Wr0fnNEGgHETE7FTmmSxVm8HCAaQ4%3D&reserved=0 > > > > > > > > > ci<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fe > > > lixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2Fci&data=05%7C01%7Ctom > > > er.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08dbb0561155%7Ca3f24931d > > > 4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985408934%7CUnknown%7CTWFpb > > > GZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0 > > > %3D%7C3000%7C%7C%7C&sdata=0l4NnlxNNGGLe%2BEG%2FXU%2B2bdMB5R%2FY%2BD3Xv > > > ndUiAWUyE%3D&reserved=0>->is_otg<https://apc01.safelinks.protection.ou > > > tlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2 > > > Fident%2Fis_otg&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cb > > > a44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C63 > > > 8297655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV > > > 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rQIdSi2Uu% > > > 2Bss84SiVOlWQkdrPXPVgJvDqPheYtPcolM%3D&reserved=0> = > > > (hw_read<https://apc01.safelinks.protection.outlook.com/?url=https%3A% > > > 2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2Fhw_read&data=05 > > > %7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08dbb0561155% > > > 7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985408934%7CUnkn > > > own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi > > > LCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HO%2F6v4XA2bQgU9jCrya2Y%2Fv8P5%2B > > > 3m%2Bn8ekJhtZLrq5A%3D&reserved=0>(ci<https://apc01.safelinks.protectio > > > n.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2 > > > FC%2Fident%2Fci&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cb > > > a44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C63 > > > 8297655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV > > > 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0l4NnlxNNG > > > GLe%2BEG%2FXU%2B2bdMB5R%2FY%2BD3XvndUiAWUyE%3D&reserved=0>, > > > CAP_DCCPARAMS<https://apc01.safelinks.protection.outlook.com/?url=http > > > s%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2FCAP_DCCPAR > > > AMS&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08 > > > dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C63829765598540 > > > 8934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT > > > iI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XmsVmw0t55YR0wcrcTngkN > > > 6vyBCj5sR5GYT2I8lIq2A%3D&reserved=0>, > > > > > > > > > DCCPARAMS_DC<https://apc01.safelinks.protection.outlook.com/?url=https > > > %3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2FDCCPARAMS_D > > > C&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08db > > > b0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C6382976559854089 > > > 34%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI > > > 6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=o9trybo5aT%2BF%2Bai6eHeH > > > %2BeQTaY5l5Jzy53u8TlLg%2Fps%3D&reserved=0> | > > > DCCPARAMS_HC<https://apc01.safelinks.protection.outlook.com/?url=https > > > %3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2FDCCPARAMS_H > > > C&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08db > > > b0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C6382976559854089 > > > 34%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI > > > 6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5Zb%2BmrV2lcQwXlz93pJtzF > > > eRNBxqiHEgD4ywW1ed4D4%3D&reserved=0>) > > > > > > == > > > (DCCPARAMS_DC<https://apc01.safelinks.protection.outlook.com/?url=http > > > s%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2FDCCPARAMS_ > > > DC&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08d > > > bb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985408 > > > 934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTi > > > I6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=o9trybo5aT%2BF%2Bai6eHe > > > H%2BeQTaY5l5Jzy53u8TlLg%2Fps%3D&reserved=0> | > > > DCCPARAMS_HC<https://apc01.safelinks.protection.outlook.com/?url=https > > > %3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2FDCCPARAMS_H > > > C&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08db > > > b0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C6382976559854089 > > > 34%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI > > > 6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5Zb%2BmrV2lcQwXlz93pJtzF > > > eRNBxqiHEgD4ywW1ed4D4%3D&reserved=0>)); > > > > > > Why otg is set only when DC and HC is set? > > > > > > By enabling ci<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2Fci&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0l4NnlxNNGGLe%2BEG%2FXU%2B2bdMB5R%2FY%2BD3XvndUiAWUyE%3D&reserved=0<https://elixir.bootlin.com/linux/v6.5.2/C/ident/ci>>->is_otg<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv6.5.2%2FC%2Fident%2Fis_otg&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638297655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rQIdSi2Uu%2Bss84SiVOlWQkdrPXPVgJvDqPheYtPcolM%3D&reserved=0<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://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felix<https://elix/> > > > ir.bootlin.com%2Flinux%2Fv6.5.2%2Fsource%2Fdrivers%2Fusb%2Fchipidea%2F > > > core.c%23L1123&data=05%7C01%7Ctomer.maimon%40nuvoton.com%7C3cc95393cba > > > 44903d9fa08dbb0561155%7Ca3f24931d4034b4a94f17d83ac638e07%7C0%7C0%7C638 > > > 297655985408934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2 > > > luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=O2JoKArqqY6 > > > IaAvYAEFXrVhuPdsArba3MczPKSJsaIc%3D&reserved=0 > > > > > > > > > > > > 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 > > ________________________________ > The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton. -- Thanks, Peter Chen