summaryrefslogtreecommitdiff
path: root/board/pazquel/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/pazquel/board.c')
-rw-r--r--board/pazquel/board.c426
1 files changed, 236 insertions, 190 deletions
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();
+}