Other Parts Discussed in Thread: PMP
Tool/software: Linux
Now i change the board , remove the vbus and id of usb1,i want use the usb1 as a mass storage device.
In software i make some modification as follows:
(1).dra7-evm-common.dtsi
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Linux
Now i change the board , remove the vbus and id of usb1,i want use the usb1 as a mass storage device.
In software i make some modification as follows:
(1).dra7-evm-common.dtsi
The log looks OK, We don't see anything wrong in it. Thanks for sharing it.
I see from you have commented the extcon in the dts file, so can you tell the USB receptacle used on your board? Note that ID pin can be omitted since you are explicitly setting the driver to operate in device mode, but note that the receptacle used must of type-B standard/micro. Otherwise, we need to make sure that the id-pin is floating.
Can you run below and provide the info:
cat /sys/kernel/debug/48890000.usb/mode
lsmod
Thanks.
Thanks for your reply.
root@dra7xx-evm:~# lsmod Module Size Used by g_mass_storage 4414 0 usb_f_mass_storage 36968 2 g_mass_storage libcomposite 44313 2 usb_f_mass_storage,g_mass_storage configfs 25310 3 libcomposite,usb_f_mass_storage xhci_plat_hcd 5183 0 xhci_hcd 108888 1 xhci_plat_hcd usbcore 195666 2 xhci_plat_hcd,xhci_hcd rpmsg_proto 7791 0 dwc3 64398 0 udc_core 12920 2 dwc3,libcomposite virtio_rpmsg_bus 12974 1 rpmsg_proto bc_example 7122 0 ahci_platform 3218 0 libahci_platform 8821 1 ahci_platform libahci 27699 2 libahci_platform,ahci_platform extcon_usb_gpio 3564 0 pvrsrvkm 412289 1 bc_example libata 195997 3 libahci,libahci_platform,ahci_platform dwc3_omap 3938 0 extcon 13815 3 dwc3,dwc3_omap,extcon_usb_gpio scsi_mod 129780 1 libata omap_sham 21089 0 omap_des 11446 0 omap_aes_driver 19166 0 omap_rng 4835 0 rng_core 7755 1 omap_rng omap_remoteproc 13155 3 remoteproc 27121 3 omap_remoteproc,virtio_rpmsg_bus,rpmsg_proto virtio 7452 2 remoteproc,virtio_rpmsg_bus virtio_ring 12291 2 remoteproc,virtio_rpmsg_bus sch_fq_codel 8059 3 root@dra7xx-evm:~# cat /sys/kernel/debug/48890000.usb/mode device root@dra7xx-evm:~#
Now, the USB receptacle we used is type A,but ithink it`s not matter,because we just use three lines (DM DP GND),
and i can use the usb of my board as the device to boot (tda2p have a usb boot mode).
Looked at lsmod and mode status provided and it looks fine.
We checked to reproduce this on the TI-EVM with the same updates to dts file (removing extcon entry and setting the dr_mode to peripheral) and found the same behavior as yours. Introducing back the extcon entry to the dts file make the gadget to be detected by the host PC properly.
So the answer to your issue is that you would need the extcon entry for the DWC3 driver to have the gadget (device mode) to work correctly.
The reason for this is that the linux dwc3 controller driver is configured to be in DRD mode.
Check the .config file in your kernel directory and you would notice that below"
# CONFIG_USB_DWC3_HOST is not set
# CONFIG_USB_DWC3_GADGET is not set
CONFIG_USB_DWC3_DUAL_ROLE=y
For more understanding of this, Suggest you to look at the drivers/usb/dwc3/core.c file and look for the code flow dwc3_probe() -> dwc3_core_init_mode() -> and dwc3_drd_init() ..
Thanks.
I look at the driver about dwc3 before. linux dwc3 controller driver depends on the "dr_mode" configed in dts to select mode.the code as fellow:
static int dwc3_core_init_mode(struct dwc3 *dwc) { struct device *dev = dwc->dev; int ret; switch (dwc->dr_mode) { case USB_DR_MODE_PERIPHERAL: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); return ret; } break; case USB_DR_MODE_HOST: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { dev_err(dev, "failed to initialize host\n"); return ret; } break; case USB_DR_MODE_OTG: ret = dwc3_drd_init(dwc); if (ret) { dev_err(dev, "limiting to peripheral only\n"); dwc->dr_mode = USB_DR_MODE_PERIPHERAL; dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); goto gadget_init; }
So it is no matter if CONFIG_USB_DWC3_DUAL_ROL was configed or CONFIG_USB_DWC3_GADGET was configed.
CONFIG_USB_DWC3_DUAL_ROL just have influence on build files.
the code flow will is dwc3_probe() -> dwc3_core_init_mode() -> and dwc3_gadget_init() ..
Another questions i don`t understand is when i add extcon entry in dts,i can`t find the usb1(48890000.usb) device in /sys/bus/platform/devices/.
And i can`t find the definition of usb1 registers on tda2px TRM,can you tell me where the definition of usb1 registers
Thanks
Hello,
As mentioned in my previous post, we could reproduce this issue on our TI EVM if I remove the extcon entry and set the dr_mode="peripheral". But, we get it back to work correctly if we put back the extcon entry in the dts file. So there is a dependency on the extcon which is doing something failing in your case.
Suggest you to explore the code and see what is the this dependency that can be removed. This would solve the problem.
Thanks.
Hello,
Now i resolve the problem. It indeed need to add the extcon. because when you load the dwc3-omap.ko,it will register a extcon and set UTMI_OTG_CTRL according to you detection by extcon. but we need make some changes.
diff --git a/ti_components/os_tools/linux/kernel/omap/arch/arm/boot/dts/dra7-evm-common.dtsi b/ti_components/os_tools/linux/kernel/omap/arch/arm/boot/dts/dra7-evm-common.dtsi index a644fed..2f48ea1 100755 --- a/ti_components/os_tools/linux/kernel/omap/arch/arm/boot/dts/dra7-evm-common.dtsi +++ b/ti_components/os_tools/linux/kernel/omap/arch/arm/boot/dts/dra7-evm-common.dtsi @@ -234,7 +234,7 @@ }; &usb1 { - dr_mode = "otg"; + dr_mode = "peripheral"; }; &usb2 { diff --git a/ti_components/os_tools/linux/kernel/omap/drivers/extcon/extcon-usb-gpio.c b/ti_components/os_tools/linux/kernel/omap/drivers/extcon/extcon-usb-gpio.c old mode 100644 new mode 100755 index c27404f..813d53d --- a/ti_components/os_tools/linux/kernel/omap/drivers/extcon/extcon-usb-gpio.c +++ b/ti_components/os_tools/linux/kernel/omap/drivers/extcon/extcon-usb-gpio.c @@ -67,16 +67,17 @@ static const unsigned int usb_extcon_cable[] = { */ static void usb_extcon_detect_cable(struct work_struct *work) { - int id, vbus; + int id = 1, vbus = 1; struct usb_extcon_info *info = container_of(to_delayed_work(work), struct usb_extcon_info, wq_detcable); - +#if 0 /* check ID and VBUS and update cable state */ id = info->id_gpiod ? gpiod_get_value_cansleep(info->id_gpiod) : 1; vbus = info->vbus_gpiod ? gpiod_get_value_cansleep(info->vbus_gpiod) : id; +#endif /* at first we clean states which are no longer active */ if (id) @@ -120,6 +121,9 @@ static int usb_extcon_probe(struct platform_device *pdev) info->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id", GPIOD_IN); info->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus", GPIOD_IN); + info->id_gpiod = NULL; + info->vbus_gpiod = NULL; +#if 0 if (!info->id_gpiod && !info->vbus_gpiod) { dev_err(dev, "failed to get gpios\n"); @@ -128,10 +132,10 @@ static int usb_extcon_probe(struct platform_device *pdev) if (IS_ERR(info->id_gpiod)) return PTR_ERR(info->id_gpiod); - + if (IS_ERR(info->vbus_gpiod)) return PTR_ERR(info->vbus_gpiod); - +#endif info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); if (IS_ERR(info->edev)) { dev_err(dev, "failed to allocate extcon device\n"); @@ -150,7 +154,7 @@ static int usb_extcon_probe(struct platform_device *pdev) if (!ret && info->vbus_gpiod) ret = gpiod_set_debounce(info->vbus_gpiod, USB_GPIO_DEBOUNCE_MS * 1000); - + if (ret < 0) info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS); @@ -174,6 +178,7 @@ static int usb_extcon_probe(struct platform_device *pdev) } } + if (info->vbus_gpiod) { info->vbus_irq = gpiod_to_irq(info->vbus_gpiod); if (info->vbus_irq < 0) {
thanks for you help.