diff options
-rw-r--r-- | board/yorp/board.c | 35 | ||||
-rw-r--r-- | board/yorp/board.h | 5 |
2 files changed, 31 insertions, 9 deletions
diff --git a/board/yorp/board.c b/board/yorp/board.c index e00b1313aa..903d1b7403 100644 --- a/board/yorp/board.c +++ b/board/yorp/board.c @@ -10,6 +10,7 @@ #include "common.h" #include "driver/bc12/bq24392.h" #include "driver/charger/bd9995x.h" +#include "driver/ppc/nx20p3483.h" #include "driver/tcpm/anx74xx.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/tcpci.h" @@ -38,7 +39,18 @@ static void tcpc_alert_event(enum gpio_signal signal) static void ppc_interrupt(enum gpio_signal signal) { - /* TODO(b/74127309): Flesh out USB code */ + switch (signal) { + case GPIO_USB_PD_C0_INT_L: + nx20p3483_interrupt(0); + break; + + case GPIO_USB_PD_C1_INT_L: + nx20p3483_interrupt(1); + break; + + default: + break; + } } /* Must come after other header files and GPIO interrupts*/ @@ -124,6 +136,14 @@ void chipset_do_shutdown(void) ; } +static void board_init(void) +{ + /* Enable PPC interrupts. */ + gpio_enable_interrupt(GPIO_USB_PD_C0_INT_L); + gpio_enable_interrupt(GPIO_USB_PD_C1_INT_L); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + enum adc_channel board_get_vbus_adc(int port) { return port ? ADC_VBUS_C1 : ADC_VBUS_C0; @@ -191,15 +211,16 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { const struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { [USB_PD_PORT_ANX74XX] = { .i2c_port = I2C_PORT_TCPC0, - /* TODO(b/74206647): Write PPC driver */ - .i2c_addr = 0, - .drv = 0 + .i2c_addr = NX20P3483_ADDR0, + .drv = &nx20p3483_drv, }, [USB_PD_PORT_PS8751] = { .i2c_port = I2C_PORT_TCPC1, - /* TODO(b/74206647): Write PPC driver */ - .i2c_addr = 0, - .drv = 0 + .i2c_addr = NX20P3483_ADDR0, + .drv = &nx20p3483_drv, + .flags = PPC_CFG_FLAGS_GPIO_CONTROL, + .snk_gpio = GPIO_USB_C1_CHARGE_ON, + .src_gpio = GPIO_EN_USB_C1_5V_OUT, }, }; const unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); diff --git a/board/yorp/board.h b/board/yorp/board.h index 3061b7b75a..44017047d5 100644 --- a/board/yorp/board.h +++ b/board/yorp/board.h @@ -10,6 +10,7 @@ /* Optional features */ #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */ +#define CONFIG_CMD_PPC_DUMP /* NPCX7 config */ #define NPCX_UART_MODULE2 1 /* GPIO64/65 are used as UART pins. */ @@ -58,7 +59,6 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_COMM_LOCKED #define CONFIG_USB_PD_DISCHARGE_PPC -#define CONFIG_USB_PD_VBUS_DETECT_PPC #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_ANX74XX /* C0 TCPC: ANX7447QN */ #define CONFIG_USB_PD_TCPM_PS8751 /* C1 TCPC: PS8751 */ @@ -67,7 +67,8 @@ #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USBC_SS_MUX #define CONFIG_USBC_SS_MUX_DFP_ONLY -#define CONFIG_USBC_PPC /* TODO(b/74206647): Remove this one have real driver */ +#define CONFIG_USBC_PPC_NX20P3483 +/* TODO (b/75975215): Add correct VBUS_DETECT config option here */ #define CONFIG_USBC_VCONN #define CONFIG_USBC_VCONN_SWAP #define CONFIG_CMD_PD_CONTROL |