diff mbox

[v2] arm64: allwinner: a64: orangepi-zero-plus2: add usb otg

Message ID 1515748144-25204-1-git-send-email-jagan@amarulasolutions.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jagan Teki Jan. 12, 2018, 9:09 a.m. UTC
Add usb otg support for orangepi-zero-plus2 board:
- Add usb_otg node with dr_mode as 'otg'
- USB0-IDDET connected to PA21
- VBUS connected through DCIN which always on

Tested mass storage function.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
Changes for v2:
- Change dr_mode to peripheral

 .../dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Maxime Ripard Jan. 15, 2018, 8:01 a.m. UTC | #1
Hi,

On Fri, Jan 12, 2018 at 02:39:04PM +0530, Jagan Teki wrote:
> Add usb otg support for orangepi-zero-plus2 board:
> - Add usb_otg node with dr_mode as 'otg'
> - USB0-IDDET connected to PA21
> - VBUS connected through DCIN which always on
> 
> Tested mass storage function.
> 
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
> Changes for v2:
> - Change dr_mode to peripheral
> 
>  .../dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts    | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> index af43533..6511190 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> @@ -73,6 +73,10 @@
>  	};
>  };
>  
> +&ehci0 {
> +	status = "okay";
> +};
> +
>  &mmc0 {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <&mmc0_pins_a>;
> @@ -111,6 +115,10 @@
>  	status = "okay";
>  };
>  
> +&ohci0 {
> +	status = "okay";
> +};
> +
>  &uart0 {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <&uart0_pins_a>;
> @@ -122,3 +130,13 @@
>  	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
>  	status = "okay";
>  };
> +
> +&usb_otg {
> +	dr_mode = "peripheral";

If VBUS is always on, this can only operate safely in host mode, not
peripheral.

Maxime
Icenowy Zheng Jan. 15, 2018, 8:05 a.m. UTC | #2
在 2018年1月15日星期一 CST 下午4:01:39,Maxime Ripard 写道:
> Hi,
> 
> On Fri, Jan 12, 2018 at 02:39:04PM +0530, Jagan Teki wrote:
> > Add usb otg support for orangepi-zero-plus2 board:
> > - Add usb_otg node with dr_mode as 'otg'
> > - USB0-IDDET connected to PA21
> > - VBUS connected through DCIN which always on
> > 
> > Tested mass storage function.
> > 
> > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > ---
> > Changes for v2:
> > - Change dr_mode to peripheral
> > 
> >  .../dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts    | 18
> >  ++++++++++++++++++ 1 file changed, 18 insertions(+)
> > 
> > diff --git
> > a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts index
> > af43533..6511190 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > @@ -73,6 +73,10 @@
> > 
> >  	};
> >  
> >  };
> > 
> > +&ehci0 {
> > +	status = "okay";
> > +};
> > +
> > 
> >  &mmc0 {
> >  
> >  	pinctrl-names = "default";
> >  	pinctrl-0 = <&mmc0_pins_a>;
> > 
> > @@ -111,6 +115,10 @@
> > 
> >  	status = "okay";
> >  
> >  };
> > 
> > +&ohci0 {
> > +	status = "okay";
> > +};
> > +
> > 
> >  &uart0 {
> >  
> >  	pinctrl-names = "default";
> >  	pinctrl-0 = <&uart0_pins_a>;
> > 
> > @@ -122,3 +130,13 @@
> > 
> >  	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
> >  	status = "okay";
> >  
> >  };
> > 
> > +
> > +&usb_otg {
> > +	dr_mode = "peripheral";
> 
> If VBUS is always on, this can only operate safely in host mode, not
> peripheral.

I think this kind of device is designed to directly drain power from the host 
in peripheral mode.

> 
> Maxime
Maxime Ripard Jan. 15, 2018, 3:33 p.m. UTC | #3
On Mon, Jan 15, 2018 at 04:05:07PM +0800, Icenowy Zheng wrote:
> 在 2018年1月15日星期一 CST 下午4:01:39,Maxime Ripard 写道:
> > Hi,
> > 
> > On Fri, Jan 12, 2018 at 02:39:04PM +0530, Jagan Teki wrote:
> > > Add usb otg support for orangepi-zero-plus2 board:
> > > - Add usb_otg node with dr_mode as 'otg'
> > > - USB0-IDDET connected to PA21
> > > - VBUS connected through DCIN which always on
> > > 
> > > Tested mass storage function.
> > > 
> > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > > ---
> > > Changes for v2:
> > > - Change dr_mode to peripheral
> > > 
> > >  .../dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts    | 18
> > >  ++++++++++++++++++ 1 file changed, 18 insertions(+)
> > > 
> > > diff --git
> > > a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > > b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts index
> > > af43533..6511190 100644
> > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
> > > @@ -73,6 +73,10 @@
> > > 
> > >  	};
> > >  
> > >  };
> > > 
> > > +&ehci0 {
> > > +	status = "okay";
> > > +};
> > > +
> > > 
> > >  &mmc0 {
> > >  
> > >  	pinctrl-names = "default";
> > >  	pinctrl-0 = <&mmc0_pins_a>;
> > > 
> > > @@ -111,6 +115,10 @@
> > > 
> > >  	status = "okay";
> > >  
> > >  };
> > > 
> > > +&ohci0 {
> > > +	status = "okay";
> > > +};
> > > +
> > > 
> > >  &uart0 {
> > >  
> > >  	pinctrl-names = "default";
> > >  	pinctrl-0 = <&uart0_pins_a>;
> > > 
> > > @@ -122,3 +130,13 @@
> > > 
> > >  	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
> > >  	status = "okay";
> > >  
> > >  };
> > > 
> > > +
> > > +&usb_otg {
> > > +	dr_mode = "peripheral";
> > 
> > If VBUS is always on, this can only operate safely in host mode, not
> > peripheral.
> 
> I think this kind of device is designed to directly drain power from the host 
> in peripheral mode.

Then the commit log has it backwards, VBUS is not connected through
DCIN, DCIN is VBUS.

Maxime
diff mbox

Patch

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
index af43533..6511190 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus2.dts
@@ -73,6 +73,10 @@ 
 	};
 };
 
+&ehci0 {
+	status = "okay";
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins_a>;
@@ -111,6 +115,10 @@ 
 	status = "okay";
 };
 
+&ohci0 {
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pins_a>;
@@ -122,3 +130,13 @@ 
 	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
 	status = "okay";
 };
+
+&usb_otg {
+	dr_mode = "peripheral";
+	status = "okay";
+};
+
+&usbphy {
+	usb0_id_det-gpios = <&pio 0 21 GPIO_ACTIVE_HIGH>; /* PA21 */
+	status = "okay";
+};