2022-07-15 10:08:52

by Gene Chen

[permalink] [raw]
Subject: [PATCH 0/3] usb: typec: tcpci_rt1711h: Add compatible with rt1715

This patch series add binding document for rt1711h and compatible driver with
rt1715.

Gene Chen (2)
dt-bindings usb: typec: rt1711h: Add binding for Richtek RT1711H
usb: typec: tcpci: Add get cc tcpci callback
usb: typec: tcpci_rt1711h: Add compatible with rt1715

Documentation/devicetree/bindings/usb/richtek,rt1711h.yaml | 96 +++++++
drivers/usb/typec/tcpm/tcpci.c | 3
drivers/usb/typec/tcpm/tcpci.h | 2
drivers/usb/typec/tcpm/tcpci_rt1711h.c | 168 ++++++++++++-
4 files changed, 262 insertions(+), 7 deletions(-)



2022-07-15 10:33:55

by Gene Chen

[permalink] [raw]
Subject: [PATCH 2/3] usb: typec: tcpci: Add get cc tcpci callback

From: Gene Chen <[email protected]>

Add set_vbus tcpci callback for vendor IC workaround.
According to different rp level detected, set corresponding
rx dead zone threshold in order to decode right pd message.

Signed-off-by: Gene Chen <[email protected]>
---
drivers/usb/typec/tcpm/tcpci.c | 3 +++
drivers/usb/typec/tcpm/tcpci.h | 2 ++
2 files changed, 5 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index f33e08eb7670..fc2f6191b7d3 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -243,6 +243,9 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
unsigned int reg, role_control;
int ret;

+ if (tcpci->data->get_cc)
+ return tcpci->data->get_cc(tcpci, tcpci->data, cc1, cc2);
+
ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &role_control);
if (ret < 0)
return ret;
diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h
index b2edd45f13c6..2cef19e131f8 100644
--- a/drivers/usb/typec/tcpm/tcpci.h
+++ b/drivers/usb/typec/tcpm/tcpci.h
@@ -190,6 +190,8 @@ struct tcpci_data {
unsigned char vbus_vsafe0v:1;

int (*init)(struct tcpci *tcpci, struct tcpci_data *data);
+ int (*get_cc)(struct tcpci *tcpci, struct tcpci_data *data,
+ enum typec_cc_status *cc1, enum typec_cc_status *cc2);
int (*set_vconn)(struct tcpci *tcpci, struct tcpci_data *data,
bool enable);
int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,
--
2.25.1

2022-07-15 14:15:34

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 2/3] usb: typec: tcpci: Add get cc tcpci callback

On 7/15/22 03:04, Gene Chen wrote:
> From: Gene Chen <[email protected]>
>
> Add set_vbus tcpci callback for vendor IC workaround.
> According to different rp level detected, set corresponding
> rx dead zone threshold in order to decode right pd message.
>

Looking at the next patch, I dispute the need for this callback.
From what I can see, the additional code should be implemented
in the driver's interrupt handler whenever CC changes, not when
CC values are read from higher level drivers.

Guenter

> Signed-off-by: Gene Chen <[email protected]>
> ---
> drivers/usb/typec/tcpm/tcpci.c | 3 +++
> drivers/usb/typec/tcpm/tcpci.h | 2 ++
> 2 files changed, 5 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index f33e08eb7670..fc2f6191b7d3 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -243,6 +243,9 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
> unsigned int reg, role_control;
> int ret;
>
> + if (tcpci->data->get_cc)
> + return tcpci->data->get_cc(tcpci, tcpci->data, cc1, cc2);
> +
> ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &role_control);
> if (ret < 0)
> return ret;
> diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h
> index b2edd45f13c6..2cef19e131f8 100644
> --- a/drivers/usb/typec/tcpm/tcpci.h
> +++ b/drivers/usb/typec/tcpm/tcpci.h
> @@ -190,6 +190,8 @@ struct tcpci_data {
> unsigned char vbus_vsafe0v:1;
>
> int (*init)(struct tcpci *tcpci, struct tcpci_data *data);
> + int (*get_cc)(struct tcpci *tcpci, struct tcpci_data *data,
> + enum typec_cc_status *cc1, enum typec_cc_status *cc2);
> int (*set_vconn)(struct tcpci *tcpci, struct tcpci_data *data,
> bool enable);
> int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,