linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support
@ 2023-06-07  8:04 Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation Neil Armstrong
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:04 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong, Krzysztof Kozlowski

This adds the missing bits to support the USB-C Altmode
support on SM8550.

These are the following changes since the previous SM8450 SoC:
- No more GLINK altmode events for USB only changes, only DP
- Type-C orientation is available on a PMIC signal connected
  to a GPIO line
- When altmode is disconnected, an 0xff mode event is sent.

In order to handle those changes, a new orientation-gpios property
is added to the usb-c connector bindings.
The 0xff altomode is translated as a SAFE type-c mux mode.

And in order to handle such info, we tie this to the UCSI connector
events to propagate the orientation to Type-C switches.

Redriver driver & bindings dependency at [1].

[1] https://lore.kernel.org/all/20230601-topic-sm8x50-upstream-redriver-v2-0-dda89b22b1c0@linaro.org/

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
Changes in v2:
- Updated redriver node to use retimer-switch on QRD
- Fixed redriver data-lane according to v2 bindings
- Added review/ack tags
- Added new change to handle retimer-switch in pmic-glink altmode driver
- Link to v1: https://lore.kernel.org/r/20230601-topic-sm8550-upstream-type-c-v1-0-d4d97b4d8bab@linaro.org

---
Neil Armstrong (8):
      dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation
      soc: qcom: pmic_glink_altmode: handle safe mode when disconnect
      usb: ucsi: glink: use the connector orientation GPIO to provide switch events
      qcom: pmic_glink_altmode: add retimer-switch support
      qcom: pmic_glink: enable altmode for SM8550
      arm64: dts: qcom: sm8550: add ports subnodes in usb/dp qmpphy node
      arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints
      arm64: dts: qcom: sm8550-qrd: add pmic glink port/endpoints

 .../bindings/connector/usb-connector.yaml          |  5 ++
 arch/arm64/boot/dts/qcom/sm8550-mtp.dts            | 67 ++++++++++++++-
 arch/arm64/boot/dts/qcom/sm8550-qrd.dts            | 99 +++++++++++++++++++++-
 arch/arm64/boot/dts/qcom/sm8550.dtsi               | 26 ++++++
 drivers/soc/qcom/pmic_glink.c                      |  6 +-
 drivers/soc/qcom/pmic_glink_altmode.c              | 61 ++++++++++++-
 drivers/usb/typec/ucsi/ucsi_glink.c                | 52 +++++++++++-
 7 files changed, 305 insertions(+), 11 deletions(-)
---
base-commit: 54bfdd3bfe0f13da0bcf6e720d0ec0020a89b4dc
change-id: 20230601-topic-sm8550-upstream-type-c-e85b4d971450

Best regards,
-- 
Neil Armstrong <neil.armstrong@linaro.org>


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

* [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-08 15:47   ` Rob Herring
  2023-06-07  8:05 ` [PATCH v2 2/8] soc: qcom: pmic_glink_altmode: handle safe mode when disconnect Neil Armstrong
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong, Krzysztof Kozlowski

On some platforms, the Type-C plug orientation is given on a GPIO line.

Document this optional Type-C connector property, and take the
assumption an active level represents an inverted/flipped orientation.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 Documentation/devicetree/bindings/connector/usb-connector.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
index ae515651fc6b..c3884eed6ba4 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
+++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
@@ -114,6 +114,11 @@ properties:
     description: Set this property if the Type-C connector has no power delivery support.
     type: boolean
 
+  orientation-gpios:
+    description: An input gpio for Type-C connector orientation, used to detect orientation
+      of the Type-C connector. GPIO active level means "CC2" or Reversed/Flipped orientation.
+    maxItems: 1
+
   # The following are optional properties for "usb-c-connector" with power
   # delivery support.
   source-pdos:

-- 
2.34.1


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

* [PATCH v2 2/8] soc: qcom: pmic_glink_altmode: handle safe mode when disconnect
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 3/8] usb: ucsi: glink: use the connector orientation GPIO to provide switch events Neil Armstrong
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

On some Qcom SoCs, the Altmode event mode is set to 0xff when
the Type-C port is disconnected.

Handle this specific mode and translate it as the SAFE mode.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/soc/qcom/pmic_glink_altmode.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
index df48fbea4b68..007d308e2f15 100644
--- a/drivers/soc/qcom/pmic_glink_altmode.c
+++ b/drivers/soc/qcom/pmic_glink_altmode.c
@@ -173,6 +173,20 @@ static void pmic_glink_altmode_enable_usb(struct pmic_glink_altmode *altmode,
 		dev_err(altmode->dev, "failed to switch mux to USB\n");
 }
 
+static void pmic_glink_altmode_safe(struct pmic_glink_altmode *altmode,
+				    struct pmic_glink_altmode_port *port)
+{
+	int ret;
+
+	port->state.alt = NULL;
+	port->state.data = NULL;
+	port->state.mode = TYPEC_STATE_SAFE;
+
+	ret = typec_mux_set(port->typec_mux, &port->state);
+	if (ret)
+		dev_err(altmode->dev, "failed to switch mux to safe mode\n");
+}
+
 static void pmic_glink_altmode_worker(struct work_struct *work)
 {
 	struct pmic_glink_altmode_port *alt_port = work_to_altmode_port(work);
@@ -180,7 +194,9 @@ static void pmic_glink_altmode_worker(struct work_struct *work)
 
 	typec_switch_set(alt_port->typec_switch, alt_port->orientation);
 
-	if (alt_port->svid == USB_TYPEC_DP_SID)
+	if (alt_port->svid == USB_TYPEC_DP_SID && alt_port->mode == 0xff)
+		pmic_glink_altmode_safe(altmode, alt_port);
+	else if (alt_port->svid == USB_TYPEC_DP_SID)
 		pmic_glink_altmode_enable_dp(altmode, alt_port, alt_port->mode,
 					     alt_port->hpd_state, alt_port->hpd_irq);
 	else

-- 
2.34.1


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

* [PATCH v2 3/8] usb: ucsi: glink: use the connector orientation GPIO to provide switch events
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 2/8] soc: qcom: pmic_glink_altmode: handle safe mode when disconnect Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 4/8] qcom: pmic_glink_altmode: add retimer-switch support Neil Armstrong
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

On SM8550, the non-altmode orientation is not given anymore within
altmode events, even with USB SVIDs events.

On the other side, the Type-C connector orientation is correctly
reported by a signal from the PMIC.

Take this gpio signal when we detect some Type-C port activity
to notify any Type-C switches tied to the Type-C port connectors.

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/usb/typec/ucsi/ucsi_glink.c | 52 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index 1fe9cb5b6bd9..88491dbff7e3 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -9,9 +9,13 @@
 #include <linux/mutex.h>
 #include <linux/property.h>
 #include <linux/soc/qcom/pdr.h>
+#include <linux/usb/typec_mux.h>
+#include <linux/gpio/consumer.h>
 #include <linux/soc/qcom/pmic_glink.h>
 #include "ucsi.h"
 
+#define PMIC_GLINK_MAX_PORTS	2
+
 #define UCSI_BUF_SIZE                   48
 
 #define MSG_TYPE_REQ_RESP               1
@@ -53,6 +57,9 @@ struct ucsi_notify_ind_msg {
 struct pmic_glink_ucsi {
 	struct device *dev;
 
+	struct gpio_desc *port_orientation[PMIC_GLINK_MAX_PORTS];
+	struct typec_switch *port_switch[PMIC_GLINK_MAX_PORTS];
+
 	struct pmic_glink_client *client;
 
 	struct ucsi *ucsi;
@@ -221,8 +228,20 @@ static void pmic_glink_ucsi_notify(struct work_struct *work)
 	}
 
 	con_num = UCSI_CCI_CONNECTOR(cci);
-	if (con_num)
+	if (con_num) {
+		if (con_num < PMIC_GLINK_MAX_PORTS &&
+		    ucsi->port_orientation[con_num - 1]) {
+			int orientation = gpiod_get_value(ucsi->port_orientation[con_num - 1]);
+
+			if (orientation >= 0) {
+				typec_switch_set(ucsi->port_switch[con_num - 1],
+						 orientation ? TYPEC_ORIENTATION_REVERSE
+							     : TYPEC_ORIENTATION_NORMAL);
+			}
+		}
+
 		ucsi_connector_change(ucsi->ucsi, con_num);
+	}
 
 	if (ucsi->sync_pending && cci & UCSI_CCI_BUSY) {
 		ucsi->sync_val = -EBUSY;
@@ -283,6 +302,7 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
 {
 	struct pmic_glink_ucsi *ucsi;
 	struct device *dev = &adev->dev;
+	struct fwnode_handle *fwnode;
 	int ret;
 
 	ucsi = devm_kzalloc(dev, sizeof(*ucsi), GFP_KERNEL);
@@ -310,6 +330,36 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
 
 	ucsi_set_drvdata(ucsi->ucsi, ucsi);
 
+	device_for_each_child_node(dev, fwnode) {
+		u32 port;
+
+		ret = fwnode_property_read_u32(fwnode, "reg", &port);
+		if (ret < 0) {
+			dev_err(dev, "missing reg property of %pOFn\n", fwnode);
+			return ret;
+		}
+
+		if (port >= PMIC_GLINK_MAX_PORTS) {
+			dev_warn(dev, "invalid connector number, ignoring\n");
+			continue;
+		}
+
+		ucsi->port_orientation[port] = devm_fwnode_gpiod_get(&adev->dev, fwnode,
+								     "orientation",
+								     GPIOD_IN, NULL);
+		if (IS_ERR(ucsi->port_orientation[port]))
+			return dev_err_probe(dev, PTR_ERR(ucsi->port_orientation[port]),
+					     "unable to acquire orientation gpio\n");
+
+		if (!ucsi->port_orientation[port])
+			continue;
+
+		ucsi->port_switch[port] = fwnode_typec_switch_get(fwnode);
+		if (IS_ERR(ucsi->port_switch[port]))
+			return dev_err_probe(dev, PTR_ERR(ucsi->port_switch[port]),
+					"failed to acquire orientation-switch\n");
+	}
+
 	ucsi->client = devm_pmic_glink_register_client(dev,
 						       PMIC_GLINK_OWNER_USBC,
 						       pmic_glink_ucsi_callback,

-- 
2.34.1


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

* [PATCH v2 4/8] qcom: pmic_glink_altmode: add retimer-switch support
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
                   ` (2 preceding siblings ...)
  2023-06-07  8:05 ` [PATCH v2 3/8] usb: ucsi: glink: use the connector orientation GPIO to provide switch events Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 5/8] qcom: pmic_glink: enable altmode for SM8550 Neil Armstrong
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

Some boards have a retimer/redriver between the SuperSpeed
PHY and the USB-C connector to compensates signal integrity
losses mainly due to PCB & transmission cables.

Add support for an optional retimer-switch in the USB-C
connector graph.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/soc/qcom/pmic_glink_altmode.c | 43 +++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
index 007d308e2f15..41d732f5b647 100644
--- a/drivers/soc/qcom/pmic_glink_altmode.c
+++ b/drivers/soc/qcom/pmic_glink_altmode.c
@@ -15,6 +15,7 @@
 #include <linux/usb/typec_altmode.h>
 #include <linux/usb/typec_dp.h>
 #include <linux/usb/typec_mux.h>
+#include <linux/usb/typec_retimer.h>
 
 #include <linux/soc/qcom/pmic_glink.h>
 
@@ -68,6 +69,8 @@ struct pmic_glink_altmode_port {
 	struct typec_switch *typec_switch;
 	struct typec_mux *typec_mux;
 	struct typec_mux_state state;
+	struct typec_retimer *typec_retimer;
+	struct typec_retimer_state retimer_state;
 	struct typec_altmode dp_alt;
 
 	struct work_struct work;
@@ -157,6 +160,14 @@ static void pmic_glink_altmode_enable_dp(struct pmic_glink_altmode *altmode,
 	ret = typec_mux_set(port->typec_mux, &port->state);
 	if (ret)
 		dev_err(altmode->dev, "failed to switch mux to DP\n");
+
+	port->retimer_state.alt = &port->dp_alt;
+	port->retimer_state.data = &dp_data;
+	port->retimer_state.mode = TYPEC_MODAL_STATE(mode);
+
+	ret = typec_retimer_set(port->typec_retimer, &port->retimer_state);
+	if (ret)
+		dev_err(altmode->dev, "failed to setup retimer to DP\n");
 }
 
 static void pmic_glink_altmode_enable_usb(struct pmic_glink_altmode *altmode,
@@ -171,6 +182,14 @@ static void pmic_glink_altmode_enable_usb(struct pmic_glink_altmode *altmode,
 	ret = typec_mux_set(port->typec_mux, &port->state);
 	if (ret)
 		dev_err(altmode->dev, "failed to switch mux to USB\n");
+
+	port->retimer_state.alt = NULL;
+	port->retimer_state.data = NULL;
+	port->retimer_state.mode = TYPEC_STATE_USB;
+
+	ret = typec_retimer_set(port->typec_retimer, &port->retimer_state);
+	if (ret)
+		dev_err(altmode->dev, "failed to setup retimer to USB\n");
 }
 
 static void pmic_glink_altmode_safe(struct pmic_glink_altmode *altmode,
@@ -185,6 +204,14 @@ static void pmic_glink_altmode_safe(struct pmic_glink_altmode *altmode,
 	ret = typec_mux_set(port->typec_mux, &port->state);
 	if (ret)
 		dev_err(altmode->dev, "failed to switch mux to safe mode\n");
+
+	port->retimer_state.alt = NULL;
+	port->retimer_state.data = NULL;
+	port->retimer_state.mode = TYPEC_STATE_SAFE;
+
+	ret = typec_retimer_set(port->typec_retimer, &port->retimer_state);
+	if (ret)
+		dev_err(altmode->dev, "failed to setup retimer to USB\n");
 }
 
 static void pmic_glink_altmode_worker(struct work_struct *work)
@@ -347,6 +374,11 @@ static const struct drm_bridge_funcs pmic_glink_altmode_bridge_funcs = {
 	.attach = pmic_glink_altmode_attach,
 };
 
+static void pmic_glink_altmode_put_retimer(void *data)
+{
+	typec_retimer_put(data);
+}
+
 static void pmic_glink_altmode_put_mux(void *data)
 {
 	typec_mux_put(data);
@@ -453,6 +485,17 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
 		if (ret)
 			return ret;
 
+		alt_port->typec_retimer = fwnode_typec_retimer_get(fwnode);
+		if (IS_ERR(alt_port->typec_retimer))
+			return dev_err_probe(dev, PTR_ERR(alt_port->typec_retimer),
+					     "failed to acquire retimer-switch for port: %d\n",
+					     port);
+
+		ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_retimer,
+					       alt_port->typec_retimer);
+		if (ret)
+			return ret;
+
 		alt_port->typec_switch = fwnode_typec_switch_get(fwnode);
 		if (IS_ERR(alt_port->typec_switch))
 			return dev_err_probe(dev, PTR_ERR(alt_port->typec_switch),

-- 
2.34.1


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

* [PATCH v2 5/8] qcom: pmic_glink: enable altmode for SM8550
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
                   ` (3 preceding siblings ...)
  2023-06-07  8:05 ` [PATCH v2 4/8] qcom: pmic_glink_altmode: add retimer-switch support Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 6/8] arm64: dts: qcom: sm8550: add ports subnodes in usb/dp qmpphy node Neil Armstrong
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

Altmode is also supported for SM8550, allow it.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/soc/qcom/pmic_glink.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c
index c87056769ebd..8af06bdc6f5a 100644
--- a/drivers/soc/qcom/pmic_glink.c
+++ b/drivers/soc/qcom/pmic_glink.c
@@ -342,13 +342,9 @@ static const unsigned long pmic_glink_sm8450_client_mask = BIT(PMIC_GLINK_CLIENT
 							   BIT(PMIC_GLINK_CLIENT_ALTMODE) |
 							   BIT(PMIC_GLINK_CLIENT_UCSI);
 
-/* Do not handle altmode for now on those platforms */
-static const unsigned long pmic_glink_sm8550_client_mask = BIT(PMIC_GLINK_CLIENT_BATT) |
-							   BIT(PMIC_GLINK_CLIENT_UCSI);
-
 static const struct of_device_id pmic_glink_of_match[] = {
 	{ .compatible = "qcom,sm8450-pmic-glink", .data = &pmic_glink_sm8450_client_mask },
-	{ .compatible = "qcom,sm8550-pmic-glink", .data = &pmic_glink_sm8550_client_mask },
+	{ .compatible = "qcom,sm8550-pmic-glink", .data = &pmic_glink_sm8450_client_mask },
 	{ .compatible = "qcom,pmic-glink" },
 	{}
 };

-- 
2.34.1


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

* [PATCH v2 6/8] arm64: dts: qcom: sm8550: add ports subnodes in usb/dp qmpphy node
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
                   ` (4 preceding siblings ...)
  2023-06-07  8:05 ` [PATCH v2 5/8] qcom: pmic_glink: enable altmode for SM8550 Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 7/8] arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints Neil Armstrong
  2023-06-07  8:05 ` [PATCH v2 8/8] arm64: dts: qcom: sm8550-qrd: " Neil Armstrong
  7 siblings, 0 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

Add the USB3+DP Combo QMP PHY port subnodes in the SM8550 SoC DTSI
to avoid duplication in the devices DTs.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm8550.dtsi | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sm8550.dtsi b/arch/arm64/boot/dts/qcom/sm8550.dtsi
index b41b3981b3ce..ca2280041f83 100644
--- a/arch/arm64/boot/dts/qcom/sm8550.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8550.dtsi
@@ -2838,6 +2838,32 @@ usb_dp_qmpphy: phy@88e8000 {
 			#phy-cells = <1>;
 
 			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+
+					usb_dp_qmpphy_out: endpoint {
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+
+					usb_dp_qmpphy_usb_ss_in: endpoint {
+					};
+				};
+
+				port@2 {
+					reg = <2>;
+
+					usb_dp_qmpphy_dp_in: endpoint {
+					};
+				};
+			};
 		};
 
 		usb_1: usb@a6f8800 {

-- 
2.34.1


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

* [PATCH v2 7/8] arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
                   ` (5 preceding siblings ...)
  2023-06-07  8:05 ` [PATCH v2 6/8] arm64: dts: qcom: sm8550: add ports subnodes in usb/dp qmpphy node Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-08 10:31   ` Krzysztof Kozlowski
  2023-06-07  8:05 ` [PATCH v2 8/8] arm64: dts: qcom: sm8550-qrd: " Neil Armstrong
  7 siblings, 1 reply; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

Add nodes to support Type-C USB/DP functionality.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm8550-mtp.dts | 67 ++++++++++++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8550-mtp.dts b/arch/arm64/boot/dts/qcom/sm8550-mtp.dts
index 579f65f52370..8d4741404f2d 100644
--- a/arch/arm64/boot/dts/qcom/sm8550-mtp.dts
+++ b/arch/arm64/boot/dts/qcom/sm8550-mtp.dts
@@ -80,7 +80,15 @@ port@1 {
 					reg = <1>;
 
 					pmic_glink_ss_in: endpoint {
-						remote-endpoint = <&usb_1_dwc3_ss>;
+						remote-endpoint = <&usb_dp_qmpphy_out>;
+					};
+				};
+
+				port@2 {
+					reg = <2>;
+
+					pmic_glink_sbu: endpoint {
+						remote-endpoint = <&fsa4480_sbu_mux>;
 					};
 				};
 			};
@@ -419,6 +427,38 @@ vreg_l3g_1p2: ldo3 {
 	};
 };
 
+&i2c_master_hub_0 {
+	status = "okay";
+};
+
+&i2c_hub_2 {
+	status = "okay";
+
+	fsa4480@42 {
+		compatible = "fcs,fsa4480";
+		reg = <0x42>;
+
+		vcc-supply = <&vreg_bob1>;
+
+		mode-switch;
+		orientation-switch;
+		svid = /bits/ 16 <0xff01>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+
+				fsa4480_sbu_mux: endpoint {
+					remote-endpoint = <&pmic_glink_sbu>;
+				};
+			};
+		};
+	};
+};
+
 &mdss {
 	status = "okay";
 };
@@ -459,6 +499,15 @@ &mdss_dsi0_phy {
 	status = "okay";
 };
 
+&mdss_dp0 {
+	status = "okay";
+};
+
+&mdss_dp0_out {
+	data-lanes = <0 1>;
+	remote-endpoint = <&usb_dp_qmpphy_dp_in>;
+};
+
 &pcie_1_phy_aux_clk {
 	clock-frequency = <1000>;
 };
@@ -652,7 +701,7 @@ &usb_1_dwc3_hs {
 };
 
 &usb_1_dwc3_ss {
-	remote-endpoint = <&pmic_glink_ss_in>;
+	remote-endpoint = <&usb_dp_qmpphy_usb_ss_in>;
 };
 
 &usb_1_hsphy {
@@ -668,9 +717,23 @@ &usb_dp_qmpphy {
 	vdda-phy-supply = <&vreg_l3e_1p2>;
 	vdda-pll-supply = <&vreg_l3f_0p91>;
 
+	orientation-switch;
+
 	status = "okay";
 };
 
+&usb_dp_qmpphy_dp_in {
+	remote-endpoint = <&mdss_dp0_out>;
+};
+
+&usb_dp_qmpphy_out {
+	remote-endpoint = <&pmic_glink_ss_in>;
+};
+
+&usb_dp_qmpphy_usb_ss_in {
+	remote-endpoint = <&usb_1_dwc3_ss>;
+};
+
 &xo_board {
 	clock-frequency = <76800000>;
 };

-- 
2.34.1


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

* [PATCH v2 8/8] arm64: dts: qcom: sm8550-qrd: add pmic glink port/endpoints
  2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
                   ` (6 preceding siblings ...)
  2023-06-07  8:05 ` [PATCH v2 7/8] arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints Neil Armstrong
@ 2023-06-07  8:05 ` Neil Armstrong
  2023-06-08 10:28   ` Krzysztof Kozlowski
  7 siblings, 1 reply; 13+ messages in thread
From: Neil Armstrong @ 2023-06-07  8:05 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb,
	Neil Armstrong

Add nodes to support Type-C USB/DP functionality.

On this platform, a Type-C redriver is added to the
SuperSpeed graph.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 99 ++++++++++++++++++++++++++++++++-
 1 file changed, 97 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8550-qrd.dts b/arch/arm64/boot/dts/qcom/sm8550-qrd.dts
index 8669d29144bb..7126c14836c9 100644
--- a/arch/arm64/boot/dts/qcom/sm8550-qrd.dts
+++ b/arch/arm64/boot/dts/qcom/sm8550-qrd.dts
@@ -64,6 +64,7 @@ connector@0 {
 			reg = <0>;
 			power-role = "dual";
 			data-role = "dual";
+			orientation-gpios = <&tlmm 11 GPIO_ACTIVE_HIGH>;
 
 			ports {
 				#address-cells = <1>;
@@ -81,7 +82,15 @@ port@1 {
 					reg = <1>;
 
 					pmic_glink_ss_in: endpoint {
-						remote-endpoint = <&usb_1_dwc3_ss>;
+						remote-endpoint = <&redriver_ss_out>;
+					};
+				};
+
+				port@2 {
+					reg = <2>;
+
+					pmic_glink_sbu: endpoint {
+						remote-endpoint = <&fsa4480_sbu_mux>;
 					};
 				};
 			};
@@ -420,6 +429,69 @@ vreg_l3g_1p2: ldo3 {
 	};
 };
 
+&i2c_master_hub_0 {
+	status = "okay";
+};
+
+&i2c_hub_2 {
+	status = "okay";
+
+	typec-mux@1c {
+		compatible = "onnn,nb7vpq904m";
+		reg = <0x1c>;
+
+		vcc-supply = <&vreg_l15b_1p8>;
+
+		retimer-switch;
+		orientation-switch;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+
+				redriver_ss_out: endpoint {
+					remote-endpoint = <&pmic_glink_ss_in>;
+				};
+			};
+
+			port@1 {
+				reg = <1>;
+
+				redriver_ss_in: endpoint {
+					data-lanes = <3 2 1 0>;
+					remote-endpoint = <&usb_dp_qmpphy_out>;
+				};
+			};
+		};
+	};
+
+	fsa4480@42 {
+		compatible = "fcs,fsa4480";
+		reg = <0x42>;
+
+		vcc-supply = <&vreg_bob1>;
+
+		mode-switch;
+		orientation-switch;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+
+				fsa4480_sbu_mux: endpoint {
+					remote-endpoint = <&pmic_glink_sbu>;
+				};
+			};
+		};
+	};
+};
+
 &gcc {
 	clocks = <&bi_tcxo_div2>, <&sleep_clk>,
 		 <&pcie0_phy>,
@@ -471,6 +543,15 @@ &mdss_dsi0_phy {
 	status = "okay";
 };
 
+&mdss_dp0 {
+	status = "okay";
+};
+
+&mdss_dp0_out {
+	data-lanes = <0 1>;
+	remote-endpoint = <&usb_dp_qmpphy_dp_in>;
+};
+
 &pcie_1_phy_aux_clk {
 	status = "disabled";
 };
@@ -650,7 +731,7 @@ &usb_1_dwc3_hs {
 };
 
 &usb_1_dwc3_ss {
-	remote-endpoint = <&pmic_glink_ss_in>;
+	remote-endpoint = <&usb_dp_qmpphy_usb_ss_in>;
 };
 
 &usb_1_hsphy {
@@ -666,9 +747,23 @@ &usb_dp_qmpphy {
 	vdda-phy-supply = <&vreg_l3e_1p2>;
 	vdda-pll-supply = <&vreg_l3f_0p88>;
 
+	orientation-switch;
+
 	status = "okay";
 };
 
+&usb_dp_qmpphy_dp_in {
+	remote-endpoint = <&mdss_dp0_out>;
+};
+
+&usb_dp_qmpphy_out {
+	remote-endpoint = <&redriver_ss_in>;
+};
+
+&usb_dp_qmpphy_usb_ss_in {
+	remote-endpoint = <&usb_1_dwc3_ss>;
+};
+
 &xo_board {
 	clock-frequency = <76800000>;
 };

-- 
2.34.1


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

* Re: [PATCH v2 8/8] arm64: dts: qcom: sm8550-qrd: add pmic glink port/endpoints
  2023-06-07  8:05 ` [PATCH v2 8/8] arm64: dts: qcom: sm8550-qrd: " Neil Armstrong
@ 2023-06-08 10:28   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2023-06-08 10:28 UTC (permalink / raw)
  To: Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Andy Gross, Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb

On 07/06/2023 10:05, Neil Armstrong wrote:
> Add nodes to support Type-C USB/DP functionality.
> 
> On this platform, a Type-C redriver is added to the
> SuperSpeed graph.
> 

...

> +			port@1 {
> +				reg = <1>;
> +
> +				redriver_ss_in: endpoint {
> +					data-lanes = <3 2 1 0>;
> +					remote-endpoint = <&usb_dp_qmpphy_out>;
> +				};
> +			};
> +		};
> +	};
> +
> +	fsa4480@42 {

typec-switch? typec-mux?

> +		compatible = "fcs,fsa4480";
> +		reg = <0x42>;
> +
> +		vcc-supply = <&vreg_bob1>;
> +
> +		mode-switch;
> +		orientation-switch;
> +




Best regards,
Krzysztof


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

* Re: [PATCH v2 7/8] arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints
  2023-06-07  8:05 ` [PATCH v2 7/8] arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints Neil Armstrong
@ 2023-06-08 10:31   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2023-06-08 10:31 UTC (permalink / raw)
  To: Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Andy Gross, Bjorn Andersson, Konrad Dybcio, Heikki Krogerus,
	Greg Kroah-Hartman
  Cc: Rob Herring, devicetree, linux-kernel, linux-arm-msm, linux-usb

On 07/06/2023 10:05, Neil Armstrong wrote:
> Add nodes to support Type-C USB/DP functionality.
> 

Thank you for your patch. There is something to discuss/improve.


> +
> +&i2c_hub_2 {
> +	status = "okay";
> +
> +	fsa4480@42 {
> +		compatible = "fcs,fsa4480";
> +		reg = <0x42>;
> +
> +		vcc-supply = <&vreg_bob1>;
> +
> +		mode-switch;
> +		orientation-switch;
> +		svid = /bits/ 16 <0xff01>;

I think this property is not documented.

Best regards,
Krzysztof


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

* Re: [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation
  2023-06-07  8:05 ` [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation Neil Armstrong
@ 2023-06-08 15:47   ` Rob Herring
  2023-06-08 16:35     ` Neil Armstrong
  0 siblings, 1 reply; 13+ messages in thread
From: Rob Herring @ 2023-06-08 15:47 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Krzysztof Kozlowski, Conor Dooley, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Heikki Krogerus, Greg Kroah-Hartman, devicetree,
	linux-kernel, linux-arm-msm, linux-usb, Krzysztof Kozlowski

On Wed, Jun 07, 2023 at 10:05:00AM +0200, Neil Armstrong wrote:
> On some platforms, the Type-C plug orientation is given on a GPIO line.
> 
> Document this optional Type-C connector property, and take the
> assumption an active level represents an inverted/flipped orientation.
> 
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  Documentation/devicetree/bindings/connector/usb-connector.yaml | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> index ae515651fc6b..c3884eed6ba4 100644
> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> @@ -114,6 +114,11 @@ properties:
>      description: Set this property if the Type-C connector has no power delivery support.
>      type: boolean
>  
> +  orientation-gpios:
> +    description: An input gpio for Type-C connector orientation, used to detect orientation
> +      of the Type-C connector. GPIO active level means "CC2" or Reversed/Flipped orientation.
> +    maxItems: 1

There's no such GPIO on a USB-C connector. Please explain this h/w 
better (in the commit message and/or description). Perhaps it is simple 
enough logic to leave the GPIO here. Perhaps there's more to the h/w you 
are not (yet) describing.

Rob

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

* Re: [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation
  2023-06-08 15:47   ` Rob Herring
@ 2023-06-08 16:35     ` Neil Armstrong
  0 siblings, 0 replies; 13+ messages in thread
From: Neil Armstrong @ 2023-06-08 16:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Conor Dooley, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Heikki Krogerus, Greg Kroah-Hartman, devicetree,
	linux-kernel, linux-arm-msm, linux-usb, Krzysztof Kozlowski

Hi Rob,

On 08/06/2023 17:47, Rob Herring wrote:
> On Wed, Jun 07, 2023 at 10:05:00AM +0200, Neil Armstrong wrote:
>> On some platforms, the Type-C plug orientation is given on a GPIO line.
>>
>> Document this optional Type-C connector property, and take the
>> assumption an active level represents an inverted/flipped orientation.
>>
>> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
>>   Documentation/devicetree/bindings/connector/usb-connector.yaml | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> index ae515651fc6b..c3884eed6ba4 100644
>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> @@ -114,6 +114,11 @@ properties:
>>       description: Set this property if the Type-C connector has no power delivery support.
>>       type: boolean
>>   
>> +  orientation-gpios:
>> +    description: An input gpio for Type-C connector orientation, used to detect orientation
>> +      of the Type-C connector. GPIO active level means "CC2" or Reversed/Flipped orientation.
>> +    maxItems: 1
> 
> There's no such GPIO on a USB-C connector. Please explain this h/w
> better (in the commit message and/or description). Perhaps it is simple
> enough logic to leave the GPIO here. Perhaps there's more to the h/w you
> are not (yet) describing.

The h/w has an I/O line representing the usb-c orientation at any time
which is driven by the PMIC in charge of the USB-C connector(s).

On this platform, the usb-c connector orientation is only unconditionally
given by this I/O connected to a GPIO line, howerver we get an altmode
event with the orientation, but only when an altmode state has been
negociated. AFAIK there's no other way or events returning this
orientation change unconditionally unlike previous HW generations.

This is why representing it as a gpio is simple but useful since there's
a lot of passive usb-c controllers also reflecting this orientation info
in a same way to be consumed by superspeed switches for example.

As an alternative I didn't find a way that fits the current bindings
to get this simple binary information.

Neil

> 
> Rob


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

end of thread, other threads:[~2023-06-08 16:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07  8:04 [PATCH v2 0/8] arm64: qcom: add Type-C Altmode support Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 1/8] dt-bindings: connector: usb-connector: add a gpio used to determine the Type-C port plug orientation Neil Armstrong
2023-06-08 15:47   ` Rob Herring
2023-06-08 16:35     ` Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 2/8] soc: qcom: pmic_glink_altmode: handle safe mode when disconnect Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 3/8] usb: ucsi: glink: use the connector orientation GPIO to provide switch events Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 4/8] qcom: pmic_glink_altmode: add retimer-switch support Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 5/8] qcom: pmic_glink: enable altmode for SM8550 Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 6/8] arm64: dts: qcom: sm8550: add ports subnodes in usb/dp qmpphy node Neil Armstrong
2023-06-07  8:05 ` [PATCH v2 7/8] arm64: dts: qcom: sm8550-mtp: add pmic glink port/endpoints Neil Armstrong
2023-06-08 10:31   ` Krzysztof Kozlowski
2023-06-07  8:05 ` [PATCH v2 8/8] arm64: dts: qcom: sm8550-qrd: " Neil Armstrong
2023-06-08 10:28   ` Krzysztof Kozlowski

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