summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2022-09-06 12:59:47 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-26 21:36:26 +0000
commit7792692d9874318efa2c819dc08b7abd65c52e89 (patch)
treedb54cc9f212aceed8e6f5f4c09af6df9df8b621c
parente384e55c5711fd62174e3aafc3e6b73679b1cd11 (diff)
downloadchrome-ec-7792692d9874318efa2c819dc08b7abd65c52e89.tar.gz
rex: Add support for C1 USB3 daughter board
This CL adds the configs required to support the USB3 C1 daughter board. In addition, the usbc support functions were updated to support C1. BRANCH=none BUG=b:240434243 TEST=zmake build rex Verified that C1 can attach and negotiate PD contract in both sink and source power roles. LOW_COVERAGE_REASON=This module does not currently have test coverage. b/247796816 has been opened to track the effort to add project specific tests for Rex. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I0782cf918b39b50713ca96d92d135e3122ac61c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3877665 Tested-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--zephyr/projects/rex/interrupts.dts15
-rw-r--r--zephyr/projects/rex/prj.conf7
-rw-r--r--zephyr/projects/rex/rex.dts23
-rw-r--r--zephyr/projects/rex/src/usbc_config.c68
-rw-r--r--zephyr/projects/rex/usbc.dts23
5 files changed, 105 insertions, 31 deletions
diff --git a/zephyr/projects/rex/interrupts.dts b/zephyr/projects/rex/interrupts.dts
index 7c4e6bca58..7de9141caf 100644
--- a/zephyr/projects/rex/interrupts.dts
+++ b/zephyr/projects/rex/interrupts.dts
@@ -42,6 +42,21 @@
flags = <GPIO_INT_EDGE_FALLING>;
handler = "bc12_interrupt";
};
+ int_usb_c1_tcpc: usb_c1_tcpc {
+ irq-pin = <&gpio_usb_c1_tcpc_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "tcpc_alert_event";
+ };
+ int_usb_c1_ppc: usb_c1_ppc {
+ irq-pin = <&gpio_usb_c1_ppc_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "ppc_interrupt";
+ };
+ int_usb_c1_bc12: usb_c1_bc12 {
+ irq-pin = <&gpio_usb_c1_bc12_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bc12_interrupt";
+ };
int_imu: ec_imu {
irq-pin = <&gpio_ec_imu_int_r_l>;
flags = <GPIO_INT_EDGE_FALLING>;
diff --git a/zephyr/projects/rex/prj.conf b/zephyr/projects/rex/prj.conf
index ec701e6c6e..62602854f2 100644
--- a/zephyr/projects/rex/prj.conf
+++ b/zephyr/projects/rex/prj.conf
@@ -101,22 +101,25 @@ CONFIG_PLATFORM_EC_USBA=y
# USBC
CONFIG_PLATFORM_EC_USBC_PPC=y
+CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y
+CONFIG_PLATFORM_EC_USBC_VCONN=y
CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
CONFIG_PLATFORM_EC_USB_PD_FRS=y
CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=y
CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y
CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y
CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y
-CONFIG_PLATFORM_EC_USBC_VCONN=y
CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
diff --git a/zephyr/projects/rex/rex.dts b/zephyr/projects/rex/rex.dts
index 259cd6ff4c..0db4b96aa7 100644
--- a/zephyr/projects/rex/rex.dts
+++ b/zephyr/projects/rex/rex.dts
@@ -197,6 +197,16 @@
pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
pinctrl-names = "default";
+
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ };
};
&i2c5_0 {
@@ -213,6 +223,19 @@
pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
pinctrl-names = "default";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c1_bc12>;
+ };
+
+ ppc_port1_nxp: nx20p348x@72 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x72>;
+ };
};
&i2c7_0 {
diff --git a/zephyr/projects/rex/src/usbc_config.c b/zephyr/projects/rex/src/usbc_config.c
index 3aeaac8977..66f3a1f45d 100644
--- a/zephyr/projects/rex/src/usbc_config.c
+++ b/zephyr/projects/rex/src/usbc_config.c
@@ -15,11 +15,13 @@
#include "driver/charger/isl9241.h"
#include "driver/retimer/bb_retimer_public.h"
#include "driver/tcpm/nct38xx.h"
+#include "driver/tcpm/ps8xxx_public.h"
#include "driver/tcpm/tcpci.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "i2c.h"
#include "ioexpander.h"
+#include "driver/ppc/nx20p348x.h"
#include "ppc/syv682x_public.h"
#include "system.h"
#include "task.h"
@@ -33,19 +35,27 @@
/* USB-C Configuration Start */
/* USB-C ports */
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_COUNT };
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
static void usbc_interrupt_init(void)
{
+ /* Only reset TCPC if not sysjump */
+ if (!system_jumped_late()) {
+ board_reset_pd_mcu();
+ }
+
/* Enable PPC interrupts. */
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
/* Enable TCPC interrupts. */
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
/* Enable BC 1.2 interrupts */
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12));
/* Enable SBU fault interrupts */
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault));
@@ -76,6 +86,9 @@ void tcpc_alert_event(enum gpio_signal signal)
case GPIO_USB_C0_TCPC_INT_ODL:
port = 0;
break;
+ case GPIO_USB_C1_TCPC_INT_ODL:
+ port = 1;
+ break;
default:
return;
}
@@ -115,6 +128,12 @@ void board_reset_pd_mcu(void)
{
/* Reset TCPC0 */
reset_nct38xx_port(USBC_PORT_C0);
+
+ /* Reset TCPC1 */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 0);
+ msleep(PS8XXX_RESET_DELAY_MS);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 1);
+ msleep(PS8815_FW_INIT_DELAY_MS);
}
uint16_t tcpc_get_alert_status(void)
@@ -122,10 +141,15 @@ uint16_t tcpc_get_alert_status(void)
uint16_t status = 0;
const struct gpio_dt_spec *tcpc_c0_rst_l;
const struct gpio_dt_spec *tcpc_c0_int_l;
+ const struct gpio_dt_spec *tcpc_c1_rst_l;
+ const struct gpio_dt_spec *tcpc_c1_int_l;
tcpc_c0_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl);
tcpc_c0_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl);
+ tcpc_c1_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl);
+ tcpc_c1_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl);
+
/*
* Check which port has the ALERT line set and ignore if that TCPC has
* its reset line active.
@@ -134,6 +158,10 @@ uint16_t tcpc_get_alert_status(void)
status |= PD_STATUS_TCPC_ALERT_0;
}
+ if (!gpio_pin_get_dt(tcpc_c1_int_l) && gpio_pin_get_dt(tcpc_c1_rst_l)) {
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+
return status;
}
@@ -143,7 +171,9 @@ void ppc_interrupt(enum gpio_signal signal)
case GPIO_USB_C0_PPC_INT_ODL:
syv682x_interrupt(USBC_PORT_C0);
break;
-
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(USBC_PORT_C1);
+ break;
default:
break;
}
@@ -155,7 +185,9 @@ void bc12_interrupt(enum gpio_signal signal)
case GPIO_USB_C0_BC12_INT_ODL:
usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
break;
-
+ case GPIO_USB_C1_BC12_INT_ODL:
+ usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
+ break;
default:
break;
}
@@ -218,38 +250,18 @@ int board_set_active_charge_port(int port)
* normal control.
*/
rv = EC_SUCCESS;
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (nct38xx_get_boot_type(i) != NCT38XX_BOOT_DEAD_BATTERY) {
- continue;
- }
-
+ if (port == USBC_PORT_C0 &&
+ nct38xx_get_boot_type(port) == NCT38XX_BOOT_DEAD_BATTERY) {
/* Handle dead battery boot case */
- CPRINTSUSB("Found dead battery on %d", i);
+ CPRINTSUSB("Found dead battery on C0");
/*
* If we have battery, get this port reset ASAP.
* This means temporarily rejecting charge manager
* sets to it.
*/
if (pd_is_battery_capable()) {
- reset_nct38xx_port(i);
- pd_set_error_recovery(i);
-
- if (port == i) {
- rv = EC_ERROR_INVAL;
- }
- } else if (port != i) {
- /*
- * If other port is selected and in dead battery
- * mode, reset this port. Otherwise, reject
- * change because we'll brown out.
- */
- if (nct38xx_get_boot_type(port) ==
- NCT38XX_BOOT_DEAD_BATTERY) {
- reset_nct38xx_port(i);
- pd_set_error_recovery(i);
- } else {
- rv = EC_ERROR_INVAL;
- }
+ reset_nct38xx_port(port);
+ pd_set_error_recovery(port);
}
}
diff --git a/zephyr/projects/rex/usbc.dts b/zephyr/projects/rex/usbc.dts
index 8b3d0aa316..84ae79fae6 100644
--- a/zephyr/projects/rex/usbc.dts
+++ b/zephyr/projects/rex/usbc.dts
@@ -11,7 +11,7 @@
usbc_port0: port0@0 {
compatible = "named-usbc-port";
reg = <0>;
- bc12 = <&i2c_ec_i2c_usb_c0_ppc_b>;
+ bc12 = <&bc12_port0>;
ppc = <&ppc_port0_syv>;
tcpc = <&tcpc_port0>;
chg = <&charger>;
@@ -26,5 +26,26 @@
compatible = "cros-ec,usbc-mux-virtual";
};
};
+
+ usbc_port1: port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ ppc = <&ppc_port1_nxp>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_c1 &tcpci_mux_c1>;
+ };
+ };
+ port1-muxes {
+ tcpci_mux_c1: tcpci-mux-c1 {
+ compatible = "cros-ec,usbc-mux-tcpci";
+ hpd-update = "ps8xxx_tcpc_update_hpd_status";
+ };
+ virtual_mux_c1: virtual-mux-c1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
};
};