Message ID | 20210312052443.3797674-1-badhri@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/2] usb: typec: tcpci: Add tcpc chip level callbacks | expand |
On Thu, Mar 11, 2021 at 09:24:42PM -0800, Badhri Jagan Sridharan wrote: > This change adds chip callbacks for the following operations: > 1. Notifying port role > 2. Notifying orientation This should be 2 different patches, one per callback, right? And where is the code using these callbacks? We can't add any hooks without in-tree users, as you know. thanks, greg k-h
On Fri, Mar 12, 2021 at 07:33:45AM +0100, Greg Kroah-Hartman wrote: > On Thu, Mar 11, 2021 at 09:24:42PM -0800, Badhri Jagan Sridharan wrote: > > This change adds chip callbacks for the following operations: > > 1. Notifying port role > > 2. Notifying orientation > > This should be 2 different patches, one per callback, right? > > And where is the code using these callbacks? We can't add any hooks > without in-tree users, as you know. Ah, your second patch added that, sorry, missed it. This should be a 4 patch series, remember, only do one thing per patch. thanks, greg k-h
On Thu, Mar 11, 2021 at 10:34 PM Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > > On Fri, Mar 12, 2021 at 07:33:45AM +0100, Greg Kroah-Hartman wrote: > > On Thu, Mar 11, 2021 at 09:24:42PM -0800, Badhri Jagan Sridharan wrote: > > > This change adds chip callbacks for the following operations: > > > 1. Notifying port role > > > 2. Notifying orientation > > > > This should be 2 different patches, one per callback, right? > > > > And where is the code using these callbacks? We can't add any hooks > > without in-tree users, as you know. > > Ah, your second patch added that, sorry, missed it. > > This should be a 4 patch series, remember, only do one thing per patch. Sure. Will do in the next version. Thanks, Badhri > > thanks, > > greg k-h
diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 027afd7dfdce..c37bbb2e9961 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -265,9 +265,16 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, if (ret < 0) return ret; - return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL, + ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL, (polarity == TYPEC_POLARITY_CC2) ? TCPC_TCPC_CTRL_ORIENTATION : 0); + if (ret < 0) + return ret; + + if (tcpci->data->set_cc_polarity) + tcpci->data->set_cc_polarity(tcpci, tcpci->data, polarity); + + return ret; } static void tcpci_set_partner_usb_comm_capable(struct tcpc_dev *tcpc, bool capable) @@ -395,6 +402,9 @@ static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached, if (ret < 0) return ret; + if (tcpci->data->set_roles) + tcpci->data->set_roles(tcpci, tcpci->data, attached, role, data); + return 0; } diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h index 57b6e24e0a0c..75a2c9b575b5 100644 --- a/drivers/usb/typec/tcpm/tcpci.h +++ b/drivers/usb/typec/tcpm/tcpci.h @@ -165,6 +165,12 @@ struct tcpci; * Optional; The USB Communications Capable bit indicates if port * partner is capable of communication over the USB data lines * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. + * @set_roles: + * Optional; This callback notifies the TCPC driver of the resolved + * port role and attached status. + * @set_cc_polarity: + * Optional; This callback notifies the TCPC driver of the resolved + * polarity. */ struct tcpci_data { struct regmap *regmap; @@ -181,6 +187,10 @@ struct tcpci_data { void (*frs_sourcing_vbus)(struct tcpci *tcpci, struct tcpci_data *data); void (*set_partner_usb_comm_capable)(struct tcpci *tcpci, struct tcpci_data *data, bool capable); + void (*set_roles)(struct tcpci *tcpci, struct tcpci_data *data, bool attached, + enum typec_role role, enum typec_data_role data_role); + void (*set_cc_polarity)(struct tcpci *tcpci, struct tcpci_data *data, + enum typec_cc_polarity polarity); }; struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);
This change adds chip callbacks for the following operations: 1. Notifying port role 2. Notifying orientation Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> --- Changes since V1: - Dropped changes related to get_/set_current_limit and pd_capable callback. Will send them in as separate patches. --- drivers/usb/typec/tcpm/tcpci.c | 12 +++++++++++- drivers/usb/typec/tcpm/tcpci.h | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)