Skip to contentSkip to conversation

ARM: dts: sun8i: h3: enable USB OTG for NanoPi Neo board

PATCH Superseded Krzysztof Adamski 2 participants 5 messages Dec 1, 2017 – Dec 7, 2017

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

PATCH 1/1 ARM: dts: sun8i: h3: enable USB OTG for NanoPi Neo board

Similarly to Orange Pi Zero, NanoPi Neo board has an USB OTG port with an ID pin but with unpowered VBUS. This patch enables this port in forced peripheral mode.

---
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +17 -0
index 78f6c24952dd..14c3f137dbd3 100644
@@ -53,3 +53,20 @@
 	allwinner,leds-active-low;
 	status = "okay";
 };
+
+&usb_otg {
+	status = "okay";
+	dr_mode = "peripheral";
+};
+
+&usbphy {
+	usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
+};
+
+&ohci0 {
+	status = "okay";
+};
+
+&ehci0 {
+	status = "okay";
+};
Signature · 1 line
2.13.6
#1 lore raw

Hi,

Quoted 24 lines · Krzysztof Adamski

Similarly to Orange Pi Zero, NanoPi Neo board has an USB OTG port with an ID pin but with unpowered VBUS. This patch enables this port in forced peripheral mode.

---
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts | 17 +++++++++++++++++

1 file changed, 17 insertions(+)
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +7 -0
index 78f6c24952dd..14c3f137dbd3 100644
@@ -53,3 +53,20 @@
 	allwinner,leds-active-low;
 	status = "okay";
 };
+
+&usb_otg {
+	status = "okay";
+	dr_mode = "peripheral";
+};
+
+&usbphy {

arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts line 72

Quoted 10 lines
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +10 -0
+	usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
+};
+
+&ohci0 {
+	status = "okay";
+};
+
+&ehci0 {
+	status = "okay";
+};

Please sort the nodes in alphabetical order.

Also, does it make sense to add the OHCI and EHCI controller for a peripheral-only device?

Maxime

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

PATCH v2 1/1 ARM: dts: sun8i: h3: enable USB OTG for NanoPi Neo board

Similarly to Orange Pi Zero, NanoPi Neo board has an USB OTG port with an ID pin but with unpowered VBUS. This patch enables this port in forced peripheral mode.

ohci/ehci nodes are still enabled since the host mode may work if external power source is used. In that case, the mode can be switched for example via sysfs. The same strategy is used for Orange Pi Zero board DTS.

---

Changes since version 1:
- nodes sorted alphabetically
- added explanation why enabling ohci/ehci still makes sense

 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +17 -0
index 78f6c24952dd..9f33f6fae595 100644
@@ -47,9 +47,26 @@
 	compatible = "friendlyarm,nanopi-neo", "allwinner,sun8i-h3";
 };
 
+&ehci0 {
+	status = "okay";
+};
+
 &emac {
 	phy-handle = <&int_mii_phy>;
 	phy-mode = "mii";
 	allwinner,leds-active-low;
 	status = "okay";
 };
+
+&ohci0 {
+	status = "okay";
+};
+
+&usb_otg {
+	status = "okay";
+	dr_mode = "peripheral";
+};
+
+&usbphy {
+	usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
+};
Signature · 1 line
2.13.6
#4 lore raw
In reply to Maxime Ripard
Quoted 19 lines · Maxime Ripard
Quoted 19 lines
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +11 -0
index 78f6c24952dd..14c3f137dbd3 100644
@@ -53,3 +53,20 @@
 	allwinner,leds-active-low;
 	status = "okay";
 };
+
+&usb_otg {
+	status = "okay";
+	dr_mode = "peripheral";
+};
+
+&usbphy {
+	usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
+};
+
+&ohci0 {
Quoted 8 lines

arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts line 72

Quoted 6 lines
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +6 -0
+	status = "okay";
+};
+
+&ehci0 {
+	status = "okay";
+};

Please sort the nodes in alphabetical order.

Will do in v2 sent in separate e-mail.

Quoted 2 lines

Also, does it make sense to add the OHCI and EHCI controller for a peripheral-only device?

It does. The reasoning is the same as for the OrangePi Zero board in the patch by Icenowy Zheng (72897fa31fcf6222a11c6ebb0bcca25628bb1f7c) - the host mode on this board should work if you have external power source. In this case you can switch the mode via sysfs. I wanted to be consistent with the approach taken for the OrangePi Zero board. I added this reasoning to the commit message of v2.

Best regards,
Krzysztof Adamski

#3 lore raw
In reply to Krzysztof Adamski
Quoted 10 lines · Krzysztof Adamski

Similarly to Orange Pi Zero, NanoPi Neo board has an USB OTG port with an ID pin but with unpowered VBUS. This patch enables this port in forced peripheral mode.

ohci/ehci nodes are still enabled since the host mode may work if external power source is used. In that case, the mode can be switched for example via sysfs. The same strategy is used for Orange Pi Zero board DTS.

Applied, thanks!

Maxime

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