diff mbox series

[6/6] arm: dts: qcom: db410c: Enable USB OTG support

Message ID 1534859756-6955-6-git-send-email-loic.poulain@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/6] usb: chipidea: Add dynamic pinctrl selection | expand

Commit Message

Loic Poulain Aug. 21, 2018, 1:55 p.m. UTC
The Dragonboard-410c is able to act either as USB Host or Device.
The role can be determined at runtime via the USB_HS_ID pin which is
derived from the micro-usb port VBUS pin.

In Host role, SoC USB D+/D- are routed to the onboard USB 2.0 HUB.
In Device role, SoC USB D+/D- are routed to the USB 2.0 micro B port.
Routing is selected via USB_SW_SEL_PM gpio.

In device role USB HUB can be held in reset.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi | 20 ++++++++++++++++++++
 arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi           |  9 +++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

Comments

Rob Herring Aug. 21, 2018, 4:09 p.m. UTC | #1
On Tue, Aug 21, 2018 at 8:56 AM Loic Poulain <loic.poulain@linaro.org> wrote:
>
> The Dragonboard-410c is able to act either as USB Host or Device.
> The role can be determined at runtime via the USB_HS_ID pin which is
> derived from the micro-usb port VBUS pin.
>
> In Host role, SoC USB D+/D- are routed to the onboard USB 2.0 HUB.
> In Device role, SoC USB D+/D- are routed to the USB 2.0 micro B port.
> Routing is selected via USB_SW_SEL_PM gpio.
>
> In device role USB HUB can be held in reset.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---

> @@ -512,7 +513,7 @@
>
>         usb_id: usb-id {
>                 compatible = "linux,extcon-usb-gpio";
> -               vbus-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;
> +               id-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;

The GPIO has magically changed from being connected to Vbus to ID? The
extcon binding is crap anyways...

Ideally, it would be nice if this was moved to the usb connector binding.

Rob
Loic Poulain Aug. 22, 2018, 8:54 a.m. UTC | #2
On 21 August 2018 at 18:09, Rob Herring <robh+dt@kernel.org> wrote:
> On Tue, Aug 21, 2018 at 8:56 AM Loic Poulain <loic.poulain@linaro.org> wrote:
>>
>> The Dragonboard-410c is able to act either as USB Host or Device.
>> The role can be determined at runtime via the USB_HS_ID pin which is
>> derived from the micro-usb port VBUS pin.
>>
>> In Host role, SoC USB D+/D- are routed to the onboard USB 2.0 HUB.
>> In Device role, SoC USB D+/D- are routed to the USB 2.0 micro B port.
>> Routing is selected via USB_SW_SEL_PM gpio.
>>
>> In device role USB HUB can be held in reset.
>>
>> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
>> ---
>
>> @@ -512,7 +513,7 @@
>>
>>         usb_id: usb-id {
>>                 compatible = "linux,extcon-usb-gpio";
>> -               vbus-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;
>> +               id-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;
>
> The GPIO has magically changed from being connected to Vbus to ID? The
> extcon binding is crap anyways...

Although the pin is derived from VBUS, it is really used as an ID pin (USB_HS_ID
on DB410C schematics [1]), so that DB410C switches to device role when a cable
is inserted to the micro B port.

> Ideally, it would be nice if this was moved to the usb connector binding.

Good suggestion, If you agree, I'll address that in a different patchset.

Regards,
Loic

[1] https://www.96boards.org/documentation/consumer/dragonboard/dragonboard410c/hardware-docs/
diff mbox series

Patch

diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi
index ec2f0de..99787cc 100644
--- a/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi
@@ -8,6 +8,16 @@ 
 		pinconf {
 			pins = "gpio3";
 			function = PMIC_GPIO_FUNC_NORMAL;
+			input-disable;
+			output-high;
+		};
+	};
+
+	usb_hub_reset_pm_device: usb_hub_reset_pm_device {
+		pinconf {
+			pins = "gpio3";
+			function = PMIC_GPIO_FUNC_NORMAL;
+			input-disable;
 			output-low;
 		};
 	};
@@ -22,6 +32,16 @@ 
 		};
 	};
 
+	usb_sw_sel_pm_device: usb_sw_sel_pm_device {
+		pinconf {
+			pins = "gpio4";
+			function = PMIC_GPIO_FUNC_NORMAL;
+			power-source = <PM8916_GPIO_VPH>;
+			input-disable;
+			output-low;
+		};
+	};
+
 	pm8916_gpios_leds: pm8916_gpios_leds {
 		pinconf {
 			pins = "gpio1", "gpio2";
diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
index 9ff8487..661a7fd 100644
--- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
@@ -371,9 +371,10 @@ 
 			adp-disable;
 			hnp-disable;
 			srp-disable;
-			dr_mode = "host";
-			pinctrl-names = "default";
-			pinctrl-0 = <&usb_sw_sel_pm>;
+			dr_mode = "otg";
+			pinctrl-names = "default", "device";
+			pinctrl-0 = <&usb_sw_sel_pm &usb_hub_reset_pm>;
+			pinctrl-1 = <&usb_sw_sel_pm_device &usb_hub_reset_pm_device>;
 			ulpi {
 				phy {
 					v1p8-supply = <&pm8916_l7>;
@@ -512,7 +513,7 @@ 
 
 	usb_id: usb-id {
 		compatible = "linux,extcon-usb-gpio";
-		vbus-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;
+		id-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&usb_id_default>;
 	};