Commit abc028a2 authored by Badhri Jagan Sridharan's avatar Badhri Jagan Sridharan Committed by Greg Kroah-Hartman
Browse files

usb: typec: tcpci: Add callback for evaluating contaminant presence



This change adds callback to evaluate presence of contaminant in
the TCPCI layer.

Signed-off-by: default avatarBadhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20230114093246.1933321-2-badhri@google.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 599f008c
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -404,6 +404,14 @@ static void tcpci_frs_sourcing_vbus(struct tcpc_dev *dev)
		tcpci->data->frs_sourcing_vbus(tcpci, tcpci->data);
}

static void tcpci_check_contaminant(struct tcpc_dev *dev)
{
	struct tcpci *tcpci = tcpc_to_tcpci(dev);

	if (tcpci->data->check_contaminant)
		tcpci->data->check_contaminant(tcpci, tcpci->data);
}

static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable)
{
	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
@@ -782,6 +790,9 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
	tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus;
	tcpci->tcpc.set_partner_usb_comm_capable = tcpci_set_partner_usb_comm_capable;

	if (tcpci->data->check_contaminant)
		tcpci->tcpc.check_contaminant = tcpci_check_contaminant;

	if (tcpci->data->auto_discharge_disconnect) {
		tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge;
		tcpci->tcpc.set_auto_vbus_discharge_threshold =
+7 −0
Original line number Diff line number Diff line
@@ -188,6 +188,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.
 * @check_contaminant:
 *		Optional; The callback is invoked when chiplevel drivers indicated
 *		that the USB port needs to be checked for contaminant presence.
 *		Chip level drivers are expected to check for contaminant and call
 *		tcpm_clean_port when the port is clean to put the port back into
 *		toggling state.
 */
struct tcpci_data {
	struct regmap *regmap;
@@ -204,6 +210,7 @@ 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 (*check_contaminant)(struct tcpci *tcpci, struct tcpci_data *data);
};

struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);