diff options
author | Devin Lu <Devin.Lu@quantatw.com> | 2021-03-19 11:07:23 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-24 00:57:37 +0000 |
commit | 01a4e861e9bd9c34e35c37a1e37a7f305f7ae9ea (patch) | |
tree | 447537b6b22d1d1a7abd4c05a4f52233cb79c9c9 /board/marzipan | |
parent | b8cee54d69416a4035e5a34be196656bf68036c5 (diff) | |
download | chrome-ec-01a4e861e9bd9c34e35c37a1e37a7f305f7ae9ea.tar.gz |
marzipan: Configure board
1. Remove ln9310 support.
2. Remove unused board REV.
3. Add support PS8755
4. Remove USB-A support
5. Remove unused GPIOs
6. Remove SKUID definition
BUG=none
BRANCH=firmware-trogdor-13577.B-master
TEST=make BOARD=marzipan
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Change-Id: I8b0be5363d775d136b587bca5b0372ae94da1015
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2772407
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Commit-Queue: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'board/marzipan')
-rw-r--r-- | board/marzipan/board.c | 201 | ||||
-rw-r--r-- | board/marzipan/board.h | 15 | ||||
-rw-r--r-- | board/marzipan/build.mk | 1 | ||||
-rw-r--r-- | board/marzipan/gpio.inc | 25 | ||||
-rw-r--r-- | board/marzipan/sku.c | 88 | ||||
-rw-r--r-- | board/marzipan/switchcap.c | 103 | ||||
-rw-r--r-- | board/marzipan/usbc_config.h | 1 |
7 files changed, 80 insertions, 354 deletions
diff --git a/board/marzipan/board.c b/board/marzipan/board.c index 00710d4913..3a97487eb7 100644 --- a/board/marzipan/board.c +++ b/board/marzipan/board.c @@ -17,7 +17,6 @@ #include "driver/accelgyro_icm426xx.h" #include "driver/accel_kionix.h" #include "driver/accel_kx022.h" -#include "driver/ln9310.h" #include "driver/ppc/sn5s330.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/tcpci.h" @@ -55,19 +54,6 @@ void usb1_evt(enum gpio_signal signal) task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12); } -static void usba_oc_deferred(void) -{ - /* Use next number after all USB-C ports to indicate the USB-A port */ - board_overcurrent_event(CONFIG_USB_PD_PORT_MAX_COUNT, - !gpio_get_level(GPIO_USB_A0_OC_ODL)); -} -DECLARE_DEFERRED(usba_oc_deferred); - -void usba_oc_interrupt(enum gpio_signal signal) -{ - hook_call_deferred(&usba_oc_deferred_data, 0); -} - void ppc_interrupt(enum gpio_signal signal) { switch (signal) { @@ -232,10 +218,6 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { } }; -const int usb_port_enable[USB_PORT_COUNT] = { - GPIO_EN_USB_A_5V, -}; - /* BC1.2 */ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { { @@ -290,30 +272,30 @@ static const mat33_fp_t lid_standard_ref_kx022 = { struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_BMA255, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &bma2x2_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_bma255_data, - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS, - .rot_standard_ref = &lid_standard_ref_bma255, - .default_range = 2, /* g, to support lid angle calculation. */ - .min_frequency = BMA255_ACCEL_MIN_FREQ, - .max_frequency = BMA255_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3_S5, + .chip = MOTIONSENSE_CHIP_BMA255, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &bma2x2_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bma255_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS, + .rot_standard_ref = &lid_standard_ref_bma255, + .default_range = 2, /* g, to support lid angle calculation. */ + .min_frequency = BMA255_ACCEL_MIN_FREQ, + .max_frequency = BMA255_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + /* Sensor on for lid angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, }, - /* Sensor on for lid angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - }, }, /* * Note: bmi160: supports accelerometer and gyro sensor @@ -321,46 +303,46 @@ struct motion_sensor_t motion_sensors[] = { * DO NOT change the order of the following table. */ [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, - .rot_standard_ref = &base_standard_ref_bmi160, - .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */ - .min_frequency = BMI_ACCEL_MIN_FREQ, - .max_frequency = BMI_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3_S5, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, + .rot_standard_ref = &base_standard_ref_bmi160, + .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */ + .min_frequency = BMI_ACCEL_MIN_FREQ, + .max_frequency = BMI_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + /* Sensor on for lid angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, }, - /* Sensor on for lid angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - }, }, [BASE_GYRO] = { - .name = "Gyro", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, - .default_range = 1000, /* dps */ - .rot_standard_ref = &base_standard_ref_bmi160, - .min_frequency = BMI_GYRO_MIN_FREQ, - .max_frequency = BMI_GYRO_MAX_FREQ, + .name = "Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3_S5, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi160_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref_bmi160, + .min_frequency = BMI_GYRO_MIN_FREQ, + .max_frequency = BMI_GYRO_MAX_FREQ, }, }; unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); @@ -381,10 +363,10 @@ struct motion_sensor_t kx022_lid_accel = { .min_frequency = KX022_ACCEL_MIN_FREQ, .max_frequency = KX022_ACCEL_MAX_FREQ, .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { .odr = 10000 | ROUND_UP_FLAG, - }, + }, /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S3] = { .odr = 10000 | ROUND_UP_FLAG, @@ -456,20 +438,6 @@ void lid_angle_peripheral_enable(int enable) } #endif -__override int board_get_default_battery_type(void) -{ - /* - * A 2S battery is set as default. If the board is configured to use - * a 3S battery, according to its SKU_ID, return a 3S battery as - * default. It helps to configure the charger to output a correct - * voltage in case the battery is not attached. - */ - if (board_get_battery_cell_type() == BATTERY_CELL_TYPE_3S) - return BATTERY_LGC_AP18C8K; - - return DEFAULT_BATTERY_TYPE; -} - static int base_accelgyro_config; void motion_interrupt(enum gpio_signal signal) @@ -511,26 +479,6 @@ static void board_detect_motionsensor(void) ? "ICM40608" : "BMI160"); } -static void board_update_sensor_config_from_sku(void) -{ - if (board_is_clamshell()) { - motion_sensor_count = 0; - gmr_tablet_switch_disable(); - /* The sensors are not stuffed; don't allow lines to float */ - gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - gpio_set_flags(GPIO_LID_ACCEL_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - } else { - board_detect_motionsensor(); - motion_sensor_count = ARRAY_SIZE(motion_sensors); - /* Enable interrupt for the base accel sensor */ - gpio_enable_interrupt(GPIO_ACCEL_GYRO_INT_L); - } -} -DECLARE_HOOK(HOOK_INIT, board_update_sensor_config_from_sku, - HOOK_PRIO_INIT_I2C + 2); - /* Initialize board. */ static void board_init(void) { @@ -538,9 +486,6 @@ static void board_init(void) gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L); gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L); - /* Enable USB-A overcurrent interrupt */ - gpio_enable_interrupt(GPIO_USB_A0_OC_ODL); - /* * The H1 SBU line for CCD are behind PPC chip. The PPC internal FETs * for SBU may be disconnected after DP alt mode is off. Should enable @@ -550,6 +495,8 @@ static void board_init(void) /* Set the backlight duty cycle to 0. AP will override it later. */ pwm_set_duty(PWM_CH_DISPLIGHT, 0); + + board_detect_motionsensor(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -557,24 +504,6 @@ void board_hibernate(void) { int i; - if (!board_is_clamshell()) { - /* - * Sensors are unpowered in hibernate. Apply PD to the - * interrupt lines such that they don't float. - */ - gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - gpio_set_flags(GPIO_LID_ACCEL_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - } - - /* - * Board rev 5+ has the hardware fix. Don't need the following - * workaround. - */ - if (system_get_board_version() >= 5) - return; - /* * Enable the PPC power sink path before EC enters hibernate; * otherwise, ACOK won't go High and can't wake EC up. Check the diff --git a/board/marzipan/board.h b/board/marzipan/board.h index f222316d16..e864114c1e 100644 --- a/board/marzipan/board.h +++ b/board/marzipan/board.h @@ -13,9 +13,6 @@ /* Internal SPI flash on NPCX7 */ #define CONFIG_FLASH_SIZE_BYTES (512 * 1024) /* 512KB internal spi flash */ -/* Switchcap */ -#define CONFIG_LN9310 - /* Keyboard */ #define CONFIG_KEYBOARD_BOARD_CONFIG #define CONFIG_PWM_KBLIGHT @@ -29,16 +26,10 @@ #define CONFIG_BC12_DETECT_PI3USB9201 /* USB */ -#define CONFIG_USB_PD_TCPM_MULTI_PS8XXX -#define CONFIG_USB_PD_TCPM_PS8751 -#define CONFIG_USB_PD_TCPM_PS8805 +#define CONFIG_USB_PD_TCPM_PS8755 #define CONFIG_USBC_PPC_SN5S330 #define CONFIG_USB_PD_PORT_MAX_COUNT 2 -/* USB-A */ -#define USB_PORT_COUNT 1 -#define CONFIG_USB_PORT_POWER_DUMB - /* Sensors */ #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT @@ -75,8 +66,6 @@ #define GPIO_AC_PRESENT GPIO_ACOK_OD #define GPIO_WP_L GPIO_EC_WP_ODL #define GPIO_PMIC_RESIN_L GPIO_PM845_RESIN_L -#define GPIO_SWITCHCAP_PG_INT_L GPIO_DA9313_GPIO0 -#define GPIO_SWITCHCAP_ON_L GPIO_SWITCHCAP_ON #ifndef __ASSEMBLER__ @@ -114,8 +103,6 @@ enum battery_type { BATTERY_TYPE_COUNT, }; -int board_is_clamshell(void); - /* Custom function to indicate if sourcing VBUS */ int board_is_sourcing_vbus(int port); /* Enable VBUS sink for a given port */ diff --git a/board/marzipan/build.mk b/board/marzipan/build.mk index 7b585accb9..09853a26d7 100644 --- a/board/marzipan/build.mk +++ b/board/marzipan/build.mk @@ -14,6 +14,5 @@ BASEBOARD:=trogdor board-y+=battery.o board-y+=board.o board-y+=led.o -board-y+=sku.o board-y+=switchcap.o board-y+=usbc_config.o diff --git a/board/marzipan/gpio.inc b/board/marzipan/gpio.inc index d85b83d9a6..be69f4f509 100644 --- a/board/marzipan/gpio.inc +++ b/board/marzipan/gpio.inc @@ -15,7 +15,6 @@ GPIO_INT(USB_C0_SWCTL_INT_ODL, PIN(0, 3), GPIO_INT_FALLING, ppc_interrupt) /* I GPIO_INT(USB_C1_SWCTL_INT_ODL, PIN(4, 0), GPIO_INT_FALLING, ppc_interrupt) /* Interrupt from port-1 PPC */ GPIO_INT(USB_C0_BC12_INT_L, PIN(6, 1), GPIO_INT_FALLING | GPIO_PULL_UP, usb0_evt) /* Interrupt from port-0 BC1.2 */ GPIO_INT(USB_C1_BC12_INT_L, PIN(8, 2), GPIO_INT_FALLING | GPIO_PULL_UP, usb1_evt) /* Interrupt from port-1 BC1.2 */ -GPIO_INT(USB_A0_OC_ODL, PIN(D, 1), GPIO_INT_BOTH | GPIO_PULL_UP, usba_oc_interrupt) /* System interrupts */ GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH, extpower_interrupt) /* ACOK */ @@ -43,13 +42,6 @@ GPIO_INT(AP_EC_SPI_CS_L, PIN(5, 3), GPIO_INT_FALLING | GPIO_PULL_DOWN, shi_cs GPIO_INT(TABLET_MODE_L, PIN(C, 6), GPIO_INT_BOTH, gmr_tablet_switch_isr) GPIO_INT(ACCEL_GYRO_INT_L, PIN(A, 0), GPIO_INT_FALLING, motion_interrupt) /* Accelerometer/gyro interrupt */ -/* Switchcap - * - * For DA9313 SKUs, it is GPIO0 of DA9313. The GPIO0 is configured as PVC_PG. - * For LN9310 SKUs, it is the interrupt line of LN9310. - */ -GPIO_INT(DA9313_GPIO0, PIN(E, 2), GPIO_INT_FALLING, ln9310_interrupt) - /* * EC_RST_ODL used to be a wake source from PSL mode. However, we disabled * the PSL mode. This GPIO does nothing now. Simply set it an INPUT. @@ -67,8 +59,6 @@ GPIO(QSIP_ON, PIN(5, 0), GPIO_OUT_LOW) /* Not used, for non-swit /* Power enables */ GPIO(HIBERNATE_L, PIN(5, 2), GPIO_OUT_HIGH) /* EC hibernate */ GPIO(SWITCHCAP_ON, PIN(D, 5), GPIO_OUT_LOW) /* Enable switch cap; will be configured in the board init */ -/* TODO(waihong): Remove it. The VBOB switch is for backup. */ -GPIO(VBOB_EN, PIN(D, 3), GPIO_OUT_LOW) /* Enable VBOB */ GPIO(EN_PP3300_A, PIN(A, 6), GPIO_OUT_LOW) /* Enable PP3300 */ GPIO(EN_PP5000_A, PIN(6, 7), GPIO_OUT_LOW) /* Enable PP5000 */ GPIO(EC_BL_DISABLE_L, PIN(B, 6), GPIO_OUT_LOW) /* Backlight disable signal from EC */ @@ -86,10 +76,6 @@ GPIO(DP_MUX_OE_L, PIN(9, 6), GPIO_ODR_HIGH) /* DP mux enable, actuall GPIO(DP_MUX_SEL, PIN(4, 5), GPIO_OUT_LOW) /* DP mux selection: L:C0, H:C1 */ GPIO(DP_HOT_PLUG_DET, PIN(9, 5), GPIO_OUT_LOW) /* DP HPD to AP */ -/* USB-A */ -GPIO(EN_USB_A_5V, PIN(8, 6), GPIO_OUT_LOW) -GPIO(USB_A_CDP_ILIM_EN, PIN(7, 5), GPIO_OUT_HIGH) /* H: CDP, L:SDP. Only one USB-A port, always CDP */ - /* LEDs */ GPIO(EC_CHG_LED_Y_C1, PIN(C, 3), GPIO_OUT_LOW) GPIO(EC_CHG_LED_B_C1, PIN(C, 4), GPIO_OUT_LOW) @@ -132,6 +118,13 @@ GPIO(SKU_ID0, PIN(F, 0), GPIO_INPUT) GPIO(SKU_ID1, PIN(4, 1), GPIO_INPUT) GPIO(SKU_ID2, PIN(D, 4), GPIO_INPUT) +/* Switchcap */ +/* + * GPIO0 is configured as PVC_PG. When the chip in power down mode, it outputs + * high-Z. Set pull-down to avoid floating. + */ +GPIO(DA9313_GPIO0, PIN(E, 2), GPIO_INPUT | GPIO_PULL_DOWN) /* Switchcap GPIO0 */ + /* Special straps */ GPIO(ARM_X86, PIN(6, 6), GPIO_OUT_LOW) /* NC, low for power saving */ @@ -160,6 +153,10 @@ UNUSED(PIN(3, 5)) UNUSED(PIN(9, 7)) UNUSED(PIN(6, 0)) UNUSED(PIN(7, 2)) +UNUSED(PIN(D, 3)) +UNUSED(PIN(8, 6)) +UNUSED(PIN(7, 5)) +UNUSED(PIN(D, 1)) /* Alternate functions GPIO definitions */ ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART (GPIO64/65) */ diff --git a/board/marzipan/sku.c b/board/marzipan/sku.c deleted file mode 100644 index a89698e8b6..0000000000 --- a/board/marzipan/sku.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "config.h" -#include "console.h" -#include "driver/ln9310.h" -#include "gpio.h" -#include "hooks.h" -#include "system.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) - -static uint8_t sku_id; - -enum board_model { - LAZOR, - LIMOZEEN, - UNKNOWN, -}; - -static const char *const model_name[] = { - "LAZOR", - "LIMOZEEN", - "UNKNOWN", -}; - -static enum board_model get_model(void) -{ - if (sku_id == 0 || sku_id == 1 || sku_id == 2 || sku_id == 3) - return LAZOR; - if (sku_id == 4 || sku_id == 5 || sku_id == 6) - return LIMOZEEN; - return UNKNOWN; -} - -/* Read SKU ID from GPIO and initialize variables for board variants */ -static void sku_init(void) -{ - uint8_t val = 0; - - if (gpio_get_level(GPIO_SKU_ID0)) - val |= 0x01; - if (gpio_get_level(GPIO_SKU_ID1)) - val |= 0x02; - if (gpio_get_level(GPIO_SKU_ID2)) - val |= 0x04; - - sku_id = val; - CPRINTS("SKU: %u (%s)", sku_id, model_name[get_model()]); -} -DECLARE_HOOK(HOOK_INIT, sku_init, HOOK_PRIO_INIT_I2C + 1); - -enum battery_cell_type board_get_battery_cell_type(void) -{ - switch (get_model()) { - case LIMOZEEN: - return BATTERY_CELL_TYPE_3S; - default: - return BATTERY_CELL_TYPE_UNKNOWN; - } -} - -int board_is_clamshell(void) -{ - return get_model() == LIMOZEEN; -} - -/* TODO(b:183118990): enable PS8xxx driver for zephyr */ -#ifndef CONFIG_ZEPHYR -#include "driver/tcpm/ps8xxx.h" -__override uint16_t board_get_ps8xxx_product_id(int port) -{ - /* - * Lazor (SKU_ID: 0, 1, 2, 3) rev 3+ changes TCPC from PS8751 to - * PS8805. - * - * Limozeen (SKU_ID: 4, 5, 6) all-rev uses PS8805. - */ - if (get_model() == LAZOR && system_get_board_version() < 3) - return PS8751_PRODUCT_ID; - - return PS8805_PRODUCT_ID; -} -#endif diff --git a/board/marzipan/switchcap.c b/board/marzipan/switchcap.c index 3d5255791c..3ed4bee1bb 100644 --- a/board/marzipan/switchcap.c +++ b/board/marzipan/switchcap.c @@ -6,7 +6,6 @@ #include "common.h" #include "config.h" #include "console.h" -#include "driver/ln9310.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" @@ -16,113 +15,17 @@ #define CPRINTS(format, args...) cprints(CC_I2C, format, ## args) #define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args) -/* LN9310 switchcap */ -const struct ln9310_config_t ln9310_config = { - .i2c_port = I2C_PORT_POWER, - .i2c_addr_flags = LN9310_I2C_ADDR_0_FLAGS, -}; - -static int board_has_ln9310(void) -{ - static int ln9310_present = -1; - int status, val; - - /* Cache the status of LN9310 present or not */ - if (ln9310_present == -1) { - status = i2c_read8(ln9310_config.i2c_port, - ln9310_config.i2c_addr_flags, - LN9310_REG_CHIP_ID, - &val); - - /* - * Any error reading LN9310 CHIP_ID over I2C means the chip - * not present. Fallback to use DA9313 switchcap. - */ - ln9310_present = !status && val == LN9310_CHIP_ID; - } - - return ln9310_present; -} - -static void switchcap_init(void) -{ - if (board_has_ln9310()) { - CPRINTS("Use switchcap: LN9310"); - - /* Configure and enable interrupt for LN9310 */ - gpio_set_flags(GPIO_SWITCHCAP_PG_INT_L, GPIO_INT_FALLING); - gpio_enable_interrupt(GPIO_SWITCHCAP_PG_INT_L); - - /* - * Configure LN9310 enable, open-drain output. Don't set the - * level here; otherwise, it will override its value and - * shutdown the switchcap when sysjump to RW. - * - * Note that the gpio.inc configures it GPIO_OUT_LOW. When - * sysjump to RW, will output push-pull a short period of - * time. As it outputs LOW, should be fine. - * - * This GPIO changes like: - * (1) EC boots from RO -> high-Z - * (2) GPIO init according to gpio.inc -> push-pull LOW - * (3) This function configures it -> open-drain HIGH - * (4) Power sequence turns on the switchcap -> open-drain LOW - * (5) EC sysjumps to RW - * (6) GPIO init according to gpio.inc -> push-pull LOW - * (7) This function configures it -> open-drain LOW - */ - gpio_set_flags(GPIO_SWITCHCAP_ON_L, - GPIO_OUTPUT | GPIO_OPEN_DRAIN); - - /* Only configure the switchcap if not sysjump */ - if (!system_jumped_late()) { - /* - * Deassert the enable pin (set it HIGH), so the - * switchcap won't be enabled after the switchcap is - * configured from standby mode to switching mode. - */ - gpio_set_level(GPIO_SWITCHCAP_ON_L, 1); - ln9310_init(); - } - } else { - CPRINTS("Use switchcap: DA9313"); - - /* - * When the chip in power down mode, it outputs high-Z. - * Set pull-down to avoid floating. - */ - gpio_set_flags(GPIO_DA9313_GPIO0, GPIO_INPUT | GPIO_PULL_DOWN); - - /* - * Configure DA9313 enable, push-pull output. Don't set the - * level here; otherwise, it will override its value and - * shutdown the switchcap when sysjump to RW. - */ - gpio_set_flags(GPIO_SWITCHCAP_ON, GPIO_OUTPUT); - } -} -DECLARE_HOOK(HOOK_INIT, switchcap_init, HOOK_PRIO_DEFAULT); - void board_set_switchcap_power(int enable) { - if (board_has_ln9310()) - gpio_set_level(GPIO_SWITCHCAP_ON_L, !enable); - else - gpio_set_level(GPIO_SWITCHCAP_ON, enable); + gpio_set_level(GPIO_SWITCHCAP_ON, enable); } int board_is_switchcap_enabled(void) { - if (board_has_ln9310()) - return !gpio_get_level(GPIO_SWITCHCAP_ON_L); - else - return gpio_get_level(GPIO_SWITCHCAP_ON); + return gpio_get_level(GPIO_SWITCHCAP_ON); } int board_is_switchcap_power_good(void) { - if (board_has_ln9310()) - return ln9310_power_good(); - else - return gpio_get_level(GPIO_DA9313_GPIO0); + return gpio_get_level(GPIO_DA9313_GPIO0); } diff --git a/board/marzipan/usbc_config.h b/board/marzipan/usbc_config.h index 6e42cc3326..7f72b01700 100644 --- a/board/marzipan/usbc_config.h +++ b/board/marzipan/usbc_config.h @@ -13,7 +13,6 @@ void tcpc_alert_event(enum gpio_signal signal); void usb0_evt(enum gpio_signal signal); void usb1_evt(enum gpio_signal signal); -void usba_oc_interrupt(enum gpio_signal signal); void ppc_interrupt(enum gpio_signal signal); void board_connect_c0_sbu(enum gpio_signal s); |