diff options
Diffstat (limited to 'board/pazquel')
-rw-r--r-- | board/pazquel/battery.c | 2 | ||||
-rw-r--r-- | board/pazquel/board.c | 426 | ||||
-rw-r--r-- | board/pazquel/board.h | 34 | ||||
-rw-r--r-- | board/pazquel/build.mk | 2 | ||||
-rw-r--r-- | board/pazquel/ec.tasklist | 2 | ||||
-rw-r--r-- | board/pazquel/gpio.inc | 8 | ||||
-rw-r--r-- | board/pazquel/led.c | 27 | ||||
-rw-r--r-- | board/pazquel/usbc_config.c | 6 |
8 files changed, 272 insertions, 235 deletions
diff --git a/board/pazquel/battery.c b/board/pazquel/battery.c index e1415f5682..bd600aed5b 100644 --- a/board/pazquel/battery.c +++ b/board/pazquel/battery.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * diff --git a/board/pazquel/board.c b/board/pazquel/board.c index d3568a4bcb..90dcc6cd0d 100644 --- a/board/pazquel/board.c +++ b/board/pazquel/board.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -10,8 +10,10 @@ #include "charge_manager.h" #include "charge_state.h" #include "extpower.h" +#include "driver/accel_kionix.h" #include "driver/accel_bma2x2.h" #include "driver/accelgyro_bmi_common.h" +#include "driver/accelgyro_bmi323.h" #include "driver/ppc/sn5s330.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/tcpci.h" @@ -33,8 +35,8 @@ #include "usbc_ocp.h" #include "usbc_ppc.h" -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) /* Forward declaration */ static void tcpc_alert_event(enum gpio_signal signal); @@ -127,10 +129,8 @@ __override struct keyboard_scan_config keyscan_config = { * 2. T11 key not in keyboard (KSI_0,KSO_1): * change actual_key_mask[1] from 0xff to 0xfe */ - .actual_key_mask = { - 0x1c, 0xfe, 0xff, 0xff, 0xff, 0xf5, 0xff, - 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca - }, + .actual_key_mask = { 0x1c, 0xfe, 0xff, 0xff, 0xff, 0xf5, 0xff, 0xa4, + 0xff, 0xfe, 0x55, 0xfa, 0xca }, /* Other values should be the same as the default configuration. */ .debounce_down_us = 9 * MSEC, .debounce_up_us = 30 * MSEC, @@ -141,41 +141,31 @@ __override struct keyboard_scan_config keyscan_config = { /* I2C port map */ const struct i2c_port_t i2c_ports[] = { - { - .name = "power", - .port = I2C_PORT_POWER, - .kbps = 100, - .scl = GPIO_EC_I2C_POWER_SCL, - .sda = GPIO_EC_I2C_POWER_SDA - }, - { - .name = "tcpc0", - .port = I2C_PORT_TCPC0, - .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_PD_SCL, - .sda = GPIO_EC_I2C_USB_C0_PD_SDA - }, - { - .name = "tcpc1", - .port = I2C_PORT_TCPC1, - .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C1_PD_SCL, - .sda = GPIO_EC_I2C_USB_C1_PD_SDA - }, - { - .name = "eeprom", - .port = I2C_PORT_EEPROM, - .kbps = 400, - .scl = GPIO_EC_I2C_EEPROM_SCL, - .sda = GPIO_EC_I2C_EEPROM_SDA - }, - { - .name = "sensor", - .port = I2C_PORT_SENSOR, - .kbps = 400, - .scl = GPIO_EC_I2C_SENSOR_SCL, - .sda = GPIO_EC_I2C_SENSOR_SDA - }, + { .name = "power", + .port = I2C_PORT_POWER, + .kbps = 100, + .scl = GPIO_EC_I2C_POWER_SCL, + .sda = GPIO_EC_I2C_POWER_SDA }, + { .name = "tcpc0", + .port = I2C_PORT_TCPC0, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C0_PD_SCL, + .sda = GPIO_EC_I2C_USB_C0_PD_SDA }, + { .name = "tcpc1", + .port = I2C_PORT_TCPC1, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C1_PD_SCL, + .sda = GPIO_EC_I2C_USB_C1_PD_SDA }, + { .name = "eeprom", + .port = I2C_PORT_EEPROM, + .kbps = 400, + .scl = GPIO_EC_I2C_EEPROM_SCL, + .sda = GPIO_EC_I2C_EEPROM_SDA }, + { .name = "sensor", + .port = I2C_PORT_SENSOR, + .kbps = 400, + .scl = GPIO_EC_I2C_SENSOR_SCL, + .sda = GPIO_EC_I2C_SENSOR_SDA }, }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); @@ -183,58 +173,39 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* ADC channels */ const struct adc_t adc_channels[] = { /* Measure VBUS through a 1/10 voltage divider */ - [ADC_VBUS] = { - "VBUS", - NPCX_ADC_CH1, - ADC_MAX_VOLT * 10, - ADC_READ_MAX + 1, - 0 - }, + [ADC_VBUS] = { "VBUS", NPCX_ADC_CH1, ADC_MAX_VOLT * 10, + ADC_READ_MAX + 1, 0 }, /* * Adapter current output or battery charging/discharging current (uV) * 18x amplification on charger side. */ - [ADC_AMON_BMON] = { - "AMON_BMON", - NPCX_ADC_CH2, - ADC_MAX_VOLT * 1000 / 18, - ADC_READ_MAX + 1, - 0 - }, + [ADC_AMON_BMON] = { "AMON_BMON", NPCX_ADC_CH2, ADC_MAX_VOLT * 1000 / 18, + ADC_READ_MAX + 1, 0 }, /* * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, to read * 0.8V @ 99 W, i.e. 124000 uW/mV. Using ADC_MAX_VOLT*124000 and * ADC_READ_MAX+1 as multiplier/divider leads to overflows, so we * only divide by 2 (enough to avoid precision issues). */ - [ADC_PSYS] = { - "PSYS", - NPCX_ADC_CH3, - ADC_MAX_VOLT * 124000 * 2 / (ADC_READ_MAX + 1), - 2, - 0 - }, + [ADC_PSYS] = { "PSYS", NPCX_ADC_CH3, + ADC_MAX_VOLT * 124000 * 2 / (ADC_READ_MAX + 1), 2, 0 }, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); const struct pwm_t pwm_channels[] = { - [PWM_CH_KBLIGHT] = { .channel = 3, .flags = 0, .freq = 10000 }, + [PWM_CH_KBLIGHT] = { .channel = 3, .flags = 0, .freq = 10000 }, [PWM_CH_DISPLIGHT] = { .channel = 5, .flags = 0, .freq = 20000 }, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /* Power Path Controller */ struct ppc_config_t ppc_chips[] = { - { - .i2c_port = I2C_PORT_TCPC0, - .i2c_addr_flags = SN5S330_ADDR0_FLAGS, - .drv = &sn5s330_drv - }, - { - .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = SN5S330_ADDR0_FLAGS, - .drv = &sn5s330_drv - }, + { .i2c_port = I2C_PORT_TCPC0, + .i2c_addr_flags = SN5S330_ADDR0_FLAGS, + .drv = &sn5s330_drv }, + { .i2c_port = I2C_PORT_TCPC1, + .i2c_addr_flags = SN5S330_ADDR0_FLAGS, + .drv = &sn5s330_drv }, }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); @@ -265,16 +236,22 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { * to AP. But the TCPC chip is also needed to know the HPD status; otherwise, * the mux misbehaves. */ -const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { +const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { - .usb_port = 0, - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, }, { - .usb_port = 1, - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, } }; @@ -293,19 +270,6 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, }, }; - -static void board_update_sensor_config_clamshell(void) -{ - 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); -} -DECLARE_HOOK(HOOK_INIT, board_update_sensor_config_clamshell, - HOOK_PRIO_INIT_I2C + 2); /* Initialize board. */ static void board_init(void) { @@ -352,9 +316,19 @@ void board_tcpc_init(void) */ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); + USB_PD_MUX_HPD_IRQ_DEASSERTED); + /* + * Pazquel/pazquel360 share the same firmware ,only pazquel360 has + * volume keys. So disable volume keys for pazquel board + */ + if (!board_has_side_volume_buttons()) { + button_disable_gpio(BUTTON_VOLUME_UP); + button_disable_gpio(BUTTON_VOLUME_DOWN); + gpio_set_flags(GPIO_VOLUME_DOWN_L, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_VOLUME_UP_L, GPIO_INPUT | GPIO_PULL_DOWN); + } } -DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1); +DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1); static void da9313_pvc_mode_ctrl(int enable) { @@ -364,12 +338,12 @@ static void da9313_pvc_mode_ctrl(int enable) */ if (enable) i2c_update8(I2C_PORT_POWER, DA9313_I2C_ADDR_FLAGS, - DA9313_REG_PVC_CTRL, - DA9313_PVC_CTRL_PVC_MODE, MASK_SET); + DA9313_REG_PVC_CTRL, DA9313_PVC_CTRL_PVC_MODE, + MASK_SET); else i2c_update8(I2C_PORT_POWER, DA9313_I2C_ADDR_FLAGS, - DA9313_REG_PVC_CTRL, - DA9313_PVC_CTRL_PVC_MODE, MASK_CLR); + DA9313_REG_PVC_CTRL, DA9313_PVC_CTRL_PVC_MODE, + MASK_CLR); } void da9313_init(void) @@ -377,7 +351,7 @@ void da9313_init(void) /* PVC operates in fixed frequency mode in S0. */ da9313_pvc_mode_ctrl(0); } -DECLARE_HOOK(HOOK_INIT, da9313_init, HOOK_PRIO_DEFAULT+1); +DECLARE_HOOK(HOOK_INIT, da9313_init, HOOK_PRIO_DEFAULT + 1); void board_hibernate(void) { @@ -387,10 +361,8 @@ void board_hibernate(void) * 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); + 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); /* * Enable the PPC power sink path before EC enters hibernate; @@ -435,8 +407,23 @@ static void board_shutdown_complete(void) } } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN_COMPLETE, board_shutdown_complete, - HOOK_PRIO_DEFAULT); + HOOK_PRIO_DEFAULT); +__override uint32_t board_get_sku_id(void) +{ + static int sku_id = -1; + + if (sku_id == -1) { + int bits[3]; + + bits[0] = gpio_get_ternary(GPIO_SKU_ID0); + bits[1] = gpio_get_ternary(GPIO_SKU_ID1); + bits[2] = gpio_get_ternary(GPIO_SKU_ID2); + sku_id = binary_first_base3_from_bits(bits, ARRAY_SIZE(bits)); + } + + return (uint32_t)sku_id; +} void board_set_switchcap_power(int enable) { @@ -495,8 +482,7 @@ void board_overcurrent_event(int port, int is_overcurrented) int board_set_active_charge_port(int port) { - int is_real_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_MAX_COUNT); + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; if (!is_real_port && port != CHARGE_PORT_NONE) @@ -524,7 +510,6 @@ int board_set_active_charge_port(int port) return EC_ERROR_INVAL; } - CPRINTS("New charge port: p%d", port); /* @@ -548,23 +533,21 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is * critical, as we may brownout. */ - if (supplier == CHARGE_SUPPLIER_PD && - charge_ma < 1500 && + if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 && charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { CPRINTS("Using max ilim %d", max_ma); charge_ma = max_ma; } - charge_set_input_current_limit(MAX(charge_ma, - CONFIG_CHARGER_INPUT_CURRENT), - charge_mv); + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } uint16_t tcpc_get_alert_status(void) @@ -585,94 +568,157 @@ uint16_t tcpc_get_alert_status(void) static struct mutex g_base_mutex; static struct mutex g_lid_mutex; -static struct bmi_drv_data_t g_bmi160_data; -static struct accelgyro_saved_data_t g_bma255_data; - /* Matrix to rotate accelerometer into standard reference frame */ -const mat33_fp_t base_standard_ref = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, FLOAT_TO_FP(-1), 0}, - { 0, 0, FLOAT_TO_FP(-1)} -}; +const mat33_fp_t base_standard_ref = { { FLOAT_TO_FP(1), 0, 0 }, + { 0, FLOAT_TO_FP(-1), 0 }, + { 0, 0, FLOAT_TO_FP(-1) } }; -static const mat33_fp_t lid_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - { FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; +static struct kionix_accel_data g_kx022_data; +static const mat33_fp_t lid_standard_ref_kx022 = { { FLOAT_TO_FP(1), 0, 0 }, + { 0, FLOAT_TO_FP(1), 0 }, + { 0, 0, FLOAT_TO_FP(-1) } }; + +static struct bmi_drv_data_t g_bmi_data; struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .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, - .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, + .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_SENSOR, + .i2c_spi_addr_flags = KX022_ADDR1_FLAGS, + .rot_standard_ref = &lid_standard_ref_kx022, + .default_range = 2, /* g */ + /* We only use 2g because its resolution is only 8-bits */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, }, - }, }, /* - * Note: bmi160: supports accelerometer and gyro sensor + * Note: bmi232: 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_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, - .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 = { - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - /* Sensor on for lid angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - }, + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMI323, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi3xx_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMI3_ADDR_I2C_PRIM, + .rot_standard_ref = &base_standard_ref, + .min_frequency = BMI_ACCEL_MIN_FREQ, + .max_frequency = BMI_ACCEL_MAX_FREQ, + .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */ + .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, + }, + }, }, [BASE_GYRO] = { - .name = "Gyro", - .active_mask = SENSOR_ACTIVE_S0_S3, - .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, - .min_frequency = BMI_GYRO_MIN_FREQ, - .max_frequency = BMI_GYRO_MAX_FREQ, + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMI323, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi3xx_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMI3_ADDR_I2C_PRIM, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = BMI_GYRO_MIN_FREQ, + .max_frequency = BMI_GYRO_MAX_FREQ, }, }; unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +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 { + 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); + +static uint8_t sku_id; + +enum board_model { + PAZQUEL, + PAZQUEL360, + UNKNOWN, +}; + +static const char *const model_name[] = { + "PAZQUEL", + "PAZQUEL360", + "UNKNOWN", +}; + +static enum board_model get_model(void) +{ + if (sku_id == 0 || sku_id == 1 || sku_id == 2 || sku_id == 3 || + sku_id == 4 || sku_id == 5 || sku_id == 6) + return PAZQUEL; + if (sku_id >= 8) + return PAZQUEL360; + return UNKNOWN; +} + +int board_is_clamshell(void) +{ + return get_model() == PAZQUEL; +} + +/* Read SKU ID from GPIO and initialize variables for board variants */ +static void sku_init(void) +{ + sku_id = system_get_sku_id(); + CPRINTS("SKU: %u (%s)", sku_id, model_name[get_model()]); +} +DECLARE_HOOK(HOOK_INIT, sku_init, HOOK_PRIO_INIT_I2C + 1); + +int board_has_side_volume_buttons(void) +{ + return get_model() == PAZQUEL360; +} +__override int mkbp_support_volume_buttons(void) +{ + return board_has_side_volume_buttons(); +} diff --git a/board/pazquel/board.h b/board/pazquel/board.h index dc80fc9829..414c8ab7dd 100644 --- a/board/pazquel/board.h +++ b/board/pazquel/board.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -11,7 +11,7 @@ #include "baseboard.h" /* Internal SPI flash on NPCX7 */ -#define CONFIG_FLASH_SIZE_BYTES (512 * 1024) /* 512KB internal spi flash */ +#define CONFIG_FLASH_SIZE_BYTES (512 * 1024) /* 512KB internal spi flash */ /* Keyboard */ #define CONFIG_KEYBOARD_PROTOCOL_MKBP @@ -37,19 +37,16 @@ #define USB_PORT_COUNT 1 #define CONFIG_USB_PORT_POWER_DUMB -/* No side volume button */ -#undef CONFIG_VOLUME_BUTTONS - /* Sensors */ #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT -/* BMI160 Base accel/gyro */ -#define CONFIG_ACCELGYRO_BMI160 -#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \ +/* BMI323 Base accel/gyro */ +#define CONFIG_ACCELGYRO_BMI3XX +#define CONFIG_ACCELGYRO_BMI3XX_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) #define OPT3001_I2C_ADDR_FLAGS OPT3001_I2C_ADDR1_FLAGS -/* BMA253 lid accel */ -#define CONFIG_ACCEL_BMA255 +/* KX022 lid accel */ +#define CONFIG_ACCEL_KX022 #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_LID_ANGLE @@ -72,17 +69,14 @@ #define DA9313_PVC_CTRL_PVC_MODE BIT(1) #define DA9313_PVC_CTRL_PVC_EN BIT(0) +/* Button Config*/ +#define CONFIG_BUTTONS_RUNTIME_CONFIG #ifndef __ASSEMBLER__ #include "gpio_signal.h" #include "registers.h" -enum adc_channel { - ADC_VBUS, - ADC_AMON_BMON, - ADC_PSYS, - ADC_CH_COUNT -}; +enum adc_channel { ADC_VBUS, ADC_AMON_BMON, ADC_PSYS, ADC_CH_COUNT }; /* Motion sensors */ enum sensor_id { @@ -92,11 +86,7 @@ enum sensor_id { SENSOR_COUNT, }; -enum pwm_channel { - PWM_CH_KBLIGHT = 0, - PWM_CH_DISPLIGHT, - PWM_CH_COUNT -}; +enum pwm_channel { PWM_CH_KBLIGHT = 0, PWM_CH_DISPLIGHT, PWM_CH_COUNT }; enum battery_type { BATTERY_GANFENG, @@ -106,6 +96,8 @@ enum battery_type { /* Reset all TCPCs. */ void board_reset_pd_mcu(void); void board_set_tcpc_power_mode(int port, int mode); +int board_is_clamshell(void); +int board_has_side_volume_buttons(void); #endif /* !defined(__ASSEMBLER__) */ diff --git a/board/pazquel/build.mk b/board/pazquel/build.mk index f130540bd4..3bc07db568 100644 --- a/board/pazquel/build.mk +++ b/board/pazquel/build.mk @@ -1,5 +1,5 @@ # -*- makefile -*- -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Copyright 2021 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # diff --git a/board/pazquel/ec.tasklist b/board/pazquel/ec.tasklist index 5beeb38feb..228828af3c 100644 --- a/board/pazquel/ec.tasklist +++ b/board/pazquel/ec.tasklist @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/board/pazquel/gpio.inc b/board/pazquel/gpio.inc index 4ebd09b4ee..8d9a2827bc 100644 --- a/board/pazquel/gpio.inc +++ b/board/pazquel/gpio.inc @@ -1,6 +1,6 @@ /* -*- mode:c -*- * - * Copyright 2021 The Chromium OS Authors. All rights reserved. + * Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -21,6 +21,8 @@ GPIO_INT(USB_A0_OC_ODL, PIN(D, 1), GPIO_INT_BOTH | GPIO_PULL_UP, usba_oc_ GPIO_INT(CHG_ACOK_OD, PIN(0, 0), GPIO_INT_BOTH, extpower_interrupt) /* ACOK */ GPIO_INT(CCD_MODE_ODL, PIN(E, 3), GPIO_INT_FALLING, board_connect_c0_sbu) /* Case Closed Debug Mode */ GPIO_INT(EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH, power_button_interrupt) /* Power button */ +GPIO_INT(EC_VOLDN_BTN_ODL, PIN(7, 0), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) /* Volume Down button */ +GPIO_INT(EC_VOLUP_BTN_ODL, PIN(F, 2), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) /* Volume Up button */ GPIO_INT(EC_WP_ODL, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) /* Write protection */ GPIO_INT(LID_OPEN_EC, PIN(D, 2), GPIO_INT_BOTH, lid_interrupt) /* Lid open */ GPIO_INT(AP_RST_L, PIN(C, 1), GPIO_INT_BOTH | GPIO_SEL_1P8V, chipset_ap_rst_interrupt) /* PMIC to signal AP reset */ @@ -39,7 +41,7 @@ GPIO_INT(AP_EC_SPI_CS_L, PIN(5, 3), GPIO_INT_FALLING | GPIO_PULL_DOWN, shi_cs /* Sensor interrupts */ 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, bmi160_interrupt) /* Accelerometer/gyro interrupt */ +GPIO_INT(ACCEL_GYRO_INT_L, PIN(A, 0), GPIO_INT_FALLING, bmi3xx_interrupt) /* Accelerometer/gyro interrupt */ /* * EC_RST_ODL used to be a wake source from PSL mode. However, we disabled @@ -157,8 +159,6 @@ UNUSED(PIN(8, 3)) UNUSED(PIN(B, 1)) UNUSED(PIN(5, 0)) UNUSED(PIN(D, 3)) -UNUSED(PIN(7, 0)) -UNUSED(PIN(F, 2)) /* Alternate functions GPIO definitions */ ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART (GPIO64/65) */ diff --git a/board/pazquel/led.c b/board/pazquel/led.c index aabf33f3f0..180e9829f5 100644 --- a/board/pazquel/led.c +++ b/board/pazquel/led.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -31,15 +31,15 @@ enum led_color { LED_OFF = 0, LED_RED, LED_BLUE, - LED_COLOR_COUNT /* Number of colors, not a color itself */ + LED_COLOR_COUNT /* Number of colors, not a color itself */ }; static void led_set_color(enum led_color color) { gpio_set_level(GPIO_EC_CHG_LED_Y_C1, - (color == LED_RED) ? BAT_LED_ON : BAT_LED_OFF); + (color == LED_RED) ? BAT_LED_ON : BAT_LED_OFF); gpio_set_level(GPIO_EC_CHG_LED_W_C1, - (color == LED_BLUE) ? BAT_LED_ON : BAT_LED_OFF); + (color == LED_BLUE) ? BAT_LED_ON : BAT_LED_OFF); } void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) @@ -65,7 +65,6 @@ static void board_led_set_battery(void) static int battery_ticks; enum led_color color = LED_OFF; int period = 0; - uint32_t chflags = charge_get_flags(); battery_ticks++; @@ -105,16 +104,16 @@ static void board_led_set_battery(void) color = LED_BLUE; break; case PWR_STATE_IDLE: /* External power connected in IDLE */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) { - /* Factory mode: Blue 2 sec, Red 2 sec */ - period = (2 + 2) * LED_ONE_SEC; - battery_ticks = battery_ticks % period; - if (battery_ticks < 2 * LED_ONE_SEC) - color = LED_BLUE; - else - color = LED_RED; - } else + color = LED_BLUE; + break; + case PWR_STATE_FORCED_IDLE: + /* Factory mode: Blue 2 sec, Red 2 sec */ + period = (2 + 2) * LED_ONE_SEC; + battery_ticks = battery_ticks % period; + if (battery_ticks < 2 * LED_ONE_SEC) color = LED_BLUE; + else + color = LED_RED; break; default: /* Other states don't alter LED behavior */ diff --git a/board/pazquel/usbc_config.c b/board/pazquel/usbc_config.c index aac136415d..5d30adb6e2 100644 --- a/board/pazquel/usbc_config.c +++ b/board/pazquel/usbc_config.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -11,8 +11,8 @@ #include "console.h" #include "usb_pd.h" -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) const struct charger_config_t chg_chips[] = { { |