summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhurima Paruchuri <mparuchuri@google.com>2023-03-28 10:16:26 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-14 21:35:54 +0000
commitfe2a860907fb41a96bca52940aef65a1506e3b76 (patch)
treefc0168a437da1ab2cbb2302a606b14def081d55b
parent2b4c13f25254014c0098a83a7f5bcd4880f5bd62 (diff)
downloadchrome-ec-fe2a860907fb41a96bca52940aef65a1506e3b76.tar.gz
zephyr: tcpc: Add TCPC alt support for all existing TCPC
Add TCPC alt support for all TCPCs and tests to test the working of TCPC alternatives BRANCH=none BUG=b:274126703 TEST=./twister -s drivers/drivers.usbc_tcpc -c Change-Id: Icafdaf8b940b09cfc3c17ed124e1b4a0a9427d01 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4375619 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--include/driver/tcpm/ps8xxx_public.h2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/analogix,anx7447-tcpc.yaml2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/cypress,ccgxxf.yaml2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/fairchild,fusb302.yaml2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/nuvoton,nct38xx.yaml2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/parade,ps8xxx.yaml2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml2
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/richtek,rt1718s-tcpc.yaml2
-rw-r--r--zephyr/shim/include/usbc/tcpci.h25
-rw-r--r--zephyr/shim/src/tcpc.c23
-rw-r--r--zephyr/test/drivers/testcase.yaml2
-rw-r--r--zephyr/test/drivers/usbc_tcpc/src/tcpc_shim.c24
-rw-r--r--zephyr/test/drivers/usbc_tcpc/tcpc_alts.dts66
13 files changed, 134 insertions, 22 deletions
diff --git a/include/driver/tcpm/ps8xxx_public.h b/include/driver/tcpm/ps8xxx_public.h
index d327dee2a3..1fdd264acd 100644
--- a/include/driver/tcpm/ps8xxx_public.h
+++ b/include/driver/tcpm/ps8xxx_public.h
@@ -10,8 +10,6 @@
#include "usb_mux.h"
-struct usb_mux;
-
/* I2C interface */
#define PS8XXX_I2C_ADDR1_P1_FLAGS 0x09
#define PS8XXX_I2C_ADDR1_P2_FLAGS 0x0A
diff --git a/zephyr/dts/bindings/usbc/tcpc/analogix,anx7447-tcpc.yaml b/zephyr/dts/bindings/usbc/tcpc/analogix,anx7447-tcpc.yaml
index 028bcfb595..aac15ad3cf 100644
--- a/zephyr/dts/bindings/usbc/tcpc/analogix,anx7447-tcpc.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/analogix,anx7447-tcpc.yaml
@@ -2,7 +2,7 @@ description: Analogix ANX7447 USBC TCPC binding
compatible: "analogix,anx7447-tcpc"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
tcpc-flags:
diff --git a/zephyr/dts/bindings/usbc/tcpc/cypress,ccgxxf.yaml b/zephyr/dts/bindings/usbc/tcpc/cypress,ccgxxf.yaml
index 2011c70662..71e3fa4250 100644
--- a/zephyr/dts/bindings/usbc/tcpc/cypress,ccgxxf.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/cypress,ccgxxf.yaml
@@ -6,7 +6,7 @@ description: USBC TCPC
compatible: "cypress,ccgxxf"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
tcpc-flags:
diff --git a/zephyr/dts/bindings/usbc/tcpc/fairchild,fusb302.yaml b/zephyr/dts/bindings/usbc/tcpc/fairchild,fusb302.yaml
index b6748a2f8b..51401f6722 100644
--- a/zephyr/dts/bindings/usbc/tcpc/fairchild,fusb302.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/fairchild,fusb302.yaml
@@ -2,7 +2,7 @@ description: USBC TCPC
compatible: "fairchild,fusb302"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
tcpc-flags:
diff --git a/zephyr/dts/bindings/usbc/tcpc/nuvoton,nct38xx.yaml b/zephyr/dts/bindings/usbc/tcpc/nuvoton,nct38xx.yaml
index 77dea4d348..14e16c87bb 100644
--- a/zephyr/dts/bindings/usbc/tcpc/nuvoton,nct38xx.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/nuvoton,nct38xx.yaml
@@ -6,7 +6,7 @@ description: Nuvoton NCT38XX USB TCPC binding
compatible: "nuvoton,nct38xx"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
gpio-dev:
diff --git a/zephyr/dts/bindings/usbc/tcpc/parade,ps8xxx.yaml b/zephyr/dts/bindings/usbc/tcpc/parade,ps8xxx.yaml
index 733b779726..a1122aeb7d 100644
--- a/zephyr/dts/bindings/usbc/tcpc/parade,ps8xxx.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/parade,ps8xxx.yaml
@@ -2,7 +2,7 @@ description: USBC TCPC
compatible: "parade,ps8xxx"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
tcpc-flags:
diff --git a/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml b/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml
index 6139db28cf..8f221890c6 100644
--- a/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml
@@ -6,7 +6,7 @@ description: Renesas RAA489000 USB TCPC binding
compatible: "renesas,raa489000"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
tcpc-flags:
diff --git a/zephyr/dts/bindings/usbc/tcpc/richtek,rt1718s-tcpc.yaml b/zephyr/dts/bindings/usbc/tcpc/richtek,rt1718s-tcpc.yaml
index 8baa3ee550..ce20dc15ad 100644
--- a/zephyr/dts/bindings/usbc/tcpc/richtek,rt1718s-tcpc.yaml
+++ b/zephyr/dts/bindings/usbc/tcpc/richtek,rt1718s-tcpc.yaml
@@ -6,7 +6,7 @@ description: USBC RT1718S TCPC
compatible: "richtek,rt1718s-tcpc"
-include: i2c-device.yaml
+include: ["i2c-device.yaml", "cros-ec,tcpci.yaml"]
properties:
tcpc-flags:
diff --git a/zephyr/shim/include/usbc/tcpci.h b/zephyr/shim/include/usbc/tcpci.h
index f106f441a6..f388f2eeeb 100644
--- a/zephyr/shim/include/usbc/tcpci.h
+++ b/zephyr/shim/include/usbc/tcpci.h
@@ -4,7 +4,18 @@
*/
#include "driver/tcpm/tcpci.h"
+#include "usbc/tcpc_anx7447.h"
+#include "usbc/tcpc_anx7447_emul.h"
+#include "usbc/tcpc_ccgxxf.h"
+#include "usbc/tcpc_fusb302.h"
+#include "usbc/tcpc_generic_emul.h"
+#include "usbc/tcpc_nct38xx.h"
+#include "usbc/tcpc_ps8xxx.h"
+#include "usbc/tcpc_ps8xxx_emul.h"
+#include "usbc/tcpc_raa489000.h"
#include "usbc/tcpc_rt1715.h"
+#include "usbc/tcpc_rt1718s.h"
+#include "usbc/utils.h"
#include <zephyr/devicetree.h>
@@ -64,7 +75,21 @@
* Forward declare a struct tcpc_config_t for every TCPC node in the tree with
* the "is-alt" property set.
*/
+DT_FOREACH_STATUS_OKAY(ANX7447_TCPC_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(CCGXXF_TCPC_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(FUSB302_TCPC_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(PS8XXX_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(NCT38XX_TCPC_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(RAA489000_TCPC_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(RT1718S_TCPC_COMPAT, TCPC_ALT_DECLARE)
DT_FOREACH_STATUS_OKAY(RT1715_TCPC_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(TCPCI_COMPAT, TCPC_ALT_DECLARE)
+
+#ifdef TEST_BUILD
+DT_FOREACH_STATUS_OKAY(TCPCI_EMUL_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(PS8XXX_EMUL_COMPAT, TCPC_ALT_DECLARE)
+DT_FOREACH_STATUS_OKAY(ANX7447_EMUL_COMPAT, TCPC_ALT_DECLARE)
+#endif
#define TCPC_ENABLE_ALTERNATE_BY_NODELABEL(usb_port_num, nodelabel) \
memcpy(&tcpc_config[usb_port_num], \
diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c
index 842c2584ab..dbe05d9565 100644
--- a/zephyr/shim/src/tcpc.c
+++ b/zephyr/shim/src/tcpc.c
@@ -98,8 +98,31 @@ MAYBE_CONST struct tcpc_config_t tcpc_config[] = { DT_FOREACH_STATUS_OKAY(
* Define a struct tcpc_config_t for every TCPC node in the tree with the
* "is-alt" property set.
*/
+DT_FOREACH_STATUS_OKAY_VARGS(ANX7447_TCPC_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_ANX7447)
+DT_FOREACH_STATUS_OKAY_VARGS(CCGXXF_TCPC_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_CCGXXF)
+DT_FOREACH_STATUS_OKAY_VARGS(FUSB302_TCPC_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_FUSB302)
+DT_FOREACH_STATUS_OKAY_VARGS(PS8XXX_COMPAT, TCPC_ALT_DEFINE, TCPC_CONFIG_PS8XXX)
+DT_FOREACH_STATUS_OKAY_VARGS(NCT38XX_TCPC_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_NCT38XX)
+DT_FOREACH_STATUS_OKAY_VARGS(RAA489000_TCPC_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_RAA489000)
+DT_FOREACH_STATUS_OKAY_VARGS(RT1718S_TCPC_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_RT1718S)
DT_FOREACH_STATUS_OKAY_VARGS(RT1715_TCPC_COMPAT, TCPC_ALT_DEFINE,
TCPC_CONFIG_RT1715)
+DT_FOREACH_STATUS_OKAY_VARGS(TCPCI_COMPAT, TCPC_ALT_DEFINE, TCPC_CONFIG_TCPCI)
+
+#ifdef TEST_BUILD
+DT_FOREACH_STATUS_OKAY_VARGS(TCPCI_EMUL_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_TCPCI_EMUL)
+DT_FOREACH_STATUS_OKAY_VARGS(PS8XXX_EMUL_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_PS8XXX_EMUL)
+DT_FOREACH_STATUS_OKAY_VARGS(ANX7447_EMUL_COMPAT, TCPC_ALT_DEFINE,
+ TCPC_CONFIG_ANX7447_EMUL)
+#endif
#ifdef CONFIG_PLATFORM_EC_TCPC_INTERRUPT
diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml
index 18391e1acf..0373c0a97b 100644
--- a/zephyr/test/drivers/testcase.yaml
+++ b/zephyr/test/drivers/testcase.yaml
@@ -432,6 +432,8 @@ tests:
- usbc_tcpc/tcpc_alts.dts
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_TCPC=y
+ - CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n
+ - CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=n
drivers.usbc_retimer.anx7483:
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_RETIMER_ANX7483=y
diff --git a/zephyr/test/drivers/usbc_tcpc/src/tcpc_shim.c b/zephyr/test/drivers/usbc_tcpc/src/tcpc_shim.c
index eb15a45416..a947682a11 100644
--- a/zephyr/test/drivers/usbc_tcpc/src/tcpc_shim.c
+++ b/zephyr/test/drivers/usbc_tcpc/src/tcpc_shim.c
@@ -17,26 +17,34 @@ static struct tcpc_config_t tcpc_config_saved[] = { DT_FOREACH_STATUS_OKAY(
ZTEST(tcpc_shim, test_tcpc_alts_exist)
{
- zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_0_alt));
- zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_1_alt));
+ /* Verify all TCPC types are able to create an alternate TCPC entry */
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_anx7447_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_ccgxxf_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_fusb302_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_ps8xxx_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_raa489000_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_nct38xx_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_rt1718s_alt));
+ zassert_not_null(&TCPC_ALT_FROM_NODELABEL(tcpc_alt));
}
ZTEST(tcpc_shim, test_tcpc_alt_enable)
{
/* Enable an alternate TCPC on each USB-C port */
- TCPC_ENABLE_ALTERNATE_BY_NODELABEL(0, tcpc_rt1715_0_alt);
- TCPC_ENABLE_ALTERNATE_BY_NODELABEL(1, tcpc_rt1715_1_alt);
+ TCPC_ENABLE_ALTERNATE_BY_NODELABEL(0, tcpc_ps8xxx_alt);
+ TCPC_ENABLE_ALTERNATE_BY_NODELABEL(1, tcpc_rt1715_alt);
zassert_mem_equal(&tcpc_config[0],
- &TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_0_alt),
+ &TCPC_ALT_FROM_NODELABEL(tcpc_ps8xxx_alt),
sizeof(struct tcpc_config_t));
zassert_mem_equal(&tcpc_config[1],
- &TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_1_alt),
+ &TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_alt),
sizeof(struct tcpc_config_t));
- TCPC_ENABLE_ALTERNATE_BY_NODELABEL(0, tcpc_rt1715_1_alt);
+ TCPC_ENABLE_ALTERNATE_BY_NODELABEL(0, tcpc_anx7447_alt);
zassert_mem_equal(&tcpc_config[0],
- &TCPC_ALT_FROM_NODELABEL(tcpc_rt1715_1_alt),
+ &TCPC_ALT_FROM_NODELABEL(tcpc_anx7447_alt),
sizeof(struct tcpc_config_t));
}
diff --git a/zephyr/test/drivers/usbc_tcpc/tcpc_alts.dts b/zephyr/test/drivers/usbc_tcpc/tcpc_alts.dts
index 5534d42a97..8fe20cf879 100644
--- a/zephyr/test/drivers/usbc_tcpc/tcpc_alts.dts
+++ b/zephyr/test/drivers/usbc_tcpc/tcpc_alts.dts
@@ -14,7 +14,54 @@
#size-cells = <0>;
status = "okay";
- tcpc_rt1715_0_alt: tcpc-rt1715-0-alt@a{
+ tcpc_anx7447_alt: tcpc-anx7447-alt@2c {
+ compatible = "analogix,anx7447-tcpc", "cros,i2c-mock";
+ reg = <0x2c>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ is-alt;
+ };
+
+ tcpc_ccgxxf_alt: tcpc-ccgxxf-alt@11 {
+ compatible = "cypress,ccgxxf", "cros,i2c-mock";
+ reg = <0x11>;
+ is-alt;
+ };
+
+ tcpc_fusb302_alt: tcpc-fusb302-alt@22 {
+ compatible = "fairchild,fusb302", "cros,i2c-mock";
+ reg = <0x22>;
+ is-alt;
+ };
+
+ tcpc_ps8xxx_alt: tcpc-ps8xxx-alt@b {
+ compatible = "parade,ps8xxx", "cros,i2c-mock";
+ reg = < 0xb >;
+ tcpc-flags = < 0xd8 >;
+ is-alt;
+ };
+
+ tcpc_raa489000_alt: tcpc-raa489000-alt@e {
+ compatible = "renesas,raa489000", "cros,i2c-mock";
+ reg = <0xe>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ is-alt;
+ };
+
+ tcpc_nct38xx_alt: tcpc-nct38xx-alt@73 {
+ compatible = "nuvoton,nct38xx", "cros,i2c-mock";
+ reg = <0x73>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
+ is-alt;
+ };
+
+
+ tcpc_rt1715_alt: tcpc-rt1715-alt@a{
compatible = "richtek,rt1715-tcpc", "cros,i2c-mock";
reg = <0xa>;
tcpc-flags = <(
@@ -23,10 +70,19 @@
is-alt;
};
- tcpc_rt1715_1_alt: tcpc-rt1715-1-alt@b{
- compatible = "richtek,rt1715-tcpc", "cros,i2c-mock";
- reg = <0xb>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ tcpc_rt1718s_alt: tcpc-rt1718s-alt@40 {
+ compatible = "richtek,rt1718s-tcpc", "cros,i2c-mock";
+ reg = <0x40>;
+ tcpc-flags = <(
+ TCPC_FLAGS_ALERT_OD |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ is-alt;
+ };
+
+ tcpc_alt: tcpc-alt@41 {
+ compatible = "cros-ec,tcpci", "cros,i2c-mock";
+ reg = <0x41>;
is-alt;
};
};