diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-09-21 14:08:36 -0700 |
---|---|---|
committer | Tom Hughes <tomhughes@chromium.org> | 2022-09-22 12:59:38 -0700 |
commit | c453fd704268ef72de871b0c5ac7a989de662334 (patch) | |
tree | fcf6ce5810f9ff9e3c8cce434812dd75492269ed /board/dojo/board.c | |
parent | 6c1587ca70f558b4f96b3f0b18ad8b027d3ba99d (diff) | |
parent | 28712dae9d7ed1e694f7622cc083afa71090d4d5 (diff) | |
download | chrome-ec-firmware-fpmcu-dartmonkey-release.tar.gz |
Merge remote-tracking branch cros/main into firmware-fpmcu-dartmonkey-releasefirmware-fpmcu-dartmonkey-release
Generated by: ./util/update_release_branch.py --board dartmonkey --relevant_paths_file
./util/fingerprint-relevant-paths.txt firmware-fpmcu-dartmonkey-release
Relevant changes:
git log --oneline 6c1587ca70..28712dae9d -- board/nocturne_fp
board/dartmonkey common/fpsensor docs/fingerprint driver/fingerprint
util/getversion.sh
ded9307b79 util/getversion.sh: Fix version when not in a git repo
956055e692 board: change Google USB vendor info
71b2ef709d Update license boilerplate text in source code files
33e11afda0 Revert "fpsensor: Build fpsensor source file with C++"
c8d0360723 fpsensor: Build fpsensor source file with C++
bc113abd53 fpsensor: Fix g++ compiler error
150a58a0dc fpsensor: Fix fp_set_sensor_mode return type
b33b5ce85b fpsensor: Remove nested designators for C++ compatibility
2e864b2539 tree-wide: const-ify argv for console commands
56d8b360f9 test: Add test for get ikm failure when seed not set
3a3d6c3690 test: Add test for fpsensor trivial key failure
233e6bbd08 fpsensor_crypto: Abstract calls to hmac_SHA256
0a041b285b docs/fingerprint: Typo correction
c03fab67e2 docs/fingerprint: Fix the path of fputils.py
0b5d4baf5a util/getversion.sh: Fix empty file list handling
6e128fe760 FPMCU dev board environment with Satlab
3eb29b6aa5 builtin: Move ssize_t to sys/types.h
345d62ebd1 docs/fingerprint: Update power numbers for latest dartmonkey release
c25ffdb316 common: Conditionally support printf %l and %i modifiers
9a3c514b45 test: Add a test to check if the debugger is connected
54e603413f Move standard library tests to their own file
43fa6b4bf8 docs/fingerprint: Update power numbers for latest bloonchipper release
25536f9a84 driver/fingerprint/fpc/bep/fpc_sensor_spi.c: Format with clang-format
4face99efd driver/fingerprint/fpc/libfp/fpc_sensor_pal.h: Format with clang-format
738de2b575 trng: Rename rand to trng_rand
14b8270edd docs/fingerprint: Update dragonclaw power numbers
0b268f93d1 driver/fingerprint/fpc/libfp/fpc_private.c: Format with clang-format
f80da163f2 driver/fingerprint/fpc/libfp/fpc_private.h: Format with clang-format
a0751778f4 board/nocturne_fp/ro_workarounds.c: Format with clang-format
5e9c85c9b1 driver/fingerprint/fpc/libfp/fpc_sensor_pal.c: Format with clang-format
c1f9dd3cf8 driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h: Format with clang-format
eb1e1bed8d driver/fingerprint/fpc/libfp/fpc1145_private.h: Format with clang-format
6e7b611821 driver/fingerprint/fpc/bep/fpc_bio_algorithm.h: Format with clang-format
e0589cd5e2 driver/fingerprint/fpc/bep/fpc1035_private.h: Format with clang-format
58f0246dbe board/nocturne_fp/board_ro.c: Format with clang-format
7905e556a0 common/fpsensor/fpsensor_crypto.c: Format with clang-format
21289d170c driver/fingerprint/fpc/bep/fpc1025_private.h: Format with clang-format
98a20f937e common/fpsensor/fpsensor_state.c: Format with clang-format
a2d255d8af common/fpsensor/fpsensor.c: Format with clang-format
84e53a65da board/nocturne_fp/board.h: Format with clang-format
73055eeb3f driver/fingerprint/fpc/bep/fpc_private.c: Format with clang-format
0f7b5cb509 common/fpsensor/fpsensor_private.h: Format with clang-format
1ceade6e65 driver/fingerprint/fpc/bep/fpc_private.h: Format with clang-format
dca9d74321 Revert "trng: Rename rand to trng_rand"
a6b0b3554f trng: Rename rand to trng_rand
28d0b75b70 third_party/boringssl: Remove unused header
BRANCH=None
BUG=b:244387210 b:242720240 b:215613183 b:242720910 b:236386294
BUG=b:234181908 b:244781166 b:234781655 b:234143158 b:234181908
BUG=b:237344361 b:236025198 b:234181908 b:180945056 chromium:1098010
BUG=b:246424843 b:234181908 b:131913998
TEST=`make -j buildall`
TEST=./util/run_device_tests.py --board dartmonkey
Test "aes": PASSED
Test "cec": PASSED
Test "cortexm_fpu": PASSED
Test "crc": PASSED
Test "flash_physical": PASSED
Test "flash_write_protect": PASSED
Test "fpsensor_hw": PASSED
Test "fpsensor_spi_ro": PASSED
Test "fpsensor_spi_rw": PASSED
Test "fpsensor_uart_ro": PASSED
Test "fpsensor_uart_rw": PASSED
Test "mpu_ro": PASSED
Test "mpu_rw": PASSED
Test "mutex": PASSED
Test "pingpong": PASSED
Test "printf": PASSED
Test "queue": PASSED
Test "rollback_region0": PASSED
Test "rollback_region1": PASSED
Test "rollback_entropy": PASSED
Test "rtc": PASSED
Test "sha256": PASSED
Test "sha256_unrolled": PASSED
Test "static_if": PASSED
Test "stdlib": PASSED
Test "system_is_locked_wp_on": PASSED
Test "system_is_locked_wp_off": PASSED
Test "timer_dos": PASSED
Test "utils": PASSED
Test "utils_str": PASSED
Test "panic_data_dartmonkey_v2.0.2887": PASSED
Test "panic_data_nocturne_fp_v2.2.64": PASSED
Test "panic_data_nami_fp_v2.2.144": PASSED
Force-Relevant-Builds: all
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I2c312583a709fedae8fe11d92c22328c3b634bc7
Diffstat (limited to 'board/dojo/board.c')
-rw-r--r-- | board/dojo/board.c | 292 |
1 files changed, 199 insertions, 93 deletions
diff --git a/board/dojo/board.c b/board/dojo/board.c index f539d17d2d..65a1635111 100644 --- a/board/dojo/board.c +++ b/board/dojo/board.c @@ -1,16 +1,20 @@ -/* 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. */ /* Dojo board configuration */ #include "cbi_fw_config.h" +#include "cbi_ssfc.h" +#include "charge_manager.h" +#include "charge_state_v2.h" #include "common.h" #include "console.h" #include "cros_board_info.h" #include "driver/accel_kionix.h" #include "driver/accel_kx022.h" #include "driver/accelgyro_icm426xx.h" +#include "driver/accelgyro_icm42607.h" #include "driver/accelgyro_icm_common.h" #include "driver/accelgyro_bmi_common_public.h" #include "driver/accelgyro_bmi260_public.h" @@ -25,10 +29,11 @@ #include "system.h" #include "usb_mux.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) uint32_t board_version; +enum ec_ssfc_base_sensor base_sensor; /* Keyboard scan setting */ __override struct keyboard_scan_config keyscan_config = { @@ -45,6 +50,31 @@ __override struct keyboard_scan_config keyscan_config = { }, }; +/* Support keyboard factory test */ +#ifdef CONFIG_KEYBOARD_FACTORY_TEST +/* + * Map keyboard connector pins to EC GPIO pins for factory test. + * Pins mapped to {-1, -1} are skipped. + * The connector has 30 pins total, and there is no pin 0. + */ +const int keyboard_factory_scan_pins[][2] = { + { -1, -1 }, { GPIO_KSO_H, 4 }, { GPIO_KSO_H, 0 }, + { GPIO_KSO_H, 1 }, { GPIO_KSO_H, 3 }, { GPIO_KSO_H, 2 }, + { -1, -1 }, { -1, -1 }, { GPIO_KSO_L, 5 }, + { GPIO_KSO_L, 6 }, { -1, -1 }, { GPIO_KSO_L, 3 }, + { GPIO_KSO_L, 2 }, { GPIO_KSI, 0 }, { GPIO_KSO_L, 1 }, + { GPIO_KSO_L, 4 }, { GPIO_KSI, 3 }, { GPIO_KSI, 2 }, + { GPIO_KSO_L, 0 }, { GPIO_KSI, 5 }, { GPIO_KSI, 4 }, + { GPIO_KSO_L, 7 }, { GPIO_KSI, 6 }, { GPIO_KSI, 7 }, + { GPIO_KSI, 1 }, { -1, -1 }, { GPIO_KSO_H, 5 }, + { -1, -1 }, { GPIO_KSO_H, 6 }, { -1, -1 }, + { -1, -1 }, +}; + +const int keyboard_factory_scan_pins_used = + ARRAY_SIZE(keyboard_factory_scan_pins); +#endif + /* Vol-up key matrix at T13 */ const struct vol_up_key vol_up_key_matrix_T13 = { .row = 3, @@ -66,17 +96,20 @@ static void board_update_vol_up_key(void) * Set vol up key to T13 for KB_BL_TOGGLE_KEY_PRESENT * and board_version >= 2 */ - set_vol_up_key(vol_up_key_matrix_T13.row, vol_up_key_matrix_T13.col); + set_vol_up_key(vol_up_key_matrix_T13.row, + vol_up_key_matrix_T13.col); } else { /* * Set vol up key to T12 for KB_BL_TOGGLE_KEY_ABSENT * and board_version >= 2 */ - set_vol_up_key(vol_up_key_matrix_T12.row, vol_up_key_matrix_T12.col); + set_vol_up_key(vol_up_key_matrix_T12.row, + vol_up_key_matrix_T12.col); } } else { /* Set vol up key to T13 for board_version < 2 */ - set_vol_up_key(vol_up_key_matrix_T13.row, vol_up_key_matrix_T13.col); + set_vol_up_key(vol_up_key_matrix_T13.row, + vol_up_key_matrix_T13.col); } } @@ -105,27 +138,26 @@ static struct mutex g_base_mutex; static struct mutex g_lid_mutex; static struct icm_drv_data_t g_icm426xx_data; +static struct icm_drv_data_t g_icm42607_data; static struct bmi_drv_data_t g_bmi260_data; static struct kionix_accel_data g_kx022_data; /* Matrix to rotate accelrator into standard reference frame */ -static 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 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)} -}; +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) } }; -static const mat33_fp_t bmi260_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 icm42607_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 icm426xx_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[] = { /* @@ -136,44 +168,46 @@ struct motion_sensor_t motion_sensors[] = { [BASE_ACCEL] = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_ICM426XX, + .chip = MOTIONSENSE_CHIP_BMI260, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &icm426xx_drv, + .drv = &bmi260_drv, .mutex = &g_base_mutex, - .drv_data = &g_icm426xx_data, + .drv_data = &g_bmi260_data, .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, - .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs. */ + .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS, .rot_standard_ref = &base_standard_ref, - .min_frequency = ICM426XX_ACCEL_MIN_FREQ, - .max_frequency = ICM426XX_ACCEL_MAX_FREQ, + .min_frequency = BMI_ACCEL_MIN_FREQ, + .max_frequency = BMI_ACCEL_MAX_FREQ, + .default_range = 4, /* g */ .config = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 100 * MSEC, }, + /* Sensor on in S3 */ [SENSOR_CONFIG_EC_S3] = { .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, }, }, }, [BASE_GYRO] = { .name = "Base Gyro", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_ICM426XX, + .chip = MOTIONSENSE_CHIP_BMI260, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, - .drv = &icm426xx_drv, + .drv = &bmi260_drv, .mutex = &g_base_mutex, - .drv_data = &g_icm426xx_data, + .drv_data = &g_bmi260_data, .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, + .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS, .default_range = 1000, /* dps */ .rot_standard_ref = &base_standard_ref, - .min_frequency = ICM426XX_GYRO_MIN_FREQ, - .max_frequency = ICM426XX_GYRO_MAX_FREQ, + .min_frequency = BMI_GYRO_MIN_FREQ, + .max_frequency = BMI_GYRO_MAX_FREQ, }, [LID_ACCEL] = { .name = "Lid Accel", @@ -205,69 +239,117 @@ struct motion_sensor_t motion_sensors[] = { }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); -struct motion_sensor_t bmi260_base_accel = { +struct motion_sensor_t icm42607_base_accel = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_BMI260, + .chip = MOTIONSENSE_CHIP_ICM42607, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi260_drv, + .drv = &icm42607_drv, .mutex = &g_base_mutex, - .drv_data = &g_bmi260_data, + .drv_data = &g_icm42607_data, .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS, - .rot_standard_ref = &bmi260_standard_ref, - .min_frequency = BMI_ACCEL_MIN_FREQ, - .max_frequency = BMI_ACCEL_MAX_FREQ, - .default_range = 4, /* g */ + .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS, + .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs.*/ + .rot_standard_ref = &icm42607_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_rate = 100 * MSEC, }, - /* Sensor on in S3 */ + /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S3] = { .odr = 10000 | ROUND_UP_FLAG, + }, + }, +}; + +struct motion_sensor_t icm42607_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 = &icm42607_standard_ref, + .min_frequency = ICM42607_GYRO_MIN_FREQ, + .max_frequency = ICM42607_GYRO_MAX_FREQ, +}; + +struct motion_sensor_t icm426xx_base_accel = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM426XX, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm426xx_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm426xx_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, + .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs. */ + .rot_standard_ref = &icm426xx_standard_ref, + .min_frequency = ICM426XX_ACCEL_MIN_FREQ, + .max_frequency = ICM426XX_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 100 * MSEC, }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, }, }; -struct motion_sensor_t bmi260_base_gyro = { +struct motion_sensor_t icm426xx_base_gyro = { .name = "Base Gyro", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_BMI260, + .chip = MOTIONSENSE_CHIP_ICM426XX, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi260_drv, + .drv = &icm426xx_drv, .mutex = &g_base_mutex, - .drv_data = &g_bmi260_data, + .drv_data = &g_icm426xx_data, .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS, + .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, .default_range = 1000, /* dps */ - .rot_standard_ref = &bmi260_standard_ref, - .min_frequency = BMI_GYRO_MIN_FREQ, - .max_frequency = BMI_GYRO_MAX_FREQ, + .rot_standard_ref = &icm426xx_standard_ref, + .min_frequency = ICM426XX_GYRO_MIN_FREQ, + .max_frequency = ICM426XX_GYRO_MAX_FREQ, }; static void board_update_motion_sensor_config(void) { - if (board_version >= 2) { - motion_sensors[BASE_ACCEL] = bmi260_base_accel; - motion_sensors[BASE_GYRO] = bmi260_base_gyro; - ccprints("BASE Accelgyro is BMI260"); - } else { + if (board_version <= 1 || base_sensor == SSFC_SENSOR_ICM426XX) { + motion_sensors[BASE_ACCEL] = icm426xx_base_accel; + motion_sensors[BASE_GYRO] = icm426xx_base_gyro; ccprints("BASE Accelgyro is ICM426XX"); + } else if (base_sensor == SSFC_SENSOR_ICM42607) { + motion_sensors[BASE_ACCEL] = icm42607_base_accel; + motion_sensors[BASE_GYRO] = icm42607_base_gyro; + ccprints("BASE Accelgyro is ICM42607"); + } else { + ccprints("BASE Accelgyro is BMI260"); } } void motion_interrupt(enum gpio_signal signal) { - if (board_version >= 2) - bmi260_interrupt(signal); - else + if (board_version <= 1 || base_sensor == SSFC_SENSOR_ICM426XX) icm426xx_interrupt(signal); + else if (base_sensor == SSFC_SENSOR_ICM42607) + icm42607_interrupt(signal); + else + bmi260_interrupt(signal); } /* PWM */ @@ -299,7 +381,7 @@ const struct pwm_t pwm_channels[] = { }, [PWM_CH_KBLIGHT] = { .channel = 3, - .freq_hz = 10000, + .freq_hz = 2400, .pcfsr_sel = PWM_PRESCALER_C6, }, [PWM_CH_LED_C0_WHITE] = { @@ -319,8 +401,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /* USB Mux */ -static int board_ps8762_mux_set(const struct usb_mux *me, - mux_state_t mux_state) +static int board_ps8762_mux_set(const struct usb_mux *me, mux_state_t mux_state) { /* Make sure the PS8802 is awake */ RETURN_ERROR(ps8802_i2c_wake(me)); @@ -328,21 +409,18 @@ static int board_ps8762_mux_set(const struct usb_mux *me, /* USB specific config */ if (mux_state & USB_PD_MUX_USB_ENABLED) { /* Boost the USB gain */ - RETURN_ERROR(ps8802_i2c_field_update16(me, - PS8802_REG_PAGE2, - PS8802_REG2_USB_SSEQ_LEVEL, - PS8802_USBEQ_LEVEL_UP_MASK, - PS8802_USBEQ_LEVEL_UP_12DB)); + RETURN_ERROR(ps8802_i2c_field_update16( + me, PS8802_REG_PAGE2, PS8802_REG2_USB_SSEQ_LEVEL, + PS8802_USBEQ_LEVEL_UP_MASK, + PS8802_USBEQ_LEVEL_UP_12DB)); } /* DP specific config */ if (mux_state & USB_PD_MUX_DP_ENABLED) { /* Boost the DP gain */ - RETURN_ERROR(ps8802_i2c_field_update8(me, - PS8802_REG_PAGE2, - PS8802_REG2_DPEQ_LEVEL, - PS8802_DPEQ_LEVEL_UP_MASK, - PS8802_DPEQ_LEVEL_UP_9DB)); + RETURN_ERROR(ps8802_i2c_field_update8( + me, PS8802_REG_PAGE2, PS8802_REG2_DPEQ_LEVEL, + PS8802_DPEQ_LEVEL_UP_MASK, PS8802_DPEQ_LEVEL_UP_9DB)); } return EC_SUCCESS; @@ -350,11 +428,10 @@ static int board_ps8762_mux_set(const struct usb_mux *me, static int board_ps8762_mux_init(const struct usb_mux *me) { - return ps8802_i2c_field_update8( - me, PS8802_REG_PAGE1, - PS8802_REG_DCIRX, - PS8802_AUTO_DCI_MODE_DISABLE | PS8802_FORCE_DCI_MODE, - PS8802_AUTO_DCI_MODE_DISABLE); + return ps8802_i2c_field_update8(me, PS8802_REG_PAGE1, PS8802_REG_DCIRX, + PS8802_AUTO_DCI_MODE_DISABLE | + PS8802_FORCE_DCI_MODE, + PS8802_AUTO_DCI_MODE_DISABLE); } static int board_anx3443_mux_set(const struct usb_mux *me, @@ -365,24 +442,40 @@ static int board_anx3443_mux_set(const struct usb_mux *me, return EC_SUCCESS; } -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, - .i2c_port = I2C_PORT_USB_MUX0, - .i2c_addr_flags = PS8802_I2C_ADDR_FLAGS, - .driver = &ps8802_usb_mux_driver, - .board_init = &board_ps8762_mux_init, - .board_set = &board_ps8762_mux_set, + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .i2c_port = I2C_PORT_USB_MUX0, + .i2c_addr_flags = PS8802_I2C_ADDR_FLAGS, + .driver = &ps8802_usb_mux_driver, + .board_init = &board_ps8762_mux_init, + .board_set = &board_ps8762_mux_set, + }, }, { - .usb_port = 1, - .i2c_port = I2C_PORT_USB_MUX1, - .i2c_addr_flags = ANX3443_I2C_ADDR0_FLAGS, - .driver = &anx3443_usb_mux_driver, - .board_set = &board_anx3443_mux_set, + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .i2c_port = I2C_PORT_USB_MUX1, + .i2c_addr_flags = ANX3443_I2C_ADDR0_FLAGS, + .driver = &anx3443_usb_mux_driver, + .board_set = &board_anx3443_mux_set, + }, }, }; +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + /* Limit input current lower than 2944 mA for safety */ + charge_ma = MIN(charge_ma, 2944); + + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} + /* Initialize board. */ static void board_init(void) { @@ -393,21 +486,34 @@ static void board_init(void) /* Store board version for use of something */ cbi_get_board_version(&board_version); + /* Store base sensor to recognize which base sensor we are using */ + base_sensor = get_cbi_ssfc_base_sensor(); + board_update_motion_sensor_config(); board_update_vol_up_key(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); -static void board_do_chipset_resume(void) +static void enable_nvme(void) { gpio_set_level(GPIO_EN_PP3300_SSD, 1); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME_INIT, enable_nvme, HOOK_PRIO_FIRST); + +static void disable_nvme(void) +{ + gpio_set_level(GPIO_EN_PP3300_SSD, 0); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, disable_nvme, HOOK_PRIO_DEFAULT); + +static void board_do_chipset_resume(void) +{ gpio_set_level(GPIO_EN_KB_BL, 1); } DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_do_chipset_resume, HOOK_PRIO_DEFAULT); static void board_do_chipset_suspend(void) { - gpio_set_level(GPIO_EN_PP3300_SSD, 0); gpio_set_level(GPIO_EN_KB_BL, 0); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_do_chipset_suspend, HOOK_PRIO_DEFAULT); |