usb: typec: maxim_contaminant: Implement check_contaminant callback
authorBadhri Jagan Sridharan <badhri@google.com>
Sat, 14 Jan 2023 09:32:46 +0000 (01:32 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Jan 2023 16:29:23 +0000 (17:29 +0100)
commit02b332a06397ef213790f9561c9c022ce1af1a97
tree502d06def7b939c97bf7cfa2a816efa64f3dffac
parentabc028a270f47f86060ef479395d1bb8c2ab6e7e
usb: typec: maxim_contaminant: Implement check_contaminant callback

Maxim TCPC has additional ADCs and low current(1ua) current source
to measure the impedance of CC and SBU pins. When tcpm invokes
the check_contaminant callback, Maxim TCPC measures the impedance
of the CC & SBU pins and when the impedance measured is less than
1MOhm, it is assumed that USB-C port is contaminated. CC comparators
are also checked to differentiate between presence of sink and
contaminant. Once USB-C is deemed to be contaminated, MAXIM TCPC
has additional hardware to disable normal DRP toggling cycle and
enable 1ua on CC pins once every 2.4secs/4.8secs. Maxim TCPC
interrupts AP once the impedance on the CC pin is above the
1MOhm threshold. The Maxim tcpc driver then signals TCPM_PORT_CLEAN
to restart toggling.

Renaming tcpci_maxim.c to tcpci_maxim_core.c and moving reg read/write
helper functions to the tcpci_maxim.h header file.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230114093246.1933321-3-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/tcpm/Makefile
drivers/usb/typec/tcpm/maxim_contaminant.c [new file with mode: 0644]
drivers/usb/typec/tcpm/tcpci_maxim.h [new file with mode: 0644]
drivers/usb/typec/tcpm/tcpci_maxim_core.c [moved from drivers/usb/typec/tcpm/tcpci_maxim.c with 93% similarity]