All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ARM: dts: sun4i: Enable USB DRC and voltage-scaling on pcDuino1/2
@ 2015-10-09 11:09 ` Siarhei Siamashka
  0 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

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

-- 
2.4.9

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 0/3] ARM: dts: sun4i: Enable USB DRC and voltage-scaling on pcDuino1/2
@ 2015-10-09 11:09 ` Siarhei Siamashka
  0 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

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

-- 
2.4.9

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/3] ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2
  2015-10-09 11:09 ` Siarhei Siamashka
@ 2015-10-09 11:09     ` Siarhei Siamashka
  -1 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

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.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/sun4i-a10-pcduino.dts b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
index c882421..0b45d27 100644
--- a/arch/arm/boot/dts/sun4i-a10-pcduino.dts
+++ b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
@@ -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";
 };
-- 
2.4.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 1/3] ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2
@ 2015-10-09 11:09     ` Siarhei Siamashka
  0 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
---
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/sun4i-a10-pcduino.dts b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
index c882421..0b45d27 100644
--- a/arch/arm/boot/dts/sun4i-a10-pcduino.dts
+++ b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
@@ -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";
 };
-- 
2.4.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/3] ARM: sun4i: dt: Add new LinkSprite pcDuino2 board
  2015-10-09 11:09 ` Siarhei Siamashka
@ 2015-10-09 11:09     ` Siarhei Siamashka
  -1 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

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.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 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

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 342ab31..c10d5aa 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -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 \
diff --git a/arch/arm/boot/dts/sun4i-a10-pcduino2.dts b/arch/arm/boot/dts/sun4i-a10-pcduino2.dts
new file mode 100644
index 0000000..de483a1
--- /dev/null
+++ b/arch/arm/boot/dts/sun4i-a10-pcduino2.dts
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015 Siarhei Siamashka <siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The LinkSprite pcDuino2 board is almost identical to the older
+ * LinkSprite pcDuino1 board. The only software visible difference
+ * is that the pcDuino2 board got a USB VBUS voltage regulator, which
+ * is controlled by the PD2 pin (pulled-up by default). Also one of
+ * the USB host ports has been replaced with a USB WIFI chip.
+ */
+
+#include "sun4i-a10-pcduino.dts"
+
+/ {
+	model = "LinkSprite pcDuino2";
+	compatible = "linksprite,a10-pcduino2", "allwinner,sun4i-a10";
+};
+
+&pio {
+	usb2_vbus_pin_pcduino2: usb2_vbus_pin@0 {
+		allwinner,pins = "PD2";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
+};
+
+&reg_usb2_vbus {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb2_vbus_pin_pcduino2>;
+	gpio = <&pio 3 2 GPIO_ACTIVE_HIGH>;
+	status = "okay";
+};
+
+&usbphy {
+	usb1_vbus-supply = <&reg_vcc3v3>; /* USB WIFI is always on */
+	usb2_vbus-supply = <&reg_usb2_vbus>;
+	status = "okay";
+};
-- 
2.4.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/3] ARM: sun4i: dt: Add new LinkSprite pcDuino2 board
@ 2015-10-09 11:09     ` Siarhei Siamashka
  0 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
---
 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

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 342ab31..c10d5aa 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -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 \
diff --git a/arch/arm/boot/dts/sun4i-a10-pcduino2.dts b/arch/arm/boot/dts/sun4i-a10-pcduino2.dts
new file mode 100644
index 0000000..de483a1
--- /dev/null
+++ b/arch/arm/boot/dts/sun4i-a10-pcduino2.dts
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015 Siarhei Siamashka <siarhei.siamashka@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The LinkSprite pcDuino2 board is almost identical to the older
+ * LinkSprite pcDuino1 board. The only software visible difference
+ * is that the pcDuino2 board got a USB VBUS voltage regulator, which
+ * is controlled by the PD2 pin (pulled-up by default). Also one of
+ * the USB host ports has been replaced with a USB WIFI chip.
+ */
+
+#include "sun4i-a10-pcduino.dts"
+
+/ {
+	model = "LinkSprite pcDuino2";
+	compatible = "linksprite,a10-pcduino2", "allwinner,sun4i-a10";
+};
+
+&pio {
+	usb2_vbus_pin_pcduino2: usb2_vbus_pin at 0 {
+		allwinner,pins = "PD2";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
+};
+
+&reg_usb2_vbus {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb2_vbus_pin_pcduino2>;
+	gpio = <&pio 3 2 GPIO_ACTIVE_HIGH>;
+	status = "okay";
+};
+
+&usbphy {
+	usb1_vbus-supply = <&reg_vcc3v3>; /* USB WIFI is always on */
+	usb2_vbus-supply = <&reg_usb2_vbus>;
+	status = "okay";
+};
-- 
2.4.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/3] ARM: dts: sun4i: Enable USB DRC on pcDuino1/2
  2015-10-09 11:09 ` Siarhei Siamashka
@ 2015-10-09 11:09     ` Siarhei Siamashka
  -1 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-pcduino.dts b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
index 0b45d27..39034aa 100644
--- a/arch/arm/boot/dts/sun4i-a10-pcduino.dts
+++ b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
@@ -164,6 +164,10 @@
 	status = "okay";
 };
 
+&otg_sram {
+	status = "okay";
+};
+
 &pio {
 	led_pins_pcduino: led_pins@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@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";
-- 
2.4.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/3] ARM: dts: sun4i: Enable USB DRC on pcDuino1/2
@ 2015-10-09 11:09     ` Siarhei Siamashka
  0 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2015-10-09 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-pcduino.dts b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
index 0b45d27..39034aa 100644
--- a/arch/arm/boot/dts/sun4i-a10-pcduino.dts
+++ b/arch/arm/boot/dts/sun4i-a10-pcduino.dts
@@ -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";
-- 
2.4.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 1/3] ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2
  2015-10-09 11:09     ` Siarhei Siamashka
@ 2015-10-11 16:47         ` Maxime Ripard
  -1 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-10-11 16:47 UTC (permalink / raw)
  To: Siarhei Siamashka
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

[-- Attachment #1: Type: text/plain, Size: 1430 bytes --]

On Fri, Oct 09, 2015 at 02:09:37PM +0300, Siarhei Siamashka wrote:
> 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.
> 
> Signed-off-by: Siarhei Siamashka <siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/3] ARM: dts: sun4i: Allow to use the PH6 pin for GPIO on pcDuino1/2
@ 2015-10-11 16:47         ` Maxime Ripard
  0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-10-11 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 09, 2015 at 02:09:37PM +0300, Siarhei Siamashka wrote:
> 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.
> 
> Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

Applied, thanks!
Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 2/3] ARM: sun4i: dt: Add new LinkSprite pcDuino2 board
  2015-10-09 11:09     ` Siarhei Siamashka
@ 2015-10-11 16:51         ` Maxime Ripard
  -1 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-10-11 16:51 UTC (permalink / raw)
  To: Siarhei Siamashka
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

On Fri, Oct 09, 2015 at 02:09:38PM +0300, Siarhei Siamashka wrote:
> 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.
> 
> Signed-off-by: Siarhei Siamashka <siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 2/3] ARM: sun4i: dt: Add new LinkSprite pcDuino2 board
@ 2015-10-11 16:51         ` Maxime Ripard
  0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-10-11 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 09, 2015 at 02:09:38PM +0300, Siarhei Siamashka wrote:
> 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.
> 
> Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

Applied, thanks!
Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 3/3] ARM: dts: sun4i: Enable USB DRC on pcDuino1/2
  2015-10-09 11:09     ` Siarhei Siamashka
@ 2015-10-11 17:06         ` Maxime Ripard
  -1 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-10-11 17:06 UTC (permalink / raw)
  To: Siarhei Siamashka
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Zoltan HERPAI

[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]

On Fri, Oct 09, 2015 at 02:09:39PM +0300, Siarhei Siamashka wrote:
> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 3/3] ARM: dts: sun4i: Enable USB DRC on pcDuino1/2
@ 2015-10-11 17:06         ` Maxime Ripard
  0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2015-10-11 17:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 09, 2015 at 02:09:39PM +0300, Siarhei Siamashka wrote:
> 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>

Applied, thanks!
Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-10-11 17:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 11:09 [PATCH v2 0/3] ARM: dts: sun4i: Enable USB DRC and voltage-scaling on pcDuino1/2 Siarhei Siamashka
2015-10-09 11:09 ` Siarhei Siamashka
     [not found] ` <1444388979-12072-1-git-send-email-siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-09 11:09   ` [PATCH v2 1/3] ARM: dts: sun4i: Allow to use the PH6 pin for GPIO " Siarhei Siamashka
2015-10-09 11:09     ` Siarhei Siamashka
     [not found]     ` <1444388979-12072-2-git-send-email-siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-11 16:47       ` Maxime Ripard
2015-10-11 16:47         ` Maxime Ripard
2015-10-09 11:09   ` [PATCH v2 2/3] ARM: sun4i: dt: Add new LinkSprite pcDuino2 board Siarhei Siamashka
2015-10-09 11:09     ` Siarhei Siamashka
     [not found]     ` <1444388979-12072-3-git-send-email-siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-11 16:51       ` Maxime Ripard
2015-10-11 16:51         ` Maxime Ripard
2015-10-09 11:09   ` [PATCH v2 3/3] ARM: dts: sun4i: Enable USB DRC on pcDuino1/2 Siarhei Siamashka
2015-10-09 11:09     ` Siarhei Siamashka
     [not found]     ` <1444388979-12072-4-git-send-email-siarhei.siamashka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-11 17:06       ` Maxime Ripard
2015-10-11 17:06         ` Maxime Ripard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.