2024-04-08 01:04:32

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH 0/3] usb: typec: ucsi: additional fixes for Qualcomm platforms

Fix small issues in the Qualcomm PMIC-GLINK UCSI implementation.

Signed-off-by: Dmitry Baryshkov <[email protected]>
---
Dmitry Baryshkov (3):
usb: typec: ucsi_glink: enable the UCSI_DELAY_DEVICE_PDOS quirk on qcm6490
usb: typec: ucsi_glink: drop NO_PARTNER_PDOS quirk for sm8550 / sm8650
usb: typec: ucsi_glink: drop special handling for CCI_BUSY

drivers/usb/typec/ucsi/ucsi_glink.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
---
base-commit: 25e918cf1bb906bd9aca19ae0270feb7f6d68783
change-id: 20240408-qcom-ucsi-fixes-bis-6b314764c5be

Best regards,
--
Dmitry Baryshkov <[email protected]>



2024-04-08 01:04:40

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH 1/3] usb: typec: ucsi_glink: enable the UCSI_DELAY_DEVICE_PDOS quirk on qcm6490

Enable the UCSI_DELAY_DEVICE_PDOS quirk on Qualcomm QCM6490. This
platform also doesn't correctly handle reading PD capabilities until PD
partner is connected.

Fixes: 5da727f75823 ("usb: typec: ucsi_glink: enable the UCSI_DELAY_DEVICE_PDOS quirk")
Signed-off-by: Dmitry Baryshkov <[email protected]>
---
drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index ef00a6563c88..9bd80a2218e4 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -316,7 +316,7 @@ static unsigned long quirk_sc8280xp = UCSI_NO_PARTNER_PDOS | UCSI_DELAY_DEVICE_P
static unsigned long quirk_sm8450 = UCSI_DELAY_DEVICE_PDOS;

static const struct of_device_id pmic_glink_ucsi_of_quirks[] = {
- { .compatible = "qcom,qcm6490-pmic-glink", .data = &quirk_sc8180x, },
+ { .compatible = "qcom,qcm6490-pmic-glink", .data = &quirk_sc8280xp, },
{ .compatible = "qcom,sc8180x-pmic-glink", .data = &quirk_sc8180x, },
{ .compatible = "qcom,sc8280xp-pmic-glink", .data = &quirk_sc8280xp, },
{ .compatible = "qcom,sm8350-pmic-glink", .data = &quirk_sc8180x, },

--
2.39.2


2024-04-08 01:04:49

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH 2/3] usb: typec: ucsi_glink: drop NO_PARTNER_PDOS quirk for sm8550 / sm8650

The Qualcomm SM8550 (and via a fallback compat SM8650) firmware properly
handles the GET_PDOS command, it sends the CCI_BUSY notification,
and then follows with the CCI_COMMAND_COMPLETE event. Stop using the quirk
for those two platforms.

Signed-off-by: Dmitry Baryshkov <[email protected]>
---
drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index 9bd80a2218e4..9ffea20020e7 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -321,7 +321,7 @@ static const struct of_device_id pmic_glink_ucsi_of_quirks[] = {
{ .compatible = "qcom,sc8280xp-pmic-glink", .data = &quirk_sc8280xp, },
{ .compatible = "qcom,sm8350-pmic-glink", .data = &quirk_sc8180x, },
{ .compatible = "qcom,sm8450-pmic-glink", .data = &quirk_sm8450, },
- { .compatible = "qcom,sm8550-pmic-glink", .data = &quirk_sc8280xp, },
+ { .compatible = "qcom,sm8550-pmic-glink", .data = &quirk_sm8450, },
{}
};


--
2.39.2


2024-04-08 01:05:03

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH 3/3] usb: typec: ucsi_glink: drop special handling for CCI_BUSY

Newer Qualcomm platforms (sm8450+) successfully handle busy state and
send the Command Completion after sending the Busy state. Older devices
have firmware bug and can not continue after sending the CCI_BUSY state,
but the command that leads to CCI_BUSY is already forbidden by the
NO_PARTNER_PDOS quirk.

Follow other UCSI glue drivers and drop special handling for CCI_BUSY
event. Let the UCSI core properly handle this state.

Signed-off-by: Dmitry Baryshkov <[email protected]>
---
drivers/usb/typec/ucsi/ucsi_glink.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index 9ffea20020e7..b91d2d15d7d9 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -176,7 +176,8 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset,
left = wait_for_completion_timeout(&ucsi->sync_ack, 5 * HZ);
if (!left) {
dev_err(ucsi->dev, "timeout waiting for UCSI sync write response\n");
- ret = -ETIMEDOUT;
+ /* return 0 here and let core UCSI code handle the CCI_BUSY */
+ ret = 0;
} else if (ucsi->sync_val) {
dev_err(ucsi->dev, "sync write returned: %d\n", ucsi->sync_val);
}
@@ -243,10 +244,7 @@ static void pmic_glink_ucsi_notify(struct work_struct *work)
ucsi_connector_change(ucsi->ucsi, con_num);
}

- if (ucsi->sync_pending && cci & UCSI_CCI_BUSY) {
- ucsi->sync_val = -EBUSY;
- complete(&ucsi->sync_ack);
- } else if (ucsi->sync_pending &&
+ if (ucsi->sync_pending &&
(cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) {
complete(&ucsi->sync_ack);
}

--
2.39.2


2024-04-09 06:30:19

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH 3/3] usb: typec: ucsi_glink: drop special handling for CCI_BUSY

On Mon, Apr 08, 2024 at 04:04:17AM +0300, Dmitry Baryshkov wrote:
> Newer Qualcomm platforms (sm8450+) successfully handle busy state and
> send the Command Completion after sending the Busy state. Older devices
> have firmware bug and can not continue after sending the CCI_BUSY state,
> but the command that leads to CCI_BUSY is already forbidden by the
> NO_PARTNER_PDOS quirk.
>
> Follow other UCSI glue drivers and drop special handling for CCI_BUSY
> event. Let the UCSI core properly handle this state.
>
> Signed-off-by: Dmitry Baryshkov <[email protected]>

One minor nitpick below, but feel free to ignore that one.

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

> ---
> drivers/usb/typec/ucsi/ucsi_glink.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index 9ffea20020e7..b91d2d15d7d9 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -176,7 +176,8 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset,
> left = wait_for_completion_timeout(&ucsi->sync_ack, 5 * HZ);
> if (!left) {
> dev_err(ucsi->dev, "timeout waiting for UCSI sync write response\n");
> - ret = -ETIMEDOUT;
> + /* return 0 here and let core UCSI code handle the CCI_BUSY */
> + ret = 0;
> } else if (ucsi->sync_val) {
> dev_err(ucsi->dev, "sync write returned: %d\n", ucsi->sync_val);
> }
> @@ -243,10 +244,7 @@ static void pmic_glink_ucsi_notify(struct work_struct *work)
> ucsi_connector_change(ucsi->ucsi, con_num);
> }
>
> - if (ucsi->sync_pending && cci & UCSI_CCI_BUSY) {
> - ucsi->sync_val = -EBUSY;
> - complete(&ucsi->sync_ack);
> - } else if (ucsi->sync_pending &&
> + if (ucsi->sync_pending &&
> (cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) {

Looks like you forgot to fix the alignment.

> complete(&ucsi->sync_ack);
> }
>
> --
> 2.39.2

--
heikki

2024-04-09 07:27:45

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH 2/3] usb: typec: ucsi_glink: drop NO_PARTNER_PDOS quirk for sm8550 / sm8650

On Mon, Apr 08, 2024 at 04:04:16AM +0300, Dmitry Baryshkov wrote:
> The Qualcomm SM8550 (and via a fallback compat SM8650) firmware properly
> handles the GET_PDOS command, it sends the CCI_BUSY notification,
> and then follows with the CCI_COMMAND_COMPLETE event. Stop using the quirk
> for those two platforms.
>
> Signed-off-by: Dmitry Baryshkov <[email protected]>

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

> ---
> drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index 9bd80a2218e4..9ffea20020e7 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -321,7 +321,7 @@ static const struct of_device_id pmic_glink_ucsi_of_quirks[] = {
> { .compatible = "qcom,sc8280xp-pmic-glink", .data = &quirk_sc8280xp, },
> { .compatible = "qcom,sm8350-pmic-glink", .data = &quirk_sc8180x, },
> { .compatible = "qcom,sm8450-pmic-glink", .data = &quirk_sm8450, },
> - { .compatible = "qcom,sm8550-pmic-glink", .data = &quirk_sc8280xp, },
> + { .compatible = "qcom,sm8550-pmic-glink", .data = &quirk_sm8450, },
> {}
> };
>
>
> --
> 2.39.2

--
heikki

2024-04-09 07:37:54

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH 1/3] usb: typec: ucsi_glink: enable the UCSI_DELAY_DEVICE_PDOS quirk on qcm6490

On Mon, Apr 08, 2024 at 04:04:15AM +0300, Dmitry Baryshkov wrote:
> Enable the UCSI_DELAY_DEVICE_PDOS quirk on Qualcomm QCM6490. This
> platform also doesn't correctly handle reading PD capabilities until PD
> partner is connected.
>
> Fixes: 5da727f75823 ("usb: typec: ucsi_glink: enable the UCSI_DELAY_DEVICE_PDOS quirk")
> Signed-off-by: Dmitry Baryshkov <[email protected]>

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

> ---
> drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index ef00a6563c88..9bd80a2218e4 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -316,7 +316,7 @@ static unsigned long quirk_sc8280xp = UCSI_NO_PARTNER_PDOS | UCSI_DELAY_DEVICE_P
> static unsigned long quirk_sm8450 = UCSI_DELAY_DEVICE_PDOS;
>
> static const struct of_device_id pmic_glink_ucsi_of_quirks[] = {
> - { .compatible = "qcom,qcm6490-pmic-glink", .data = &quirk_sc8180x, },
> + { .compatible = "qcom,qcm6490-pmic-glink", .data = &quirk_sc8280xp, },
> { .compatible = "qcom,sc8180x-pmic-glink", .data = &quirk_sc8180x, },
> { .compatible = "qcom,sc8280xp-pmic-glink", .data = &quirk_sc8280xp, },
> { .compatible = "qcom,sm8350-pmic-glink", .data = &quirk_sc8180x, },
>
> --
> 2.39.2

--
heikki