From 14074729dc54d70a919896671362a46cce77ac13 Mon Sep 17 00:00:00 2001 From: Tommy Chung Date: Tue, 21 Dec 2021 14:57:16 +0800 Subject: dojo: Initial EC image Create the initial EC image for the dojo variant by copying the cherry reference board EC files into a new directory named for the variant. (Auto-Generated by create_initial_ec_image.sh version 1.5.0). BUG=b:211528578 BRANCH=None TEST=make BOARD=dojo Signed-off-by: Tommy Chung Change-Id: I703a83e616914b69367fe4da129ee172ce6b878f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3350380 Reviewed-by: Devin Lu Reviewed-by: Ting Shen --- board/dojo/battery.c | 126 +++++++++++++++++++++++++++++++ board/dojo/board.c | 179 ++++++++++++++++++++++++++++++++++++++++++++ board/dojo/board.h | 105 ++++++++++++++++++++++++++ board/dojo/build.mk | 14 ++++ board/dojo/ec.tasklist | 23 ++++++ board/dojo/gpio.inc | 164 ++++++++++++++++++++++++++++++++++++++++ board/dojo/led.c | 87 +++++++++++++++++++++ board/dojo/vif_override.xml | 3 + 8 files changed, 701 insertions(+) create mode 100644 board/dojo/battery.c create mode 100644 board/dojo/board.c create mode 100644 board/dojo/board.h create mode 100644 board/dojo/build.mk create mode 100644 board/dojo/ec.tasklist create mode 100644 board/dojo/gpio.inc create mode 100644 board/dojo/led.c create mode 100644 board/dojo/vif_override.xml diff --git a/board/dojo/battery.c b/board/dojo/battery.c new file mode 100644 index 0000000000..72daf4966d --- /dev/null +++ b/board/dojo/battery.c @@ -0,0 +1,126 @@ +/* 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 "battery.h" +#include "battery_fuel_gauge.h" +#include "battery_smart.h" + +const struct board_batt_params board_battery_info[] = { + /* Panasonic AP16L5J Battery Information */ + [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, + .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] = { + .fuel_gauge = { + .manuf_name = "PANASONIC KT00205009", + .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, + .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, + }, + }, + /* AP16L8J */ + [BATTERY_AP16L8J] = { + .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, /* mV */ + .voltage_min = 6000, /* mV */ + .precharge_current = 256, /* mA */ + .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, + }, + }, + /* LGC AP18C8K Battery Information */ + [BATTERY_LGC_AP18C8K] = { + .fuel_gauge = { + .manuf_name = "LGC KT0030G020", + .device_name = "AP18C8K", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x43, + .reg_mask = 0x0001, + .disconnect_val = 0x0, + }, + }, + .batt_info = { + .voltage_max = 13050, + .voltage_normal = 11250, + .voltage_min = 9000, + .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, + }, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); + +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC_AC16L5J; diff --git a/board/dojo/board.c b/board/dojo/board.c new file mode 100644 index 0000000000..35dae9ed36 --- /dev/null +++ b/board/dojo/board.c @@ -0,0 +1,179 @@ +/* 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. + */ +/* Cherry board configuration */ + +#include "common.h" +#include "console.h" +#include "driver/accel_bma422.h" +#include "driver/accel_kionix.h" +#include "driver/accel_kx022.h" +#include "driver/accelgyro_icm42607.h" +#include "driver/accelgyro_icm_common.h" +#include "gpio.h" +#include "hooks.h" +#include "motion_sense.h" +#include "pwm.h" +#include "pwm_chip.h" +#include "system.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) + +/* Sensor */ +static struct mutex g_base_mutex; +static struct mutex g_lid_mutex; + +static struct icm_drv_data_t g_icm42607_data; +static struct kionix_accel_data g_kx022_data; +static struct accelgyro_saved_data_t g_bma422_data; + +/* Matrix to rotate accelrator into standard reference frame */ +static const mat33_fp_t base_standard_ref = { + { 0, FLOAT_TO_FP(1), 0}, + { FLOAT_TO_FP(1), 0, 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + +static const mat33_fp_t lid_standard_ref = { + { FLOAT_TO_FP(-1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +struct motion_sensor_t motion_sensors[] = { + /* + * Note: bmi160: supports accelerometer and gyro sensor + * Requirement: accelerometer sensor must init before gyro sensor + * DO NOT change the order of the following table. + */ + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM42607, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm42607_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm42607_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS, + .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs.*/ + .rot_standard_ref = &base_standard_ref, + .min_frequency = ICM42607_ACCEL_MIN_FREQ, + .max_frequency = ICM42607_ACCEL_MAX_FREQ, + .config = { + /* 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, + }, + }, + }, + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM42607, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm42607_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm42607_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = ICM42607_GYRO_MIN_FREQ, + .max_frequency = ICM42607_GYRO_MAX_FREQ, + }, + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = KX022_ADDR1_FLAGS, + .rot_standard_ref = &lid_standard_ref, + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + }, + }, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +struct motion_sensor_t bma422_lid_accel = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMA422, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &bma4_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bma422_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = BMA4_I2C_ADDR_PRIMARY, + .rot_standard_ref = &lid_standard_ref, + .min_frequency = BMA4_ACCEL_MIN_FREQ, + .max_frequency = BMA4_ACCEL_MAX_FREQ, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 12500 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on in S3 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 12500 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + }, +}; + +static void board_update_motion_sensor_config(void) +{ + if (system_get_board_version() >= 2) { + motion_sensors[LID_ACCEL] = bma422_lid_accel; + ccprints("LID ACCEL is BMA422"); + } else { + ccprints("LID ACCEL is KX022"); + } +} + +/* Initialize board. */ +static void board_init(void) +{ + /* Enable motion sensor interrupt */ + gpio_enable_interrupt(GPIO_BASE_IMU_INT_L); + gpio_enable_interrupt(GPIO_LID_ACCEL_INT_L); + + /* Disable PWM_CH_LED2(Green) for unuse */ + pwm_enable(PWM_CH_LED2, 0); + + board_update_motion_sensor_config(); + + if (board_get_version() >= 2) { + gpio_set_flags(GPIO_I2C_H_SCL, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_I2C_H_SDA, GPIO_INPUT | GPIO_PULL_DOWN); + } +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/dojo/board.h b/board/dojo/board.h new file mode 100644 index 0000000000..1c52eac8ba --- /dev/null +++ b/board/dojo/board.h @@ -0,0 +1,105 @@ +/* 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. + */ +/* Cherry board configuration */ + +#ifndef __CROS_EC_BOARD_H +#define __CROS_EC_BOARD_H + +#include "baseboard.h" + +/* Chipset config */ +#define CONFIG_BRINGUP + +/* Optional features */ +#define CONFIG_SYSTEM_UNLOCKED +#define CONFIG_LTO +#define CONFIG_PRESERVE_LOGS + +/* + * TODO: Remove this option once the VBAT no longer keeps high when + * system's power isn't presented. + */ +#define CONFIG_IT83XX_RESET_PD_CONTRACT_IN_BRAM + +/* BC12 */ + +/* LED */ +#define CONFIG_LED_ONOFF_STATES +#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10 + +/* PD / USB-C / PPC */ +#define CONFIG_USB_PD_DEBUG_LEVEL 0 + +/* Optional console commands */ +#define CONFIG_CMD_FLASH +#define CONFIG_CMD_SCRATCHPAD +#define CONFIG_CMD_STACKOVERFLOW + +#define CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV 9000 + +/* Keyboard */ +#define GPIO_EN_KEYBOARD_BACKLIGHT GPIO_EN_KB_BL +#define CONFIG_KEYBOARD_REFRESH_ROW3 + +/* Sensor */ +#define CONFIG_GMR_TABLET_MODE +#define CONFIG_TABLET_MODE +#define CONFIG_TABLET_MODE_SWITCH +#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L + +/* ICM426XX Base accel/gyro */ +#define CONFIG_ACCELGYRO_ICM42607 +#define CONFIG_ACCELGYRO_ICM42607_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) + +/* KX022 Lid accel */ +#define CONFIG_ACCEL_KX022 + +/* BMA422 Lid accel */ +#define CONFIG_ACCEL_BMA4XX + +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) + +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL +#define CONFIG_LID_ANGLE_UPDATE + +/* SPI / Host Command */ +#undef CONFIG_HOSTCMD_DEBUG_MODE +#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF + +/* USB-A */ +#define USBA_PORT_COUNT 1 + +/* Temperature */ +#define CONFIG_TEMP_SENSOR +#define CONFIG_THERMISTOR +#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B + +#ifndef __ASSEMBLER__ + +#include "gpio_signal.h" +#include "registers.h" + +enum battery_type { + BATTERY_PANASONIC_AC16L5J, + BATTERY_PANASONIC_AC16L5J_KT00205009, + BATTERY_AP16L8J, + BATTERY_LGC_AP18C8K, + BATTERY_TYPE_COUNT, +}; + +enum sensor_id { + BASE_ACCEL = 0, + BASE_GYRO, + LID_ACCEL, + SENSOR_COUNT, +}; + +int board_accel_force_mode_mask(void); + +#endif /* !__ASSEMBLER__ */ +#endif /* __CROS_EC_BOARD_H */ diff --git a/board/dojo/build.mk b/board/dojo/build.mk new file mode 100644 index 0000000000..0b0569c6d8 --- /dev/null +++ b/board/dojo/build.mk @@ -0,0 +1,14 @@ +# -*- makefile -*- +# 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. +# +# Board specific files build + +# the IC is ITE IT8xxx2 +CHIP:=it83xx +CHIP_FAMILY:=it8xxx2 +CHIP_VARIANT:=it81202bx_1024 +BASEBOARD:=cherry + +board-y+=led.o battery.o board.o diff --git a/board/dojo/ec.tasklist b/board/dojo/ec.tasklist new file mode 100644 index 0000000000..f9050fef87 --- /dev/null +++ b/board/dojo/ec.tasklist @@ -0,0 +1,23 @@ +/* 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. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TASK_LIST \ + TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(CHARGER, charger_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, 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, LARGER_TASK_STACK_SIZE) \ + TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \ + TASK_ALWAYS(DPS, dps_task, NULL, 1280) \ + TASK_ALWAYS(PD_C0, pd_task, NULL, 1280) \ + TASK_ALWAYS(PD_C1, pd_task, NULL, 1280) \ + TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, 1024) \ + diff --git a/board/dojo/gpio.inc b/board/dojo/gpio.inc new file mode 100644 index 0000000000..296e3a418e --- /dev/null +++ b/board/dojo/gpio.inc @@ -0,0 +1,164 @@ +/* -*- mode:c -*- + * + * 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. + */ + +/* Declare symbolic names for all the GPIOs that we care about. + * Note: Those with interrupt handlers must be declared first. */ + +/* Wake Source interrupts */ +GPIO_INT(POWER_BUTTON_L, PIN(E, 4), GPIO_INT_BOTH | GPIO_PULL_UP | + GPIO_HIB_WAKE_HIGH, power_button_interrupt) /* GSC_EC_PWR_BTN_ODL */ +GPIO_INT(LID_OPEN, PIN(E, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, + lid_interrupt) +GPIO_INT(TABLET_MODE_L, PIN(J, 7), GPIO_INT_BOTH, + gmr_tablet_switch_isr) + +/* Chipset interrupts */ +GPIO_INT(AP_EC_WARM_RST_REQ, PIN(D, 3), GPIO_INT_RISING | GPIO_SEL_1P8V, + chipset_reset_request_interrupt) + +/* Power sequencing interrupts */ +GPIO_INT(AP_EC_WATCHDOG_L, PIN(C, 7), GPIO_INT_BOTH | GPIO_SEL_1P8V, + chipset_watchdog_interrupt) +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_PWRGD, PIN(F, 3), + GPIO_INT_BOTH | GPIO_PULL_DOWN | GPIO_SEL_1P8V, power_signal_interrupt) + +/* Sensor Interrupts */ +GPIO_INT(BASE_IMU_INT_L, PIN(M, 3), GPIO_INT_FALLING | GPIO_SEL_1P8V, + icm42607_interrupt) +/* USB-C interrupts */ +GPIO_INT(USB_C0_PPC_INT_ODL, PIN(D, 1), GPIO_INT_BOTH, ppc_interrupt) +#ifdef BOARD_CHERRY +GPIO_INT(USB_C0_BC12_INT_ODL,PIN(J, 4), GPIO_INT_FALLING, bc12_interrupt) +#else /* TOMATO */ +GPIO_INT(USB_C0_BC12_INT_ODL,PIN(I, 5), GPIO_INT_FALLING, bc12_interrupt) +#endif +GPIO_INT(USB_C1_INT_ODL, PIN(B, 2), GPIO_INT_FALLING, rt1718s_tcpc_interrupt) +/* TODO: not used in other devices? */ +GPIO(LID_ACCEL_INT_L, PIN(M, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V) + +/* Volume button interrupts */ +GPIO_INT(VOLUME_DOWN_L, PIN(D, 5), GPIO_INT_BOTH | GPIO_PULL_UP, + button_interrupt) /* EC_VOLDN_BTN_ODL */ +GPIO_INT(VOLUME_UP_L, PIN(D, 6), GPIO_INT_BOTH | GPIO_PULL_UP, + button_interrupt) /* EC_VOLUP_BTN_ODL */ + +/* Other interrupts */ +GPIO_INT(AC_PRESENT, PIN(E, 5), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, + extpower_interrupt) /* AC_OK / AC_PRESENT in rev1+ */ +GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_FALLING, + uart_deepsleep_interrupt) /* UART_DEBUG_TX_EC_RX */ +GPIO_INT(WP, PIN(I, 4), GPIO_INT_BOTH | GPIO_SEL_1P8V, + switch_interrupt) /* EC_FLASH_WP_OD */ +GPIO_INT(SPI0_CS, PIN(M, 5), GPIO_INT_FALLING, + spi_event) /* SPI slave Chip Select -- AP_SPI_EC_CS_L */ +#ifndef BOARD_CHERRY +GPIO_INT(AP_XHCI_INIT_DONE, PIN(J, 5), GPIO_INT_BOTH | GPIO_PULL_DOWN | GPIO_SEL_1P8V, + xhci_init_done_interrupt) +#endif + +/* Power Sequencing Signals */ +GPIO(EC_PMIC_EN_ODL, PIN(D, 0), GPIO_ODR_HIGH | GPIO_SEL_1P8V) +GPIO(EC_PMIC_WATCHDOG_L, PIN(H, 0), GPIO_ODR_LOW | GPIO_SEL_1P8V) +GPIO(EN_PP5000_A, PIN(C, 6), GPIO_OUT_HIGH) +GPIO(PG_MT6315_PROC_B_ODL, PIN(E, 1), GPIO_INPUT) +GPIO(PG_MT6360_ODL, PIN(F, 1), GPIO_INPUT) +GPIO(EN_SLP_Z, PIN(E, 3), GPIO_OUT_LOW) +GPIO(SYS_RST_ODL, PIN(B, 6), GPIO_ODR_LOW) +GPIO(EC_BL_EN_OD, PIN(B, 5), GPIO_ODR_LOW | GPIO_SEL_1P8V) + +/* MKBP event synchronization */ +GPIO(EC_INT_L, PIN(E, 6), GPIO_ODR_HIGH | GPIO_SEL_1P8V) /* EC_AP_INT_ODL */ + +/* USB and USBC Signals */ +GPIO(DP_PATH_SEL, PIN(G, 0), GPIO_OUT_HIGH) +GPIO(DP_DEMUX_EN, PIN(G, 1), GPIO_OUT_LOW) +GPIO(EC_AP_DP_HPD_ODL, PIN(J, 0), GPIO_ODR_HIGH) +GPIO(EN_PP5000_USB_A0_VBUS_X,PIN(B, 7), GPIO_OUT_LOW) +GPIO(USB_C0_DP_IN_HPD, PIN(H, 4), GPIO_OUT_LOW) +GPIO(USB_C1_DP_IN_HPD, PIN(J, 1), GPIO_OUT_LOW) +GPIO(USB_C0_FRS_EN, PIN(F, 0), GPIO_OUT_LOW) + +/* Misc Signals */ +GPIO(EN_KB_BL, PIN(A, 6), GPIO_OUT_LOW) +GPIO(EC_BATT_PRES_ODL, PIN(C, 0), GPIO_INPUT) +GPIO(EN_EC_ID_ODL, PIN(H, 5), GPIO_ODR_LOW) +GPIO(ENTERING_RW, PIN(C, 5), GPIO_OUT_LOW) /* EC_ENTERING_RW */ +GPIO(EN_5V_USM, PIN(G, 3), GPIO_OUT_LOW) +GPIO(USB_A0_FAULT_ODL, PIN(J, 6), GPIO_INPUT) +GPIO(PACKET_MODE_EN, PIN(D, 4), GPIO_OUT_LOW) /* EC_GSC_PACKET_MODE */ + +/* I2C pins - Alternate function below configures I2C module on these pins */ +GPIO(I2C_A_SCL, PIN(B, 3), GPIO_INPUT) /* I2C_CHG_BATT_SCL */ +GPIO(I2C_A_SDA, PIN(B, 4), GPIO_INPUT) /* I2C_CHG_BATT_SDA */ +GPIO(I2C_B_SCL, PIN(C, 1), GPIO_INPUT | GPIO_SEL_1P8V) /* I2C_SENSOR_SCL */ +GPIO(I2C_B_SDA, PIN(C, 2), GPIO_INPUT | GPIO_SEL_1P8V) /* I2C_SENSOR_SDA */ +GPIO(I2C_C_SCL, PIN(F, 6), GPIO_INPUT) /* I2C_USB_C0_SCL */ +GPIO(I2C_C_SDA, PIN(F, 7), GPIO_INPUT) /* I2C_USB_C0_SDA */ +GPIO(I2C_E_SCL, PIN(E, 0), GPIO_INPUT) /* I2C_USB_C1_SCL */ +GPIO(I2C_E_SDA, PIN(E, 7), GPIO_INPUT) /* I2C_USB_C1_SDA */ +GPIO(I2C_F_SCL, PIN(A, 4), GPIO_INPUT) /* Rev 2+ I2C_PROG_SCL */ +GPIO(I2C_F_SDA, PIN(A, 5), GPIO_INPUT) /* Rev 2+ I2C_PROG_SDA */ +GPIO(I2C_H_SCL, PIN(H, 1), GPIO_INPUT) /* Rev 0,1 I2C_PROG_SCL */ +GPIO(I2C_H_SDA, PIN(H, 2), GPIO_INPUT) /* Rev 0,1 I2C_PROG_SDA */ + +/* Alternate functions GPIO definitions */ +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 */ +ALTERNATE(PIN_MASK(E, 0x81), 1, MODULE_I2C, 0) /* I2C E */ + +/* UART */ +ALTERNATE(PIN_MASK(B, 0x03), 1, MODULE_UART, 0) /* EC to Servo */ + +/* PWM */ +ALTERNATE(PIN_MASK(A, 0b1111), 1, MODULE_PWM, 0) /* PWM 0,1,2,3 */ + +/* ADC */ +ALTERNATE(PIN_MASK(I, 0b11001001), 0, MODULE_ADC, 0) /* ADC 0,3,6,7 */ + +/* SPI */ +ALTERNATE(PIN_MASK(M, 0x33), 0, MODULE_SPI, 0) /* SPI */ + +/* Unimplemented Pins */ +GPIO(PG_PP5000_S5_OD, PIN(D, 2), GPIO_INPUT) +/* *_ODL pin has external pullup so don't pull it down. */ +GPIO(PG_MT6315_GPU_ODL, PIN(H, 6), GPIO_INPUT) +/* reserved for future use */ +GPIO(CCD_MODE_ODL, PIN(C, 4), GPIO_INPUT) +/* + * ADC pins don't have internal pull-down capability, + * so we set them as output low. + */ +#ifdef BOARD_CHERRY +GPIO(NC_GPI5, PIN(I, 5), GPIO_OUT_LOW) +#else +GPIO(NC_GPJ4, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN) +#endif +/* NC pins, enable internal pull-up/down to avoid floating state. */ +GPIO(NC_GPA1, PIN(A, 1), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(PWM7, PIN(A, 7), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(EC_NVME_PLN_ODL, PIN(D, 7), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(SPI_CLK_GPG6, PIN(G, 6), GPIO_INPUT | GPIO_PULL_UP) +GPIO(PG_NVME_OD, PIN(H, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(EN_PP2500_NVME_X, PIN(J, 2), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(EN_PP1200_NVME_X, PIN(J, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(NC_GPM6, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN) +/* + * These pins don't have internal pull-down capability, + * so we set them as output low. + */ +GPIO(SPI_MOSI_GPG4, PIN(G, 4), GPIO_OUT_LOW) +GPIO(SPI_MISO_GPG5, PIN(G, 5), GPIO_OUT_LOW) +GPIO(SPI_CS_GPG7, PIN(G, 7), GPIO_OUT_LOW) +GPIO(EC_ID0, PIN(I, 1), GPIO_OUT_LOW) +GPIO(EC_ID1, PIN(I, 2), GPIO_OUT_LOW) + +/* Other unused pins */ +GPIO(NVME_EC_PLA_S3_ODL, PIN(I, 7), GPIO_INPUT) + diff --git a/board/dojo/led.c b/board/dojo/led.c new file mode 100644 index 0000000000..c177a1b48f --- /dev/null +++ b/board/dojo/led.c @@ -0,0 +1,87 @@ +/* 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 "chipset.h" +#include "common.h" +#include "gpio.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "pwm.h" + +#define LED_OFF_LVL 0 +#define LED_ON_LVL 1 + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 95; + +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, + [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, + [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} }, + [STATE_CHARGING_FULL_S5] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S3] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, + {LED_OFF, 3 * LED_ONE_SEC} }, + [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, + [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, + {LED_OFF, 1 * LED_ONE_SEC} }, + [STATE_FACTORY_TEST] = {{EC_LED_COLOR_BLUE, 2 * LED_ONE_SEC}, + {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, +}; + +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_BATTERY_LED, +}; +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_AMBER: + pwm_enable(PWM_CH_LED1, LED_ON_LVL); + pwm_enable(PWM_CH_LED3, LED_OFF_LVL); + break; + case EC_LED_COLOR_BLUE: + pwm_enable(PWM_CH_LED1, LED_OFF_LVL); + pwm_enable(PWM_CH_LED3, LED_ON_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + pwm_enable(PWM_CH_LED1, LED_OFF_LVL); + pwm_enable(PWM_CH_LED3, LED_OFF_LVL); + break; + } +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + brightness_range[EC_LED_COLOR_AMBER] = 1; + brightness_range[EC_LED_COLOR_BLUE] = 1; +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else if (brightness[EC_LED_COLOR_BLUE] != 0) + led_set_color_battery(EC_LED_COLOR_BLUE); + else + led_set_color_battery(LED_OFF); + return EC_SUCCESS; +} + +__override enum led_states board_led_get_state(enum led_states desired_state) +{ + if (desired_state == STATE_BATTERY_ERROR) { + if (chipset_in_state(CHIPSET_STATE_ON)) + return desired_state; + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) + return STATE_DISCHARGE_S3; + else + return STATE_DISCHARGE_S5; + } + return desired_state; +} diff --git a/board/dojo/vif_override.xml b/board/dojo/vif_override.xml new file mode 100644 index 0000000000..32736caf64 --- /dev/null +++ b/board/dojo/vif_override.xml @@ -0,0 +1,3 @@ + -- cgit v1.2.1