BPI-R2 USB support

Hello,

I wish to use a USB device with Kernel 4.9

CONFIG_SCSI=y
CONFIG_USB=y
CONFIG_USB_STORAGE=y
CONFIG_USB_XHCI_MTK=y
CONFIG_USB_NET_DRIVERS=y

On boot i can see

# dmesg  | grep usb
[    0.110583] usbcore: registered new interface driver usbfs
[    0.110659] usbcore: registered new interface driver hub
[    0.110732] usbcore: registered new device driver usb
[    1.210236] xhci-mtk 1a1c0000.usb: fail to get vbus
[    1.215194] xhci-mtk 1a240000.usb: fail to get vbus
[    1.220161] usbcore: registered new interface driver usb-storage
[    1.530417] usbcore: registered new interface driver usbhid
[    1.535988] usbhid: USB HID core driver
[    2.338831] xhci-mtk 1a1c0000.usb: fail to get vbus
[    2.343887] xhci-mtk 1a240000.usb: fail to get vbus
[    2.358346] vusb: disabling
[    2.683718] xhci-mtk 1a1c0000.usb: fail to get vbus
[    2.683899] xhci-mtk 1a240000.usb: fail to get vbus
[    3.303720] xhci-mtk 1a1c0000.usb: fail to get vbus
[    3.303900] xhci-mtk 1a240000.usb: fail to get vbus
[    7.011130] xhci-mtk 1a1c0000.usb: fail to get vbus
[    7.016386] xhci-mtk 1a240000.usb: fail to get vbus
[    7.024016] xhci-mtk 1a1c0000.usb: fail to get vbus
[    7.029242] xhci-mtk 1a240000.usb: fail to get vbus
[    7.034539] xhci-mtk 1a1c0000.usb: fail to get vbus
[    7.039724] xhci-mtk 1a240000.usb: fail to get vbus
[    7.077388] xhci-mtk 1a1c0000.usb: fail to get vbus
[    7.082619] xhci-mtk 1a240000.usb: fail to get vbus

My lsusb is still empty

$ lsusb -v
$ cat /proc/bus/usb/devices
cat: /proc/bus/usb/devices: No such file or directory

How can i get support for USB on BPI-R2.

Which device do you want to use? A simple usb-stick (mass-storage) is working in 4.14 with my config

Seem the USB is not detected. I want to use a usb-stick (mass-storage) and Wifi dongle. I was thinking it might be due to dtd. Not sure where to check.

# ls /sys/firmware/devicetree/base/usb*
/sys/firmware/devicetree/base/usb@1a1c0000:
clock-names  clocks  compatible  interrupts  name  phys  power-domains  reg  reg-names  status  vbus-supply  vusb33-supply

/sys/firmware/devicetree/base/usb@1a240000:
clock-names  clocks  compatible  interrupts  name  phys  power-domains  reg  reg-names  status  vbus-supply  vusb33-supply

/sys/firmware/devicetree/base/usb-phy@1a1c4000:
#address-cells  clock-names  clocks  compatible  name  ranges  reg  #size-cells  status  usb-phy@1a1c4800  usb-phy@1a1c4900

/sys/firmware/devicetree/base/usb-phy@1a244000:
#address-cells  clock-names  clocks  compatible  name  ranges  reg  #size-cells  status  usb-phy@1a244800  usb-phy@1a244900

USB node in dts seems to lack a vbus property .

for comparision:

[14:23] root@bpi-r2-e:~# uname -a
Linux bpi-r2-e 4.14.34-bpi-r2-4.14-main #178 SMP Sun Apr 15 19:30:06 CEST 2018 armv7l GNU/Linux

[14:23] root@bpi-r2-e:~# lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 0951:1649 Kingston Technology 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

[14:24] root@bpi-r2-e:~# ls /sys/firmware/devicetree/base/usb*
/sys/firmware/devicetree/base/usb@1a1c0000:
clock-names  clocks  compatible  interrupts  name  phys  power-domains	reg  reg-names	status	vusb33-supply

/sys/firmware/devicetree/base/usb@1a240000:
clock-names  clocks  compatible  interrupts  name  phys  power-domains	reg  reg-names	status	vusb33-supply

/sys/firmware/devicetree/base/usb-phy@1a1c4000:
#address-cells	clock-names  clocks  compatible  name  ranges  reg  #size-cells  status  usb-phy@1a1c4800  usb-phy@1a1c4900

/sys/firmware/devicetree/base/usb-phy@1a244000:
#address-cells	clock-names  clocks  compatible  name  ranges  reg  #size-cells  status  usb-phy@1a244800  usb-phy@1a244900

[14:26] root@bpi-r2-e:~# dmesg | grep 'xhci-mtk'
[    0.411004] xhci-mtk 1a1c0000.usb: 1a1c0000.usb supply vbus not found, using dummy regulator
[    0.411452] xhci-mtk 1a1c0000.usb: xHCI Host Controller
[    0.411481] xhci-mtk 1a1c0000.usb: new USB bus registered, assigned bus number 1
[    0.412108] xhci-mtk 1a1c0000.usb: hcc params 0x01401198 hci version 0x96 quirks 0x00210010
[    0.412167] xhci-mtk 1a1c0000.usb: irq 231, io mem 0x1a1c0000
[    0.413365] xhci-mtk 1a1c0000.usb: xHCI Host Controller
[    0.413382] xhci-mtk 1a1c0000.usb: new USB bus registered, assigned bus number 2
[    0.414571] xhci-mtk 1a240000.usb: 1a240000.usb supply vbus not found, using dummy regulator
[    0.414937] xhci-mtk 1a240000.usb: xHCI Host Controller
[    0.414959] xhci-mtk 1a240000.usb: new USB bus registered, assigned bus number 3
[    0.415445] xhci-mtk 1a240000.usb: hcc params 0x01401198 hci version 0x96 quirks 0x00210010
[    0.415505] xhci-mtk 1a240000.usb: irq 232, io mem 0x1a240000
[    0.416553] xhci-mtk 1a240000.usb: xHCI Host Controller
[    0.416569] xhci-mtk 1a240000.usb: new USB bus registered, assigned bus number 4
[2957243.692114] usb 3-1: new high-speed USB device number 2 using xhci-mtk

I used the openwrt patch to have HW nat enable. In this DTS there seem to have no support for USB. I try to merge from the official 4.9.70 BPI kernel however not much success, the kernel failed to compile.

https://github.com/BPI-SINOVOIP/BPI-R2-bsp/blob/master/linux-mt/arch/arm/boot/dts/mt7623n-bpi-r2.dts with: https://github.com/frank-w/BPI-R2-4.14/blob/4.9-main/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts

How can i have USB and HWNAT?

4.9 on my repo has patches from garys lede repo…maybe you only have to activate hnat in menuconfig…hnat has nothing to do with usb

all hardware must be reference in the DTS. If you check the hnat is present as well as the USB. So far no DTS are complete with HNAT, 2GMac, USB, etc…

I’m not familar with DTS so not sure what I’m doing, so far no luck.

Usb is here (also needs uxphy-nodes): https://github.com/frank-w/BPI-R2-4.14/blob/48685e78a5b39b226eacc3a6e9cb6a54e948e458/arch/arm/boot/dts/mt7623.dtsi#L839

Hnat: https://github.com/frank-w/BPI-R2-4.14/blob/48685e78a5b39b226eacc3a6e9cb6a54e948e458/arch/arm/boot/dts/mt7623.dtsi#L958

I grep for vbus and found the following in arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts

&usb1 {
        vusb33-supply = <&fixedregulator3v3>;
        vbus-supply = <&fixedregulator5v>;
        status = "okay";
};

&usb2 {
        vusb33-supply = <&fixedregulator3v3>;
        vbus-supply = <&fixedregulator5v>;
        status = "okay";
};

Is fixedregulator3v3 and fixedregulator5v defined in your dts(i)?

	fixedregulator3v3: regulator-3v3 {
		compatible = "regulator-fixed";
		regulator-name = "fixed-3.3V";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
	};

	fixedregulator5v: regulator-5v {
		compatible = "regulator-fixed";
		regulator-name = "fixed-5V";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
};

5v regulator looks strange…see microvolts

	compatible = "regulator-fixed";
	regulator-name = "fixed-5V";
	regulator-min-microvolt = <5000000>;
	regulator-max-microvolt = <5000000>

Fixed the 5V entry as mention by Frank. However still no USB. Where can i check the vbus property, both usb entry have vbus-supply?

Did you enable related configs for PMIC and regulators?

Don’t see this problem when I use the image I released, below is the log, you can refer to the kernel config file

kernel-4.9.config (106.5 KB)

> root@LEDE:/# [  215.474685] usb 3-1: new high-speed USB device number 2 using xhci-mtk
> [  215.650901] usb-storage 3-1:1.0: USB Mass Storage device detected
> [  215.657264] scsi host2: usb-storage 3-1:1.0
> [  216.784873] scsi 2:0:0:0: Direct-Access     TOSHIBA  TransMemory      PMAP PQ: 0 ANSI: 4
> [  216.793649] sd 2:0:0:0: Attached scsi generic sg0 type 0
> [  218.273827] sd 2:0:0:0: [sda] 30490624 512-byte logical blocks: (15.6 GB/14.5 GiB)
> [  218.282940] sd 2:0:0:0: [sda] Write Protect is off
> [  218.289304] sd 2:0:0:0: [sda] No Caching mode page found
> [  218.294572] sd 2:0:0:0: [sda] Assuming drive cache: write through
> [  218.335058]  sda: sda1
> [  218.342222] sd 2:0:0:0: [sda] Attached SCSI removable disk
> 
> root@LEDE:/# ls /dev/sda
> /dev/sda
> root@LEDE:/# [  232.760274] usb 3-1: USB disconnect, device number 2
> [  237.064633] usb 1-1: new high-speed USB device number 2 using xhci-mtk
> [  237.240888] usb-storage 1-1:1.0: USB Mass Storage device detected
> [  237.257241] scsi host2: usb-storage 1-1:1.0
> [  238.384849] scsi 2:0:0:0: Direct-Access     TOSHIBA  TransMemory      PMAP PQ: 0 ANSI: 4
> [  238.393501] sd 2:0:0:0: Attached scsi generic sg0 type 0
> [  239.884192] sd 2:0:0:0: [sda] 30490624 512-byte logical blocks: (15.6 GB/14.5 GiB)
> [  239.893303] sd 2:0:0:0: [sda] Write Protect is off
> [  239.899668] sd 2:0:0:0: [sda] No Caching mode page found
> [  239.904953] sd 2:0:0:0: [sda] Assuming drive cache: write through
> [  239.944969]  sda: sda1
> [  239.952496] sd 2:0:0:0: [sda] Attached SCSI removable disk

I used frank kernel 4.9-main branch which the kernel vanilla 4.9 + openwrt patch. I do confirm the official image works fine however it miss the 2GMAC and the Hardware NAT. As i plan to use my BPI-R2 as a main gateway those feature are critical.

The two GMAC-s and hardware NAT are also working fine if you use official image, source code of openwrt is here: https://github.com/garywangcn/bpi-r2_lede/tree/bpi-r2-on-lede-v1.

he want to use a full-feature-kernel in ubuntu/debian…stripping kernel out of lede is a bit tricky

for usb-issue please try only this (reset branch before): https://patchwork.kernel.org/patch/10237289/

as you see

vusb33-supply = <&mt6323_vusb_reg>;

will be removed and replaced by the fixed regulators (3v3/5v)

which is needed? we face this error also in 4.16

vbus is set in dts by default…