diff options
author | Matt_Wang <Matt_Wang@compal.corp-partner.google.com> | 2020-07-10 14:39:24 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-17 05:06:56 +0000 |
commit | f0ed846e721e7c7fc6fbf4b49a3afc485d8512ac (patch) | |
tree | 890590ea6800941a30ed4f511841946ea519870c /board | |
parent | 7bd58571378a4cf2aeb0e93b67f645b8084c9b80 (diff) | |
download | chrome-ec-f0ed846e721e7c7fc6fbf4b49a3afc485d8512ac.tar.gz |
Fleex: enable 2nd ppc source syv682x
This patch adds 2nd ppc source syv682x base on GPIO97 status.
BUG=b:160139798
BRANCH=octopus
TEST=The GPIO97 high can switch PPC from NPX to syv682x code.
Change-Id: If813ed6993338981417d7271bf0920f15bdb5e1a
Signed-off-by: Matt_Wang <Matt_Wang@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2291451
Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Reviewed-by: Marco Chen <marcochen@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Commit-Queue: Matt Wang <matt_wang@compal.corp-partner.google.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/fleex/board.c | 58 | ||||
-rw-r--r-- | board/fleex/board.h | 5 | ||||
-rw-r--r-- | board/fleex/gpio.inc | 3 |
3 files changed, 63 insertions, 3 deletions
diff --git a/board/fleex/board.c b/board/fleex/board.c index c487da68f2..95d3f0fbdb 100644 --- a/board/fleex/board.c +++ b/board/fleex/board.c @@ -18,6 +18,7 @@ #include "driver/accelgyro_lsm6dsm.h" #include "driver/charger/isl923x.h" #include "driver/ppc/nx20p348x.h" +#include "driver/ppc/syv682x.h" #include "driver/tcpm/anx7447.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/tcpci.h" @@ -49,16 +50,57 @@ #define USB_PD_PORT_PS8751 1 static uint8_t sku_id; +static int is_support_syv_ppc; + +const struct ppc_config_t ppc_syv682x_port0 = { + .i2c_port = I2C_PORT_TCPC0, + .i2c_addr_flags = SYV682X_ADDR0_FLAGS, + .drv = &syv682x_drv, +}; + +const struct ppc_config_t ppc_syv682x_port1 = { + .i2c_port = I2C_PORT_TCPC1, + .i2c_addr_flags = SYV682X_ADDR0_FLAGS, + .drv = &syv682x_drv, +}; + +/* Check PPC_ID pin status to decide which one ppc is used. */ +static int board_is_syv_ppc(void) +{ + return gpio_get_level(GPIO_PPC_ID); +} + +static void board_update_ppc_config_from_board(void) +{ + if (!is_support_syv_ppc) + return; + + memcpy(&ppc_chips[USB_PD_PORT_TCPC_0], + &ppc_syv682x_port0, + sizeof(struct ppc_config_t)); + memcpy(&ppc_chips[USB_PD_PORT_TCPC_1], + &ppc_syv682x_port1, + sizeof(struct ppc_config_t)); + + gpio_set_flags(GPIO_USB_PD_C0_INT_ODL, GPIO_INT_BOTH); + gpio_set_flags(GPIO_USB_PD_C1_INT_ODL, GPIO_INT_BOTH); +} static void ppc_interrupt(enum gpio_signal signal) { switch (signal) { case GPIO_USB_PD_C0_INT_ODL: - nx20p348x_interrupt(0); + if (is_support_syv_ppc) + syv682x_interrupt(0); + else + nx20p348x_interrupt(0); break; case GPIO_USB_PD_C1_INT_ODL: - nx20p348x_interrupt(1); + if (is_support_syv_ppc) + syv682x_interrupt(1); + else + nx20p348x_interrupt(1); break; default: @@ -278,5 +320,17 @@ static void charger_set_buck_boost_mode(void) static void board_init(void) { charger_set_buck_boost_mode(); + + is_support_syv_ppc = board_is_syv_ppc(); + + board_update_ppc_config_from_board(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +int ppc_get_alert_status(int port) +{ + if (port == 0) + return gpio_get_level(GPIO_USB_PD_C0_INT_ODL) == 0; + + return gpio_get_level(GPIO_USB_PD_C1_INT_ODL) == 0; +}
\ No newline at end of file diff --git a/board/fleex/board.h b/board/fleex/board.h index fe48f4e232..d225b5cc1a 100644 --- a/board/fleex/board.h +++ b/board/fleex/board.h @@ -65,6 +65,11 @@ #define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) + +/* Additional PPC second source */ +#define CONFIG_USBC_PPC_SYV682X +#define CONFIG_USBC_PPC_DEDICATED_INT + #ifndef __ASSEMBLER__ #include "gpio_signal.h" diff --git a/board/fleex/gpio.inc b/board/fleex/gpio.inc index 726f2da951..efedd6989b 100644 --- a/board/fleex/gpio.inc +++ b/board/fleex/gpio.inc @@ -152,11 +152,12 @@ GPIO(EC_GPIO03, PIN(0, 3), GPIO_INPUT) /* TP only */ /* MKBP event synchronization */ GPIO(EC_INT_L, PIN(9, 4), GPIO_ODR_HIGH) /* EC_AP_INT_ODL */ +GPIO(PPC_ID, PIN(9, 7), GPIO_INPUT | GPIO_PULL_DOWN) /* PPC ID Pin */ + /* Unused Pins */ GPIO(CHARGER_PMON, PIN(4, 2), GPIO_INPUT) GPIO(CHARGER_IADP, PIN(4, 3), GPIO_INPUT) GPIO(EC_GPIO57, PIN(5, 7), GPIO_INPUT | GPIO_PULL_UP) /* TP Only */ -GPIO(EC_GPIO97, PIN(9, 7), GPIO_INPUT | GPIO_PULL_UP) /* TP Only */ GPIO(EC_I2S_SFRM, PIN(A, 5), GPIO_INPUT | GPIO_SEL_1P8V) GPIO(EC_I2S_SCLK, PIN(A, 7), GPIO_INPUT | GPIO_SEL_1P8V) GPIO(EC_I2S_TX_PCH_RX, PIN(B, 0), GPIO_INPUT | GPIO_SEL_1P8V) |