diff mbox series

[v2,5/5] usb: typec: ucsi: glink: set orientation aware if supported

Message ID 20240411-ucsi-orient-aware-v2-5-d4b1cb22a33f@linaro.org (mailing list archive)
State Accepted
Commit 3d1b6c9d47707d6a0f80bb5db6473b1f107b5baf
Headers show
Series usb: typec: ucsi: glink: rework orientation handling | expand

Commit Message

Dmitry Baryshkov April 11, 2024, 4:49 a.m. UTC
If the PMIC-GLINK device has orientation GPIOs declared, then it will
report connection orientation. In this case set the flag to mark
registered ports as orientation-aware.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/usb/typec/ucsi/ucsi_glink.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Heikki Krogerus April 15, 2024, 7:08 a.m. UTC | #1
On Thu, Apr 11, 2024 at 07:49:57AM +0300, Dmitry Baryshkov wrote:
> If the PMIC-GLINK device has orientation GPIOs declared, then it will
> report connection orientation. In this case set the flag to mark
> registered ports as orientation-aware.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/ucsi/ucsi_glink.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index d279e2cf9bba..f7546bb488c3 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -186,6 +186,17 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset,
>  	return ret;
>  }
>  
> +static void pmic_glink_ucsi_update_connector(struct ucsi_connector *con)
> +{
> +	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
> +	int i;
> +
> +	for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) {
> +		if (ucsi->port_orientation[i])
> +			con->typec_cap.orientation_aware = true;
> +	}
> +}
> +
>  static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)
>  {
>  	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
> @@ -208,6 +219,7 @@ static const struct ucsi_operations pmic_glink_ucsi_ops = {
>  	.read = pmic_glink_ucsi_read,
>  	.sync_write = pmic_glink_ucsi_sync_write,
>  	.async_write = pmic_glink_ucsi_async_write,
> +	.update_connector = pmic_glink_ucsi_update_connector,
>  	.connector_status = pmic_glink_ucsi_connector_status,
>  };
>  
> 
> -- 
> 2.39.2
diff mbox series

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index d279e2cf9bba..f7546bb488c3 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -186,6 +186,17 @@  static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset,
 	return ret;
 }
 
+static void pmic_glink_ucsi_update_connector(struct ucsi_connector *con)
+{
+	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
+	int i;
+
+	for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) {
+		if (ucsi->port_orientation[i])
+			con->typec_cap.orientation_aware = true;
+	}
+}
+
 static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)
 {
 	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
@@ -208,6 +219,7 @@  static const struct ucsi_operations pmic_glink_ucsi_ops = {
 	.read = pmic_glink_ucsi_read,
 	.sync_write = pmic_glink_ucsi_sync_write,
 	.async_write = pmic_glink_ucsi_async_write,
+	.update_connector = pmic_glink_ucsi_update_connector,
 	.connector_status = pmic_glink_ucsi_connector_status,
 };