linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] usb: misc: usb3503: support usb3803 and bypass mode
@ 2023-03-13 16:50 Francesco Dolcini
  2023-03-13 16:50 ` [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803 Francesco Dolcini
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Francesco Dolcini @ 2023-03-13 16:50 UTC (permalink / raw)
  To: linux-usb; +Cc: Francesco Dolcini, linux-kernel, Greg Kroah-Hartman

From: Francesco Dolcini <francesco.dolcini@toradex.com>

Add support for USB3803 and bypass mode.

While the usb3503 variant uses a HSIC connection to upstream, the usb3803 uses
a regular USB connection and provides a bypass mode.

In bypass mode the downstream port 3 is connected to the upstream port with low
switch resistance R_on.

Controlling mode of operations:

| RESET_N | BYPASS_N | Mode    |
--------------------------------
|    0    |    0     | standby |
|    1    |    0     | bypass  |
|    1    |    1     | hub     |


Emanuele Ghidoli (3):
  dt-bindings: usb: smsc,usb3503: Add usb3803
  usb: misc: usb3503: refactor code to prepare for usb3803 addition
  usb: misc: usb3503: support usb3803 and bypass mode

 .../devicetree/bindings/usb/smsc,usb3503.yaml | 54 +++++++++++++++-
 drivers/usb/misc/usb3503.c                    | 64 +++++++++++--------
 include/linux/platform_data/usb3503.h         |  1 +
 3 files changed, 92 insertions(+), 27 deletions(-)

-- 
2.25.1


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

* [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803
  2023-03-13 16:50 [PATCH v1 0/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini
@ 2023-03-13 16:50 ` Francesco Dolcini
  2023-03-14  8:59   ` Krzysztof Kozlowski
  2023-03-13 16:50 ` [PATCH v1 2/3] usb: misc: usb3503: refactor code to prepare for usb3803 addition Francesco Dolcini
  2023-03-13 16:50 ` [PATCH v1 3/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini
  2 siblings, 1 reply; 5+ messages in thread
From: Francesco Dolcini @ 2023-03-13 16:50 UTC (permalink / raw)
  To: linux-usb, devicetree
  Cc: Emanuele Ghidoli, linux-kernel, Greg Kroah-Hartman, Rob Herring,
	Krzysztof Kozlowski, Dongjin Kim, Francesco Dolcini

From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>

Add support for usb3803, compared to usb3503 it uses a regular USB
connection to upstream instead of HSIC, it has an additional
low power mode (bypass) and an additional control signal (BYPASS_N).

In bypass mode the downstream port 3 is connected to the upstream port
with low switch resistance R_on.

Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
 .../devicetree/bindings/usb/smsc,usb3503.yaml | 54 ++++++++++++++++++-
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml b/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml
index a09f4528aea3..6156dc26e65c 100644
--- a/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml
+++ b/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml
@@ -14,6 +14,7 @@ properties:
     enum:
       - smsc,usb3503
       - smsc,usb3503a
+      - smsc,usb3803
 
   reg:
     maxItems: 1
@@ -33,6 +34,12 @@ properties:
     description: >
       GPIO for reset
 
+  bypass-gpios:
+    maxItems: 1
+    description: >
+      GPIO for bypass.
+      Control signal to select between HUB MODE and BYPASS MODE.
+
   disabled-ports:
     $ref: /schemas/types.yaml#/definitions/uint32-array
     minItems: 1
@@ -46,9 +53,10 @@ properties:
 
   initial-mode:
     $ref: /schemas/types.yaml#/definitions/uint32
-    enum: [1, 2]
     description: >
-      Specifies initial mode. 1 for Hub mode, 2 for standby mode.
+      Specifies initial mode. 1 for Hub mode, 2 for standby mode and 3 for bypass mode.
+      In bypass mode the downstream port 3 is connected to the upstream port with low
+      switch resistance R_on.
 
   clocks:
     maxItems: 1
@@ -71,6 +79,29 @@ properties:
 required:
   - compatible
 
+allOf:
+  - if:
+      not:
+        properties:
+          compatible:
+            enum:
+              - smsc,usb3803
+    then:
+      properties:
+        bypass-gpios: false
+
+  - if:
+      required:
+        - bypass-gpios
+    then:
+      properties:
+        initial-mode:
+          enum: [1, 2, 3]
+    else:
+      properties:
+        initial-mode:
+          enum: [1, 2]
+
 additionalProperties: false
 
 examples:
@@ -92,6 +123,25 @@ examples:
           };
       };
 
+  - |
+      i2c {
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          usb-hub@8 {
+              compatible = "smsc,usb3803";
+              reg = <0x08>;
+              connect-gpios = <&gpx3 0 1>;
+              disabled-ports = <2 3>;
+              intn-gpios = <&gpx3 4 1>;
+              reset-gpios = <&gpx3 5 1>;
+              bypass-gpios = <&gpx3 6 1>;
+              initial-mode = <3>;
+              clocks = <&clks 80>;
+              clock-names = "refclk";
+          };
+      };
+
   - |
       #include <dt-bindings/gpio/gpio.h>
 
-- 
2.25.1


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

* [PATCH v1 2/3] usb: misc: usb3503: refactor code to prepare for usb3803 addition
  2023-03-13 16:50 [PATCH v1 0/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini
  2023-03-13 16:50 ` [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803 Francesco Dolcini
@ 2023-03-13 16:50 ` Francesco Dolcini
  2023-03-13 16:50 ` [PATCH v1 3/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini
  2 siblings, 0 replies; 5+ messages in thread
From: Francesco Dolcini @ 2023-03-13 16:50 UTC (permalink / raw)
  To: linux-usb
  Cc: Emanuele Ghidoli, linux-kernel, Greg Kroah-Hartman, Francesco Dolcini

From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>

Refactor code to simplify adding support for USB3803 and bypass mode.

Remove static usb3503_reset() and move it to usb3503_switch_mode(),
with the addition of the bypass mode we need to drive the various
control signals to the expected configuration, not just to
assert/release the reset.

In addition to that the usb3503_connect() needs to be called only
for HUB mode.

No functional changes expected nor intended because of this change.

Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
 drivers/usb/misc/usb3503.c | 44 ++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index bd47c4437ca4..3044db9fd8aa 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -52,28 +52,11 @@ struct usb3503 {
 	bool	secondary_ref_clk;
 };
 
-static int usb3503_reset(struct usb3503 *hub, int state)
-{
-	if (!state && hub->connect)
-		gpiod_set_value_cansleep(hub->connect, 0);
-
-	if (hub->reset)
-		gpiod_set_value_cansleep(hub->reset, !state);
-
-	/* Wait T_HUBINIT == 4ms for hub logic to stabilize */
-	if (state)
-		usleep_range(4000, 10000);
-
-	return 0;
-}
-
 static int usb3503_connect(struct usb3503 *hub)
 {
 	struct device *dev = hub->dev;
 	int err;
 
-	usb3503_reset(hub, 1);
-
 	if (hub->regmap) {
 		/* SP_ILOCK: set connect_n, config_n for config */
 		err = regmap_write(hub->regmap, USB3503_SP_ILOCK,
@@ -126,25 +109,36 @@ static int usb3503_connect(struct usb3503 *hub)
 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode)
 {
 	struct device *dev = hub->dev;
-	int err = 0;
+	int rst, conn;
 
 	switch (mode) {
 	case USB3503_MODE_HUB:
-		err = usb3503_connect(hub);
+		conn = 1;
+		rst = 0;
 		break;
-
 	case USB3503_MODE_STANDBY:
-		usb3503_reset(hub, 0);
+		conn = 0;
+		rst = 1;
 		dev_info(dev, "switched to STANDBY mode\n");
 		break;
-
 	default:
 		dev_err(dev, "unknown mode is requested\n");
-		err = -EINVAL;
-		break;
+		return -EINVAL;
 	}
 
-	return err;
+	if (!conn && hub->connect)
+		gpiod_set_value_cansleep(hub->connect, 0);
+
+	if (hub->reset)
+		gpiod_set_value_cansleep(hub->reset, rst);
+
+	if (conn) {
+		/* Wait T_HUBINIT == 4ms for hub logic to stabilize */
+		usleep_range(4000, 10000);
+		return usb3503_connect(hub);
+	}
+
+	return 0;
 }
 
 static const struct regmap_config usb3503_regmap_config = {
-- 
2.25.1


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

* [PATCH v1 3/3] usb: misc: usb3503: support usb3803 and bypass mode
  2023-03-13 16:50 [PATCH v1 0/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini
  2023-03-13 16:50 ` [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803 Francesco Dolcini
  2023-03-13 16:50 ` [PATCH v1 2/3] usb: misc: usb3503: refactor code to prepare for usb3803 addition Francesco Dolcini
@ 2023-03-13 16:50 ` Francesco Dolcini
  2 siblings, 0 replies; 5+ messages in thread
From: Francesco Dolcini @ 2023-03-13 16:50 UTC (permalink / raw)
  To: linux-usb
  Cc: Emanuele Ghidoli, linux-kernel, Greg Kroah-Hartman, Francesco Dolcini

From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>

Add support for USB3803 and bypass mode, with this change
is also possible to move the component out of bypass mode.

In bypass mode the downstream port 3 is connected to the
upstream port with low switch resistance R_on.

Controlling mode of operations:

| RESET_N | BYPASS_N | Mode    |
--------------------------------
|    0    |    0     | standby |
|    1    |    0     | bypass  |
|    1    |    1     | hub     |

Datasheet: https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/DataSheets/00001691D.pdf
Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
 drivers/usb/misc/usb3503.c            | 22 +++++++++++++++++++++-
 include/linux/platform_data/usb3503.h |  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index 3044db9fd8aa..c6cfd1edaf76 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -46,6 +46,7 @@ struct usb3503 {
 	struct device		*dev;
 	struct clk		*clk;
 	u8	port_off_mask;
+	struct gpio_desc	*bypass;
 	struct gpio_desc	*intn;
 	struct gpio_desc 	*reset;
 	struct gpio_desc 	*connect;
@@ -109,18 +110,25 @@ static int usb3503_connect(struct usb3503 *hub)
 static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode)
 {
 	struct device *dev = hub->dev;
-	int rst, conn;
+	int rst, bypass, conn;
 
 	switch (mode) {
 	case USB3503_MODE_HUB:
 		conn = 1;
 		rst = 0;
+		bypass = 0;
 		break;
 	case USB3503_MODE_STANDBY:
 		conn = 0;
 		rst = 1;
+		bypass = 1;
 		dev_info(dev, "switched to STANDBY mode\n");
 		break;
+	case USB3503_MODE_BYPASS:
+		conn = 0;
+		rst = 0;
+		bypass = 1;
+		break;
 	default:
 		dev_err(dev, "unknown mode is requested\n");
 		return -EINVAL;
@@ -132,6 +140,9 @@ static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode)
 	if (hub->reset)
 		gpiod_set_value_cansleep(hub->reset, rst);
 
+	if (hub->bypass)
+		gpiod_set_value_cansleep(hub->bypass, bypass);
+
 	if (conn) {
 		/* Wait T_HUBINIT == 4ms for hub logic to stabilize */
 		usleep_range(4000, 10000);
@@ -247,6 +258,14 @@ static int usb3503_probe(struct usb3503 *hub)
 	if (hub->connect)
 		gpiod_set_consumer_name(hub->connect, "usb3503 connect");
 
+	hub->bypass = devm_gpiod_get_optional(dev, "bypass", GPIOD_OUT_HIGH);
+	if (IS_ERR(hub->bypass)) {
+		err = PTR_ERR(hub->bypass);
+		goto err_clk;
+	}
+	if (hub->bypass)
+		gpiod_set_consumer_name(hub->bypass, "usb3503 bypass");
+
 	hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(hub->reset)) {
 		err = PTR_ERR(hub->reset);
@@ -382,6 +401,7 @@ MODULE_DEVICE_TABLE(i2c, usb3503_id);
 static const struct of_device_id usb3503_of_match[] = {
 	{ .compatible = "smsc,usb3503", },
 	{ .compatible = "smsc,usb3503a", },
+	{ .compatible = "smsc,usb3803", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, usb3503_of_match);
diff --git a/include/linux/platform_data/usb3503.h b/include/linux/platform_data/usb3503.h
index d01ef97ddf36..f3c942f396f8 100644
--- a/include/linux/platform_data/usb3503.h
+++ b/include/linux/platform_data/usb3503.h
@@ -12,6 +12,7 @@ enum usb3503_mode {
 	USB3503_MODE_UNKNOWN,
 	USB3503_MODE_HUB,
 	USB3503_MODE_STANDBY,
+	USB3503_MODE_BYPASS,
 };
 
 struct usb3503_platform_data {
-- 
2.25.1


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

* Re: [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803
  2023-03-13 16:50 ` [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803 Francesco Dolcini
@ 2023-03-14  8:59   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2023-03-14  8:59 UTC (permalink / raw)
  To: Francesco Dolcini, linux-usb, devicetree
  Cc: Emanuele Ghidoli, linux-kernel, Greg Kroah-Hartman, Rob Herring,
	Krzysztof Kozlowski, Dongjin Kim, Francesco Dolcini

On 13/03/2023 17:50, Francesco Dolcini wrote:
> From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
> 
> Add support for usb3803, compared to usb3503 it uses a regular USB
> connection to upstream instead of HSIC, it has an additional
> low power mode (bypass) and an additional control signal (BYPASS_N).
> 
> In bypass mode the downstream port 3 is connected to the upstream port
> with low switch resistance R_on.
> 
> Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


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

end of thread, other threads:[~2023-03-14  8:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 16:50 [PATCH v1 0/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini
2023-03-13 16:50 ` [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803 Francesco Dolcini
2023-03-14  8:59   ` Krzysztof Kozlowski
2023-03-13 16:50 ` [PATCH v1 2/3] usb: misc: usb3503: refactor code to prepare for usb3803 addition Francesco Dolcini
2023-03-13 16:50 ` [PATCH v1 3/3] usb: misc: usb3503: support usb3803 and bypass mode Francesco Dolcini

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