Skip to contentSkip to conversation

ARM: dts: sun4i: Enable USB DRC and voltage-scaling on pcDuino1/2

PATCH New Siarhei Siamashka 2 participants 7 messages Oct 9, 2015 – Oct 11, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover ARM: dts: sun4i: Enable USB DRC and voltage-scaling on pcDuino1/2

Hello,

This is the v2 of the older patches from:

    http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/374377.html

Changes since v1:
- The voltage scaling patch (AXP209 PMU regulators) has been already applied by Maxime, so it is not included in this patch set anymore.
- A new patch with a separate dts for pcDuino2 has been added, as had been requested during the previous review round.
- Instead of removing "usb1_vbus-supply" and "usb2_vbus-supply", they now refer to "reg_vcc5v0" (this had been discussed on IRC).

Siarhei Siamashka (3):
ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2
ARM: sun4i: dt: Add new LinkSprite pcDuino2 board
ARM: dts: sun4i: Enable USB DRC on pcDuino1/2

 arch/arm/boot/dts/Makefile               |  3 +-
 arch/arm/boot/dts/sun4i-a10-pcduino.dts  | 29 ++++++++----
 arch/arm/boot/dts/sun4i-a10-pcduino2.dts | 78 ++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/boot/dts/sun4i-a10-pcduino2.dts
Signature · 1 line
2.4.9
#1 lore raw

PATCH v2 1/3 ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2

The pcDuino1 board does not use any power switches at all for its two USB host ports and the VBUS pins are always connected to 5V.

The pcDuino2 board uses the RT9701GB power switch for its single USB host port, but the USB_EN pin (PD2) is pulled up with a 10K resistor. So that the USB power is still enabled by default, resulting in the same behaviour as pcDuino1 if nobody touches the PD2 pin. This minor difference is going to be handled in a follow-up patch, introducing a separate dts file for pcDuino2.

The primary reason for this fix is that the current dts file unnecessarily meddles with the PH3 and PH6 pins. But the PH6 pin is available on the Arduino-compatible expansion header and may have a better use for other purposes. This patch fixes the problem and now the PH6 pin can be used with the GPIO sysfs interface. Tested on a pcDuino2 board with a multimeter:

echo 230 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio230/direction echo 0 > /sys/class/gpio/gpio230/value echo 1 > /sys/class/gpio/gpio230/value

USB still works as expected too.

---
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
arch/arm/boot/dts/sun4i-a10-pcduino.dts +2 -10
index c882421..0b45d27 100644
@@ -180,14 +180,6 @@
 	};
 };
 
-&reg_usb1_vbus {
-	status = "okay";
-};
-
-&reg_usb2_vbus {
-	status = "okay";
-};
-
 #include "axp209.dtsi"
 
 &reg_dcdc2 {
@@ -222,7 +214,7 @@
 };
 
 &usbphy {
-	usb1_vbus-supply = <&reg_usb1_vbus>;
-	usb2_vbus-supply = <&reg_usb2_vbus>;
+	usb1_vbus-supply = <&reg_vcc5v0>; /* USB1 VBUS is always on */
+	usb2_vbus-supply = <&reg_vcc5v0>; /* USB2 VBUS is always on */
 	status = "okay";
 };
Signature · 1 line
2.4.9
#2 lore raw

PATCH v2 1/3 ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2

Quoted 17 lines · Siarhei Siamashka

The pcDuino1 board does not use any power switches at all for its two USB host ports and the VBUS pins are always connected to 5V.

The pcDuino2 board uses the RT9701GB power switch for its single USB host port, but the USB_EN pin (PD2) is pulled up with a 10K resistor. So that the USB power is still enabled by default, resulting in the same behaviour as pcDuino1 if nobody touches the PD2 pin. This minor difference is going to be handled in a follow-up patch, introducing a separate dts file for pcDuino2.

The primary reason for this fix is that the current dts file unnecessarily meddles with the PH3 and PH6 pins. But the PH6 pin is available on the Arduino-compatible expansion header and may have a better use for other purposes. This patch fixes the problem and now the PH6 pin can be used with the GPIO sysfs interface. Tested on a pcDuino2 board with a multimeter:

Quoted 8 lines

echo 230 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio230/direction echo 0 > /sys/class/gpio/gpio230/value echo 1 > /sys/class/gpio/gpio230/value

USB still works as expected too.

Applied, thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151011/2e4c9dc6/attachment.sig>
#3 lore raw

PATCH v2 2/3 ARM: sun4i: dt: Add new LinkSprite pcDuino2 board

In reply to Siarhei Siamashka

The LinkSprite pcDuino2 board is almost identical to the older LinkSprite pcDuino1 board according to the schematic pdf files. So we just include the existing "sun4i-a10-pcduino.dts" file and make the necessary adjustments.

---
 arch/arm/boot/dts/Makefile               |  3 +-
 arch/arm/boot/dts/sun4i-a10-pcduino2.dts | 78 ++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/sun4i-a10-pcduino2.dts
arch/arm/boot/dts/Makefile +2 -1
index 342ab31..c10d5aa 100644
@@ -587,7 +587,8 @@ dtb-$(CONFIG_MACH_SUN4I) += \
 	sun4i-a10-mk802.dtb \
 	sun4i-a10-mk802ii.dtb \
 	sun4i-a10-olinuxino-lime.dtb \
-	sun4i-a10-pcduino.dtb
+	sun4i-a10-pcduino.dtb \
+	sun4i-a10-pcduino2.dtb
 dtb-$(CONFIG_MACH_SUN5I) += \
 	sun5i-a10s-auxtek-t003.dtb \
 	sun5i-a10s-auxtek-t004.dtb \
arch/arm/boot/dts/sun4i-a10-pcduino2.dts new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
2.4.9
#4 lore raw

PATCH v2 2/3 ARM: sun4i: dt: Add new LinkSprite pcDuino2 board

Quoted 6 lines · Siarhei Siamashka

The LinkSprite pcDuino2 board is almost identical to the older LinkSprite pcDuino1 board according to the schematic pdf files. So we just include the existing "sun4i-a10-pcduino.dts" file and make the necessary adjustments.

Applied, thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151011/440099d5/attachment-0001.sig>
#5 lore raw

PATCH v2 3/3 ARM: dts: sun4i: Enable USB DRC on pcDuino1/2

In reply to Siarhei Siamashka

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.

---
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/boot/dts/sun4i-a10-pcduino.dts +19 -0
index 0b45d27..39034aa 100644
@@ -164,6 +164,10 @@
 	status = "okay";
 };
 
+&otg_sram {
+	status = "okay";
+};
+
 &pio {
 	led_pins_pcduino: led_pins at 0 {
 		allwinner,pins = "PH15", "PH16";
@@ -178,6 +182,13 @@
 		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
 		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 	};
+
+	usb0_id_detect_pin: usb0_id_detect_pin at 0 {
+		allwinner,pins = "PH4";
+		allwinner,function = "gpio_in";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+	};
 };
 
 #include "axp209.dtsi"
@@ -213,7 +224,15 @@
 	status = "okay";
 };
 
+&usb_otg {
+	dr_mode = "otg";
+	status = "okay";
+};
+
 &usbphy {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb0_id_detect_pin>;
+	usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
 	usb1_vbus-supply = <&reg_vcc5v0>; /* USB1 VBUS is always on */
 	usb2_vbus-supply = <&reg_vcc5v0>; /* USB2 VBUS is always on */
 	status = "okay";
Signature · 1 line
2.4.9
#6 lore raw

PATCH v2 3/3 ARM: dts: sun4i: Enable USB DRC on pcDuino1/2

Quoted 26 lines · Siarhei Siamashka

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.

Quoted 6 lines

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.

Applied, thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151011/ea3a3063/attachment.sig>