R-Car/Change-probing-timing-of-USB-2-function-driver

Overview
Until v5.12, if we use the USB 2.0 function (renesas_usbhs) and USB 3.0 function (renesas_usb3) drivers as built-in, the HS-USB channel 0 on r8a77951-salvator-xs was probed at first like the following.

[   3.013125] renesas_usbhs e6590000.usb: host probed [   3.018118] renesas_usbhs e6590000.usb: no transceiver found [   3.024441] renesas_usbhs e6590000.usb: gadget probed [   3.029885] renesas_usbhs e6590000.usb: probed [   3.035699] renesas_usbhs e659c000.usb: host probed [   3.040751] renesas_usbhs e659c000.usb: no transceiver found [   3.046848] renesas_usbhs e659c000.usb: gadget probed [   3.052308] renesas_usbhs e659c000.usb: probed [   3.059663] renesas_usb3 ee020000.usb: probed with phy
 * 1) dmesg | grep -e e659 -e ee02

However, from v5.13-rc1, the HS-USB channel 3 was probed at first. Second, the USB 3.0 peripheral was probed, and then the HS-USB channel 0 was probed finally:

[   3.150070] renesas_usbhs e659c000.usb: host probed [   3.155062] renesas_usbhs e659c000.usb: no transceiver found [   3.161374] renesas_usbhs e659c000.usb: gadget probed [   3.166794] renesas_usbhs e659c000.usb: probed [   3.173950] renesas_usb3 ee020000.usb: probed with phy [   4.010558] renesas_usbhs e6590000.usb: host probed [   4.015548] renesas_usbhs e6590000.usb: no transceiver found [   4.021870] renesas_usbhs e6590000.usb: gadget probed [   4.027315] renesas_usbhs e6590000.usb: probed
 * 1) dmesg | grep -e e65 -e 9 -e  -e ee02

So, if we use a "USB Gadget precomposed configrations" driver like g_mass_storage on v5.13-rc1, a gadget driver will bind the HS-USB channel 3 at first.

How to use the HS-USB channel 0 on v5.13-rc1?
We have some solutions to use it like below:
 * Unbind other UDC instances at first
 * Use kernel modules of renesas_usbhs and renesas_usb3 drivers instead
 * Use "USB Gadget functions configurable through configfs" instead
 * Use fw_devlink=permissive

Unbind other UDC instances at first

 * 1) e659c000.usb > /sys/bus/platform/drivers/renesas_usbhs/unbind
 * 2) ee020000.usb > /sys/bus/platform/drivers/renesas_usb3/unbind
 * 3) modprobe

Use kernel modules of renesas_usbhs and renesas_usb3 drivers instead
In kernel config,

CONFIG_USB_RENESAS_USBHS=m CONFIG_USB_RENESAS_USBHS_UDC=m CONFIG_USB_RENESAS_USB3=m

and we input the following on the board:


 * 1) modprobe renesas_usbhs
 * 2) modprobe

Use "USB Gadget functions configurable through configfs" instead
This is an example how to use HS-USB channel 0 acts as a mass storage device.


 * 1) modprobe libcomposite
 * 2) mkdir /dev/shm/config
 * 3) mount -t configfs none /dev/shm/config
 * 4) mkdir /dev/shm/config/usb_gadget/g1
 * 5) cd /dev/shm/config/usb_gadget/g1


 * 1) echo > idVendor
 * 2) echo > idProduct


 * 1) mkdir strings/0x409
 * 2) echo  > strings/0x409/serialnumber
 * 3) echo > strings/0x409/manufacturer
 * 4) echo > strings/0x409/product


 * 1) mkdir configs/c.1
 * 2) mkdir configs/c.1/strings/0x409


 * 1) dd if=/dev/zero of=/dev/shm/storage.bin bs=1M count=350
 * 2) modprobe usb_f_mass_storage
 * 3) mkdir functions/mass_storage.usb0
 * 4) echo /dev/shm/storage.bin > functions/mass_storage.usb0/lun.0/file


 * 1) ln -s functions/mass_storage.usb0 configs/c.1/
 * 2) echo e6590000.usb > UDC

Use fw_devlink=permissive
This kernel parameter will act like v5.12.

Why was the behavior change from v5.13-rc1?
This is related to 2 things:


 * Board specification of the Salvator-XS
 * Kernel parameter "fw_devlink"

The usb2_phy0 node has vbus-supply property. However, other nodes of usb[23]_phy* don't have vbus-supply property. And, the following commit is applied on v5.13-rc1.

ea718c699055 Revert "Revert "driver core: Set fw_devlink=on by default""

So, creating devlinks differs between fw_devlink=on (v5.13-rc1) and fw_devlink=permissive (v5.12) like below.

fw_devlink=on
ls | grep usb phy:phy-e65ee000.usb-phy.12--platform:ee020000.usb phy:phy-ee080200.usb-phy.14--platform:ee080000.usb phy:phy-ee080200.usb-phy.15--platform:ee080100.usb phy:phy-ee0a0200.usb-phy.1--platform:ee0a0000.usb phy:phy-ee0a0200.usb-phy.2--platform:ee0a0100.usb phy:phy-ee0c0200.usb-phy.5--platform:ee0c0000.usb phy:phy-ee0c0200.usb-phy.6--platform:ee0c0100.usb phy:phy-ee0e0200.usb-phy.10--platform:ee0e0100.usb phy:phy-ee0e0200.usb-phy.9--platform:ee0e0000.usb platform:e6055400.gpio--platform:regulator-vbus0-usb2 platform:e6060000.pinctrl--platform:ee000000.usb platform:e6060000.pinctrl--platform:ee080200.usb-phy platform:e6060000.pinctrl--platform:ee0a0200.usb-phy platform:e6060000.pinctrl--platform:ee0c0200.usb-phy platform:e6060000.pinctrl--platform:ee0e0200.usb-phy platform:e6150000.clock-controller--platform:e6590000.usb platform:e6150000.clock-controller--platform:e659c000.usb platform:e6150000.clock-controller--platform:e65ee000.usb-phy platform:e6150000.clock-controller--platform:ee000000.usb platform:e6150000.clock-controller--platform:ee020000.usb platform:e6150000.clock-controller--platform:ee080000.usb platform:e6150000.clock-controller--platform:ee080100.usb platform:e6150000.clock-controller--platform:ee080200.usb-phy platform:e6150000.clock-controller--platform:ee0a0000.usb platform:e6150000.clock-controller--platform:ee0a0100.usb platform:e6150000.clock-controller--platform:ee0a0200.usb-phy platform:e6150000.clock-controller--platform:ee0c0000.usb platform:e6150000.clock-controller--platform:ee0c0100.usb platform:e6150000.clock-controller--platform:ee0c0200.usb-phy platform:e6150000.clock-controller--platform:ee0e0000.usb platform:e6150000.clock-controller--platform:ee0e0100.usb platform:e6150000.clock-controller--platform:ee0e0200.usb-phy platform:e65ee000.usb-phy--platform:ee020000.usb platform:ee080200.usb-phy--platform:e6590000.usb platform:ee080200.usb-phy--platform:ee080000.usb platform:ee080200.usb-phy--platform:ee080100.usb platform:ee0a0200.usb-phy--platform:ee0a0000.usb platform:ee0a0200.usb-phy--platform:ee0a0100.usb platform:ee0c0200.usb-phy--platform:ee0c0000.usb platform:ee0c0200.usb-phy--platform:ee0c0100.usb platform:ee0e0200.usb-phy--platform:e659c000.usb platform:ee0e0200.usb-phy--platform:ee0e0000.usb platform:ee0e0200.usb-phy--platform:ee0e0100.usb platform:regulator-vbus0-usb2--platform:ee080200.usb-phy regulator:regulator.4--platform:ee080200.usb-phy
 * 1) cd /sys/class/devlink

fw_devlink=permissive
phy:phy-e65ee000.usb-phy.12--platform:ee020000.usb phy:phy-ee080200.usb-phy.14--platform:ee080000.usb phy:phy-ee080200.usb-phy.15--platform:ee080100.usb phy:phy-ee0a0200.usb-phy.1--platform:ee0a0000.usb phy:phy-ee0a0200.usb-phy.2--platform:ee0a0100.usb phy:phy-ee0c0200.usb-phy.5--platform:ee0c0000.usb phy:phy-ee0c0200.usb-phy.6--platform:ee0c0100.usb phy:phy-ee0e0200.usb-phy.10--platform:ee0e0100.usb phy:phy-ee0e0200.usb-phy.9--platform:ee0e0000.usb platform:e6060000.pinctrl--platform:ee000000.usb platform:e6150000.clock-controller--platform:ee000000.usb regulator:regulator.4--platform:ee080200.usb-phy