2023-11-21 20:32:04

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH v2 0/2] usb: typec: tcpm: Handle Accessory Modes

In addition to Alternative Modes (see [1]), some of the TCPM-backed
boards (e.g. Qualcomm SM8150-HDK) can support USB-C Accessory Modes
(e.g. the Analog Audio). Add bindings and driver support for parsing
this kind of information.

Note, while it might make sense to put accessory-mode-audio and -debug
handling to typec_get_fw_cap(), I decided against it. Several existing
drivers use this function, while providing AccMode caps based on some
internal logic.

[1] https://lore.kernel.org/linux-usb/[email protected]/

Changes since v1:

- Initialised the `mode' variable to 0 (Sergei Shtylyov)

Dmitry Baryshkov (2):
dt-bindings: connector: usb: add accessory mode description
usb: typec: tcpm: Parse Accessory Mode information

.../devicetree/bindings/connector/usb-connector.yaml | 12 ++++++++++++
drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
2 files changed, 21 insertions(+)

--
2.42.0


2023-11-21 20:32:07

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH v2 2/2] usb: typec: tcpm: Parse Accessory Mode information

Some of the boards supported by the TCPM drivers can support USB-C
Accessory Modes (Analog Audio, Debug). Parse information about supported
modes from the device tree.

Signed-off-by: Dmitry Baryshkov <[email protected]>
---
drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 6e843c511b85..ba2926846269 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -6114,6 +6114,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
{
const char *opmode_str;
int ret;
+ int mode;
u32 mw, frs_current;

if (!fwnode)
@@ -6132,6 +6133,14 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
if (ret < 0)
return ret;

+ mode = 0;
+
+ if (fwnode_property_read_bool(fwnode, "accessory-mode-audio"))
+ port->typec_caps.accessory[mode++] = TYPEC_ACCESSORY_AUDIO;
+
+ if (fwnode_property_read_bool(fwnode, "accessory-mode-debug"))
+ port->typec_caps.accessory[mode++] = TYPEC_ACCESSORY_DEBUG;
+
port->port_type = port->typec_caps.type;
port->pd_supported = !fwnode_property_read_bool(fwnode, "pd-disable");

--
2.42.0

2023-11-24 09:32:06

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] usb: typec: tcpm: Parse Accessory Mode information

On Tue, Nov 21, 2023 at 10:27:00PM +0200, Dmitry Baryshkov wrote:
> Some of the boards supported by the TCPM drivers can support USB-C
> Accessory Modes (Analog Audio, Debug). Parse information about supported
> modes from the device tree.
>
> Signed-off-by: Dmitry Baryshkov <[email protected]>

Reviewed-by: Heikki Krogerus <[email protected]>

> ---
> drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 6e843c511b85..ba2926846269 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6114,6 +6114,7 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> {
> const char *opmode_str;
> int ret;
> + int mode;
> u32 mw, frs_current;
>
> if (!fwnode)
> @@ -6132,6 +6133,14 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
> if (ret < 0)
> return ret;
>
> + mode = 0;
> +
> + if (fwnode_property_read_bool(fwnode, "accessory-mode-audio"))
> + port->typec_caps.accessory[mode++] = TYPEC_ACCESSORY_AUDIO;
> +
> + if (fwnode_property_read_bool(fwnode, "accessory-mode-debug"))
> + port->typec_caps.accessory[mode++] = TYPEC_ACCESSORY_DEBUG;
> +
> port->port_type = port->typec_caps.type;
> port->pd_supported = !fwnode_property_read_bool(fwnode, "pd-disable");
>
> --
> 2.42.0

--
heikki