linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board
@ 2023-08-25 21:54 Sam Protsenko
  2023-08-25 21:54 ` [PATCH v2 1/2] arm64: dts: exynos: Enable USB in Exynos850 Sam Protsenko
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Sam Protsenko @ 2023-08-25 21:54 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring
  Cc: Conor Dooley, Alim Akhtar, Marek Szyprowski, JaeHun Jung,
	devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel

This patch series enables USB gadget, USB host and Ethernet support for
E850-96 board. The most major change was done in USB PHY driver, as the
register layout of PHY block in Exynos850 is very different from
Exynos5 one.

Changes in v2:
  - Removed already applied patches from the patch series
  - Rebased on top of latest linux-next
  - Put ranges after compatible in usbdrd node (patch #1)

Sam Protsenko (8):
  dt-bindings: usb: samsung,exynos-dwc3: Add Exynos850 support
  dt-bindings: phy: samsung,usb3-drd-phy: Add Exynos850 support
  usb: dwc3: exynos: Add support for Exynos850 variant
  phy: exynos5-usbdrd: Make it possible to pass custom phy ops
  phy: exynos5-usbdrd: Add 26MHz ref clk support
  phy: exynos5-usbdrd: Add Exynos850 support
  arm64: dts: exynos: Enable USB in Exynos850
  arm64: dts: exynos: Enable USB support on E850-96 board

 .../bindings/phy/samsung,usb3-drd-phy.yaml    |   1 +
 .../bindings/usb/samsung,exynos-dwc3.yaml     |  16 ++
 .../boot/dts/exynos/exynos850-e850-96.dts     |  58 ++++++
 arch/arm64/boot/dts/exynos/exynos850.dtsi     |  30 +++
 drivers/phy/samsung/phy-exynos5-usbdrd.c      | 182 +++++++++++++++++-
 drivers/usb/dwc3/dwc3-exynos.c                |   9 +
 6 files changed, 294 insertions(+), 2 deletions(-)

-- 
2.39.2


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

* [PATCH v2 1/2] arm64: dts: exynos: Enable USB in Exynos850
  2023-08-25 21:54 [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board Sam Protsenko
@ 2023-08-25 21:54 ` Sam Protsenko
  2023-08-25 21:54 ` [PATCH v2 2/2] arm64: dts: exynos: Enable USB support on E850-96 board Sam Protsenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Sam Protsenko @ 2023-08-25 21:54 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring
  Cc: Conor Dooley, Alim Akhtar, Marek Szyprowski, JaeHun Jung,
	devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel

Add USB controller and USB PHY controller nodes for Exynos850 SoC.

The USB controller has next features:
  - Dual Role Device (DRD) controller
  - DWC3 compatible
  - Supports USB 2.0 host and USB 2.0 device interfaces
  - Supports  full-speed (12 Mbps) and high-speed (480 Mbps) modes with
    USB device 2.0 interface
  - Supports on-chip USB PHY transceiver
  - Supports up to 16 bi-directional endpoints (that includes control
    endpoint 0)
  - Complies with xHCI 1.00 specification

Only USB 2.0 is supported in Exynos850, so only UTMI+ PHY interface is
specified in "phys" property (index 0) and PIPE3 is omitted (index 1).

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
  - Put ranges after compatible in usbdrd node

 arch/arm64/boot/dts/exynos/exynos850.dtsi | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/exynos850.dtsi b/arch/arm64/boot/dts/exynos/exynos850.dtsi
index aa077008b3be..53104e65b9c6 100644
--- a/arch/arm64/boot/dts/exynos/exynos850.dtsi
+++ b/arch/arm64/boot/dts/exynos/exynos850.dtsi
@@ -570,6 +570,36 @@ sysreg_cmgp: syscon@11c20000 {
 			clocks = <&cmu_cmgp CLK_GOUT_SYSREG_CMGP_PCLK>;
 		};
 
+		usbdrd: usb@13600000 {
+			compatible = "samsung,exynos850-dwusb3";
+			ranges = <0x0 0x13600000 0x10000>;
+			clocks = <&cmu_hsi CLK_GOUT_USB_BUS_EARLY_CLK>,
+				 <&cmu_hsi CLK_GOUT_USB_REF_CLK>;
+			clock-names = "bus_early", "ref";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			status = "disabled";
+
+			usbdrd_dwc3: usb@0 {
+				compatible = "snps,dwc3";
+				reg = <0x0 0x10000>;
+				interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usbdrd_phy 0>;
+				phy-names = "usb2-phy";
+			};
+		};
+
+		usbdrd_phy: phy@135d0000 {
+			compatible = "samsung,exynos850-usbdrd-phy";
+			reg = <0x135d0000 0x100>;
+			clocks = <&cmu_hsi CLK_GOUT_USB_PHY_ACLK>,
+				 <&cmu_hsi CLK_GOUT_USB_PHY_REF_CLK>;
+			clock-names = "phy", "ref";
+			samsung,pmu-syscon = <&pmu_system_controller>;
+			#phy-cells = <1>;
+			status = "disabled";
+		};
+
 		usi_uart: usi@138200c0 {
 			compatible = "samsung,exynos850-usi";
 			reg = <0x138200c0 0x20>;
-- 
2.39.2


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

* [PATCH v2 2/2] arm64: dts: exynos: Enable USB support on E850-96 board
  2023-08-25 21:54 [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board Sam Protsenko
  2023-08-25 21:54 ` [PATCH v2 1/2] arm64: dts: exynos: Enable USB in Exynos850 Sam Protsenko
@ 2023-08-25 21:54 ` Sam Protsenko
  2023-08-26 18:10 ` [PATCH v2 0/2] arm64: dts: exynos: Enable USB for " Krzysztof Kozlowski
  2023-09-11 11:39 ` Krzysztof Kozlowski
  3 siblings, 0 replies; 7+ messages in thread
From: Sam Protsenko @ 2023-08-25 21:54 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring
  Cc: Conor Dooley, Alim Akhtar, Marek Szyprowski, JaeHun Jung,
	devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel

The E850-96 board has a micro-USB socket and two USB 2.0 host sockets.
The USB role (host or peripheral) is selected automatically depending on
micro-USB cable attachment state:
  - micro-USB cable is attached: USB device role
  - micro-USB cable is detached: USB host role

USB can't act simultaneously as a device and a host, because Exynos850
SoC has only one USB controller and there are no external USB
controllers on the E850-96 board. So the USB switch chip (specifically
TS3USB221A) connects SoC USB lines either to micro-USB connector or to
USB hub chip (LAN9514), w.r.t. micro-USB cable attachment state.

When USB works in the host role, Ethernet capability becomes available
too, as the LAN9514 chip (providing USB hub) also enables Ethernet PHY
and Ethernet MAC.

Dynamic role switching is done in gpio-usb-b-connector, using current
micro-USB VBUS line level as a trigger:
  - VBUS=high: SoC USB lines are wired to micro-USB socket
  - VBUS=low: SoC USB lines are wired to USB hub chip

In order to make USB host functional when the board was booted with
micro-USB cable disconnected, role-switch-default-mode = "host" is used.

One can use E850-96 board schematics [1] to figure out how exactly all
related USB hardware connections and lines reflect into corresponding
device tree definitions.

As PMIC regulators are not implemented yet, we rely on USB LDOs being
already enabled in the bootloader. A dummy regulator is provided to
"usbdrd" vdd nodes for now.

[1] https://www.96boards.org/documentation/consumer/e850-96b/hardware-docs/

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
  - none

 .../boot/dts/exynos/exynos850-e850-96.dts     | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/exynos850-e850-96.dts b/arch/arm64/boot/dts/exynos/exynos850-e850-96.dts
index 6ed38912507f..8d733361ef82 100644
--- a/arch/arm64/boot/dts/exynos/exynos850-e850-96.dts
+++ b/arch/arm64/boot/dts/exynos/exynos850-e850-96.dts
@@ -29,6 +29,22 @@ chosen {
 		stdout-path = &serial_0;
 	};
 
+	connector {
+		compatible = "gpio-usb-b-connector", "usb-b-connector";
+		label = "micro-USB";
+		type = "micro";
+		vbus-supply = <&reg_usb_host_vbus>;
+		id-gpios = <&gpa0 0 GPIO_ACTIVE_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&micro_usb_det_pins>;
+
+		port {
+			usb_dr_connector: endpoint {
+				remote-endpoint = <&usb1_drd_sw>;
+			};
+		};
+	};
+
 	/*
 	 * RAM: 4 GiB (eMCP):
 	 *   - 2 GiB at 0x80000000
@@ -111,6 +127,20 @@ bt_active_led: led-5 {
 		};
 	};
 
+	/* TODO: Remove this once PMIC is implemented  */
+	reg_dummy: regulator-0 {
+		compatible = "regulator-fixed";
+		regulator-name = "dummy_reg";
+	};
+
+	reg_usb_host_vbus: regulator-1 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb_host_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpa3 5 GPIO_ACTIVE_LOW>;
+	};
+
 	/*
 	 * RTC clock (XrtcXTI); external, must be 32.768 kHz.
 	 *
@@ -172,6 +202,12 @@ key_volup_pins: key-volup-pins {
 		samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
 		samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>;
 	};
+
+	micro_usb_det_pins: micro-usb-det-pins {
+		samsung,pins = "gpa0-0";
+		samsung,pin-function = <EXYNOS_PIN_FUNC_INPUT>;
+		samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
+	};
 };
 
 &rtc {
@@ -186,6 +222,28 @@ &serial_0 {
 	pinctrl-0 = <&uart1_pins>;
 };
 
+&usbdrd {
+	status = "okay";
+	vdd10-supply = <&reg_dummy>;
+	vdd33-supply = <&reg_dummy>;
+};
+
+&usbdrd_dwc3 {
+	dr_mode = "otg";
+	usb-role-switch;
+	role-switch-default-mode = "host";
+
+	port {
+		usb1_drd_sw: endpoint {
+			remote-endpoint = <&usb_dr_connector>;
+		};
+	};
+};
+
+&usbdrd_phy {
+	status = "okay";
+};
+
 &usi_uart {
 	samsung,clkreq-on; /* needed for UART mode */
 	status = "okay";
-- 
2.39.2


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

* Re: [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board
  2023-08-25 21:54 [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board Sam Protsenko
  2023-08-25 21:54 ` [PATCH v2 1/2] arm64: dts: exynos: Enable USB in Exynos850 Sam Protsenko
  2023-08-25 21:54 ` [PATCH v2 2/2] arm64: dts: exynos: Enable USB support on E850-96 board Sam Protsenko
@ 2023-08-26 18:10 ` Krzysztof Kozlowski
  2023-08-30  0:44   ` Sam Protsenko
  2023-09-11 11:39 ` Krzysztof Kozlowski
  3 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-08-26 18:10 UTC (permalink / raw)
  To: Sam Protsenko, Krzysztof Kozlowski, Rob Herring
  Cc: Conor Dooley, Alim Akhtar, Marek Szyprowski, JaeHun Jung,
	devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel

On 25/08/2023 23:54, Sam Protsenko wrote:
> This patch series enables USB gadget, USB host and Ethernet support for
> E850-96 board. The most major change was done in USB PHY driver, as the
> register layout of PHY block in Exynos850 is very different from
> Exynos5 one.
> 
> Changes in v2:

Thank you for the patch. Looks good.
It is too late in the cycle for me to pick it up. I will take it after
the merge window.

Best regards,
Krzysztof


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

* Re: [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board
  2023-08-26 18:10 ` [PATCH v2 0/2] arm64: dts: exynos: Enable USB for " Krzysztof Kozlowski
@ 2023-08-30  0:44   ` Sam Protsenko
  2023-08-30  6:53     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Sam Protsenko @ 2023-08-30  0:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Krzysztof Kozlowski, Rob Herring, Conor Dooley, Alim Akhtar,
	Marek Szyprowski, JaeHun Jung, devicetree, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

On Sat, Aug 26, 2023 at 1:10 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> On 25/08/2023 23:54, Sam Protsenko wrote:
> > This patch series enables USB gadget, USB host and Ethernet support for
> > E850-96 board. The most major change was done in USB PHY driver, as the
> > register layout of PHY block in Exynos850 is very different from
> > Exynos5 one.
> >
> > Changes in v2:
>
> Thank you for the patch. Looks good.
> It is too late in the cycle for me to pick it up. I will take it after
> the merge window.
>

Thanks, Krzysztof! So we can expect these to get into v6.6, correct?
Also, I'm trying to keep track of all my patches, so please let me
know if you are going to apply this series to your trees soon, and
which exactly (I presume krzk/linux-dt.git/for-next?).

> Best regards,
> Krzysztof
>

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

* Re: [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board
  2023-08-30  0:44   ` Sam Protsenko
@ 2023-08-30  6:53     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-08-30  6:53 UTC (permalink / raw)
  To: Sam Protsenko
  Cc: Krzysztof Kozlowski, Rob Herring, Conor Dooley, Alim Akhtar,
	Marek Szyprowski, JaeHun Jung, devicetree, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

On 30/08/2023 02:44, Sam Protsenko wrote:
> On Sat, Aug 26, 2023 at 1:10 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>>
>> On 25/08/2023 23:54, Sam Protsenko wrote:
>>> This patch series enables USB gadget, USB host and Ethernet support for
>>> E850-96 board. The most major change was done in USB PHY driver, as the
>>> register layout of PHY block in Exynos850 is very different from
>>> Exynos5 one.
>>>
>>> Changes in v2:
>>
>> Thank you for the patch. Looks good.
>> It is too late in the cycle for me to pick it up. I will take it after
>> the merge window.
>>
> 
> Thanks, Krzysztof! So we can expect these to get into v6.6, correct?

No, this is v6.6 merge window and it already started. I will take it
after, thus v6.7.

> Also, I'm trying to keep track of all my patches, so please let me
> know if you are going to apply this series to your trees soon, and
> which exactly (I presume krzk/linux-dt.git/for-next?).

I always send confirmation of applied patches with reference to repo and
commit (although not branch).

Best regards,
Krzysztof


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

* Re: [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board
  2023-08-25 21:54 [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board Sam Protsenko
                   ` (2 preceding siblings ...)
  2023-08-26 18:10 ` [PATCH v2 0/2] arm64: dts: exynos: Enable USB for " Krzysztof Kozlowski
@ 2023-09-11 11:39 ` Krzysztof Kozlowski
  3 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-09-11 11:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Sam Protsenko
  Cc: Krzysztof Kozlowski, Conor Dooley, Alim Akhtar, Marek Szyprowski,
	JaeHun Jung, devicetree, linux-arm-kernel, linux-samsung-soc,
	linux-kernel


On Fri, 25 Aug 2023 16:54:43 -0500, Sam Protsenko wrote:
> This patch series enables USB gadget, USB host and Ethernet support for
> E850-96 board. The most major change was done in USB PHY driver, as the
> register layout of PHY block in Exynos850 is very different from
> Exynos5 one.
> 
> Changes in v2:
>   - Removed already applied patches from the patch series
>   - Rebased on top of latest linux-next
>   - Put ranges after compatible in usbdrd node (patch #1)
> 
> [...]

Applied, thanks!

[1/2] arm64: dts: exynos: Enable USB in Exynos850
      https://git.kernel.org/krzk/linux/c/2f911ca41e519dc5986f9483d3e15df4802b64f5
[2/2] arm64: dts: exynos: Enable USB support on E850-96 board
      https://git.kernel.org/krzk/linux/c/f2951ee8f7bcdb3844ffe6e54b0601ad8fa58640

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

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

end of thread, other threads:[~2023-09-11 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25 21:54 [PATCH v2 0/2] arm64: dts: exynos: Enable USB for E850-96 board Sam Protsenko
2023-08-25 21:54 ` [PATCH v2 1/2] arm64: dts: exynos: Enable USB in Exynos850 Sam Protsenko
2023-08-25 21:54 ` [PATCH v2 2/2] arm64: dts: exynos: Enable USB support on E850-96 board Sam Protsenko
2023-08-26 18:10 ` [PATCH v2 0/2] arm64: dts: exynos: Enable USB for " Krzysztof Kozlowski
2023-08-30  0:44   ` Sam Protsenko
2023-08-30  6:53     ` Krzysztof Kozlowski
2023-09-11 11:39 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).