Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: dts: sun4i: Enable USB DRC on pcDuino1/2

Enable the otg/drc usb controller on the pcDuino1/2 board. Note
that the pcDuino1 FEX file from the vendor contains the following
information in the [usbc0] section:
usb_id_gpio = port:PH04<0><1><default><default>
usb_det_vbus_gpio = port:PH05<0><0><default><default>
usb_drv_vbus_gpio = port:PB09<1><0><default><0>
While the pcDuino2 FEX has:
usb_id_gpio = port:PH04<0><1><default><default>
usb_det_vbus_gpio = port:PH05<0><0><default><default>
usb_drv_vbus_gpio = port:PD02<1><0><default><0>

The ID pin is indeed PH4. The PD2 pin can be used to switch power
on/off for the USB Type A receptacle on pcDuino2, but it has nothing
to do with the MicroUSB OTG receptacle. The VBUS pin of the MicroUSB
receptacle is always connected to 5V according to the schematics
(both pcDuino1 and pcDuino2) and confirmed by doing some tests on
pcDuino2. The PH5 pin is just one of the pins on the J8 expansion
header and has nothing to do with USB OTG. The PB9 pin is pulled
up and connected to the N_VBUSEN pin of AXP209 PMIC, while the
VBUS pin of AXP209 only has a capacitor between it and the
ground (this pin is not used for anything else).

To sum it up. Only the ID pin (PH4) has a real use. And 5V voltage
is always served to the MicroUSB OTG receptacle no matter what is
the state of the PB9/PD2 pins.

This patch has been tested on pcDuino2 to work fine in a host role
with a USB keyboard connected via an OTG cable. It also works fine
in a device role (cdc_ether) with a regular Micro-B cable connected
to a desktop PC.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

authored by

Siarhei Siamashka and committed by
Maxime Ripard
5d0c8b19 d6f17def

+19
+19
arch/arm/boot/dts/sun4i-a10-pcduino.dts
··· 164 164 status = "okay"; 165 165 }; 166 166 167 + &otg_sram { 168 + status = "okay"; 169 + }; 170 + 167 171 &pio { 168 172 led_pins_pcduino: led_pins@0 { 169 173 allwinner,pins = "PH15", "PH16"; ··· 181 177 allwinner,function = "gpio_in"; 182 178 allwinner,drive = <SUN4I_PINCTRL_10_MA>; 183 179 allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; 180 + }; 181 + 182 + usb0_id_detect_pin: usb0_id_detect_pin@0 { 183 + allwinner,pins = "PH4"; 184 + allwinner,function = "gpio_in"; 185 + allwinner,drive = <SUN4I_PINCTRL_10_MA>; 186 + allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; 184 187 }; 185 188 }; 186 189 ··· 224 213 status = "okay"; 225 214 }; 226 215 216 + &usb_otg { 217 + dr_mode = "otg"; 218 + status = "okay"; 219 + }; 220 + 227 221 &usbphy { 222 + pinctrl-names = "default"; 223 + pinctrl-0 = <&usb0_id_detect_pin>; 224 + usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ 228 225 usb1_vbus-supply = <&reg_vcc5v0>; /* USB1 VBUS is always on */ 229 226 usb2_vbus-supply = <&reg_vcc5v0>; /* USB2 VBUS is always on */ 230 227 status = "okay";