All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props
@ 2020-05-19 21:46 Prashant Malani
  2020-05-19 21:46 ` [PATCH v3 2/2] platform/chrome: typec: Register Type C switches Prashant Malani
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Prashant Malani @ 2020-05-19 21:46 UTC (permalink / raw)
  To: linux-kernel, robh+dt
  Cc: heikki.krogerus, Prashant Malani, Benson Leung,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Enric Balletbo i Serra, Guenter Roeck

Add properties for mode, orientation and USB data role switches for
Type C connectors. When available, these will allow the Type C connector
class port driver to configure the various switches according to USB PD
information (like orientation, alt mode etc.) provided by the Chrome OS
EC controller.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Acked-by: Benson Leung <bleung@chromium.org>
---

Changes in v3:
- Fixed Acked-by tag typo.

Changes in v2:
- Added more text to the switch descriptions, explaining their purpose,
  and relation to the Type C connector class framework.

 .../bindings/chrome/google,cros-ec-typec.yaml | 40 ++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml b/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml
index 6d7396ab8bee..800c005a0e44 100644
--- a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml
+++ b/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml
@@ -21,7 +21,34 @@ properties:
     const: google,cros-ec-typec
 
   connector:
-    $ref: /schemas/connector/usb-connector.yaml#
+    allOf:
+      - $ref: /schemas/connector/usb-connector.yaml#
+      - type: object
+        properties:
+          mode-switch:
+            description: Reference to a DT node for the USB Type C Multiplexer
+              for this connector. This switch controls the data lines routing
+              for this connector for various operation modes, including
+              Alternate Modes. This switch is assumed registered with the Type C
+              connector class framework by its driver. The Type C connector
+              class framework assumes that the mode switch property uses this
+              name.
+
+          orientation-switch:
+            description: Reference to a DT node for the USB Type C orientation
+              switch for this connector. This switch controls routing the
+              correct data pairs depending on the cable plug orientation from
+              this connector to the USB / Alternate Mode controllers. This
+              switch is assumed registered with the Type C connector class
+              framework by its driver. The Type C connector class framework
+              assumes that the orientation switch property uses this name.
+
+          usb-role-switch:
+            description: Reference to a DT node for the USB Data role switch
+              for this connector. This switch is assumed registered with the
+              Type C connector class framework by its driver. The Type C
+              connector class framework assumes that the USB role switch
+              property uses this name.
 
 required:
   - compatible
@@ -49,6 +76,17 @@ examples:
             data-role = "dual";
             try-power-role = "source";
           };
+
+          connector@1 {
+            compatible = "usb-c-connector";
+            reg = <1>;
+            power-role = "dual";
+            data-role = "host";
+            try-power-role = "source";
+            mode-switch = <&typec_mux>;
+            orientation-switch = <&typec_orientation_switch>;
+            usb-role-switch = <&typec_mux>;
+          };
         };
       };
     };
-- 
2.26.2.761.g0e0b3e54be-goog


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

* [PATCH v3 2/2] platform/chrome: typec: Register Type C switches
  2020-05-19 21:46 [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
@ 2020-05-19 21:46 ` Prashant Malani
  2020-06-25 11:59   ` Enric Balletbo i Serra
  2020-05-29 19:28 ` [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
  2020-06-12 17:16 ` Prashant Malani
  2 siblings, 1 reply; 5+ messages in thread
From: Prashant Malani @ 2020-05-19 21:46 UTC (permalink / raw)
  To: linux-kernel, robh+dt
  Cc: heikki.krogerus, Prashant Malani, Enric Balletbo i Serra,
	Benson Leung,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Guenter Roeck

Register Type C mux and switch handles, when provided via firmware
bindings. These will allow the cros-ec-typec driver, and also alternate
mode drivers to configure connected Muxes correctly, according to PD
information retrieved from the Chrome OS EC.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

Changes in v3:
- Added Acked-by tag.
- Fixed Heikki's email address in Reviewed-by tag.

Changes in v2:
- Changed dev_info prints to dev_dbg.

 drivers/platform/chrome/cros_ec_typec.c | 47 +++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 66b8d21092af..6e79f917314b 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -14,6 +14,8 @@
 #include <linux/platform_data/cros_usbpd_notify.h>
 #include <linux/platform_device.h>
 #include <linux/usb/typec.h>
+#include <linux/usb/typec_mux.h>
+#include <linux/usb/role.h>
 
 #define DRV_NAME "cros-ec-typec"
 
@@ -25,6 +27,9 @@ struct cros_typec_port {
 	struct typec_partner *partner;
 	/* Port partner PD identity info. */
 	struct usb_pd_identity p_identity;
+	struct typec_switch *ori_sw;
+	struct typec_mux *mux;
+	struct usb_role_switch *role_sw;
 };
 
 /* Platform-specific data for the Chrome OS EC Type C controller. */
@@ -84,6 +89,40 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
 	return 0;
 }
 
+static int cros_typec_get_switch_handles(struct cros_typec_port *port,
+					 struct fwnode_handle *fwnode,
+					 struct device *dev)
+{
+	port->mux = fwnode_typec_mux_get(fwnode, NULL);
+	if (IS_ERR(port->mux)) {
+		dev_dbg(dev, "Mux handle not found.\n");
+		goto mux_err;
+	}
+
+	port->ori_sw = fwnode_typec_switch_get(fwnode);
+	if (IS_ERR(port->ori_sw)) {
+		dev_dbg(dev, "Orientation switch handle not found.\n");
+		goto ori_sw_err;
+	}
+
+	port->role_sw = fwnode_usb_role_switch_get(fwnode);
+	if (IS_ERR(port->role_sw)) {
+		dev_dbg(dev, "USB role switch handle not found.\n");
+		goto role_sw_err;
+	}
+
+	return 0;
+
+role_sw_err:
+	usb_role_switch_put(port->role_sw);
+ori_sw_err:
+	typec_switch_put(port->ori_sw);
+mux_err:
+	typec_mux_put(port->mux);
+
+	return -ENODEV;
+}
+
 static void cros_unregister_ports(struct cros_typec_data *typec)
 {
 	int i;
@@ -91,6 +130,9 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
 	for (i = 0; i < typec->num_ports; i++) {
 		if (!typec->ports[i])
 			continue;
+		usb_role_switch_put(typec->ports[i]->role_sw);
+		typec_switch_put(typec->ports[i]->ori_sw);
+		typec_mux_put(typec->ports[i]->mux);
 		typec_unregister_port(typec->ports[i]->port);
 	}
 }
@@ -153,6 +195,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 			ret = PTR_ERR(cros_port->port);
 			goto unregister_ports;
 		}
+
+		ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
+		if (ret)
+			dev_dbg(dev, "No switch control for port %d\n",
+				port_num);
 	}
 
 	return 0;
-- 
2.26.2.761.g0e0b3e54be-goog


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

* Re: [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props
  2020-05-19 21:46 [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
  2020-05-19 21:46 ` [PATCH v3 2/2] platform/chrome: typec: Register Type C switches Prashant Malani
@ 2020-05-29 19:28 ` Prashant Malani
  2020-06-12 17:16 ` Prashant Malani
  2 siblings, 0 replies; 5+ messages in thread
From: Prashant Malani @ 2020-05-29 19:28 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Rob Herring
  Cc: Heikki Krogerus, Benson Leung,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Enric Balletbo i Serra, Guenter Roeck

Hi Rob,

Would you prefer these switches to be defined in the
usb-connector.yaml bindings file?
If there are no other concerns, I can push a fresh version of the
patch with the properties defined in usb-connector.yaml.

Thanks,

On Tue, May 19, 2020 at 2:46 PM Prashant Malani <pmalani@chromium.org> wrote:
>
> Add properties for mode, orientation and USB data role switches for
> Type C connectors. When available, these will allow the Type C connector
> class port driver to configure the various switches according to USB PD
> information (like orientation, alt mode etc.) provided by the Chrome OS
> EC controller.
>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> Acked-by: Benson Leung <bleung@chromium.org>
> ---
>
> Changes in v3:
> - Fixed Acked-by tag typo.
>
> Changes in v2:
> - Added more text to the switch descriptions, explaining their purpose,
>   and relation to the Type C connector class framework.
>
>  .../bindings/chrome/google,cros-ec-typec.yaml | 40 ++++++++++++++++++-
>  1 file changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml b/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml
> index 6d7396ab8bee..800c005a0e44 100644
> --- a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml
> +++ b/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml
> @@ -21,7 +21,34 @@ properties:
>      const: google,cros-ec-typec
>
>    connector:
> -    $ref: /schemas/connector/usb-connector.yaml#
> +    allOf:
> +      - $ref: /schemas/connector/usb-connector.yaml#
> +      - type: object
> +        properties:
> +          mode-switch:
> +            description: Reference to a DT node for the USB Type C Multiplexer
> +              for this connector. This switch controls the data lines routing
> +              for this connector for various operation modes, including
> +              Alternate Modes. This switch is assumed registered with the Type C
> +              connector class framework by its driver. The Type C connector
> +              class framework assumes that the mode switch property uses this
> +              name.
> +
> +          orientation-switch:
> +            description: Reference to a DT node for the USB Type C orientation
> +              switch for this connector. This switch controls routing the
> +              correct data pairs depending on the cable plug orientation from
> +              this connector to the USB / Alternate Mode controllers. This
> +              switch is assumed registered with the Type C connector class
> +              framework by its driver. The Type C connector class framework
> +              assumes that the orientation switch property uses this name.
> +
> +          usb-role-switch:
> +            description: Reference to a DT node for the USB Data role switch
> +              for this connector. This switch is assumed registered with the
> +              Type C connector class framework by its driver. The Type C
> +              connector class framework assumes that the USB role switch
> +              property uses this name.
>
>  required:
>    - compatible
> @@ -49,6 +76,17 @@ examples:
>              data-role = "dual";
>              try-power-role = "source";
>            };
> +
> +          connector@1 {
> +            compatible = "usb-c-connector";
> +            reg = <1>;
> +            power-role = "dual";
> +            data-role = "host";
> +            try-power-role = "source";
> +            mode-switch = <&typec_mux>;
> +            orientation-switch = <&typec_orientation_switch>;
> +            usb-role-switch = <&typec_mux>;
> +          };
>          };
>        };
>      };
> --
> 2.26.2.761.g0e0b3e54be-goog
>

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

* Re: [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props
  2020-05-19 21:46 [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
  2020-05-19 21:46 ` [PATCH v3 2/2] platform/chrome: typec: Register Type C switches Prashant Malani
  2020-05-29 19:28 ` [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
@ 2020-06-12 17:16 ` Prashant Malani
  2 siblings, 0 replies; 5+ messages in thread
From: Prashant Malani @ 2020-06-12 17:16 UTC (permalink / raw)
  To: linux-kernel, robh+dt
  Cc: heikki.krogerus, Benson Leung,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Enric Balletbo i Serra, Guenter Roeck

Hi,

From the discussion in [1], it looks like reconciling ACPI and DT
bindings for these properties to be identical is challenging.

Let's drop this patch, and move forward with the Patch 2/2 in this
series [2] alone.

We'll continue the discussion about how we can add these properties to
devicetree bindings in a conformant way.

Thanks everyone,

-Prashant,

[1]:
https://lore.kernel.org/lkml/CAL_Jsq+ORkzHchpD0qsH97zDJzXGj3jWy8=orXSVhNQd4kr9Kg@mail.gmail.com/T/#t
[2]: https://lkml.org/lkml/2020/5/19/1219

(Trimming text);
On Tue, May 19, 2020 at 02:46:02PM -0700, Prashant Malani wrote:
> Add properties for mode, orientation and USB data role switches for
> Type C connectors. When available, these will allow the Type C connector
> class port driver to configure the various switches according to USB PD
> information (like orientation, alt mode etc.) provided by the Chrome OS
> EC controller.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> Acked-by: Benson Leung <bleung@chromium.org>
> ---
> 
> Changes in v3:
> - Fixed Acked-by tag typo.
> 
> Changes in v2:
> - Added more text to the switch descriptions, explaining their purpose,
>   and relation to the Type C connector class framework.
> 
>  .../bindings/chrome/google,cros-ec-typec.yaml | 40 ++++++++++++++++++-
>  1 file changed, 39 insertions(+), 1 deletion(-)
> 

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

* Re: [PATCH v3 2/2] platform/chrome: typec: Register Type C switches
  2020-05-19 21:46 ` [PATCH v3 2/2] platform/chrome: typec: Register Type C switches Prashant Malani
@ 2020-06-25 11:59   ` Enric Balletbo i Serra
  0 siblings, 0 replies; 5+ messages in thread
From: Enric Balletbo i Serra @ 2020-06-25 11:59 UTC (permalink / raw)
  To: Prashant Malani, linux-kernel, robh+dt
  Cc: heikki.krogerus, Benson Leung,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Guenter Roeck

Hi Prashant,

On 19/5/20 23:46, Prashant Malani wrote:
> Register Type C mux and switch handles, when provided via firmware
> bindings. These will allow the cros-ec-typec driver, and also alternate
> mode drivers to configure connected Muxes correctly, according to PD
> information retrieved from the Chrome OS EC.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>


Applied this patch for 5.9 to support ACPI devices, as discussed, the first
patch, the DT bindings, are still not ready.

Thanks,
 Enric

> ---
> 
> Changes in v3:
> - Added Acked-by tag.
> - Fixed Heikki's email address in Reviewed-by tag.
> 
> Changes in v2:
> - Changed dev_info prints to dev_dbg.
> 
>  drivers/platform/chrome/cros_ec_typec.c | 47 +++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 66b8d21092af..6e79f917314b 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -14,6 +14,8 @@
>  #include <linux/platform_data/cros_usbpd_notify.h>
>  #include <linux/platform_device.h>
>  #include <linux/usb/typec.h>
> +#include <linux/usb/typec_mux.h>
> +#include <linux/usb/role.h>
>  
>  #define DRV_NAME "cros-ec-typec"
>  
> @@ -25,6 +27,9 @@ struct cros_typec_port {
>  	struct typec_partner *partner;
>  	/* Port partner PD identity info. */
>  	struct usb_pd_identity p_identity;
> +	struct typec_switch *ori_sw;
> +	struct typec_mux *mux;
> +	struct usb_role_switch *role_sw;
>  };
>  
>  /* Platform-specific data for the Chrome OS EC Type C controller. */
> @@ -84,6 +89,40 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
>  	return 0;
>  }
>  
> +static int cros_typec_get_switch_handles(struct cros_typec_port *port,
> +					 struct fwnode_handle *fwnode,
> +					 struct device *dev)
> +{
> +	port->mux = fwnode_typec_mux_get(fwnode, NULL);
> +	if (IS_ERR(port->mux)) {
> +		dev_dbg(dev, "Mux handle not found.\n");
> +		goto mux_err;
> +	}
> +
> +	port->ori_sw = fwnode_typec_switch_get(fwnode);
> +	if (IS_ERR(port->ori_sw)) {
> +		dev_dbg(dev, "Orientation switch handle not found.\n");
> +		goto ori_sw_err;
> +	}
> +
> +	port->role_sw = fwnode_usb_role_switch_get(fwnode);
> +	if (IS_ERR(port->role_sw)) {
> +		dev_dbg(dev, "USB role switch handle not found.\n");
> +		goto role_sw_err;
> +	}
> +
> +	return 0;
> +
> +role_sw_err:
> +	usb_role_switch_put(port->role_sw);
> +ori_sw_err:
> +	typec_switch_put(port->ori_sw);
> +mux_err:
> +	typec_mux_put(port->mux);
> +
> +	return -ENODEV;
> +}
> +
>  static void cros_unregister_ports(struct cros_typec_data *typec)
>  {
>  	int i;
> @@ -91,6 +130,9 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
>  	for (i = 0; i < typec->num_ports; i++) {
>  		if (!typec->ports[i])
>  			continue;
> +		usb_role_switch_put(typec->ports[i]->role_sw);
> +		typec_switch_put(typec->ports[i]->ori_sw);
> +		typec_mux_put(typec->ports[i]->mux);
>  		typec_unregister_port(typec->ports[i]->port);
>  	}
>  }
> @@ -153,6 +195,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
>  			ret = PTR_ERR(cros_port->port);
>  			goto unregister_ports;
>  		}
> +
> +		ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
> +		if (ret)
> +			dev_dbg(dev, "No switch control for port %d\n",
> +				port_num);
>  	}
>  
>  	return 0;
> 

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

end of thread, other threads:[~2020-06-25 11:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19 21:46 [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
2020-05-19 21:46 ` [PATCH v3 2/2] platform/chrome: typec: Register Type C switches Prashant Malani
2020-06-25 11:59   ` Enric Balletbo i Serra
2020-05-29 19:28 ` [PATCH v3 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
2020-06-12 17:16 ` Prashant Malani

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.