diff options
author | Dino Li <Dino.Li@ite.com.tw> | 2021-02-25 14:23:23 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-03 07:35:04 +0000 |
commit | 090b9de6ffbdd65a83968535924d87234bbd6c40 (patch) | |
tree | 6e09464ec5194fee369a4e8a72902cfc0220022b /board/icarus | |
parent | 2694b7aa320a3651859327c0eb2f3cd0e9befb53 (diff) | |
download | chrome-ec-090b9de6ffbdd65a83968535924d87234bbd6c40.tar.gz |
board/icarus: initial it81202 based board
This change is based on jacuzzi's board code and modified for it81202.
BUG=b:180668427
BRANCH=none
TEST=- Booted to kernel.
- Battery charging/discharging works fine.
- LEDs works fine.
Change-Id: Ie6e7763fe7bd652ae87e69ddbba08c5022b0818c
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2706663
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'board/icarus')
-rw-r--r-- | board/icarus/battery.c | 93 | ||||
-rw-r--r-- | board/icarus/board.c | 202 | ||||
-rw-r--r-- | board/icarus/board.h | 52 | ||||
-rw-r--r-- | board/icarus/build.mk | 8 | ||||
-rw-r--r-- | board/icarus/ec.tasklist | 6 | ||||
-rw-r--r-- | board/icarus/gpio.inc | 189 | ||||
-rw-r--r-- | board/icarus/led.c | 27 |
7 files changed, 213 insertions, 364 deletions
diff --git a/board/icarus/battery.c b/board/icarus/battery.c index 748dd5c81a..4786ecd9a5 100644 --- a/board/icarus/battery.c +++ b/board/icarus/battery.c @@ -8,51 +8,25 @@ #include "gpio.h" const struct board_batt_params board_battery_info[] = { - [BATTERY_PANASONIC_AC15A3J] = { + /* LGC AP18C8K Battery Information */ + [BATTERY_LGC_AP18C8K] = { .fuel_gauge = { - .manuf_name = "PANASONIC", - .device_name = "AC15A3J", + .manuf_name = "LGC KT0030G020", + .device_name = "AP18C8K", .ship_mode = { .reg_addr = 0x3A, .reg_data = { 0xC574, 0xC574 }, }, .fet = { - .reg_addr = 0x0, - .reg_mask = 0x4000, + .reg_addr = 0x43, + .reg_mask = 0x0001, .disconnect_val = 0x0, - } - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11580, - .voltage_min = 9000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 60, - }, - }, - [BATTERY_PANASONIC_AC16L5J] = { - .fuel_gauge = { - .manuf_name = "PANASONIC", - .device_name = "AP16L5J", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x4000, - .disconnect_val = 0x0, - } }, .batt_info = { - .voltage_max = 8800, - .voltage_normal = 7700, - .voltage_min = 6000, + .voltage_max = 13050, + .voltage_normal = 11250, + .voltage_min = 9000, .precharge_current = 256, .start_charging_min_c = 0, .start_charging_max_c = 50, @@ -62,52 +36,25 @@ const struct board_batt_params board_battery_info[] = { .discharging_max_c = 75, }, }, - [BATTERY_LGC_AC16L8J] = { - .fuel_gauge = { - .manuf_name = "LGC KT0020G010", - .device_name = "AP16L8J", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .mfgacc_support = 1, - .reg_addr = 0x0, - .reg_mask = 0x0002, - .disconnect_val = 0x0, - } - }, - .batt_info = { - .voltage_max = 8700, - .voltage_normal = 7500, - .voltage_min = 6000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, - }, - }, - [BATTERY_PANASONIC_AC16L5J_KT00205009] = { + /* Murata AP18C4K Battery Information */ + [BATTERY_MURATA_AP18C4K] = { .fuel_gauge = { - .manuf_name = "PANASONIC KT00205009", - .device_name = "AP16L5J", + .manuf_name = "Murata KT00304012", + .device_name = "AP18C4K", .ship_mode = { .reg_addr = 0x3A, .reg_data = { 0xC574, 0xC574 }, }, .fet = { .reg_addr = 0x0, - .reg_mask = 0x4000, - .disconnect_val = 0x0, - } + .reg_mask = 0x2000, + .disconnect_val = 0x2000, + }, }, .batt_info = { - .voltage_max = 8800, - .voltage_normal = 7700, - .voltage_min = 6000, + .voltage_max = 13200, + .voltage_normal = 11400, + .voltage_min = 9000, .precharge_current = 256, .start_charging_min_c = 0, .start_charging_max_c = 50, @@ -120,7 +67,7 @@ const struct board_batt_params board_battery_info[] = { }; BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); -const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC_AC16L5J_KT00205009; +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_LGC_AP18C8K; enum battery_present battery_hw_present(void) { diff --git a/board/icarus/board.c b/board/icarus/board.c index 9750c83fee..13b41c0b82 100644 --- a/board/icarus/board.c +++ b/board/icarus/board.c @@ -21,7 +21,7 @@ #include "driver/battery/max17055.h" #include "driver/bc12/pi3usb9201.h" #include "driver/charger/isl923x.h" -#include "driver/tcpm/fusb302.h" +#include "driver/tcpm/it83xx_pd.h" #include "driver/usb_mux/it5205.h" #include "ec_commands.h" #include "extpower.h" @@ -29,8 +29,6 @@ #include "hooks.h" #include "host_command.h" #include "i2c.h" -#include "i2c_bitbang.h" -#include "it8801.h" #include "keyboard_scan.h" #include "lid_switch.h" #include "power.h" @@ -42,6 +40,7 @@ #include "task.h" #include "tcpm/tcpm.h" #include "timer.h" +#include "uart.h" #include "usb_charge.h" #include "usb_mux.h" #include "usb_pd_tcpm.h" @@ -50,38 +49,37 @@ #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) -static void tcpc_alert_event(enum gpio_signal signal) -{ - schedule_deferred_pd_interrupt(0 /* port */); -} - #include "gpio_list.h" +/* Wake-up pins for hibernate */ +const enum gpio_signal hibernate_wake_pins[] = { + GPIO_AC_PRESENT, + GPIO_LID_OPEN, + GPIO_POWER_BUTTON_L, +}; +const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); + /******************************************************************************/ /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { - [ADC_BOARD_ID] = {"BOARD_ID", 3300, 4096, 0, STM32_AIN(10)}, - [ADC_EC_SKU_ID] = {"EC_SKU_ID", 3300, 4096, 0, STM32_AIN(8)}, + [ADC_BOARD_ID] = {"BOARD_ID", ADC_MAX_MVOLT, ADC_READ_MAX + 1, 0, + CHIP_ADC_CH1}, + [ADC_EC_SKU_ID] = {"EC_SKU_ID", ADC_MAX_MVOLT, ADC_READ_MAX + 1, 0, + CHIP_ADC_CH2}, + [ADC_VBUS] = {"VBUS", ADC_MAX_MVOLT * 10, ADC_READ_MAX + 1, 0, + CHIP_ADC_CH0}, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /******************************************************************************/ /* I2C ports */ const struct i2c_port_t i2c_ports[] = { - {"typec", 0, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA}, -#ifdef BOARD_JACUZZI - {"other", 1, 100, GPIO_I2C2_SCL, GPIO_I2C2_SDA}, -#else /* Juniper */ - {"other", 1, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA}, -#endif + {"typec", IT83XX_I2C_CH_C, 400, GPIO_I2C_C_SCL, GPIO_I2C_C_SDA}, + {"other", IT83XX_I2C_CH_B, 100, GPIO_I2C_B_SCL, GPIO_I2C_B_SDA}, + {"battery", IT83XX_I2C_CH_A, 100, GPIO_I2C_A_SCL, GPIO_I2C_A_SDA}, }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -const struct i2c_port_t i2c_bitbang_ports[] = { - {"battery", 2, 100, GPIO_I2C3_SCL, GPIO_I2C3_SDA, .drv = &bitbang_drv}, -}; -const unsigned int i2c_bitbang_ports_used = ARRAY_SIZE(i2c_bitbang_ports); - #define BC12_I2C_ADDR PI3USB9201_I2C_ADDR_3 /* power signal list. Must match order of enum power_signal. */ @@ -91,39 +89,7 @@ const struct power_signal_info power_signal_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); -/* Keyboard scan setting */ -struct keyboard_scan_config keyscan_config = { - /* - * TODO(b/133200075): Tune this once we have the final performance - * out of the driver and the i2c bus. - */ - .output_settle_us = 35, - .debounce_down_us = 5 * MSEC, - .debounce_up_us = 40 * MSEC, - .scan_period_us = 10 * MSEC, - .min_post_scan_delay_us = 10 * MSEC, - .poll_timeout_us = 100 * MSEC, - .actual_key_mask = { - 0x14, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, - 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */ - }, -}; - -struct ioexpander_config_t ioex_config[CONFIG_IO_EXPANDER_PORT_COUNT] = { - [0] = { - .i2c_host_port = I2C_PORT_IO_EXPANDER_IT8801, - .i2c_slave_addr = IT8801_I2C_ADDR, - .drv = &it8801_ioexpander_drv, - }, -}; - /******************************************************************************/ -/* SPI devices */ -const struct spi_device_t spi_devices[] = { - { CONFIG_SPI_ACCEL_PORT, 2, GPIO_EC_SENSOR_SPI_NSS }, -}; -const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); - const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { { .i2c_port = I2C_PORT_BC12, @@ -134,12 +100,11 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { /******************************************************************************/ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_TCPC0, - .addr_flags = FUSB302_I2C_ADDR_FLAGS, - }, - .drv = &fusb302_tcpm_drv, + .bus_type = EC_BUS_TYPE_EMBEDDED, + /* TCPC is embedded within EC so no i2c config needed */ + .drv = &it8xxx2_tcpm_drv, + /* Alert is active-low, push-pull */ + .flags = 0, }, }; @@ -166,29 +131,12 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { /* Charger config. Start i2c address at 1, update during runtime */ struct charger_config_t chg_chips[] = { { - .i2c_port = 1, + .i2c_port = I2C_PORT_CHARGER, .i2c_addr_flags = ISL923X_ADDR_FLAGS, .drv = &isl923x_drv, }, }; -/* Board version depends on ADCs, so init i2c port after ADC */ -static void charger_config_complete(void) -{ - chg_chips[0].i2c_port = board_get_charger_i2c(); -} -DECLARE_HOOK(HOOK_INIT, charger_config_complete, HOOK_PRIO_INIT_ADC + 1); - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - - if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL)) - status |= PD_STATUS_TCPC_ALERT_0; - - return status; -} - static int force_discharge; int board_set_active_charge_port(int charge_port) @@ -250,10 +198,14 @@ int board_discharge_on_ac(int enable) return board_set_active_charge_port(port); } +#define VBUS_THRESHOLD_MV 4200 int pd_snk_is_vbus_provided(int port) { - /* TODO(b:138352732): read IT8801 GPIO EN_USBC_CHARGE_L */ - return EC_ERROR_UNIMPLEMENTED; + /* This board has only one port. */ + if (!port) + return adc_read_channel(ADC_VBUS) > VBUS_THRESHOLD_MV ? 1 : 0; + else + return 0; } void bc12_interrupt(enum gpio_signal signal) @@ -261,48 +213,6 @@ void bc12_interrupt(enum gpio_signal signal) task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12); } -#ifndef VARIANT_KUKUI_NO_SENSORS -static void board_spi_enable(void) -{ - /* - * Pin mux spi peripheral away from emmc, since RO might have - * left them there. - */ - gpio_config_module(MODULE_SPI_FLASH, 0); - - /* Enable clocks to SPI2 module. */ - STM32_RCC_APB1ENR |= STM32_RCC_PB1_SPI2; - - /* Reset SPI2 to clear state left over from the emmc slave. */ - STM32_RCC_APB1RSTR |= STM32_RCC_PB1_SPI2; - STM32_RCC_APB1RSTR &= ~STM32_RCC_PB1_SPI2; - - /* Reinitialize spi peripheral. */ - spi_enable(&spi_devices[0], 1); - - /* Pin mux spi peripheral toward the sensor. */ - gpio_config_module(MODULE_SPI_MASTER, 1); -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, - board_spi_enable, - MOTION_SENSE_HOOK_PRIO - 1); - -static void board_spi_disable(void) -{ - /* Set pins to a state calming the sensor down. */ - gpio_set_flags(GPIO_EC_SENSOR_SPI_CK, GPIO_OUT_LOW); - gpio_set_level(GPIO_EC_SENSOR_SPI_CK, 0); - gpio_config_module(MODULE_SPI_MASTER, 0); - - /* Disable spi peripheral and clocks. */ - spi_enable(&spi_devices[0], 0); - STM32_RCC_APB1ENR &= ~STM32_RCC_PB1_SPI2; -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, - board_spi_disable, - MOTION_SENSE_HOOK_PRIO + 1); -#endif /* !VARIANT_KUKUI_NO_SENSORS */ - static void board_init(void) { /* If the reset cause is external, pulse PMIC force reset. */ @@ -312,17 +222,9 @@ static void board_init(void) gpio_set_level(GPIO_PMIC_FORCE_RESET_ODL, 1); } - /* Enable TCPC alert interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); - -#ifndef VARIANT_KUKUI_NO_SENSORS /* Enable interrupts from BMI160 sensor. */ gpio_enable_interrupt(GPIO_ACCEL_INT_ODL); - /* For some reason we have to do this again in case of sysjump */ - board_spi_enable(); -#endif /* !VARIANT_KUKUI_NO_SENSORS */ - /* Enable interrupt from PMIC. */ gpio_enable_interrupt(GPIO_PMIC_EC_RESETB); @@ -331,7 +233,6 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); -#ifndef VARIANT_KUKUI_NO_SENSORS /* Motion sensors */ /* Mutexes */ static struct mutex g_lid_mutex; @@ -400,8 +301,8 @@ struct motion_sensor_t motion_sensors[] = { .drv = &bmi160_drv, .mutex = &g_base_mutex, .drv_data = &g_bmi160_data, - .port = CONFIG_SPI_ACCEL_PORT, - .i2c_spi_addr_flags = SLAVE_MK_SPI_ADDR_FLAGS(CONFIG_SPI_ACCEL_PORT), + .port = I2C_PORT_SENSORS, + .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, .rot_standard_ref = &base_bmi160_ref, .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs.*/ .min_frequency = BMI_ACCEL_MIN_FREQ, @@ -428,8 +329,8 @@ struct motion_sensor_t motion_sensors[] = { .drv = &bmi160_drv, .mutex = &g_base_mutex, .drv_data = &g_bmi160_data, - .port = CONFIG_SPI_ACCEL_PORT, - .i2c_spi_addr_flags = SLAVE_MK_SPI_ADDR_FLAGS(CONFIG_SPI_ACCEL_PORT), + .port = I2C_PORT_SENSORS, + .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, .default_range = 1000, /* dps */ .rot_standard_ref = &base_bmi160_ref, .min_frequency = BMI_GYRO_MIN_FREQ, @@ -447,8 +348,8 @@ struct motion_sensor_t icm426xx_base_accel = { .drv = &icm426xx_drv, .mutex = &g_base_mutex, .drv_data = &g_icm426xx_data, - .port = CONFIG_SPI_ACCEL_PORT, - .i2c_spi_addr_flags = SLAVE_MK_SPI_ADDR_FLAGS(CONFIG_SPI_ACCEL_PORT), + .port = I2C_PORT_SENSORS, + .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs.*/ .rot_standard_ref = &base_icm426xx_ref, .min_frequency = ICM426XX_ACCEL_MIN_FREQ, @@ -474,8 +375,8 @@ struct motion_sensor_t icm426xx_base_gyro = { .drv = &icm426xx_drv, .mutex = &g_base_mutex, .drv_data = &g_icm426xx_data, - .port = CONFIG_SPI_ACCEL_PORT, - .i2c_spi_addr_flags = SLAVE_MK_SPI_ADDR_FLAGS(CONFIG_SPI_ACCEL_PORT), + .port = I2C_PORT_SENSORS, + .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, .default_range = 1000, /* dps */ .rot_standard_ref = &base_icm426xx_ref, .min_frequency = ICM426XX_GYRO_MIN_FREQ, @@ -515,7 +416,19 @@ static void board_detect_motionsensor(void) ? "ICM40608" : "BMI160"); } DECLARE_HOOK(HOOK_INIT, board_detect_motionsensor, HOOK_PRIO_DEFAULT); -#endif /* !VARIANT_KUKUI_NO_SENSORS */ + +/* Vconn control for integrated ITE TCPC */ +void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) +{ + /* Vconn control is only for port 0 */ + if (port) + return; + + if (cc_pin == USBPD_CC_PIN_1) + gpio_set_level(GPIO_EN_USB_C0_CC1_VCONN, !!enabled); + else + gpio_set_level(GPIO_EN_USB_C0_CC2_VCONN, !!enabled); +} /* Called on AP S5 -> S3 transition */ static void board_chipset_startup(void) @@ -530,14 +443,3 @@ static void board_chipset_shutdown(void) gpio_set_level(GPIO_EN_USBA_5V, 0); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); - -int board_get_charger_i2c(void) -{ - /* TODO(b:138415463): confirm the bus allocation for future builds */ - return board_get_version() == 1 ? 2 : 1; -} - -int board_get_battery_i2c(void) -{ - return board_get_version() >= 1 ? 2 : 1; -} diff --git a/board/icarus/board.h b/board/icarus/board.h index 7a78c74d3e..17382496c4 100644 --- a/board/icarus/board.h +++ b/board/icarus/board.h @@ -11,20 +11,17 @@ #define VARIANT_KUKUI_JACUZZI #define VARIANT_KUKUI_BATTERY_SMART #define VARIANT_KUKUI_CHARGER_ISL9238 -#define VARIANT_KUKUI_EC_STM32F098 - -#ifndef SECTION_IS_RW -#define VARIANT_KUKUI_NO_SENSORS -#endif /* SECTION_IS_RW */ +#define VARIANT_KUKUI_EC_IT81202 #include "baseboard.h" -#ifdef BOARD_JUNIPER +/* TODO: remove me once we fix IT83XX_ILM_BLOCK_SIZE out of space issue */ +#undef CONFIG_LTO + #undef CONFIG_CHIPSET_POWER_SEQ_VERSION #define CONFIG_CHIPSET_POWER_SEQ_VERSION 1 -#undef CONFIG_SYSTEM_UNLOCKED -#endif +#define CONFIG_SYSTEM_UNLOCKED #define CONFIG_BATTERY_HW_PRESENT_CUSTOM @@ -38,20 +35,17 @@ #undef CONFIG_EXTPOWER_DEBOUNCE_MS #define CONFIG_EXTPOWER_DEBOUNCE_MS 200 -#define CONFIG_I2C_BITBANG -#define I2C_BITBANG_PORT_COUNT 1 #undef CONFIG_I2C_NACK_RETRY_COUNT #define CONFIG_I2C_NACK_RETRY_COUNT 10 #define CONFIG_SMBUS_PEC -#define CONFIG_USB_PD_TCPM_FUSB302 +#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP #define CONFIG_USB_PD_DISCHARGE_GPIO #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_MUX_IT5205 /* Motion Sensors */ -#ifndef VARIANT_KUKUI_NO_SENSORS #define CONFIG_ACCEL_KX022 /* Lid accel */ #define CONFIG_ACCELGYRO_BMI160 /* Base accel */ #define CONFIG_ACCEL_INTERRUPTS @@ -72,24 +66,15 @@ #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) -#endif /* VARIANT_KUKUI_NO_SENSORS */ - /* I2C ports */ -#define I2C_PORT_BC12 0 -#define I2C_PORT_TCPC0 0 -#define I2C_PORT_USB_MUX 0 -#define I2C_PORT_CHARGER board_get_charger_i2c() -#define I2C_PORT_SENSORS 1 -#define I2C_PORT_IO_EXPANDER_IT8801 1 +#define I2C_PORT_BC12 IT83XX_I2C_CH_C +#define I2C_PORT_TCPC0 IT83XX_I2C_CH_C +#define I2C_PORT_USB_MUX IT83XX_I2C_CH_C +#define I2C_PORT_CHARGER IT83XX_I2C_CH_A +#define I2C_PORT_SENSORS IT83XX_I2C_CH_B +#define I2C_PORT_ACCEL I2C_PORT_SENSORS +#define I2C_PORT_BATTERY IT83XX_I2C_CH_A #define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY -#ifdef BOARD_JACUZZI -#define I2C_PORT_BATTERY 1 -#else /* Juniper */ -#define I2C_PORT_BATTERY 2 -#endif - -/* Enable Accel over SPI */ -#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */ #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT @@ -107,6 +92,7 @@ enum adc_channel { /* Real ADC channels begin here */ ADC_BOARD_ID = 0, ADC_EC_SKU_ID, + ADC_VBUS, ADC_CH_COUNT }; @@ -132,10 +118,8 @@ enum charge_port { }; enum battery_type { - BATTERY_PANASONIC_AC15A3J, - BATTERY_PANASONIC_AC16L5J, - BATTERY_LGC_AC16L8J, - BATTERY_PANASONIC_AC16L5J_KT00205009, + BATTERY_LGC_AP18C8K, + BATTERY_MURATA_AP18C4K, BATTERY_TYPE_COUNT, }; @@ -143,8 +127,8 @@ enum battery_type { #include "registers.h" #ifdef SECTION_IS_RO -/* Interrupt handler for emmc task */ -void emmc_cmd_interrupt(enum gpio_signal signal); +/* Interrupt handler for AP jump to BL */ +void emmc_ap_jump_to_bl(enum gpio_signal signal); #endif void bc12_interrupt(enum gpio_signal signal); diff --git a/board/icarus/build.mk b/board/icarus/build.mk index 04b88d3d79..9ca7933e2a 100644 --- a/board/icarus/build.mk +++ b/board/icarus/build.mk @@ -6,10 +6,10 @@ # Board specific files build # # -# STmicro STM32F098VC -CHIP:=stm32 -CHIP_FAMILY:=stm32f0 -CHIP_VARIANT:=stm32f09x +# IC is ITE IT81202 +CHIP:=it83xx +CHIP_FAMILY:=it8xxx2 +CHIP_VARIANT:=it81202bx_1024 BASEBOARD:=kukui board-y=battery.o board.o led.o diff --git a/board/icarus/ec.tasklist b/board/icarus/ec.tasklist index e943459024..8d4f451072 100644 --- a/board/icarus/ec.tasklist +++ b/board/icarus/ec.tasklist @@ -11,10 +11,8 @@ TASK_ALWAYS(CHARGER, charger_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P0, usb_charger_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS_RW(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, 1024) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C0, pd_task, NULL, 1280) \ - TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, 1024) \ - TASK_ALWAYS_RO(EMMC, emmc_task, NULL, LARGER_TASK_STACK_SIZE) + TASK_ALWAYS(PD_C0, pd_task, NULL, 1280) diff --git a/board/icarus/gpio.inc b/board/icarus/gpio.inc index 5d8d6f6ebd..335260c308 100644 --- a/board/icarus/gpio.inc +++ b/board/icarus/gpio.inc @@ -11,116 +11,135 @@ */ /* Interrupts */ -GPIO_INT(USB_C0_PD_INT_ODL, PIN(B, 1), GPIO_INT_FALLING | GPIO_PULL_UP, - tcpc_alert_event) -GPIO_INT(POWER_BUTTON_L, PIN(A, 0), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(POWER_BUTTON_L, PIN(E, 4), GPIO_INT_BOTH, power_button_interrupt) /* EC_PWR_BTN_ODL */ -GPIO_INT(AP_IN_SLEEP_L, PIN(C, 12), GPIO_INT_BOTH | GPIO_PULL_DOWN, +GPIO_INT(AP_IN_SLEEP_L, PIN(F, 2), GPIO_INT_BOTH | GPIO_PULL_DOWN | GPIO_SEL_1P8V, power_signal_interrupt) -GPIO_INT(PMIC_EC_RESETB, PIN(B, 7), GPIO_INT_BOTH | GPIO_PULL_DOWN, +GPIO_INT(PMIC_EC_RESETB, PIN(F, 3), GPIO_INT_BOTH | GPIO_PULL_DOWN | GPIO_SEL_1P8V, power_signal_interrupt) -GPIO_INT(WARM_RESET_REQ, PIN(A, 3), GPIO_INT_RISING | GPIO_PULL_DOWN, +GPIO_INT(WARM_RESET_REQ, PIN(D, 3), GPIO_INT_RISING | GPIO_PULL_DOWN | GPIO_SEL_1P8V, chipset_reset_request_interrupt) -GPIO_INT_RW(ACCEL_INT_ODL, PIN(A, 4), GPIO_INT_FALLING | GPIO_SEL_1P8V | GPIO_PULL_UP, +GPIO_INT(ACCEL_INT_ODL, PIN(J, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, motion_interrupt) -GPIO_INT_RO(EMMC_CMD, PIN(B, 15), GPIO_INT_FALLING, - emmc_cmd_interrupt) -GPIO_INT(SPI1_NSS, PIN(A, 15), GPIO_INT_BOTH | GPIO_PULL_UP, - spi_event) /* SPI_AP_EC_CS_L */ -GPIO_INT(LID_OPEN, PIN(C, 5), GPIO_INT_BOTH, +GPIO_INT_RO(BOOTBLOCK_EN_L, PIN(J, 1), GPIO_INT_RISING | GPIO_SEL_1P8V, + emmc_ap_jump_to_bl) +GPIO_INT(SPI0_CS, PIN(M, 5), GPIO_INT_FALLING, + spi_event) /* SPI slave Chip Select -- AP_SPI_EC_CS_L */ +GPIO_INT(LID_OPEN, PIN(E, 2), GPIO_INT_BOTH, lid_interrupt) -GPIO_INT(AC_PRESENT, PIN(A, 6), GPIO_INT_BOTH, +GPIO_INT(AC_PRESENT, PIN(E, 5), GPIO_INT_BOTH, extpower_interrupt) /* ACOK_OD */ -GPIO_INT(BC12_EC_INT_ODL, PIN(C, 9), GPIO_INT_FALLING, +GPIO_INT(BC12_EC_INT_ODL, PIN(J, 6), GPIO_INT_FALLING, bc12_interrupt) -GPIO_INT(IT8801_SMB_INT, PIN(A, 8), GPIO_INT_FALLING | GPIO_PULL_UP, - io_expander_it8801_interrupt) /* KB_INT_ODL */ -GPIO_INT(AP_EC_WATCHDOG_L, PIN(D, 2), GPIO_INT_FALLING, +GPIO_INT(AP_EC_WATCHDOG_L, PIN(C, 7), GPIO_INT_FALLING | GPIO_SEL_1P8V, chipset_watchdog_interrupt) -GPIO_INT(TABLET_MODE_L, PIN(B, 11), GPIO_INT_BOTH, +GPIO_INT(TABLET_MODE_L, PIN(J, 7), GPIO_INT_BOTH, gmr_tablet_switch_isr) - +GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_FALLING, + uart_deepsleep_interrupt) /* UART_DEBUG_TX_EC_RX */ /* Unimplemented interrupts */ -GPIO(ALS_RGB_INT_ODL, PIN(C, 10), GPIO_INPUT) +GPIO(VOLUME_DOWN_L, PIN(D, 5), GPIO_INPUT) +GPIO(VOLUME_UP_L, PIN(D, 6), GPIO_INPUT) +GPIO(ALS_RGB_INT_ODL, PIN(F, 0), GPIO_INPUT) +GPIO(LID_ACCEL_INT_ODL, PIN(J, 3), GPIO_INPUT | GPIO_SEL_1P8V) /* Reset pins */ -GPIO(AP_SYS_RST_L, PIN(C, 11), GPIO_OUT_LOW) -GPIO(PMIC_WATCHDOG_L, PIN(A, 2), GPIO_OUT_LOW) -GPIO(PMIC_EN_ODL, PIN(F, 0), GPIO_ODR_HIGH) +GPIO(AP_SYS_RST_L, PIN(B, 6), GPIO_OUT_LOW) +/* 1.8V PP or 1.8V OD output with external 10K PU */ +GPIO(PMIC_WATCHDOG_L, PIN(H, 0), GPIO_ODR_LOW | GPIO_SEL_1P8V) +/* OD output with 5VT (there is 5V internal PU on PWRKEY of MT6358) */ +GPIO(PMIC_EN_ODL, PIN(E, 1), GPIO_ODR_HIGH) /* * I2C pins should be configured as inputs until I2C module is * initialized. This will avoid driving the lines unintentionally. */ -GPIO(I2C1_SCL, PIN(B, 8), GPIO_INPUT) -GPIO(I2C1_SDA, PIN(B, 9), GPIO_INPUT) -GPIO(I2C2_SCL, PIN(A, 11), GPIO_INPUT) -GPIO(I2C2_SDA, PIN(A, 12), GPIO_INPUT) -GPIO(I2C3_SCL, PIN(A, 5), GPIO_ODR_HIGH) -GPIO(I2C3_SDA, PIN(C, 4), GPIO_ODR_HIGH) - -/* Analog pins */ -GPIO(BOARD_ID, PIN(C, 0), GPIO_ANALOG) -GPIO(EC_SKU_ID, PIN(B, 0), GPIO_ANALOG) +/* EC programming */ +GPIO(I2C_E_SCL, PIN(A, 4), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(I2C_E_SDA, PIN(A, 5), GPIO_INPUT | GPIO_SEL_1P8V) +/* battery and charger */ +GPIO(I2C_A_SCL, PIN(B, 3), GPIO_INPUT) +GPIO(I2C_A_SDA, PIN(B, 4), GPIO_INPUT) +/* sensor */ +GPIO(I2C_B_SCL, PIN(C, 1), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(I2C_B_SDA, PIN(C, 2), GPIO_INPUT | GPIO_SEL_1P8V) +/* typec */ +GPIO(I2C_C_SCL, PIN(F, 6), GPIO_INPUT) +GPIO(I2C_C_SDA, PIN(F, 7), GPIO_INPUT) /* Other input pins */ -GPIO(WP_L, PIN(C, 8), GPIO_INPUT) /* EC_FLASH_WP_ODL */ -GPIO(BOOT0, PIN(F, 11), GPIO_INPUT) -GPIO(CCD_MODE_ODL, PIN(A, 1), GPIO_INPUT) +/* TODO(WP_L): change to interrupt pin ? */ +GPIO(WP_L, PIN(I, 4), GPIO_INPUT | GPIO_SEL_1P8V) /* EC_FLASH_WP_ODL */ +GPIO(CCD_MODE_ODL, PIN(C, 4), GPIO_INPUT) /* Other output pins */ -GPIO(EC_BATT_PRES_ODL, PIN(A, 7), GPIO_INPUT) -GPIO(EC_BL_EN_OD, PIN(A, 13), GPIO_ODR_HIGH) -GPIO(EN_USBA_5V, PIN(C, 14), GPIO_OUT_LOW) -GPIO(EC_SENSOR_SPI_MISO, PIN(C, 2), GPIO_INPUT) -GPIO(EC_SENSOR_SPI_MOSI, PIN(C, 3), GPIO_OUT_LOW) -GPIO(EC_SENSOR_SPI_NSS, PIN(B, 12), GPIO_OUT_HIGH) -GPIO(EC_SENSOR_SPI_CK, PIN(B, 10), GPIO_OUT_LOW) -GPIO(ENTERING_RW, PIN(C, 6), GPIO_ODR_HIGH) /* EC_ENTERING_RW_ODL */ -GPIO(EC_INT_L, PIN(C, 7), GPIO_ODR_HIGH) /* EC_AP_INT_ODL */ -GPIO(EC_BOARD_ID_EN_L, PIN(C, 15), GPIO_ODR_HIGH) /* EC_BOARD_ID_EN_ODL */ -GPIO(USB_C0_HPD_OD, PIN(F, 1), GPIO_ODR_LOW) -GPIO(BOOTBLOCK_EN_L, PIN(C, 1), GPIO_ODR_HIGH) -GPIO(USB_C0_DISCHARGE, PIN(B, 6), GPIO_OUT_LOW) +GPIO(EC_BATT_PRES_ODL, PIN(C, 0), GPIO_INPUT) +GPIO(EC_BL_EN_OD, PIN(B, 5), GPIO_ODR_HIGH | GPIO_SEL_1P8V) +GPIO(EN_USBA_5V, PIN(B, 7), GPIO_OUT_LOW) +GPIO(ENTERING_RW, PIN(C, 5), GPIO_ODR_HIGH) /* EC_ENTERING_RW_ODL */ +GPIO(EC_INT_L, PIN(E, 6), GPIO_ODR_HIGH | GPIO_SEL_1P8V) /* EC_AP_INT_ODL */ +GPIO(EC_BOARD_ID_EN_L, PIN(H, 5), GPIO_ODR_HIGH) /* EC_BOARD_ID_EN_ODL */ +GPIO(USB_C0_HPD_OD, PIN(J, 0), GPIO_ODR_LOW) +GPIO(USB_C0_DISCHARGE, PIN(H, 3), GPIO_OUT_LOW) +GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 1), GPIO_OUT_LOW) +GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 2), GPIO_OUT_LOW) -IOEX(LED_BLUE, EXPIN(0, 1, 4), GPIO_OUT_HIGH) /* LED BLUE */ -IOEX(LED_GREEN, EXPIN(0, 1, 3), GPIO_OUT_HIGH) /* LED GREEN */ -IOEX(LED_ORANGE, EXPIN(0, 1, 2), GPIO_OUT_HIGH) /* LED ORANGE */ +/* LEDs */ +GPIO(LED_BLUE, PIN(A, 2), GPIO_OUT_HIGH) +GPIO(LED_GREEN, PIN(A, 1), GPIO_OUT_HIGH) +GPIO(LED_ORANGE, PIN(A, 0), GPIO_OUT_HIGH) +GPIO(EN_PP1800_S5_L, PIN(D, 0), GPIO_OUT_LOW) -#ifdef BOARD_JACUZZI -GPIO(LID_ACCEL_INT_ODL, PIN(A, 14), GPIO_INPUT) -/* Jacuzzi doesn't have EN_PP1800_S5_L. */ -UNIMPLEMENTED(EN_PP1800_S5_L) -#else -GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_LOW) -#endif +/* Unimplemented Pins */ +GPIO(PG_PP5000_A_OD, PIN(A, 6), GPIO_INPUT) +GPIO(USB_A0_OC_ODL, PIN(A, 7), GPIO_INPUT) +GPIO(EC_PROCHOT_ODL, PIN(C, 3), GPIO_INPUT) +GPIO(PMIC_FORCE_RESET_ODL, PIN(C, 6), GPIO_INPUT) +GPIO(USB_C0_PD_INT_ODL, PIN(D, 1), GPIO_INPUT) /* no used on this board */ +GPIO(EN_PP5000A_USM, PIN(D, 7), GPIO_INPUT) +GPIO(EN_USBC_CHARGE_L, PIN(F, 1), GPIO_INPUT) +GPIO(EN_PP5000_USBC, PIN(H, 4), GPIO_INPUT) +GPIO(PP1800_H1_PG, PIN(H, 6), GPIO_INPUT) + +/* NC pins, ensure they aren't in floating state. */ +GPIO(NC_GPA3, PIN(A, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPB2, PIN(B, 2), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPD2, PIN(D, 2), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPD4, PIN(D, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPE0, PIN(E, 0), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPE3, PIN(E, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPE7, PIN(E, 7), GPIO_INPUT | GPIO_PULL_DOWN) /* - * TODO(b:138352732): On IT88801 expander, To be readded once IT8801 driver and - * gpio expander framework has landed. + * ADC pins don't have internal pull-down capability, + * so we set them as output low. */ -UNIMPLEMENTED(EN_PP5000_USBC) -UNIMPLEMENTED(PMIC_FORCE_RESET_ODL) -UNIMPLEMENTED(EN_USBC_CHARGE_L) - -/* USART1: PA9/PA10 */ -ALTERNATE(PIN_MASK(A, 0x0600), 1, MODULE_UART, 0) -/* I2C MASTER: PB8/9 */ -ALTERNATE(PIN_MASK(B, 0x0300), 1, MODULE_I2C, GPIO_ODR_HIGH ) -/* I2C MASTER: PA11/12 */ -ALTERNATE(PIN_MASK(A, 0x1800), 5, MODULE_I2C, GPIO_ODR_HIGH ) +GPIO(NC_GPI5, PIN(I, 5), GPIO_OUT_LOW) +GPIO(NC_GPI7, PIN(I, 7), GPIO_OUT_LOW) +GPIO(NC_GPJ4, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPJ5, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN) +/* + * GPG3,4,5,7 don't have internal pull-down capability, + * so we set them as output low. + */ +GPIO(NC_GPG0, PIN(G, 0), GPIO_INPUT | GPIO_PULL_DOWN) +/* Don't touch GPG1 and GPG2 */ +GPIO(NC_GPG3, PIN(G, 3), GPIO_OUT_LOW) +GPIO(EC_SPI_FLASH_MOSI, PIN(G, 4), GPIO_OUT_LOW) +GPIO(EC_SPI_FLASH_MISO, PIN(G, 5), GPIO_OUT_LOW) +GPIO(EC_SPI_FLASH_CLK, PIN(G, 6), GPIO_INPUT | GPIO_PULL_UP) +GPIO(EC_SPI_FLASH_CS_L, PIN(G, 7), GPIO_OUT_LOW) -/* SPI1 */ -/* SPI SLAVE: PB3/4/5 */ -ALTERNATE(PIN_MASK(B, 0x0038), 0, MODULE_SPI, 0) -/* SPI SLAVE CS: PA15 */ -ALTERNATE(PIN_MASK(A, 0x8000), 0, MODULE_SPI, 0) - -/* SPI2 */ -/* Shared between slave for emmc and master for bmi160 */ -/* They're mutually exclusive with gpio_config_module. */ -/* EMMC SPI SLAVE: PB13/14/15 */ -ALTERNATE(PIN_MASK(B, 0xE000), 0, MODULE_SPI_FLASH, 0) -/* SENSORS SPI MASTER: PB10, PB12, PC2, PC3 */ -ALTERNATE(PIN_MASK(B, 0x0400), 5, MODULE_SPI_MASTER, 0) -ALTERNATE(PIN_MASK(C, 0x000C), 1, MODULE_SPI_MASTER, 0) +/* Alternate functions GPIO definitions */ +/* I2C */ +ALTERNATE(PIN_MASK(B, 0x18), 1, MODULE_I2C, 0) /* I2C A */ +ALTERNATE(PIN_MASK(C, 0x06), 1, MODULE_I2C, GPIO_SEL_1P8V) /* I2C B */ +ALTERNATE(PIN_MASK(F, 0xC0), 1, MODULE_I2C, 0) /* I2C C */ +/* ADC */ +ALTERNATE(PIN_MASK(I, 0x4F), 0, MODULE_ADC, 0) /* ADC 0,1,2,3,6 */ +/* UART */ +ALTERNATE(PIN_MASK(B, 0x03), 1, MODULE_UART, 0) /* EC to Servo */ +/* EMMC SPI SLAVE M2:CLK, M3:CMD, M6:DATA0 */ +ALTERNATE(PIN_MASK(M, 0x4C), 0, MODULE_SPI_FLASH, 0) +/* SPI */ +ALTERNATE(PIN_MASK(M, 0x33), 0, MODULE_SPI, 0) /* SPI for communication */ diff --git a/board/icarus/led.c b/board/icarus/led.c index 2a577e2c80..0f5cd07849 100644 --- a/board/icarus/led.c +++ b/board/icarus/led.c @@ -5,9 +5,8 @@ * Power and battery LED control for Jacuzzi */ #include "common.h" -#include "ioexpander.h" -#include "driver/ioexpander/it8801.h" #include "ec_commands.h" +#include "gpio.h" #include "led_common.h" #include "led_onoff_states.h" #define LED_ON_LVL 0 @@ -35,24 +34,24 @@ void led_set_color_battery(enum ec_led_colors color) { switch (color) { case EC_LED_COLOR_AMBER: - ioex_set_level(IOEX_LED_ORANGE, LED_ON_LVL); - ioex_set_level(IOEX_LED_BLUE, LED_OFF_LVL); - ioex_set_level(IOEX_LED_GREEN, LED_OFF_LVL); + gpio_set_level(GPIO_LED_ORANGE, LED_ON_LVL); + gpio_set_level(GPIO_LED_BLUE, LED_OFF_LVL); + gpio_set_level(GPIO_LED_GREEN, LED_OFF_LVL); break; case EC_LED_COLOR_BLUE: - ioex_set_level(IOEX_LED_BLUE, LED_ON_LVL); - ioex_set_level(IOEX_LED_ORANGE, LED_OFF_LVL); - ioex_set_level(IOEX_LED_GREEN, LED_OFF_LVL); + gpio_set_level(GPIO_LED_BLUE, LED_ON_LVL); + gpio_set_level(GPIO_LED_ORANGE, LED_OFF_LVL); + gpio_set_level(GPIO_LED_GREEN, LED_OFF_LVL); break; case EC_LED_COLOR_GREEN: - ioex_set_level(IOEX_LED_GREEN, LED_ON_LVL); - ioex_set_level(IOEX_LED_BLUE, LED_OFF_LVL); - ioex_set_level(IOEX_LED_ORANGE, LED_OFF_LVL); + gpio_set_level(GPIO_LED_GREEN, LED_ON_LVL); + gpio_set_level(GPIO_LED_BLUE, LED_OFF_LVL); + gpio_set_level(GPIO_LED_ORANGE, LED_OFF_LVL); break; default: /* LED_OFF and other unsupported colors */ - ioex_set_level(IOEX_LED_GREEN, LED_OFF_LVL); - ioex_set_level(IOEX_LED_BLUE, LED_OFF_LVL); - ioex_set_level(IOEX_LED_ORANGE, LED_OFF_LVL); + gpio_set_level(GPIO_LED_GREEN, LED_OFF_LVL); + gpio_set_level(GPIO_LED_BLUE, LED_OFF_LVL); + gpio_set_level(GPIO_LED_ORANGE, LED_OFF_LVL); break; } } |