linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm)
@ 2024-12-06 16:31 André Draszik
  2024-12-06 16:31 ` [PATCH v4 1/7] dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties André Draszik
                   ` (9 more replies)
  0 siblings, 10 replies; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik,
	Krzysztof Kozlowski

Hi,

This series enables USB3 Type-C lane orientation detection and
configuration on platforms that support this (Google gs101), and it
also allows the DWC3 core to enter runtime suspend even when UDC is
active.

For lane orientation, this driver now optionally (based on DT)
subscribes to the TCPC's lane orientation notifier and remembers the
orientation to later be used during phy_init().

To enable DWC3 runtime suspend, the gadget needs to inform the core via
dwc3_gadget_interrupt() with event type == DWC3_DEVICE_EVENT_DISCONNECT
of a cable disconnect. For that to allow to happen, this driver
therefore needs to stop forcing the Vbus and bvalid signals to active
and instead change their state based on actual conditions. The same
TCPC notifier is used to detect this, and program the hardware
accordingly.

That signal state is based on advice given by Thinh in
https://lore.kernel.org/all/20240813230625.jgkatqstyhcmpezv@synopsys.com/

Both changes together now allow cable orientation detection to work, as
the DWC3 will now call phy_exit() on cable disconnect, and we can
reprogram the lane mux in phy_init().

On top of that, there are some small related cleanup patches.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
Changes in v4:
- separate out patch 5 'phy: exynos5-usbdrd: gs101: ensure power is
  gated to SS phy in phy_exit()' from this series, as a stable patch
  shouldn't be buried inside a series like this (Greg)
  Link: https://lore.kernel.org/all/20241205-gs101-usb-phy-fix-v4-1-0278809fb810@linaro.org/
- Link to v3: https://lore.kernel.org/r/20241205-gs101-phy-lanes-orientation-phy-v3-0-32f721bed219@linaro.org

Changes in v3:
- patches 1 & 2: update as per Rob's suggestions
- patch 7 & 8: drop init to -1 of phy_drd->orientation (Vinod)
- patch 7: avoid an #ifdef 
- Link to v2: https://lore.kernel.org/r/20241203-gs101-phy-lanes-orientation-phy-v2-0-40dcf1b7670d@linaro.org

Changes in v2:
- squash patches #2 and #3 from v1 to actually disallow
  orientation-switch on !gs101 (not just optional) (Conor)
- update bindings commit message to clarify that the intention for the
  driver is to work with old and new DTS (Conor)
- add cc-stable and fixes tags to power gating patch (Krzysztof)
- fix an #include and typo (Peter)
- Link to v1: https://lore.kernel.org/r/20241127-gs101-phy-lanes-orientation-phy-v1-0-1b7fce24960b@linaro.org

---
André Draszik (7):
      dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties
      dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties
      phy: exynos5-usbdrd: convert to dev_err_probe
      phy: exynos5-usbdrd: fix EDS distribution tuning (gs101)
      phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation
      phy: exynos5-usbdrd: subscribe to orientation notifier if required
      phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)

 .../bindings/phy/samsung,usb3-drd-phy.yaml         |  21 ++-
 drivers/phy/samsung/Kconfig                        |   1 +
 drivers/phy/samsung/phy-exynos5-usbdrd.c           | 202 ++++++++++++++++-----
 3 files changed, 182 insertions(+), 42 deletions(-)
---
base-commit: c245a7a79602ccbee780c004c1e4abcda66aec32
change-id: 20241127-gs101-phy-lanes-orientation-phy-29d20c6d84d2

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



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

* [PATCH v4 1/7] dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-06 16:31 ` [PATCH v4 2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties André Draszik
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik

In [1], Rob pointed out that we should really be separating properties
with blank lines in between, which is universal style. Only where
properties are booleans, empty lines are not required.

Do so.

Link: https://lore.kernel.org/all/20240711212359.GA3023490-robh@kernel.org/ [1]
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v3:
* update subject line (Rob)
* collect tags

v2:
* collect tags
---
 .../devicetree/bindings/phy/samsung,usb3-drd-phy.yaml     | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml b/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml
index 16321cdd4919..1f8b35917b11 100644
--- a/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml
@@ -83,14 +83,19 @@ properties:
 
   pll-supply:
     description: Power supply for the USB PLL.
+
   dvdd-usb20-supply:
     description: DVDD power supply for the USB 2.0 phy.
+
   vddh-usb20-supply:
     description: VDDh power supply for the USB 2.0 phy.
+
   vdd33-usb20-supply:
     description: 3.3V power supply for the USB 2.0 phy.
+
   vdda-usbdp-supply:
     description: VDDa power supply for the USB DP phy.
+
   vddh-usbdp-supply:
     description: VDDh power supply for the USB DP phy.
 
@@ -117,6 +122,7 @@ allOf:
             - description: Gate of control interface AXI clock
             - description: Gate of control interface APB clock
             - description: Gate of SCL APB clock
+
         clock-names:
           items:
             - const: phy
@@ -124,10 +130,13 @@ allOf:
             - const: ctrl_aclk
             - const: ctrl_pclk
             - const: scl_pclk
+
         reg:
           minItems: 3
+
         reg-names:
           minItems: 3
+
       required:
         - reg-names
         - pll-supply
@@ -149,6 +158,7 @@ allOf:
         clocks:
           minItems: 5
           maxItems: 5
+
         clock-names:
           items:
             - const: phy
@@ -156,8 +166,10 @@ allOf:
             - const: phy_utmi
             - const: phy_pipe
             - const: itp
+
         reg:
           maxItems: 1
+
         reg-names:
           maxItems: 1
 
@@ -174,12 +186,15 @@ allOf:
         clocks:
           minItems: 2
           maxItems: 2
+
         clock-names:
           items:
             - const: phy
             - const: ref
+
         reg:
           maxItems: 1
+
         reg-names:
           maxItems: 1
 

-- 
2.47.0.338.g60cca15819-goog



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

* [PATCH v4 2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
  2024-12-06 16:31 ` [PATCH v4 1/7] dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-11 15:47   ` Rob Herring (Arm)
  2024-12-06 16:31 ` [PATCH v4 3/7] phy: exynos5-usbdrd: convert to dev_err_probe André Draszik
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik

orientation-switch is the standard declaration to inform the Type-C mux
layer that a remote-endpoint is capable of processing orientation
change messages.

The USB PHY on gs101 needs to be configured based on the orientation of
the connector. For that the DTS needs a link between the phy's port and
a TCPCi, and we'll need to inform the phy driver that it should handle
the orientation (register a handler).

Update the schema to enforce that by requiring the orientation-switch
and port properties on gs101 (only). We disallow orientation-switch on
all other supported platforms, since other versions of this phy (or its
system integration) don't currently support or even need it.

Even though this new required gs101 property is an ABI break, the
intention for the driver is to behave as before if it's missing
(meaning for gs101 it will work in SS mode in one orientation only).
Other platforms are not affected.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v3:
* update as per Rob's suggestion (I hope :-)

v2:
* squash original patches #2 and #3
* actually disallow orientation-switch on !gs101 (not just optional) (Conor)
* update commit message to clarify that the intention for the driver is
  to work with old and new DTS (Conor)
* collect tags

foo
---
 Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml b/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml
index 1f8b35917b11..27295acbba76 100644
--- a/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml
@@ -114,6 +114,8 @@ allOf:
           contains:
             const: google,gs101-usb31drd-phy
     then:
+      $ref: /schemas/usb/usb-switch.yaml#
+
       properties:
         clocks:
           items:
@@ -139,6 +141,8 @@ allOf:
 
       required:
         - reg-names
+        - orientation-switch
+        - port
         - pll-supply
         - dvdd-usb20-supply
         - vddh-usb20-supply
@@ -198,7 +202,7 @@ allOf:
         reg-names:
           maxItems: 1
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |

-- 
2.47.0.338.g60cca15819-goog



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

* [PATCH v4 3/7] phy: exynos5-usbdrd: convert to dev_err_probe
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
  2024-12-06 16:31 ` [PATCH v4 1/7] dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties André Draszik
  2024-12-06 16:31 ` [PATCH v4 2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-26 17:29   ` William McVicker
  2024-12-06 16:31 ` [PATCH v4 4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101) André Draszik
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik,
	Krzysztof Kozlowski

dev_err_probe() exists to simplify code.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v2:
* collect tags
---
 drivers/phy/samsung/phy-exynos5-usbdrd.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index c421b495eb0f..ceae4b47cece 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -1725,10 +1725,9 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 
 	reg_pmu = syscon_regmap_lookup_by_phandle(dev->of_node,
 						   "samsung,pmu-syscon");
-	if (IS_ERR(reg_pmu)) {
-		dev_err(dev, "Failed to lookup PMU regmap\n");
-		return PTR_ERR(reg_pmu);
-	}
+	if (IS_ERR(reg_pmu))
+		return dev_err_probe(dev, PTR_ERR(reg_pmu),
+				     "Failed to lookup PMU regmap\n");
 
 	/*
 	 * Exynos5420 SoC has multiple channels for USB 3.0 PHY, with
@@ -1759,10 +1758,9 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {
 		struct phy *phy = devm_phy_create(dev, NULL, drv_data->phy_ops);
 
-		if (IS_ERR(phy)) {
-			dev_err(dev, "Failed to create usbdrd_phy phy\n");
-			return PTR_ERR(phy);
-		}
+		if (IS_ERR(phy))
+			return dev_err_probe(dev, PTR_ERR(phy),
+					     "Failed to create usbdrd_phy phy\n");
 
 		phy_drd->phys[i].phy = phy;
 		phy_drd->phys[i].index = i;
@@ -1786,10 +1784,9 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 
 	phy_provider = devm_of_phy_provider_register(dev,
 						     exynos5_usbdrd_phy_xlate);
-	if (IS_ERR(phy_provider)) {
-		dev_err(phy_drd->dev, "Failed to register phy provider\n");
-		return PTR_ERR(phy_provider);
-	}
+	if (IS_ERR(phy_provider))
+		return dev_err_probe(phy_drd->dev, PTR_ERR(phy_provider),
+				     "Failed to register phy provider\n");
 
 	return 0;
 }

-- 
2.47.0.338.g60cca15819-goog



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

* [PATCH v4 4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101)
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (2 preceding siblings ...)
  2024-12-06 16:31 ` [PATCH v4 3/7] phy: exynos5-usbdrd: convert to dev_err_probe André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-26 17:31   ` William McVicker
  2024-12-06 16:31 ` [PATCH v4 5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation André Draszik
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik

This code's intention is to configure lane0 and lane2 tunings, but for
lane2 there is a typo and it ends up tuning something else.

Fix the typo, as it doesn't appear to make sense to apply different
tunings for lane0 vs lane2.

The same typo appears to exist in the bootloader, hence we restore the
original value in the typo'd registers as well. This can be removed
once / if the bootloader is updated.

Note that this is incorrect in the downstream driver as well - the
values had been copied from there.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Tested-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v2:
* collect tags
---
 drivers/phy/samsung/phy-exynos5-usbdrd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index ceae4b47cece..2a724d362c2d 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -1510,8 +1510,11 @@ static const struct exynos5_usbdrd_phy_tuning gs101_tunes_pipe3_preinit[] = {
 	PHY_TUNING_ENTRY_PMA(0x09e0, -1, 0x00),
 	PHY_TUNING_ENTRY_PMA(0x09e4, -1, 0x36),
 	PHY_TUNING_ENTRY_PMA(0x1e7c, -1, 0x06),
-	PHY_TUNING_ENTRY_PMA(0x1e90, -1, 0x00),
-	PHY_TUNING_ENTRY_PMA(0x1e94, -1, 0x36),
+	PHY_TUNING_ENTRY_PMA(0x19e0, -1, 0x00),
+	PHY_TUNING_ENTRY_PMA(0x19e4, -1, 0x36),
+	/* fix bootloader bug */
+	PHY_TUNING_ENTRY_PMA(0x1e90, -1, 0x02),
+	PHY_TUNING_ENTRY_PMA(0x1e94, -1, 0x0b),
 	/* improve LVCC */
 	PHY_TUNING_ENTRY_PMA(0x08f0, -1, 0x30),
 	PHY_TUNING_ENTRY_PMA(0x18f0, -1, 0x30),

-- 
2.47.0.338.g60cca15819-goog



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

* [PATCH v4 5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (3 preceding siblings ...)
  2024-12-06 16:31 ` [PATCH v4 4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101) André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-26 17:31   ` William McVicker
  2024-12-06 16:31 ` [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required André Draszik
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik

USB SS lanes need to be configured based on the connector orientation -
at most two lanes will be in use for USB (and the remaining two for
alternate modes like DP).

For the USB link to come up in SS, the lane configuration registers
have to be programmed accordingly.

While we still need a way to be notified of the actual connector
orientation and then reprogram the registers accordingly (at the moment
the configuration happens just once during phy_init() and never again),
we can prepare the code doing the configuration to take the orientation
into account.

Do so.

Note: the mutex is needed to synchronize this with the upcoming
connector orientation callback.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Tested-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v2:
* collect tags
* replace #include typec_mux.h with typec.h, and move the former into
  next patch (Peter)
* commit message typo (Peter)
---
 drivers/phy/samsung/phy-exynos5-usbdrd.c | 72 ++++++++++++++++++++++----------
 1 file changed, 51 insertions(+), 21 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index 2a724d362c2d..61e0de4b3d4b 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -23,6 +23,7 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/soc/samsung/exynos-regs-pmu.h>
+#include <linux/usb/typec.h>
 
 /* Exynos USB PHY registers */
 #define EXYNOS5_FSEL_9MHZ6		0x0
@@ -209,6 +210,10 @@
 
 #define EXYNOS9_PMA_USBDP_CMN_REG00B8		0x02e0
 #define CMN_REG00B8_LANE_MUX_SEL_DP		GENMASK(3, 0)
+#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE3	BIT(3)
+#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE2	BIT(2)
+#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE1	BIT(1)
+#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE0	BIT(0)
 
 #define EXYNOS9_PMA_USBDP_CMN_REG01C0		0x0700
 #define CMN_REG01C0_ANA_LCPLL_LOCK_DONE		BIT(7)
@@ -383,11 +388,13 @@ struct exynos5_usbdrd_phy_drvdata {
  * @clks: clocks for register access
  * @core_clks: core clocks for phy (ref, pipe3, utmi+, ITP, etc. as required)
  * @drv_data: pointer to SoC level driver data structure
+ * @phy_mutex: mutex protecting phy_init/exit & TCPC callbacks
  * @phys: array for 'EXYNOS5_DRDPHYS_NUM' number of PHY
  *	    instances each with its 'phy' and 'phy_cfg'.
  * @extrefclk: frequency select settings when using 'separate
  *	       reference clocks' for SS and HS operations
  * @regulators: regulators for phy
+ * @orientation: TypeC connector orientation - normal or flipped
  */
 struct exynos5_usbdrd_phy {
 	struct device *dev;
@@ -397,6 +404,7 @@ struct exynos5_usbdrd_phy {
 	struct clk_bulk_data *clks;
 	struct clk_bulk_data *core_clks;
 	const struct exynos5_usbdrd_phy_drvdata *drv_data;
+	struct mutex phy_mutex;
 	struct phy_usb_instance {
 		struct phy *phy;
 		u32 index;
@@ -406,6 +414,8 @@ struct exynos5_usbdrd_phy {
 	} phys[EXYNOS5_DRDPHYS_NUM];
 	u32 extrefclk;
 	struct regulator_bulk_data *regulators;
+
+	enum typec_orientation orientation;
 };
 
 static inline
@@ -647,22 +657,38 @@ exynos5_usbdrd_usbdp_g2_v4_pma_lane_mux_sel(struct exynos5_usbdrd_phy *phy_drd)
 	/* lane configuration: USB on all lanes */
 	reg = readl(regs_base + EXYNOS9_PMA_USBDP_CMN_REG00B8);
 	reg &= ~CMN_REG00B8_LANE_MUX_SEL_DP;
-	writel(reg, regs_base + EXYNOS9_PMA_USBDP_CMN_REG00B8);
-
 	/*
-	 * FIXME: below code supports one connector orientation only. It needs
-	 * updating once we can receive connector events.
+	 * USB on lanes 0 & 1 in normal mode, or 2 & 3 if reversed, DP on the
+	 * other ones.
 	 */
+	reg |= FIELD_PREP(CMN_REG00B8_LANE_MUX_SEL_DP,
+			  ((phy_drd->orientation == TYPEC_ORIENTATION_NORMAL)
+			   ? (CMN_REG00B8_LANE_MUX_SEL_DP_LANE3
+			      | CMN_REG00B8_LANE_MUX_SEL_DP_LANE2)
+			   : (CMN_REG00B8_LANE_MUX_SEL_DP_LANE1
+			      | CMN_REG00B8_LANE_MUX_SEL_DP_LANE0)));
+	writel(reg, regs_base + EXYNOS9_PMA_USBDP_CMN_REG00B8);
+
 	/* override of TX receiver detector and comparator: lane 1 */
 	reg = readl(regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0413);
-	reg &= ~TRSV_REG0413_OVRD_LN1_TX_RXD_COMP_EN;
-	reg &= ~TRSV_REG0413_OVRD_LN1_TX_RXD_EN;
+	if (phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) {
+		reg &= ~TRSV_REG0413_OVRD_LN1_TX_RXD_COMP_EN;
+		reg &= ~TRSV_REG0413_OVRD_LN1_TX_RXD_EN;
+	} else {
+		reg |= TRSV_REG0413_OVRD_LN1_TX_RXD_COMP_EN;
+		reg |= TRSV_REG0413_OVRD_LN1_TX_RXD_EN;
+	}
 	writel(reg, regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0413);
 
 	/* lane 3 */
 	reg = readl(regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0813);
-	reg |= TRSV_REG0813_OVRD_LN3_TX_RXD_COMP_EN;
-	reg |= TRSV_REG0813_OVRD_LN3_TX_RXD_EN;
+	if (phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) {
+		reg |= TRSV_REG0813_OVRD_LN3_TX_RXD_COMP_EN;
+		reg |= TRSV_REG0813_OVRD_LN3_TX_RXD_EN;
+	} else {
+		reg &= ~TRSV_REG0813_OVRD_LN3_TX_RXD_COMP_EN;
+		reg &= ~TRSV_REG0813_OVRD_LN3_TX_RXD_EN;
+	}
 	writel(reg, regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0813);
 }
 
@@ -700,21 +726,18 @@ exynos5_usbdrd_usbdp_g2_v4_pma_check_cdr_lock(struct exynos5_usbdrd_phy *phy_drd
 	int err;
 
 	err = readl_poll_timeout(
-			phy_drd->reg_pma + EXYNOS9_PMA_USBDP_TRSV_REG03C3,
-			reg, (reg & locked) == locked, sleep_us, timeout_us);
-	if (!err)
-		return;
-
-	dev_err(phy_drd->dev,
-		"timed out waiting for CDR lock (l0): %#.8x, retrying\n", reg);
-
-	/* based on cable orientation, this might be on the other phy port */
-	err = readl_poll_timeout(
-			phy_drd->reg_pma + EXYNOS9_PMA_USBDP_TRSV_REG07C3,
+			/* lane depends on cable orientation */
+			(phy_drd->reg_pma
+			 + ((phy_drd->orientation == TYPEC_ORIENTATION_NORMAL)
+			    ? EXYNOS9_PMA_USBDP_TRSV_REG03C3
+			    : EXYNOS9_PMA_USBDP_TRSV_REG07C3)),
 			reg, (reg & locked) == locked, sleep_us, timeout_us);
 	if (err)
 		dev_err(phy_drd->dev,
-			"timed out waiting for CDR lock (l2): %#.8x\n", reg);
+			"timed out waiting for CDR(l%d) lock: %#.8x\n",
+			((phy_drd->orientation == TYPEC_ORIENTATION_NORMAL)
+			 ? 0
+			 : 2), reg);
 }
 
 static void exynos5_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd)
@@ -1184,7 +1207,8 @@ static int exynos850_usbdrd_phy_init(struct phy *phy)
 		return ret;
 
 	/* UTMI or PIPE3 specific init */
-	inst->phy_cfg->phy_init(phy_drd);
+	scoped_guard(mutex, &phy_drd->phy_mutex)
+		inst->phy_cfg->phy_init(phy_drd);
 
 	clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks);
 
@@ -1203,6 +1227,8 @@ static int exynos850_usbdrd_phy_exit(struct phy *phy)
 	if (ret)
 		return ret;
 
+	guard(mutex)(&phy_drd->phy_mutex);
+
 	/* Set PHY clock and control HS PHY */
 	reg = readl(regs_base + EXYNOS850_DRD_UTMI);
 	reg &= ~(UTMI_DP_PULLDOWN | UTMI_DM_PULLDOWN);
@@ -1698,6 +1724,10 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 		return -EINVAL;
 	phy_drd->drv_data = drv_data;
 
+	ret = devm_mutex_init(dev, &phy_drd->phy_mutex);
+	if (ret)
+		return ret;
+
 	if (of_property_present(dev->of_node, "reg-names")) {
 		void __iomem *reg;
 

-- 
2.47.0.338.g60cca15819-goog



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

* [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (4 preceding siblings ...)
  2024-12-06 16:31 ` [PATCH v4 5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-07 21:31   ` Peter Griffin
                     ` (2 more replies)
  2024-12-06 16:31 ` [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+) André Draszik
                   ` (3 subsequent siblings)
  9 siblings, 3 replies; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik

gs101's SS phy needs to be configured differently based on the
connector orientation, as the SS link can only be established if the
mux is configured correctly.

The code to handle programming of the mux is in place already, this commit
now adds the missing pieces to subscribe to the Type-C orientation
switch event.

Note that for this all to work we rely on the USB controller
re-initialising us. It should invoke our .exit() upon cable unplug, and
during cable plug we'll receive the orientation event after which we
expect our .init() to be called.

Above reinitialisation happens if the DWC3 controller can enter runtime
suspend automatically. For the DWC3 driver, this is an opt-in:
    echo auto > /sys/devices/.../11110000.usb/power/control
Once done, things work as long as the UDC is not bound as otherwise it
stays busy because it doesn't cancel / stop outstanding TRBs. For now
we have to manually unbind the UDC in that case:
     echo "" > sys/kernel/config/usb_gadget/.../UDC

Note that if the orientation-switch property is missing from the DT,
the code will behave as before this commit (meaning for gs101 it will
work in SS mode in one orientation only). Other platforms are not
affected either way.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v3:
* drop init to -1 of phy_drd->orientation (Vinod)
* avoid #ifdef and switch to normal conditional IS_ENABLED() for
  CONFIG_TYPEC

v2:
* move #include typec_mux.h from parent patch into this one (Peter)
---
 drivers/phy/samsung/Kconfig              |  1 +
 drivers/phy/samsung/phy-exynos5-usbdrd.c | 56 ++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig
index f10afa3d7ff5..fc7bd1088576 100644
--- a/drivers/phy/samsung/Kconfig
+++ b/drivers/phy/samsung/Kconfig
@@ -80,6 +80,7 @@ config PHY_EXYNOS5_USBDRD
 	tristate "Exynos5 SoC series USB DRD PHY driver"
 	depends on (ARCH_EXYNOS && OF) || COMPILE_TEST
 	depends on HAS_IOMEM
+	depends on TYPEC || (TYPEC=n && COMPILE_TEST)
 	depends on USB_DWC3_EXYNOS
 	select GENERIC_PHY
 	select MFD_SYSCON
diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index 61e0de4b3d4b..8fc15847cfd8 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -24,6 +24,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/soc/samsung/exynos-regs-pmu.h>
 #include <linux/usb/typec.h>
+#include <linux/usb/typec_mux.h>
 
 /* Exynos USB PHY registers */
 #define EXYNOS5_FSEL_9MHZ6		0x0
@@ -394,6 +395,7 @@ struct exynos5_usbdrd_phy_drvdata {
  * @extrefclk: frequency select settings when using 'separate
  *	       reference clocks' for SS and HS operations
  * @regulators: regulators for phy
+ * @sw: TypeC orientation switch handle
  * @orientation: TypeC connector orientation - normal or flipped
  */
 struct exynos5_usbdrd_phy {
@@ -415,6 +417,7 @@ struct exynos5_usbdrd_phy {
 	u32 extrefclk;
 	struct regulator_bulk_data *regulators;
 
+	struct typec_switch_dev *sw;
 	enum typec_orientation orientation;
 };
 
@@ -1397,6 +1400,55 @@ static int exynos5_usbdrd_phy_clk_handle(struct exynos5_usbdrd_phy *phy_drd)
 	return 0;
 }
 
+static int exynos5_usbdrd_orien_sw_set(struct typec_switch_dev *sw,
+				       enum typec_orientation orientation)
+{
+	struct exynos5_usbdrd_phy *phy_drd = typec_switch_get_drvdata(sw);
+
+	scoped_guard(mutex, &phy_drd->phy_mutex)
+		phy_drd->orientation = orientation;
+
+	return 0;
+}
+
+static void exynos5_usbdrd_orien_switch_unregister(void *data)
+{
+	struct exynos5_usbdrd_phy *phy_drd = data;
+
+	typec_switch_unregister(phy_drd->sw);
+}
+
+static int exynos5_usbdrd_setup_notifiers(struct exynos5_usbdrd_phy *phy_drd)
+{
+	int ret;
+
+	if (!IS_ENABLED(CONFIG_TYPEC))
+		return 0;
+
+	if (device_property_present(phy_drd->dev, "orientation-switch")) {
+		struct typec_switch_desc sw_desc = { };
+
+		sw_desc.drvdata = phy_drd;
+		sw_desc.fwnode = dev_fwnode(phy_drd->dev);
+		sw_desc.set = exynos5_usbdrd_orien_sw_set;
+
+		phy_drd->sw = typec_switch_register(phy_drd->dev, &sw_desc);
+		if (IS_ERR(phy_drd->sw))
+			return dev_err_probe(phy_drd->dev,
+					     PTR_ERR(phy_drd->sw),
+					     "Failed to register TypeC orientation switch\n");
+
+		ret = devm_add_action_or_reset(phy_drd->dev,
+					       exynos5_usbdrd_orien_switch_unregister,
+					       phy_drd);
+		if (ret)
+			return dev_err_probe(phy_drd->dev, ret,
+					     "Failed to register TypeC orientation devm action\n");
+	}
+
+	return 0;
+}
+
 static const struct exynos5_usbdrd_phy_config phy_cfg_exynos5[] = {
 	{
 		.id		= EXYNOS5_DRDPHY_UTMI,
@@ -1786,6 +1838,10 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to get regulators\n");
 
+	ret = exynos5_usbdrd_setup_notifiers(phy_drd);
+	if (ret)
+		return ret;
+
 	dev_vdbg(dev, "Creating usbdrd_phy phy\n");
 
 	for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {

-- 
2.47.0.338.g60cca15819-goog



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

* [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (5 preceding siblings ...)
  2024-12-06 16:31 ` [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required André Draszik
@ 2024-12-06 16:31 ` André Draszik
  2024-12-07 22:03   ` Peter Griffin
  2024-12-26 17:34   ` William McVicker
  2024-12-26 17:28 ` [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) William McVicker
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 27+ messages in thread
From: André Draszik @ 2024-12-06 16:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, André Draszik

To make USB runtime suspend work when a UDC has been bound, the phy
needs to inform the USBDRD controller (DWC3) that Vbus and bvalid are
gone, so that it can in turn raise the respective gadget interrupt with
event == DWC3_DEVICE_EVENT_DISCONNECT, which will cause the USB stack
to clean up, allowing DWC3 to enter runtime suspend.

On e850 and gs101 this isn't working, as the respective signals are not
directly connected, and instead this driver uses override bits in the
PHY IP to set those signals. It currently forcefully sets them to 'on',
so the above mentioned interrupt will not be raised, preventing runtime
suspend.

To detect that state, update this driver to act on the TCPC's
orientation signal - when orientation == NONE, Vbus is gone and we can
clear the respective bits. Similarly, for other orientation values we
re-enable them.

This makes runtime suspend work on platforms with a TCPC (like Pixel6),
while keeping compatibility with platforms without (e850-96).

With runtime suspend working, USB-C cable orientation detection now
also fully works on such platforms, and the link comes up as Superspeed
as expected irrespective of the cable orientation and whether UDC /
gadget are configured and active.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v3:
* update exynos5_usbdrd_orien_sw_set() to not test against previous
  orientation
---
 drivers/phy/samsung/phy-exynos5-usbdrd.c | 50 +++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index 8fc15847cfd8..bac1dc927b26 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -1137,13 +1137,15 @@ static void exynos850_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd)
 	reg |= LINKCTRL_BUS_FILTER_BYPASS(0xf);
 	writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL);
 
-	reg = readl(regs_base + EXYNOS850_DRD_UTMI);
-	reg |= UTMI_FORCE_BVALID | UTMI_FORCE_VBUSVALID;
-	writel(reg, regs_base + EXYNOS850_DRD_UTMI);
-
-	reg = readl(regs_base + EXYNOS850_DRD_HSP);
-	reg |= HSP_VBUSVLDEXT | HSP_VBUSVLDEXTSEL;
-	writel(reg, regs_base + EXYNOS850_DRD_HSP);
+	if (!phy_drd->sw) {
+		reg = readl(regs_base + EXYNOS850_DRD_UTMI);
+		reg |= UTMI_FORCE_BVALID | UTMI_FORCE_VBUSVALID;
+		writel(reg, regs_base + EXYNOS850_DRD_UTMI);
+
+		reg = readl(regs_base + EXYNOS850_DRD_HSP);
+		reg |= HSP_VBUSVLDEXT | HSP_VBUSVLDEXTSEL;
+		writel(reg, regs_base + EXYNOS850_DRD_HSP);
+	}
 
 	reg = readl(regs_base + EXYNOS850_DRD_SSPPLLCTL);
 	reg &= ~SSPPLLCTL_FSEL;
@@ -1404,9 +1406,41 @@ static int exynos5_usbdrd_orien_sw_set(struct typec_switch_dev *sw,
 				       enum typec_orientation orientation)
 {
 	struct exynos5_usbdrd_phy *phy_drd = typec_switch_get_drvdata(sw);
+	int ret;
+
+	ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks);
+	if (ret) {
+		dev_err(phy_drd->dev, "Failed to enable PHY clocks(s)\n");
+		return ret;
+	}
+
+	scoped_guard(mutex, &phy_drd->phy_mutex) {
+		void __iomem * const regs_base = phy_drd->reg_phy;
+		unsigned int reg;
+
+		if (orientation == TYPEC_ORIENTATION_NONE) {
+			reg = readl(regs_base + EXYNOS850_DRD_UTMI);
+			reg &= ~(UTMI_FORCE_VBUSVALID | UTMI_FORCE_BVALID);
+			writel(reg, regs_base +  EXYNOS850_DRD_UTMI);
+
+			reg = readl(regs_base + EXYNOS850_DRD_HSP);
+			reg |= HSP_VBUSVLDEXTSEL;
+			reg &= ~HSP_VBUSVLDEXT;
+			writel(reg, regs_base + EXYNOS850_DRD_HSP);
+		} else {
+			reg = readl(regs_base + EXYNOS850_DRD_UTMI);
+			reg |= UTMI_FORCE_VBUSVALID | UTMI_FORCE_BVALID;
+			writel(reg, regs_base +  EXYNOS850_DRD_UTMI);
+
+			reg = readl(regs_base + EXYNOS850_DRD_HSP);
+			reg |= HSP_VBUSVLDEXTSEL | HSP_VBUSVLDEXT;
+			writel(reg, regs_base + EXYNOS850_DRD_HSP);
+		}
 
-	scoped_guard(mutex, &phy_drd->phy_mutex)
 		phy_drd->orientation = orientation;
+	}
+
+	clk_bulk_disable(phy_drd->drv_data->n_clks, phy_drd->clks);
 
 	return 0;
 }

-- 
2.47.0.338.g60cca15819-goog



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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2024-12-06 16:31 ` [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required André Draszik
@ 2024-12-07 21:31   ` Peter Griffin
  2024-12-11 17:55     ` Peter Griffin
  2024-12-26 17:33   ` William McVicker
  2025-02-14 19:30   ` Marek Szyprowski
  2 siblings, 1 reply; 27+ messages in thread
From: Peter Griffin @ 2024-12-07 21:31 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Tudor Ambarus, Sam Protsenko,
	Will McVicker, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

Hi André,

Firstly, thanks for all your work getting USB on Pixel 6 / gs101
working upstream :)

On Fri, 6 Dec 2024 at 16:31, André Draszik <andre.draszik@linaro.org> wrote:
>
> gs101's SS phy needs to be configured differently based on the
> connector orientation, as the SS link can only be established if the
> mux is configured correctly.
>
> The code to handle programming of the mux is in place already, this commit
> now adds the missing pieces to subscribe to the Type-C orientation
> switch event.
>
> Note that for this all to work we rely on the USB controller
> re-initialising us. It should invoke our .exit() upon cable unplug, and
> during cable plug we'll receive the orientation event after which we
> expect our .init() to be called.
>
> Above reinitialisation happens if the DWC3 controller can enter runtime
> suspend automatically. For the DWC3 driver, this is an opt-in:
>     echo auto > /sys/devices/.../11110000.usb/power/control
> Once done, things work as long as the UDC is not bound as otherwise it
> stays busy because it doesn't cancel / stop outstanding TRBs. For now
> we have to manually unbind the UDC in that case:
>      echo "" > sys/kernel/config/usb_gadget/.../UDC
>
> Note that if the orientation-switch property is missing from the DT,
> the code will behave as before this commit (meaning for gs101 it will
> work in SS mode in one orientation only). Other platforms are not
> affected either way.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Tested-by: Peter Griffin <peter.griffin@linaro.org>

Notes on testing:

I tested this series with the corresponding DT using a Pixel 6 device
with 2 different USB hubs and also plugging directly into my laptop.
I've tried various combinations of plugging / unplugging from both
ends of the USB cable and changing cable orientation. With the latest
series the disconnect/reconnect always seems robustly detected and
Pixel is enumerated as a USB device by the host, adb connection to the
phone is possible even with the cable orientation changing between
disconnect/reconnect.

One thing I did notice during testing is that in one cable orientation
Pixel is detected as a `SuperSpeed USB device` by the host and in the
other cable orientation it is detected as a `high-speed USB device`.
Which suggests there is still a latent bug in the phy
re-configuration. Although I think it is fine to fix this
incrementally, as prior to this series the other cable orientation
didn't work at all.

I just tested my personal Pixel 6 running the downstream production
drivers, and that is detected as a `SuperSpeed USB device` in both
cable orientations.

Thanks,

Peter


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

* Re: [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)
  2024-12-06 16:31 ` [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+) André Draszik
@ 2024-12-07 22:03   ` Peter Griffin
  2024-12-11 17:53     ` Peter Griffin
  2024-12-26 17:34   ` William McVicker
  1 sibling, 1 reply; 27+ messages in thread
From: Peter Griffin @ 2024-12-07 22:03 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Tudor Ambarus, Sam Protsenko,
	Will McVicker, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

Hi André,

On Fri, 6 Dec 2024 at 16:31, André Draszik <andre.draszik@linaro.org> wrote:
>
> To make USB runtime suspend work when a UDC has been bound, the phy
> needs to inform the USBDRD controller (DWC3) that Vbus and bvalid are
> gone, so that it can in turn raise the respective gadget interrupt with
> event == DWC3_DEVICE_EVENT_DISCONNECT, which will cause the USB stack
> to clean up, allowing DWC3 to enter runtime suspend.
>
> On e850 and gs101 this isn't working, as the respective signals are not
> directly connected, and instead this driver uses override bits in the
> PHY IP to set those signals. It currently forcefully sets them to 'on',
> so the above mentioned interrupt will not be raised, preventing runtime
> suspend.
>
> To detect that state, update this driver to act on the TCPC's
> orientation signal - when orientation == NONE, Vbus is gone and we can
> clear the respective bits. Similarly, for other orientation values we
> re-enable them.
>
> This makes runtime suspend work on platforms with a TCPC (like Pixel6),
> while keeping compatibility with platforms without (e850-96).
>
> With runtime suspend working, USB-C cable orientation detection now
> also fully works on such platforms, and the link comes up as Superspeed
> as expected irrespective of the cable orientation and whether UDC /
> gadget are configured and active.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

As mentioned on the last patch, in my testing cable orientation
detection is working, but Pixel is detected as a superspeed device in
one orientation, and high speed device in the other orientation. So
you should either change the wording of the last paragraph in the
commit message (assuming you get the same results as me) or make it
detect as superspeed in both orientations.

Thanks,

Peter.


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

* Re: [PATCH v4 2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties
  2024-12-06 16:31 ` [PATCH v4 2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties André Draszik
@ 2024-12-11 15:47   ` Rob Herring (Arm)
  0 siblings, 0 replies; 27+ messages in thread
From: Rob Herring (Arm) @ 2024-12-11 15:47 UTC (permalink / raw)
  To: André Draszik
  Cc: Roy Luo, Tudor Ambarus, Will McVicker, linux-phy,
	linux-arm-kernel, Alim Akhtar, Kishon Vijay Abraham I, devicetree,
	Peter Griffin, linux-samsung-soc, Sam Protsenko, Marek Szyprowski,
	Vinod Koul, Krzysztof Kozlowski, Sylwester Nawrocki, kernel-team,
	Conor Dooley, linux-kernel


On Fri, 06 Dec 2024 16:31:02 +0000, André Draszik wrote:
> orientation-switch is the standard declaration to inform the Type-C mux
> layer that a remote-endpoint is capable of processing orientation
> change messages.
> 
> The USB PHY on gs101 needs to be configured based on the orientation of
> the connector. For that the DTS needs a link between the phy's port and
> a TCPCi, and we'll need to inform the phy driver that it should handle
> the orientation (register a handler).
> 
> Update the schema to enforce that by requiring the orientation-switch
> and port properties on gs101 (only). We disallow orientation-switch on
> all other supported platforms, since other versions of this phy (or its
> system integration) don't currently support or even need it.
> 
> Even though this new required gs101 property is an ABI break, the
> intention for the driver is to behave as before if it's missing
> (meaning for gs101 it will work in SS mode in one orientation only).
> Other platforms are not affected.
> 
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> 
> ---
> v3:
> * update as per Rob's suggestion (I hope :-)
> 
> v2:
> * squash original patches #2 and #3
> * actually disallow orientation-switch on !gs101 (not just optional) (Conor)
> * update commit message to clarify that the intention for the driver is
>   to work with old and new DTS (Conor)
> * collect tags
> 
> foo
> ---
>  Documentation/devicetree/bindings/phy/samsung,usb3-drd-phy.yaml | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>



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

* Re: [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)
  2024-12-07 22:03   ` Peter Griffin
@ 2024-12-11 17:53     ` Peter Griffin
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Griffin @ 2024-12-11 17:53 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Tudor Ambarus, Sam Protsenko,
	Will McVicker, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

Hi André,

On Sat, 7 Dec 2024 at 22:03, Peter Griffin <peter.griffin@linaro.org> wrote:
>
> Hi André,
>
> On Fri, 6 Dec 2024 at 16:31, André Draszik <andre.draszik@linaro.org> wrote:
> >
> > To make USB runtime suspend work when a UDC has been bound, the phy
> > needs to inform the USBDRD controller (DWC3) that Vbus and bvalid are
> > gone, so that it can in turn raise the respective gadget interrupt with
> > event == DWC3_DEVICE_EVENT_DISCONNECT, which will cause the USB stack
> > to clean up, allowing DWC3 to enter runtime suspend.
> >
> > On e850 and gs101 this isn't working, as the respective signals are not
> > directly connected, and instead this driver uses override bits in the
> > PHY IP to set those signals. It currently forcefully sets them to 'on',
> > so the above mentioned interrupt will not be raised, preventing runtime
> > suspend.
> >
> > To detect that state, update this driver to act on the TCPC's
> > orientation signal - when orientation == NONE, Vbus is gone and we can
> > clear the respective bits. Similarly, for other orientation values we
> > re-enable them.
> >
> > This makes runtime suspend work on platforms with a TCPC (like Pixel6),
> > while keeping compatibility with platforms without (e850-96).
> >
> > With runtime suspend working, USB-C cable orientation detection now
> > also fully works on such platforms, and the link comes up as Superspeed
> > as expected irrespective of the cable orientation and whether UDC /
> > gadget are configured and active.
> >
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
>
> As mentioned on the last patch, in my testing cable orientation
> detection is working, but Pixel is detected as a superspeed device in
> one orientation, and high speed device in the other orientation. So
> you should either change the wording of the last paragraph in the
> commit message (assuming you get the same results as me) or make it
> detect as superspeed in both orientations.

You can disregard this point, I had a typo in my test setup :( I just
confirmed that it is detected as SuperSpeed in both orientations.

Thanks,

Peter


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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2024-12-07 21:31   ` Peter Griffin
@ 2024-12-11 17:55     ` Peter Griffin
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Griffin @ 2024-12-11 17:55 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Tudor Ambarus, Sam Protsenko,
	Will McVicker, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

Hi André,

On Sat, 7 Dec 2024 at 21:31, Peter Griffin <peter.griffin@linaro.org> wrote:
>
> Hi André,
>
> Firstly, thanks for all your work getting USB on Pixel 6 / gs101
> working upstream :)
>
> On Fri, 6 Dec 2024 at 16:31, André Draszik <andre.draszik@linaro.org> wrote:
> >
> > gs101's SS phy needs to be configured differently based on the
> > connector orientation, as the SS link can only be established if the
> > mux is configured correctly.
> >
> > The code to handle programming of the mux is in place already, this commit
> > now adds the missing pieces to subscribe to the Type-C orientation
> > switch event.
> >
> > Note that for this all to work we rely on the USB controller
> > re-initialising us. It should invoke our .exit() upon cable unplug, and
> > during cable plug we'll receive the orientation event after which we
> > expect our .init() to be called.
> >
> > Above reinitialisation happens if the DWC3 controller can enter runtime
> > suspend automatically. For the DWC3 driver, this is an opt-in:
> >     echo auto > /sys/devices/.../11110000.usb/power/control
> > Once done, things work as long as the UDC is not bound as otherwise it
> > stays busy because it doesn't cancel / stop outstanding TRBs. For now
> > we have to manually unbind the UDC in that case:
> >      echo "" > sys/kernel/config/usb_gadget/.../UDC
> >
> > Note that if the orientation-switch property is missing from the DT,
> > the code will behave as before this commit (meaning for gs101 it will
> > work in SS mode in one orientation only). Other platforms are not
> > affected either way.
> >
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
>
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Tested-by: Peter Griffin <peter.griffin@linaro.org>
>
> Notes on testing:
>
> I tested this series with the corresponding DT using a Pixel 6 device
> with 2 different USB hubs and also plugging directly into my laptop.
> I've tried various combinations of plugging / unplugging from both
> ends of the USB cable and changing cable orientation. With the latest
> series the disconnect/reconnect always seems robustly detected and
> Pixel is enumerated as a USB device by the host, adb connection to the
> phone is possible even with the cable orientation changing between
> disconnect/reconnect.
>
> One thing I did notice during testing is that in one cable orientation
> Pixel is detected as a `SuperSpeed USB device` by the host and in the
> other cable orientation it is detected as a `high-speed USB device`.
> Which suggests there is still a latent bug in the phy
> re-configuration.

You can disregard this last point, I had a typo in my test setup :( I
just confirmed that it is detected as SuperSpeed in both orientations.

Thanks,

Peter


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

* Re: [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm)
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (6 preceding siblings ...)
  2024-12-06 16:31 ` [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+) André Draszik
@ 2024-12-26 17:28 ` William McVicker
  2025-01-06 14:26 ` André Draszik
  2025-02-13 18:16 ` Vinod Koul
  9 siblings, 0 replies; 27+ messages in thread
From: William McVicker @ 2024-12-26 17:28 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Peter Griffin, Tudor Ambarus,
	Sam Protsenko, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc,
	Krzysztof Kozlowski

On 12/06/2024, André Draszik wrote:
> Hi,
> 
> This series enables USB3 Type-C lane orientation detection and
> configuration on platforms that support this (Google gs101), and it
> also allows the DWC3 core to enter runtime suspend even when UDC is
> active.
> 
> For lane orientation, this driver now optionally (based on DT)
> subscribes to the TCPC's lane orientation notifier and remembers the
> orientation to later be used during phy_init().
> 
> To enable DWC3 runtime suspend, the gadget needs to inform the core via
> dwc3_gadget_interrupt() with event type == DWC3_DEVICE_EVENT_DISCONNECT
> of a cable disconnect. For that to allow to happen, this driver
> therefore needs to stop forcing the Vbus and bvalid signals to active
> and instead change their state based on actual conditions. The same
> TCPC notifier is used to detect this, and program the hardware
> accordingly.
> 
> That signal state is based on advice given by Thinh in
> https://lore.kernel.org/all/20240813230625.jgkatqstyhcmpezv@synopsys.com/
> 
> Both changes together now allow cable orientation detection to work, as
> the DWC3 will now call phy_exit() on cable disconnect, and we can
> reprogram the lane mux in phy_init().
> 
> On top of that, there are some small related cleanup patches.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
> Changes in v4:
> - separate out patch 5 'phy: exynos5-usbdrd: gs101: ensure power is
>   gated to SS phy in phy_exit()' from this series, as a stable patch
>   shouldn't be buried inside a series like this (Greg)
>   Link: https://lore.kernel.org/all/20241205-gs101-usb-phy-fix-v4-1-0278809fb810@linaro.org/
> - Link to v3: https://lore.kernel.org/r/20241205-gs101-phy-lanes-orientation-phy-v3-0-32f721bed219@linaro.org
> 
> Changes in v3:
> - patches 1 & 2: update as per Rob's suggestions
> - patch 7 & 8: drop init to -1 of phy_drd->orientation (Vinod)
> - patch 7: avoid an #ifdef 
> - Link to v2: https://lore.kernel.org/r/20241203-gs101-phy-lanes-orientation-phy-v2-0-40dcf1b7670d@linaro.org
> 
> Changes in v2:
> - squash patches #2 and #3 from v1 to actually disallow
>   orientation-switch on !gs101 (not just optional) (Conor)
> - update bindings commit message to clarify that the intention for the
>   driver is to work with old and new DTS (Conor)
> - add cc-stable and fixes tags to power gating patch (Krzysztof)
> - fix an #include and typo (Peter)
> - Link to v1: https://lore.kernel.org/r/20241127-gs101-phy-lanes-orientation-phy-v1-0-1b7fce24960b@linaro.org
> 
> ---
> André Draszik (7):
>       dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties
>       dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties
>       phy: exynos5-usbdrd: convert to dev_err_probe
>       phy: exynos5-usbdrd: fix EDS distribution tuning (gs101)
>       phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation
>       phy: exynos5-usbdrd: subscribe to orientation notifier if required
>       phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)
> 
>  .../bindings/phy/samsung,usb3-drd-phy.yaml         |  21 ++-
>  drivers/phy/samsung/Kconfig                        |   1 +
>  drivers/phy/samsung/phy-exynos5-usbdrd.c           | 202 ++++++++++++++++-----
>  3 files changed, 182 insertions(+), 42 deletions(-)
> ---
> base-commit: c245a7a79602ccbee780c004c1e4abcda66aec32
> change-id: 20241127-gs101-phy-lanes-orientation-phy-29d20c6d84d2
> 
> Best regards,
> -- 
> André Draszik <andre.draszik@linaro.org>
> 

Thanks Andre for getting this working! I've tested this on my Pixel 6 Pro.
I was able to verify runtime PM works in both orientations with high-speed,
super-speed, and super-speed-plus. Feel free to include:

Tested-by: Will McVicker <willmcvicker@google.com>

Thanks,
Will


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

* Re: [PATCH v4 3/7] phy: exynos5-usbdrd: convert to dev_err_probe
  2024-12-06 16:31 ` [PATCH v4 3/7] phy: exynos5-usbdrd: convert to dev_err_probe André Draszik
@ 2024-12-26 17:29   ` William McVicker
  0 siblings, 0 replies; 27+ messages in thread
From: William McVicker @ 2024-12-26 17:29 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Peter Griffin, Tudor Ambarus,
	Sam Protsenko, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc,
	Krzysztof Kozlowski

On 12/06/2024, André Draszik wrote:
> dev_err_probe() exists to simplify code.
> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Tested-by: Will McVicker <willmcvicker@google.com>

Thanks,
Will

<snip>


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

* Re: [PATCH v4 4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101)
  2024-12-06 16:31 ` [PATCH v4 4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101) André Draszik
@ 2024-12-26 17:31   ` William McVicker
  0 siblings, 0 replies; 27+ messages in thread
From: William McVicker @ 2024-12-26 17:31 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Peter Griffin, Tudor Ambarus,
	Sam Protsenko, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

On 12/06/2024, André Draszik wrote:
> This code's intention is to configure lane0 and lane2 tunings, but for
> lane2 there is a typo and it ends up tuning something else.
> 
> Fix the typo, as it doesn't appear to make sense to apply different
> tunings for lane0 vs lane2.
> 
> The same typo appears to exist in the bootloader, hence we restore the
> original value in the typo'd registers as well. This can be removed
> once / if the bootloader is updated.
> 
> Note that this is incorrect in the downstream driver as well - the
> values had been copied from there.
> 
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Tested-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Verified on my Pixel 6 Pro.

Tested-by: Will McVicker <willmcvicker@google.com>

Thanks,
Will

<snip>


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

* Re: [PATCH v4 5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation
  2024-12-06 16:31 ` [PATCH v4 5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation André Draszik
@ 2024-12-26 17:31   ` William McVicker
  0 siblings, 0 replies; 27+ messages in thread
From: William McVicker @ 2024-12-26 17:31 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Peter Griffin, Tudor Ambarus,
	Sam Protsenko, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

On 12/06/2024, André Draszik wrote:
> USB SS lanes need to be configured based on the connector orientation -
> at most two lanes will be in use for USB (and the remaining two for
> alternate modes like DP).
> 
> For the USB link to come up in SS, the lane configuration registers
> have to be programmed accordingly.
> 
> While we still need a way to be notified of the actual connector
> orientation and then reprogram the registers accordingly (at the moment
> the configuration happens just once during phy_init() and never again),
> we can prepare the code doing the configuration to take the orientation
> into account.
> 
> Do so.
> 
> Note: the mutex is needed to synchronize this with the upcoming
> connector orientation callback.
> 
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Tested-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Verified on my Pixel 6 Pro.

Tested-by: Will McVicker <willmcvicker@google.com>

Thanks,
Will

<snip>


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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2024-12-06 16:31 ` [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required André Draszik
  2024-12-07 21:31   ` Peter Griffin
@ 2024-12-26 17:33   ` William McVicker
  2025-02-14 19:30   ` Marek Szyprowski
  2 siblings, 0 replies; 27+ messages in thread
From: William McVicker @ 2024-12-26 17:33 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Peter Griffin, Tudor Ambarus,
	Sam Protsenko, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

On 12/06/2024, André Draszik wrote:
> gs101's SS phy needs to be configured differently based on the
> connector orientation, as the SS link can only be established if the
> mux is configured correctly.
> 
> The code to handle programming of the mux is in place already, this commit
> now adds the missing pieces to subscribe to the Type-C orientation
> switch event.
> 
> Note that for this all to work we rely on the USB controller
> re-initialising us. It should invoke our .exit() upon cable unplug, and
> during cable plug we'll receive the orientation event after which we
> expect our .init() to be called.
> 
> Above reinitialisation happens if the DWC3 controller can enter runtime
> suspend automatically. For the DWC3 driver, this is an opt-in:
>     echo auto > /sys/devices/.../11110000.usb/power/control
> Once done, things work as long as the UDC is not bound as otherwise it
> stays busy because it doesn't cancel / stop outstanding TRBs. For now
> we have to manually unbind the UDC in that case:
>      echo "" > sys/kernel/config/usb_gadget/.../UDC
> 
> Note that if the orientation-switch property is missing from the DT,
> the code will behave as before this commit (meaning for gs101 it will
> work in SS mode in one orientation only). Other platforms are not
> affected either way.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Verified on my Pixel 6 Pro.

Tested-by: Will McVicker <willmcvicker@google.com>

Thanks,
Will

<snip>


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

* Re: [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)
  2024-12-06 16:31 ` [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+) André Draszik
  2024-12-07 22:03   ` Peter Griffin
@ 2024-12-26 17:34   ` William McVicker
  1 sibling, 0 replies; 27+ messages in thread
From: William McVicker @ 2024-12-26 17:34 UTC (permalink / raw)
  To: André Draszik
  Cc: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar, Peter Griffin, Tudor Ambarus,
	Sam Protsenko, Roy Luo, kernel-team, linux-phy, devicetree,
	linux-kernel, linux-arm-kernel, linux-samsung-soc

On 12/06/2024, André Draszik wrote:
> To make USB runtime suspend work when a UDC has been bound, the phy
> needs to inform the USBDRD controller (DWC3) that Vbus and bvalid are
> gone, so that it can in turn raise the respective gadget interrupt with
> event == DWC3_DEVICE_EVENT_DISCONNECT, which will cause the USB stack
> to clean up, allowing DWC3 to enter runtime suspend.
> 
> On e850 and gs101 this isn't working, as the respective signals are not
> directly connected, and instead this driver uses override bits in the
> PHY IP to set those signals. It currently forcefully sets them to 'on',
> so the above mentioned interrupt will not be raised, preventing runtime
> suspend.
> 
> To detect that state, update this driver to act on the TCPC's
> orientation signal - when orientation == NONE, Vbus is gone and we can
> clear the respective bits. Similarly, for other orientation values we
> re-enable them.
> 
> This makes runtime suspend work on platforms with a TCPC (like Pixel6),
> while keeping compatibility with platforms without (e850-96).
> 
> With runtime suspend working, USB-C cable orientation detection now
> also fully works on such platforms, and the link comes up as Superspeed
> as expected irrespective of the cable orientation and whether UDC /
> gadget are configured and active.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Verified on my Pixel 6 Pro.

Tested-by: Will McVicker <willmcvicker@google.com>

Thanks,
Will

<snip>


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

* Re: [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm)
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (7 preceding siblings ...)
  2024-12-26 17:28 ` [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) William McVicker
@ 2025-01-06 14:26 ` André Draszik
  2025-02-13  6:59   ` André Draszik
  2025-02-13 18:16 ` Vinod Koul
  9 siblings, 1 reply; 27+ messages in thread
From: André Draszik @ 2025-01-06 14:26 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, Krzysztof Kozlowski

Hi Vinod,

On Fri, 2024-12-06 at 16:31 +0000, André Draszik wrote:
> Hi,
> 
> This series enables USB3 Type-C lane orientation detection and
> configuration on platforms that support this (Google gs101), and it
> also allows the DWC3 core to enter runtime suspend even when UDC is
> active.

Friendly ping on this series :-) Do you require anything else?

Cheers,
Andre'



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

* Re: [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm)
  2025-01-06 14:26 ` André Draszik
@ 2025-02-13  6:59   ` André Draszik
  0 siblings, 0 replies; 27+ messages in thread
From: André Draszik @ 2025-02-13  6:59 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Marek Szyprowski,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, Krzysztof Kozlowski

Hi Vinod,

On Mon, 2025-01-06 at 14:26 +0000, André Draszik wrote:
> Hi Vinod,
> 
> On Fri, 2024-12-06 at 16:31 +0000, André Draszik wrote:
> > Hi,
> > 
> > This series enables USB3 Type-C lane orientation detection and
> > configuration on platforms that support this (Google gs101), and it
> > also allows the DWC3 core to enter runtime suspend even when UDC is
> > active.
> 
> Friendly ping on this series :-) Do you require anything else?

Ping again :-)

Cheers,
Andre'



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

* Re: [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm)
  2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
                   ` (8 preceding siblings ...)
  2025-01-06 14:26 ` André Draszik
@ 2025-02-13 18:16 ` Vinod Koul
  9 siblings, 0 replies; 27+ messages in thread
From: Vinod Koul @ 2025-02-13 18:16 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Marek Szyprowski, Sylwester Nawrocki, Alim Akhtar,
	André Draszik
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc, Krzysztof Kozlowski


On Fri, 06 Dec 2024 16:31:00 +0000, André Draszik wrote:
> This series enables USB3 Type-C lane orientation detection and
> configuration on platforms that support this (Google gs101), and it
> also allows the DWC3 core to enter runtime suspend even when UDC is
> active.
> 
> For lane orientation, this driver now optionally (based on DT)
> subscribes to the TCPC's lane orientation notifier and remembers the
> orientation to later be used during phy_init().
> 
> [...]

Applied, thanks!

[1/7] dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties
      commit: 642b1ed4cd184d5c2e5814c220bb93453492644d
[2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties
      commit: c38528812c2e9b05fe8b5fd1f66cf4c75835a38e
[3/7] phy: exynos5-usbdrd: convert to dev_err_probe
      commit: ee064390b82329df7fd8e0c48da03a8fee7d46ce
[4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101)
      commit: 21860f340ba76ee042e5431ff92537f89bc11476
[5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation
      commit: 0bccdcb3eea93e087887027ff374dac5c3de36cd
[6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
      commit: 09dc674295a388e71192430b6f9c3c5cb0eb47da
[7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)
      commit: f4fb9c4d7f94dabef4abf2209cf840dd1c9ca11e

Best regards,
-- 
~Vinod




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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2024-12-06 16:31 ` [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required André Draszik
  2024-12-07 21:31   ` Peter Griffin
  2024-12-26 17:33   ` William McVicker
@ 2025-02-14 19:30   ` Marek Szyprowski
  2025-02-15  9:24     ` Krzysztof Kozlowski
  2025-02-15 10:07     ` Krzysztof Kozlowski
  2 siblings, 2 replies; 27+ messages in thread
From: Marek Szyprowski @ 2025-02-14 19:30 UTC (permalink / raw)
  To: André Draszik, Vinod Koul, Kishon Vijay Abraham I,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc

On 06.12.2024 17:31, André Draszik wrote:
> gs101's SS phy needs to be configured differently based on the
> connector orientation, as the SS link can only be established if the
> mux is configured correctly.
>
> The code to handle programming of the mux is in place already, this commit
> now adds the missing pieces to subscribe to the Type-C orientation
> switch event.
>
> Note that for this all to work we rely on the USB controller
> re-initialising us. It should invoke our .exit() upon cable unplug, and
> during cable plug we'll receive the orientation event after which we
> expect our .init() to be called.
>
> Above reinitialisation happens if the DWC3 controller can enter runtime
> suspend automatically. For the DWC3 driver, this is an opt-in:
>      echo auto > /sys/devices/.../11110000.usb/power/control
> Once done, things work as long as the UDC is not bound as otherwise it
> stays busy because it doesn't cancel / stop outstanding TRBs. For now
> we have to manually unbind the UDC in that case:
>       echo "" > sys/kernel/config/usb_gadget/.../UDC
>
> Note that if the orientation-switch property is missing from the DT,
> the code will behave as before this commit (meaning for gs101 it will
> work in SS mode in one orientation only). Other platforms are not
> affected either way.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>
> ---
> v3:
> * drop init to -1 of phy_drd->orientation (Vinod)
> * avoid #ifdef and switch to normal conditional IS_ENABLED() for
>    CONFIG_TYPEC
>
> v2:
> * move #include typec_mux.h from parent patch into this one (Peter)
> ---
>   drivers/phy/samsung/Kconfig              |  1 +
>   drivers/phy/samsung/phy-exynos5-usbdrd.c | 56 ++++++++++++++++++++++++++++++++
>   2 files changed, 57 insertions(+)
>
> diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig
> index f10afa3d7ff5..fc7bd1088576 100644
> --- a/drivers/phy/samsung/Kconfig
> +++ b/drivers/phy/samsung/Kconfig
> @@ -80,6 +80,7 @@ config PHY_EXYNOS5_USBDRD
>   	tristate "Exynos5 SoC series USB DRD PHY driver"
>   	depends on (ARCH_EXYNOS && OF) || COMPILE_TEST
>   	depends on HAS_IOMEM
> +	depends on TYPEC || (TYPEC=n && COMPILE_TEST)
>   	depends on USB_DWC3_EXYNOS
>   	select GENERIC_PHY
>   	select MFD_SYSCON

I've just noticed that the above disables Exynos DRD PHY driver in the 
default exynos_defconfig for arm 32bit. Enabling CONFIG_TYPEC is 
exynos_defconfig probably is the easiest way to fix this. I will send a 
patch then.

> diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> index 61e0de4b3d4b..8fc15847cfd8 100644
> --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
> +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> @@ -24,6 +24,7 @@
>   #include <linux/regulator/consumer.h>
>   #include <linux/soc/samsung/exynos-regs-pmu.h>
>   #include <linux/usb/typec.h>
> +#include <linux/usb/typec_mux.h>
>   
>   /* Exynos USB PHY registers */
>   #define EXYNOS5_FSEL_9MHZ6		0x0
> @@ -394,6 +395,7 @@ struct exynos5_usbdrd_phy_drvdata {
>    * @extrefclk: frequency select settings when using 'separate
>    *	       reference clocks' for SS and HS operations
>    * @regulators: regulators for phy
> + * @sw: TypeC orientation switch handle
>    * @orientation: TypeC connector orientation - normal or flipped
>    */
>   struct exynos5_usbdrd_phy {
> @@ -415,6 +417,7 @@ struct exynos5_usbdrd_phy {
>   	u32 extrefclk;
>   	struct regulator_bulk_data *regulators;
>   
> +	struct typec_switch_dev *sw;
>   	enum typec_orientation orientation;
>   };
>   
> @@ -1397,6 +1400,55 @@ static int exynos5_usbdrd_phy_clk_handle(struct exynos5_usbdrd_phy *phy_drd)
>   	return 0;
>   }
>   
> +static int exynos5_usbdrd_orien_sw_set(struct typec_switch_dev *sw,
> +				       enum typec_orientation orientation)
> +{
> +	struct exynos5_usbdrd_phy *phy_drd = typec_switch_get_drvdata(sw);
> +
> +	scoped_guard(mutex, &phy_drd->phy_mutex)
> +		phy_drd->orientation = orientation;
> +
> +	return 0;
> +}
> +
> +static void exynos5_usbdrd_orien_switch_unregister(void *data)
> +{
> +	struct exynos5_usbdrd_phy *phy_drd = data;
> +
> +	typec_switch_unregister(phy_drd->sw);
> +}
> +
> +static int exynos5_usbdrd_setup_notifiers(struct exynos5_usbdrd_phy *phy_drd)
> +{
> +	int ret;
> +
> +	if (!IS_ENABLED(CONFIG_TYPEC))
> +		return 0;
> +
> +	if (device_property_present(phy_drd->dev, "orientation-switch")) {
> +		struct typec_switch_desc sw_desc = { };
> +
> +		sw_desc.drvdata = phy_drd;
> +		sw_desc.fwnode = dev_fwnode(phy_drd->dev);
> +		sw_desc.set = exynos5_usbdrd_orien_sw_set;
> +
> +		phy_drd->sw = typec_switch_register(phy_drd->dev, &sw_desc);
> +		if (IS_ERR(phy_drd->sw))
> +			return dev_err_probe(phy_drd->dev,
> +					     PTR_ERR(phy_drd->sw),
> +					     "Failed to register TypeC orientation switch\n");
> +
> +		ret = devm_add_action_or_reset(phy_drd->dev,
> +					       exynos5_usbdrd_orien_switch_unregister,
> +					       phy_drd);
> +		if (ret)
> +			return dev_err_probe(phy_drd->dev, ret,
> +					     "Failed to register TypeC orientation devm action\n");
> +	}
> +
> +	return 0;
> +}
> +
>   static const struct exynos5_usbdrd_phy_config phy_cfg_exynos5[] = {
>   	{
>   		.id		= EXYNOS5_DRDPHY_UTMI,
> @@ -1786,6 +1838,10 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
>   	if (ret)
>   		return dev_err_probe(dev, ret, "failed to get regulators\n");
>   
> +	ret = exynos5_usbdrd_setup_notifiers(phy_drd);
> +	if (ret)
> +		return ret;
> +
>   	dev_vdbg(dev, "Creating usbdrd_phy phy\n");
>   
>   	for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) {
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland



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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2025-02-14 19:30   ` Marek Szyprowski
@ 2025-02-15  9:24     ` Krzysztof Kozlowski
  2025-02-15  9:34       ` Krzysztof Kozlowski
  2025-02-15 10:07     ` Krzysztof Kozlowski
  1 sibling, 1 reply; 27+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-15  9:24 UTC (permalink / raw)
  To: Marek Szyprowski, André Draszik, Vinod Koul,
	Kishon Vijay Abraham I, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc

On 14/02/2025 20:30, Marek Szyprowski wrote:
> On 06.12.2024 17:31, André Draszik wrote:
>> gs101's SS phy needs to be configured differently based on the
>> connector orientation, as the SS link can only be established if the
>> mux is configured correctly.
>>
>> The code to handle programming of the mux is in place already, this commit
>> now adds the missing pieces to subscribe to the Type-C orientation
>> switch event.
>>
>> Note that for this all to work we rely on the USB controller
>> re-initialising us. It should invoke our .exit() upon cable unplug, and
>> during cable plug we'll receive the orientation event after which we
>> expect our .init() to be called.
>>
>> Above reinitialisation happens if the DWC3 controller can enter runtime
>> suspend automatically. For the DWC3 driver, this is an opt-in:
>>      echo auto > /sys/devices/.../11110000.usb/power/control
>> Once done, things work as long as the UDC is not bound as otherwise it
>> stays busy because it doesn't cancel / stop outstanding TRBs. For now
>> we have to manually unbind the UDC in that case:
>>       echo "" > sys/kernel/config/usb_gadget/.../UDC
>>
>> Note that if the orientation-switch property is missing from the DT,
>> the code will behave as before this commit (meaning for gs101 it will
>> work in SS mode in one orientation only). Other platforms are not
>> affected either way.
>>
>> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>>
>> ---
>> v3:
>> * drop init to -1 of phy_drd->orientation (Vinod)
>> * avoid #ifdef and switch to normal conditional IS_ENABLED() for
>>    CONFIG_TYPEC
>>
>> v2:
>> * move #include typec_mux.h from parent patch into this one (Peter)
>> ---
>>   drivers/phy/samsung/Kconfig              |  1 +
>>   drivers/phy/samsung/phy-exynos5-usbdrd.c | 56 ++++++++++++++++++++++++++++++++
>>   2 files changed, 57 insertions(+)
>>
>> diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig
>> index f10afa3d7ff5..fc7bd1088576 100644
>> --- a/drivers/phy/samsung/Kconfig
>> +++ b/drivers/phy/samsung/Kconfig
>> @@ -80,6 +80,7 @@ config PHY_EXYNOS5_USBDRD
>>   	tristate "Exynos5 SoC series USB DRD PHY driver"
>>   	depends on (ARCH_EXYNOS && OF) || COMPILE_TEST
>>   	depends on HAS_IOMEM
>> +	depends on TYPEC || (TYPEC=n && COMPILE_TEST)
>>   	depends on USB_DWC3_EXYNOS
>>   	select GENERIC_PHY
>>   	select MFD_SYSCON


So that explains why on recent next some of my boards don't boot. I was
about to dig over the weekend.

> 
> I've just noticed that the above disables Exynos DRD PHY driver in the 
> default exynos_defconfig for arm 32bit. Enabling CONFIG_TYPEC is 
> exynos_defconfig probably is the easiest way to fix this. I will send a 
> patch then.

No, it's just wrong. Nothing here depends on typec and ARMv7 does not
have Typec.

Best regards,
Krzysztof


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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2025-02-15  9:24     ` Krzysztof Kozlowski
@ 2025-02-15  9:34       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 27+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-15  9:34 UTC (permalink / raw)
  To: Marek Szyprowski, André Draszik, Vinod Koul,
	Kishon Vijay Abraham I, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc

On 15/02/2025 10:24, Krzysztof Kozlowski wrote:
> On 14/02/2025 20:30, Marek Szyprowski wrote:
>> On 06.12.2024 17:31, André Draszik wrote:
>>> gs101's SS phy needs to be configured differently based on the
>>> connector orientation, as the SS link can only be established if the
>>> mux is configured correctly.
>>>
>>> The code to handle programming of the mux is in place already, this commit
>>> now adds the missing pieces to subscribe to the Type-C orientation
>>> switch event.
>>>
>>> Note that for this all to work we rely on the USB controller
>>> re-initialising us. It should invoke our .exit() upon cable unplug, and
>>> during cable plug we'll receive the orientation event after which we
>>> expect our .init() to be called.
>>>
>>> Above reinitialisation happens if the DWC3 controller can enter runtime
>>> suspend automatically. For the DWC3 driver, this is an opt-in:
>>>      echo auto > /sys/devices/.../11110000.usb/power/control
>>> Once done, things work as long as the UDC is not bound as otherwise it
>>> stays busy because it doesn't cancel / stop outstanding TRBs. For now
>>> we have to manually unbind the UDC in that case:
>>>       echo "" > sys/kernel/config/usb_gadget/.../UDC
>>>
>>> Note that if the orientation-switch property is missing from the DT,
>>> the code will behave as before this commit (meaning for gs101 it will
>>> work in SS mode in one orientation only). Other platforms are not
>>> affected either way.
>>>
>>> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>>>
>>> ---
>>> v3:
>>> * drop init to -1 of phy_drd->orientation (Vinod)
>>> * avoid #ifdef and switch to normal conditional IS_ENABLED() for
>>>    CONFIG_TYPEC
>>>
>>> v2:
>>> * move #include typec_mux.h from parent patch into this one (Peter)
>>> ---
>>>   drivers/phy/samsung/Kconfig              |  1 +
>>>   drivers/phy/samsung/phy-exynos5-usbdrd.c | 56 ++++++++++++++++++++++++++++++++
>>>   2 files changed, 57 insertions(+)
>>>
>>> diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig
>>> index f10afa3d7ff5..fc7bd1088576 100644
>>> --- a/drivers/phy/samsung/Kconfig
>>> +++ b/drivers/phy/samsung/Kconfig
>>> @@ -80,6 +80,7 @@ config PHY_EXYNOS5_USBDRD
>>>   	tristate "Exynos5 SoC series USB DRD PHY driver"
>>>   	depends on (ARCH_EXYNOS && OF) || COMPILE_TEST
>>>   	depends on HAS_IOMEM
>>> +	depends on TYPEC || (TYPEC=n && COMPILE_TEST)
>>>   	depends on USB_DWC3_EXYNOS
>>>   	select GENERIC_PHY
>>>   	select MFD_SYSCON
> 
> 
> So that explains why on recent next some of my boards don't boot. I was
> about to dig over the weekend.
> 
>>
>> I've just noticed that the above disables Exynos DRD PHY driver in the 
>> default exynos_defconfig for arm 32bit. Enabling CONFIG_TYPEC is 
>> exynos_defconfig probably is the easiest way to fix this. I will send a 
>> patch then.
> 
> No, it's just wrong. Nothing here depends on typec and ARMv7 does not
> have Typec.
> 
I'll send a fix for this.

Best regards,
Krzysztof


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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2025-02-14 19:30   ` Marek Szyprowski
  2025-02-15  9:24     ` Krzysztof Kozlowski
@ 2025-02-15 10:07     ` Krzysztof Kozlowski
  2025-02-15 16:09       ` André Draszik
  1 sibling, 1 reply; 27+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-15 10:07 UTC (permalink / raw)
  To: Marek Szyprowski, André Draszik, Vinod Koul,
	Kishon Vijay Abraham I, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc

On 14/02/2025 20:30, Marek Szyprowski wrote:
> On 06.12.2024 17:31, André Draszik wrote:
>> gs101's SS phy needs to be configured differently based on the
>> connector orientation, as the SS link can only be established if the
>> mux is configured correctly.
>>
>> The code to handle programming of the mux is in place already, this commit
>> now adds the missing pieces to subscribe to the Type-C orientation
>> switch event.
>>
>> Note that for this all to work we rely on the USB controller
>> re-initialising us. It should invoke our .exit() upon cable unplug, and
>> during cable plug we'll receive the orientation event after which we
>> expect our .init() to be called.
>>
>> Above reinitialisation happens if the DWC3 controller can enter runtime
>> suspend automatically. For the DWC3 driver, this is an opt-in:
>>      echo auto > /sys/devices/.../11110000.usb/power/control
>> Once done, things work as long as the UDC is not bound as otherwise it
>> stays busy because it doesn't cancel / stop outstanding TRBs. For now
>> we have to manually unbind the UDC in that case:
>>       echo "" > sys/kernel/config/usb_gadget/.../UDC
>>
>> Note that if the orientation-switch property is missing from the DT,
>> the code will behave as before this commit (meaning for gs101 it will
>> work in SS mode in one orientation only). Other platforms are not
>> affected either way.
>>
>> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>>
>> ---
>> v3:
>> * drop init to -1 of phy_drd->orientation (Vinod)
>> * avoid #ifdef and switch to normal conditional IS_ENABLED() for
>>    CONFIG_TYPEC
>>
>> v2:
>> * move #include typec_mux.h from parent patch into this one (Peter)
>> ---
>>   drivers/phy/samsung/Kconfig              |  1 +
>>   drivers/phy/samsung/phy-exynos5-usbdrd.c | 56 ++++++++++++++++++++++++++++++++
>>   2 files changed, 57 insertions(+)
>>
>> diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig
>> index f10afa3d7ff5..fc7bd1088576 100644
>> --- a/drivers/phy/samsung/Kconfig
>> +++ b/drivers/phy/samsung/Kconfig
>> @@ -80,6 +80,7 @@ config PHY_EXYNOS5_USBDRD
>>   	tristate "Exynos5 SoC series USB DRD PHY driver"
>>   	depends on (ARCH_EXYNOS && OF) || COMPILE_TEST
>>   	depends on HAS_IOMEM
>> +	depends on TYPEC || (TYPEC=n && COMPILE_TEST)

BTW, this syntax never made any sense - it did not work. The optional
dependency is expressed as:
	depends on TYPEC || !TYPEC

but what it epxressed is that it is possible to build it without typec
only for compile test, which is odd if this was meant to be optional.
And further code:
	if (!IS_ENABLED(CONFIG_TYPEC))

clearly suggests this should be optional.


Best regards,
Krzysztof


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

* Re: [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required
  2025-02-15 10:07     ` Krzysztof Kozlowski
@ 2025-02-15 16:09       ` André Draszik
  0 siblings, 0 replies; 27+ messages in thread
From: André Draszik @ 2025-02-15 16:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Marek Szyprowski, Vinod Koul,
	Kishon Vijay Abraham I, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Sylwester Nawrocki, Alim Akhtar
  Cc: Peter Griffin, Tudor Ambarus, Sam Protsenko, Will McVicker,
	Roy Luo, kernel-team, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, linux-samsung-soc

Hi Krzysztof,

On Sat, 2025-02-15 at 11:07 +0100, Krzysztof Kozlowski wrote:
> On 14/02/2025 20:30, Marek Szyprowski wrote:
> > On 06.12.2024 17:31, André Draszik wrote:
> > > gs101's SS phy needs to be configured differently based on the
> > > connector orientation, as the SS link can only be established if the
> > > mux is configured correctly.
> > > 
> > > The code to handle programming of the mux is in place already, this commit
> > > now adds the missing pieces to subscribe to the Type-C orientation
> > > switch event.
> > > 
> > > Note that for this all to work we rely on the USB controller
> > > re-initialising us. It should invoke our .exit() upon cable unplug, and
> > > during cable plug we'll receive the orientation event after which we
> > > expect our .init() to be called.
> > > 
> > > Above reinitialisation happens if the DWC3 controller can enter runtime
> > > suspend automatically. For the DWC3 driver, this is an opt-in:
> > >      echo auto > /sys/devices/.../11110000.usb/power/control
> > > Once done, things work as long as the UDC is not bound as otherwise it
> > > stays busy because it doesn't cancel / stop outstanding TRBs. For now
> > > we have to manually unbind the UDC in that case:
> > >       echo "" > sys/kernel/config/usb_gadget/.../UDC
> > > 
> > > Note that if the orientation-switch property is missing from the DT,
> > > the code will behave as before this commit (meaning for gs101 it will
> > > work in SS mode in one orientation only). Other platforms are not
> > > affected either way.
> > > 
> > > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > > 
> > > ---
> > > v3:
> > > * drop init to -1 of phy_drd->orientation (Vinod)
> > > * avoid #ifdef and switch to normal conditional IS_ENABLED() for
> > >    CONFIG_TYPEC
> > > 
> > > v2:
> > > * move #include typec_mux.h from parent patch into this one (Peter)
> > > ---
> > >   drivers/phy/samsung/Kconfig              |  1 +
> > >   drivers/phy/samsung/phy-exynos5-usbdrd.c | 56 ++++++++++++++++++++++++++++++++
> > >   2 files changed, 57 insertions(+)
> > > 
> > > diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig
> > > index f10afa3d7ff5..fc7bd1088576 100644
> > > --- a/drivers/phy/samsung/Kconfig
> > > +++ b/drivers/phy/samsung/Kconfig
> > > @@ -80,6 +80,7 @@ config PHY_EXYNOS5_USBDRD
> > >   	tristate "Exynos5 SoC series USB DRD PHY driver"
> > >   	depends on (ARCH_EXYNOS && OF) || COMPILE_TEST
> > >   	depends on HAS_IOMEM
> > > +	depends on TYPEC || (TYPEC=n && COMPILE_TEST)
> 
> BTW, this syntax never made any sense - it did not work. The optional
> dependency is expressed as:
> 	depends on TYPEC || !TYPEC

The depends is required to get it to link. PHY_EXYNOS5_USBDRD
defaults to Y, while TYPEC defaults to M in the arm64 defconfig.
Using this expression, PHY_EXYNOS5_USBDRD changes to M.

Otherwise it won't link.


> but what it epxressed is that it is possible to build it without typec
> only for compile test, which is odd if this was meant to be optional.
> And further code:
> 	if (!IS_ENABLED(CONFIG_TYPEC))
> 
> clearly suggests this should be optional.

Yes, it's meant to be optional.

Cheers,
Andre'



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

end of thread, other threads:[~2025-02-15 16:11 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-06 16:31 [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) André Draszik
2024-12-06 16:31 ` [PATCH v4 1/7] dt-bindings: phy: samsung,usb3-drd-phy: add blank lines between DT properties André Draszik
2024-12-06 16:31 ` [PATCH v4 2/7] dt-bindings: phy: samsung,usb3-drd-phy: gs101: require Type-C properties André Draszik
2024-12-11 15:47   ` Rob Herring (Arm)
2024-12-06 16:31 ` [PATCH v4 3/7] phy: exynos5-usbdrd: convert to dev_err_probe André Draszik
2024-12-26 17:29   ` William McVicker
2024-12-06 16:31 ` [PATCH v4 4/7] phy: exynos5-usbdrd: fix EDS distribution tuning (gs101) André Draszik
2024-12-26 17:31   ` William McVicker
2024-12-06 16:31 ` [PATCH v4 5/7] phy: exynos5-usbdrd: gs101: configure SS lanes based on orientation André Draszik
2024-12-26 17:31   ` William McVicker
2024-12-06 16:31 ` [PATCH v4 6/7] phy: exynos5-usbdrd: subscribe to orientation notifier if required André Draszik
2024-12-07 21:31   ` Peter Griffin
2024-12-11 17:55     ` Peter Griffin
2024-12-26 17:33   ` William McVicker
2025-02-14 19:30   ` Marek Szyprowski
2025-02-15  9:24     ` Krzysztof Kozlowski
2025-02-15  9:34       ` Krzysztof Kozlowski
2025-02-15 10:07     ` Krzysztof Kozlowski
2025-02-15 16:09       ` André Draszik
2024-12-06 16:31 ` [PATCH v4 7/7] phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+) André Draszik
2024-12-07 22:03   ` Peter Griffin
2024-12-11 17:53     ` Peter Griffin
2024-12-26 17:34   ` William McVicker
2024-12-26 17:28 ` [PATCH v4 0/7] USB31DRD phy updates for Google Tensor gs101 (orientation & DWC3 rpm) William McVicker
2025-01-06 14:26 ` André Draszik
2025-02-13  6:59   ` André Draszik
2025-02-13 18:16 ` Vinod Koul

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