linux-samsung-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] enable USB on Pixel 6 (Oriole)
@ 2024-04-23 20:52 André Draszik
  2024-04-23 20:52 ` [PATCH 1/2] arm64: dts: exynos: gs101: add USB & USB-phy nodes André Draszik
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: André Draszik @ 2024-04-23 20:52 UTC (permalink / raw)
  To: Peter Griffin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Alim Akhtar
  Cc: Tudor Ambarus, Will McVicker, Roy Luo, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	André Draszik

These patches enable USB in peripheral mode on Pixel 6.

We can only support peripheral mode at this stage, as the MAX77759 TCPCI
controller used on Pixel 6 to do the role selection doesn't have a(n
upstream) Linux driver. Therefore the role is defaulted to peripheral
without any endpoints / ports.

For the same reason, we can not detect the orientation of a SS USB-C cable
and therefore it will only establish a link in SS mode in one of the
possible orientations of the cable. In all other cases, the link will be HS.

This series has a dependency on other patches, please see below.

I have mainly tested this as CDC ECM Ethernet device using the following:

    mount -t configfs configfs /sys/kernel/config/
    modprobe libcomposite
    modprobe usb_f_ecm
    mkdir /sys/kernel/config/usb_gadget/g3
    cd /sys/kernel/config/usb_gadget/g3

    echo 0xadad > idVendor
    echo 0xddaa > idProduct
    mkdir strings/0x409
    echo 01234567 > strings/0x409/serialnumber
    echo ADADAD > strings/0x409/manufacturer
    cat /proc/device-tree/model > strings/0x409/product
    # create the function (name must match a usb_f_<name> module such as 'acm')
    mkdir functions/ecm.usb0
    # stable MAC addresses
    echo "6e:27:3a:b9:40:87" > functions/ecm.usb0/dev_addr
    echo "ca:49:84:b0:3b:bc" > functions/ecm.usb0/host_addr

    mkdir configs/c.1
    ln -s functions/ecm.usb0 configs/c.1/
    echo $(ls -1 /sys/class/udc/) > UDC

    ifconfig usb0 192.168.1.2 up

at which point the other side should detect it and network communication
becomes possible (once the other side also configures its network
interface).

Due to the clock IDs, this series depends on the bindings patch
"dt-bindings: clock: google,gs101-clock: add HSI0 clock management unit" of
the series in
https://lore.kernel.org/r/20240423-hsi0-gs101-v1-0-2c3ddb50c720@linaro.org

The bindings for USB and USB-phy have been proposed as part of:
https://lore.kernel.org/r/20240423-usb-dwc3-gs101-v1-0-2f331f88203f@linaro.org
and
https://lore.kernel.org/r/20240423-usb-phy-gs101-v1-0-ebdcb3ac174d@linaro.org
respectively.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
André Draszik (2):
      arm64: dts: exynos: gs101: add USB & USB-phy nodes
      arm64: dts: exynos: gs101-oriole: enable USB on this board

 arch/arm64/boot/dts/exynos/google/gs101-oriole.dts | 24 +++++++++++++
 arch/arm64/boot/dts/exynos/google/gs101.dtsi       | 41 ++++++++++++++++++++++
 2 files changed, 65 insertions(+)
---
base-commit: a59668a9397e7245b26e9be85d23f242ff757ae8
change-id: 20240423-usb-dts-gs101-4269e0177c0f

Best regards,
-- 
André Draszik <andre.draszik@linaro.org>


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

* [PATCH 1/2] arm64: dts: exynos: gs101: add USB & USB-phy nodes
  2024-04-23 20:52 [PATCH 0/2] enable USB on Pixel 6 (Oriole) André Draszik
@ 2024-04-23 20:52 ` André Draszik
  2024-04-23 20:52 ` [PATCH 2/2] arm64: dts: exynos: gs101-oriole: enable USB on this board André Draszik
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: André Draszik @ 2024-04-23 20:52 UTC (permalink / raw)
  To: Peter Griffin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Alim Akhtar
  Cc: Tudor Ambarus, Will McVicker, Roy Luo, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	André Draszik

Add the USB 3.1 Dual Role Device (DRD) controller and USB-PHY nodes for
Google Tensor GS101.

The USB 3.1 DRD controller has the following features:
* compliant with both USB device 3.1 and USB device 2.0 standards
* compliant with USB host 3.1 and USB host 2.0 standards
* supports USB device 3.1 and USB device 2.0 interfaces
* supports USB host 3.1 and USB host 2.0 interfaces
* full-speed (12 Mbps) and high-speed (480 Mbps) modes with USB device
  2.0 interface
* super-speed (5 Gbps) mode with USB device 3.1 Gen1 interface
* super-speed plus (10 Gbps) mode with USB device 3.1 Gen2 interface
* single USB port which can be be used for USB 3.1 or USB 2.0
* on-chip USB PHY transceiver
* DWC3 compatible
* supports up to 16 bi-directional endpoints
* compliant with xHCI 1.1 specification

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 arch/arm64/boot/dts/exynos/google/gs101.dtsi | 41 ++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
index eddb6b326fde..b4e48ab890a6 100644
--- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
+++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
@@ -1247,6 +1247,47 @@ spi_13: spi@10d60000 {
 			};
 		};
 
+		usbdrd31_phy: phy@11100000 {
+			compatible = "google,gs101-usb31drd-phy";
+			reg = <0x11100000 0x0100>,
+			      <0x110f0000 0x0800>,
+			      <0x110e0000 0x2800>;
+			reg-names = "phy", "pcs", "pma";
+			clocks = <&cmu_hsi0 CLK_GOUT_HSI0_USB31DRD_ACLK_PHYCTRL>,
+				 <&cmu_hsi0 CLK_GOUT_HSI0_USB31DRD_I_USB20_PHY_REFCLK_26>,
+				 <&cmu_hsi0 CLK_GOUT_HSI0_UASC_HSI0_CTRL_ACLK>,
+				 <&cmu_hsi0 CLK_GOUT_HSI0_UASC_HSI0_CTRL_PCLK>,
+				 <&cmu_hsi0 CLK_GOUT_HSI0_USB31DRD_I_USBDPPHY_SCL_APB_PCLK>;
+			clock-names = "phy", "ref", "ctrl_aclk", "ctrl_pclk", "scl_pclk";
+			samsung,pmu-syscon = <&pmu_system_controller>;
+			#phy-cells = <1>;
+			status = "disabled";
+		};
+
+		usbdrd31: usb@11110000 {
+			compatible = "google,gs101-dwusb3";
+			clocks = <&cmu_hsi0 CLK_GOUT_HSI0_USB31DRD_BUS_CLK_EARLY>,
+				<&cmu_hsi0 CLK_GOUT_HSI0_USB31DRD_I_USB31DRD_SUSPEND_CLK_26>,
+				<&cmu_hsi0 CLK_GOUT_HSI0_UASC_HSI0_LINK_ACLK>,
+				<&cmu_hsi0 CLK_GOUT_HSI0_UASC_HSI0_LINK_PCLK>;
+			clock-names = "bus_early", "susp_clk", "link_aclk", "link_pclk";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x0 0x11110000 0x10000>;
+			status = "disabled";
+
+			usbdrd31_dwc3: usb@0 {
+				compatible = "snps,dwc3";
+				clocks = <&cmu_hsi0 CLK_GOUT_HSI0_USB31DRD_I_USB31DRD_REF_CLK_40>;
+				clock-names = "ref";
+				reg = <0x0 0x10000>;
+				interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
+				phys = <&usbdrd31_phy 0>, <&usbdrd31_phy 1>;
+				phy-names = "usb2-phy", "usb3-phy";
+				status = "disabled";
+			};
+		};
+
 		pinctrl_hsi1: pinctrl@11840000 {
 			compatible = "google,gs101-pinctrl";
 			reg = <0x11840000 0x00001000>;

-- 
2.44.0.769.g3c40516874-goog


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

* [PATCH 2/2] arm64: dts: exynos: gs101-oriole: enable USB on this board
  2024-04-23 20:52 [PATCH 0/2] enable USB on Pixel 6 (Oriole) André Draszik
  2024-04-23 20:52 ` [PATCH 1/2] arm64: dts: exynos: gs101: add USB & USB-phy nodes André Draszik
@ 2024-04-23 20:52 ` André Draszik
  2024-04-28 15:53 ` [PATCH 0/2] enable USB on Pixel 6 (Oriole) Krzysztof Kozlowski
  2024-04-28 15:59 ` Krzysztof Kozlowski
  3 siblings, 0 replies; 6+ messages in thread
From: André Draszik @ 2024-04-23 20:52 UTC (permalink / raw)
  To: Peter Griffin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Alim Akhtar
  Cc: Tudor Ambarus, Will McVicker, Roy Luo, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	André Draszik

Pixel 6 (Oriole) has a USB-C connector that can act as host or device.

The USB role is detected dynamically using a MAX77759 TCPCI controller,
but since there is no driver for the MAX77759, the role is defaulted to
peripheral, without any endpoints / ports.

This allows Oriole to be configured as a gadget, e.g. using configfs.

As PMIC regulators are not implemented yet, we rely on USB LDOs being
enabled enabled by the bootloader. A placeholder regulator is used for
now.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 arch/arm64/boot/dts/exynos/google/gs101-oriole.dts | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/google/gs101-oriole.dts b/arch/arm64/boot/dts/exynos/google/gs101-oriole.dts
index 6be15e990b65..03b2a6fdfdc4 100644
--- a/arch/arm64/boot/dts/exynos/google/gs101-oriole.dts
+++ b/arch/arm64/boot/dts/exynos/google/gs101-oriole.dts
@@ -53,6 +53,12 @@ button-power {
 			wakeup-source;
 		};
 	};
+
+	/* TODO: Remove this once PMIC is implemented  */
+	reg_placeholder: regulator-0 {
+		compatible = "regulator-fixed";
+		regulator-name = "placeholder_reg";
+	};
 };
 
 &ext_24_5m {
@@ -106,6 +112,24 @@ &serial_0 {
 	status = "okay";
 };
 
+&usbdrd31 {
+	status = "okay";
+	vdd10-supply = <&reg_placeholder>;
+	vdd33-supply = <&reg_placeholder>;
+};
+
+&usbdrd31_dwc3 {
+	dr_mode = "otg";
+	usb-role-switch;
+	role-switch-default-mode = "peripheral";
+	maximum-speed = "super-speed-plus";
+	status = "okay";
+};
+
+&usbdrd31_phy {
+	status = "okay";
+};
+
 &usi_uart {
 	samsung,clkreq-on; /* needed for UART mode */
 	status = "okay";

-- 
2.44.0.769.g3c40516874-goog


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

* Re: [PATCH 0/2] enable USB on Pixel 6 (Oriole)
  2024-04-23 20:52 [PATCH 0/2] enable USB on Pixel 6 (Oriole) André Draszik
  2024-04-23 20:52 ` [PATCH 1/2] arm64: dts: exynos: gs101: add USB & USB-phy nodes André Draszik
  2024-04-23 20:52 ` [PATCH 2/2] arm64: dts: exynos: gs101-oriole: enable USB on this board André Draszik
@ 2024-04-28 15:53 ` Krzysztof Kozlowski
  2024-04-28 15:59 ` Krzysztof Kozlowski
  3 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-28 15:53 UTC (permalink / raw)
  To: André Draszik, Peter Griffin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Alim Akhtar
  Cc: Tudor Ambarus, Will McVicker, Roy Luo, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel

On 23/04/2024 22:52, André Draszik wrote:
> These patches enable USB in peripheral mode on Pixel 6.
> 
> We can only support peripheral mode at this stage, as the MAX77759 TCPCI
> controller used on Pixel 6 to do the role selection doesn't have a(n
> upstream) Linux driver. Therefore the role is defaulted to peripheral
> without any endpoints / ports.

Be sure you run checkpatch *before* sending patches:

WARNING: Possible repeated word: 'be'

WARNING: Possible repeated word: 'enabled'


Best regards,
Krzysztof


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

* Re: [PATCH 0/2] enable USB on Pixel 6 (Oriole)
  2024-04-23 20:52 [PATCH 0/2] enable USB on Pixel 6 (Oriole) André Draszik
                   ` (2 preceding siblings ...)
  2024-04-28 15:53 ` [PATCH 0/2] enable USB on Pixel 6 (Oriole) Krzysztof Kozlowski
@ 2024-04-28 15:59 ` Krzysztof Kozlowski
  2024-04-29 10:37   ` André Draszik
  3 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-28 15:59 UTC (permalink / raw)
  To: André Draszik, Peter Griffin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Alim Akhtar
  Cc: Tudor Ambarus, Will McVicker, Roy Luo, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel

On 23/04/2024 22:52, André Draszik wrote:
> These patches enable USB in peripheral mode on Pixel 6.
> 
> We can only support peripheral mode at this stage, as the MAX77759 TCPCI
> controller used on Pixel 6 to do the role selection doesn't have a(n
> upstream) Linux driver. Therefore the role is defaulted to peripheral
> without any endpoints / ports.
> 
> For the same reason, we can not detect the orientation of a SS USB-C cable
> and therefore it will only establish a link in SS mode in one of the
> possible orientations of the cable. In all other cases, the link will be HS.
> 
> This series has a dependency on other patches, please see below.
> 
> I have mainly tested this as CDC ECM Ethernet device using the following:
> 
>     mount -t configfs configfs /sys/kernel/config/
>     modprobe libcomposite
>     modprobe usb_f_ecm
>     mkdir /sys/kernel/config/usb_gadget/g3
>     cd /sys/kernel/config/usb_gadget/g3
> 
>     echo 0xadad > idVendor
>     echo 0xddaa > idProduct
>     mkdir strings/0x409
>     echo 01234567 > strings/0x409/serialnumber
>     echo ADADAD > strings/0x409/manufacturer
>     cat /proc/device-tree/model > strings/0x409/product
>     # create the function (name must match a usb_f_<name> module such as 'acm')
>     mkdir functions/ecm.usb0
>     # stable MAC addresses
>     echo "6e:27:3a:b9:40:87" > functions/ecm.usb0/dev_addr
>     echo "ca:49:84:b0:3b:bc" > functions/ecm.usb0/host_addr
> 
>     mkdir configs/c.1
>     ln -s functions/ecm.usb0 configs/c.1/
>     echo $(ls -1 /sys/class/udc/) > UDC
> 
>     ifconfig usb0 192.168.1.2 up
> 
> at which point the other side should detect it and network communication
> becomes possible (once the other side also configures its network
> interface).
> 
> Due to the clock IDs, this series depends on the bindings patch
> "dt-bindings: clock: google,gs101-clock: add HSI0 clock management unit" of
> the series in
> https://lore.kernel.org/r/20240423-hsi0-gs101-v1-0-2c3ddb50c720@linaro.org
> 

This is weird. The patchset applied cleanly without DTS parts from above
set, but then failed to build. Obviously, because it depends on DTS,
even though it is not explicitly said here...

But when I applied DTS from above, these two patches fail to apply, so I
really wonder how this was organized in the first place. Please rebase.

Best regards,
Krzysztof


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

* Re: [PATCH 0/2] enable USB on Pixel 6 (Oriole)
  2024-04-28 15:59 ` Krzysztof Kozlowski
@ 2024-04-29 10:37   ` André Draszik
  0 siblings, 0 replies; 6+ messages in thread
From: André Draszik @ 2024-04-29 10:37 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Peter Griffin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Alim Akhtar
  Cc: Tudor Ambarus, Will McVicker, Roy Luo, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel

On Sun, 2024-04-28 at 17:59 +0200, Krzysztof Kozlowski wrote:
> On 23/04/2024 22:52, André Draszik wrote:
> > 
> > Due to the clock IDs, this series depends on the bindings patch
> > "dt-bindings: clock: google,gs101-clock: add HSI0 clock management unit" of
> > the series in
> > https://lore.kernel.org/r/20240423-hsi0-gs101-v1-0-2c3ddb50c720@linaro.org
> > 
> 
> This is weird. The patchset applied cleanly without DTS parts from above
> set, but then failed to build. Obviously, because it depends on DTS,
> even though it is not explicitly said here...

Note that this also depends on the DT bindings for USB & phy mentioned in the
cover letter, though. I've made that statement more explicit as well.

Thanks Krzysztof!

Cheers,
Andre


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

end of thread, other threads:[~2024-04-29 10:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 20:52 [PATCH 0/2] enable USB on Pixel 6 (Oriole) André Draszik
2024-04-23 20:52 ` [PATCH 1/2] arm64: dts: exynos: gs101: add USB & USB-phy nodes André Draszik
2024-04-23 20:52 ` [PATCH 2/2] arm64: dts: exynos: gs101-oriole: enable USB on this board André Draszik
2024-04-28 15:53 ` [PATCH 0/2] enable USB on Pixel 6 (Oriole) Krzysztof Kozlowski
2024-04-28 15:59 ` Krzysztof Kozlowski
2024-04-29 10:37   ` André Draszik

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