summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2022-05-24 14:07:39 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-26 23:13:58 +0000
commitb1d76f2078c5d72347a442418c0e3f06129f5222 (patch)
treed1683ef7cd77a48df9e712d78ce80c4ca070de32
parent24dcbaf1a255324feb8f473972ba6dcc28468ae2 (diff)
downloadchrome-ec-b1d76f2078c5d72347a442418c0e3f06129f5222.tar.gz
tcpm: Support PD chips with SBU protection
Some PD chips have integrated port protection for SBU lines and the switches to enable the SBU lines coming out of the PD chip are controlled by vendor specific registers. Hence, added the code in TCPM & driver skeleton in TCPCI to support those chips. By checking if the SBU enable function exists in TCPM driver before trying to enable the SBU from discrete PPC, this code supports co-existence of both PD based SBU protection and discrete PPC chip SBU protection in a same platform. BUG=none BRANCH=none TEST=make buildall -j, zmake testall Change-Id: I3d3a5eec9077df95c0eb91cf1a709cb79f36ca60 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3227374 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/typec_control.c4
-rw-r--r--include/config.h7
-rw-r--r--include/driver/tcpm/tcpm.h18
-rw-r--r--include/usb_pd_tcpm.h19
-rw-r--r--zephyr/Kconfig.tcpm7
-rw-r--r--zephyr/shim/include/config_chip.h5
6 files changed, 59 insertions, 1 deletions
diff --git a/common/typec_control.c b/common/typec_control.c
index 0528d88f60..1fea258389 100644
--- a/common/typec_control.c
+++ b/common/typec_control.c
@@ -21,6 +21,10 @@ void typec_set_sbu(int port, bool enable)
{
if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
ppc_set_sbu(port, enable);
+
+#ifdef CONFIG_USB_PD_TCPM_SBU
+ tcpc_set_sbu(port, enable);
+#endif
}
__overridable void typec_set_source_current_limit(int port,
diff --git a/include/config.h b/include/config.h
index 9ffaacaa54..84338a56ff 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4903,6 +4903,13 @@
#undef CONFIG_USB_PD_TCPM_MUX
/*
+ * Some PD chips have integrated port protection for SBU lines.
+ * If the switches to enable those SBU lines are controlled by the PD
+ * chip, enable this config.
+ */
+#undef CONFIG_USB_PD_TCPM_SBU
+
+/*
* The TCPM must know whether VBUS is present in order to make proper state
* transitions. In addition, charge_manager must know about VBUS presence in
* order to make charging decisions. VBUS state can be determined by various
diff --git a/include/driver/tcpm/tcpm.h b/include/driver/tcpm/tcpm.h
index 8c77caffc0..ef47a3b1e2 100644
--- a/include/driver/tcpm/tcpm.h
+++ b/include/driver/tcpm/tcpm.h
@@ -432,6 +432,23 @@ static inline int tcpm_set_frs_enable(int port, int enable)
}
#endif /* defined(CONFIG_USB_PD_FRS) */
+#ifdef CONFIG_USB_PD_TCPM_SBU
+/**
+ * Turn on/off the SBU FETs
+ *
+ * @param port Type-C port number
+ * @param enable true:enable, false:disable
+ *
+ * @return EC_SUCCESS or error
+ */
+static inline int tcpc_set_sbu(int port, bool enable)
+{
+ return tcpc_config[port].drv->set_sbu ?
+ tcpc_config[port].drv->set_sbu(port, enable) :
+ EC_SUCCESS;
+}
+#endif /* CONFIG_USB_PD_TCPM_SBU */
+
#else /* CONFIG_USB_PD_TCPC */
/**
@@ -564,7 +581,6 @@ int tcpm_transmit(int port, enum tcpci_msg_type type, uint16_t header,
* @param port Type-C port number
*/
void tcpc_alert(int port);
-
#endif /* CONFIG_USB_PD_TCPC */
/**
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index 641c7afd5c..e34329eb18 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -426,6 +426,25 @@ struct tcpm_drv {
*/
int (*set_src_ctrl)(int port, int enable);
+#ifdef CONFIG_USB_PD_TCPM_SBU
+ /*
+ * Enable SBU lines.
+ *
+ * Some PD chips have integrated port protection for SBU lines and the
+ * switches to enable the SBU lines coming out of the PD chips are
+ * controlled by vendor specific registers. Hence, this function has to
+ * be written in vendor specific driver code and the board specific
+ * tcpc_config[] has to initialize the function with vendor specific
+ * function at board level.
+ *
+ * @param port Type-C port number
+ * @enable true for enable, false for disable
+ *
+ * @return EC_SUCCESS or error
+ */
+ int (*set_sbu)(int port, bool enable);
+#endif /* CONFIG_USB_PD_TCPM_SBU */
+
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
/**
* Instructs the TCPC to enter into low power mode.
diff --git a/zephyr/Kconfig.tcpm b/zephyr/Kconfig.tcpm
index d74c3368d6..1e7d52358a 100644
--- a/zephyr/Kconfig.tcpm
+++ b/zephyr/Kconfig.tcpm
@@ -249,6 +249,13 @@ config PLATFORM_EC_USB_PD_TCPM_MUX
Controller Interface Specification, Revision 2.0, Version 1.2 for more
information.
+config PLATFORM_EC_USB_PD_TCPM_SBU
+ bool "PD chip has integrated port protection for SBU lines"
+ help
+ Some PD chips have integrated port protection for SBU lines.
+ If the switches to enable those SBU lines are controlled by the PD
+ chip, enable this config.
+
config PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP
bool "Console command: tcpc_dump"
# anx7447 also supports this command, but is not yet enabled
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 080b585b16..feeb5c2599 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1686,6 +1686,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_PD_TCPM_MUX
#endif
+#undef CONFIG_USB_PD_TCPM_SBU
+#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU
+#define CONFIG_USB_PD_TCPM_SBU
+#endif
+
#undef CONFIG_USBC_PPC_DEDICATED_INT
#ifdef CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT
#define CONFIG_USBC_PPC_DEDICATED_INT