diff options
Diffstat (limited to 'board/meep/board.c')
-rw-r--r-- | board/meep/board.c | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/board/meep/board.c b/board/meep/board.c index 068d4140df..0577671755 100644 --- a/board/meep/board.c +++ b/board/meep/board.c @@ -33,7 +33,6 @@ #include "motion_sense.h" #include "power.h" #include "power_button.h" -#include "stdbool.h" #include "switch.h" #include "system.h" #include "tablet_mode.h" @@ -58,20 +57,21 @@ should not be defined." #endif static uint8_t sku_id; -static bool support_syv_ppc; +static int c0_port_ppc; +static int c1_port_ppc; static void ppc_interrupt(enum gpio_signal signal) { switch (signal) { case GPIO_USB_PD_C0_INT_ODL: - if (support_syv_ppc) + if (c0_port_ppc == PPC_SYV682X) syv682x_interrupt(0); else nx20p348x_interrupt(0); break; case GPIO_USB_PD_C1_INT_ODL: - if (support_syv_ppc) + if (c1_port_ppc == PPC_SYV682X) syv682x_interrupt(1); else nx20p348x_interrupt(1); @@ -253,9 +253,38 @@ static void board_update_sensor_config_from_sku(void) } } -static bool board_is_support_syv_ppc(uint32_t board_version) +static int get_ppc_port_config(uint32_t board_version, int port) { - return ((board_version >= 6) && gpio_get_level(GPIO_PPC_ID)); + switch (port) { + /* + * Meep C0 port PPC was configrated by PPC ID pin only. + */ + case USB_PD_PORT_TCPC_0: + if ((board_version >= 6) && gpio_get_level(GPIO_PPC_ID)) + return PPC_SYV682X; + else + return PPC_NX20P348X; + /* + * Meep C1 port PPC was configrated by PPC ID pin or SSFC, + * The first of all we should check SSFC with priority one, + * then check PPC ID if board is unalbe to get SSFC. + */ + case USB_PD_PORT_TCPC_1: + switch (get_cbi_ssfc_ppc_p1()) { + case SSFC_PPC_P1_DEFAULT: + if ((board_version >= 6) && gpio_get_level(GPIO_PPC_ID)) + return PPC_SYV682X; + else + return PPC_NX20P348X; + case SSFC_PPC_P1_SYV682X: + return PPC_SYV682X; + case SSFC_PPC_P1_NX20P348X: + default: + return PPC_NX20P348X; + } + default: + return PPC_NX20P348X; + } } static void cbi_init(void) @@ -271,7 +300,8 @@ static void cbi_init(void) if (cbi_get_board_version(&val) == EC_SUCCESS) ccprints("Board Version: %d", val); - support_syv_ppc = board_is_support_syv_ppc(val); + c0_port_ppc = get_ppc_port_config(val, USB_PD_PORT_TCPC_0); + c1_port_ppc = get_ppc_port_config(val, USB_PD_PORT_TCPC_1); } DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1); @@ -379,18 +409,21 @@ static const struct ppc_config_t ppc_syv682x_port1 = { static void board_setup_ppc(void) { - if (!support_syv_ppc) - return; + if (c0_port_ppc == PPC_SYV682X) { + memcpy(&ppc_chips[USB_PD_PORT_TCPC_0], + &ppc_syv682x_port0, + sizeof(struct ppc_config_t)); - 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_C0_INT_ODL, GPIO_INT_BOTH); - gpio_set_flags(GPIO_USB_PD_C1_INT_ODL, GPIO_INT_BOTH); + if (c1_port_ppc == PPC_SYV682X) { + memcpy(&ppc_chips[USB_PD_PORT_TCPC_1], + &ppc_syv682x_port1, + sizeof(struct ppc_config_t)); + + gpio_set_flags(GPIO_USB_PD_C1_INT_ODL, GPIO_INT_BOTH); + } } DECLARE_HOOK(HOOK_INIT, board_setup_ppc, HOOK_PRIO_INIT_I2C + 2); |