diff options
author | wen zhang <zhangwen6@huaqin.corp-partner.google.com> | 2020-10-27 17:17:07 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-02 11:24:50 +0000 |
commit | 1172759baa40708ed96de90bc2d541cba1ef3438 (patch) | |
tree | 70cd36a5b3879d5f62d9c6fe75a73e6b35d55c65 /board/kakadu/board.c | |
parent | 71069893536962157b3b25330851a1c2c7cd6da5 (diff) | |
download | chrome-ec-1172759baa40708ed96de90bc2d541cba1ef3438.tar.gz |
Kukui: initial a new models kakadu of ec.
Copy from krane, which is a model from Kukui.
Modified for building pass.
It will need to be revised later.
BUG=b:171763111
BRANCH=master
TEST=make -j BOARD=kakadu
Change-Id: I87fcf8c8e3bd4fa669e0bcb7fbb9d125a9926cdb
Signed-off-by: wen zhang <zhangwen6@huaqin.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2501801
Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org>
Diffstat (limited to 'board/kakadu/board.c')
-rw-r--r-- | board/kakadu/board.c | 226 |
1 files changed, 150 insertions, 76 deletions
diff --git a/board/kakadu/board.c b/board/kakadu/board.c index 47cf5ee3be..2f541cca1e 100644 --- a/board/kakadu/board.c +++ b/board/kakadu/board.c @@ -14,7 +14,8 @@ #include "chipset.h" #include "common.h" #include "console.h" -#include "driver/accelgyro_lsm6dsm.h" +#include "driver/accelgyro_bmi_common.h" +#include "driver/als_tcs3400.h" #include "driver/charger/rt946x.h" #include "driver/sync.h" #include "driver/tcpm/mt6370.h" @@ -75,6 +76,7 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); + /* power signal list. Must match order of enum power_signal. */ const struct power_signal_info power_signal_list[] = { {GPIO_AP_IN_SLEEP_L, POWER_SIGNAL_ACTIVE_LOW, "AP_IN_S3_L"}, @@ -101,7 +103,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { }; struct mt6370_thermal_bound thermal_bound = { - .target = 90, + .target = 80, .err = 4, }; @@ -118,7 +120,7 @@ static void board_hpd_update(const struct usb_mux *me, __override const struct rt946x_init_setting *board_rt946x_init_setting(void) { static const struct rt946x_init_setting battery_init_setting = { - .eoc_current = 500, + .eoc_current = 140, .mivr = 4000, .ircmp_vclamp = 32, .ircmp_res = 25, @@ -129,7 +131,7 @@ __override const struct rt946x_init_setting *board_rt946x_init_setting(void) return &battery_init_setting; } -const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .usb_port = 0, .i2c_port = I2C_PORT_USB_MUX, @@ -241,20 +243,8 @@ int pd_snk_is_vbus_provided(int port) return rt946x_is_vbus_ready(); } - -#define CHARGER_I2C_ADDR_FLAGS RT946X_ADDR_FLAGS - static void board_init(void) { - -#ifdef SECTION_IS_RW - int val; - i2c_read8(I2C_PORT_CHARGER, CHARGER_I2C_ADDR_FLAGS, - RT946X_REG_CHGCTRL1, &val); - val &= RT946X_MASK_OPA_MODE; - i2c_write8(I2C_PORT_CHARGER, CHARGER_I2C_ADDR_FLAGS, - RT946X_REG_CHGCTRL1, (val | RT946X_MASK_STAT_EN)); -#endif /* If the reset cause is external, pulse PMIC force reset. */ if (system_get_reset_flags() == EC_RESET_FLAG_RESET_PIN) { gpio_set_level(GPIO_PMIC_FORCE_RESET_ODL, 0); @@ -269,7 +259,7 @@ static void board_init(void) gpio_enable_interrupt(GPIO_CHARGER_INT_ODL); #ifdef SECTION_IS_RW - /* Enable interrupts from LSM6DS3TR sensor. */ + /* Enable interrupts from BMI160 sensor. */ gpio_enable_interrupt(GPIO_ACCEL_INT_ODL); /* Enable interrupt for the camera vsync. */ @@ -300,18 +290,9 @@ static void board_rev_init(void) * Keep this pin defaults to P1 setting since that eMMC enabled with * High-Z stat. */ - /* TODO */ /* Put initial code here for different EC board reversion */ - - /* Display bias settings. */ - mt6370_db_set_voltages(6000, 5800, 5800); - - /* - * Enable MT6370 DB_POSVOUT/DB_NEGVOUT (controlled by _EN pins). - */ - mt6370_db_external_control(1); - + return; } DECLARE_HOOK(HOOK_INIT, board_rev_init, HOOK_PRIO_INIT_ADC + 1); @@ -325,12 +306,66 @@ void sensor_board_proc_double_tap(void) #ifndef VARIANT_KUKUI_NO_SENSORS static struct mutex g_lid_mutex; -static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; +static struct bmi_drv_data_t g_bmi160_data; + +/* TCS3400 private data */ +static struct als_drv_data_t g_tcs3400_data = { + .als_cal.scale = 1, + .als_cal.uscale = 0, + .als_cal.offset = 0, + .als_cal.channel_scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kc */ + .cover_scale = ALS_CHANNEL_SCALE(1.0), /* CT */ + }, +}; + +static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = { + /* + * TODO(b:139366662): calculates the actual coefficients and scaling + * factors + */ + .calibration.rgb_cal[X] = { + .offset = 0, + .scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kr */ + .cover_scale = ALS_CHANNEL_SCALE(1.0) + }, + .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(0), + }, + .calibration.rgb_cal[Y] = { + .offset = 0, + .scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kg */ + .cover_scale = ALS_CHANNEL_SCALE(1.0) + }, + .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(0.1), + }, + .calibration.rgb_cal[Z] = { + .offset = 0, + .scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kb */ + .cover_scale = ALS_CHANNEL_SCALE(1.0) + }, + .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(0), + }, + .calibration.irt = INT_TO_FP(1), + .saturation.again = TCS_DEFAULT_AGAIN, + .saturation.atime = TCS_DEFAULT_ATIME, +}; /* Matrix to rotate accelerometer into standard reference frame */ static const mat33_fp_t lid_standard_ref = { - {0, FLOAT_TO_FP(1), 0}, {FLOAT_TO_FP(-1), 0, 0}, + {0, FLOAT_TO_FP(-1), 0}, {0, 0, FLOAT_TO_FP(1)} }; @@ -341,61 +376,100 @@ struct motion_sensor_t motion_sensors[] = { * DO NOT change the order of the following table. */ [LID_ACCEL] = { - .name = "Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &lsm6dsm_drv, - .mutex = &g_lid_mutex, - .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, - MOTIONSENSE_TYPE_ACCEL), - .int_signal = GPIO_ACCEL_INT_ODL, - .flags = MOTIONSENSE_FLAG_INT_SIGNAL, - .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, - .rot_standard_ref = &lid_standard_ref, - .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - /* Enable accel in S0 */ + .name = "Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &bmi160_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, + .rot_standard_ref = &lid_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 = { + /* Enable accel in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = TAP_ODR, + .ec_rate = 100 * MSEC, + }, + /* For double tap detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = TAP_ODR, + .ec_rate = 100 * MSEC, + }, + }, + }, + [LID_GYRO] = { + .name = "Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_LID, + .drv = &bmi160_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &lid_standard_ref, + .min_frequency = BMI_GYRO_MIN_FREQ, + .max_frequency = BMI_GYRO_MAX_FREQ, + }, + [CLEAR_ALS] = { + .name = "Clear Light", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_TCS3400, + .type = MOTIONSENSE_TYPE_LIGHT, + .location = MOTIONSENSE_LOC_LID, + .drv = &tcs3400_drv, + .drv_data = &g_tcs3400_data, + .port = I2C_PORT_ALS, + .i2c_spi_addr_flags = TCS3400_I2C_ADDR_FLAGS, + .rot_standard_ref = NULL, + .default_range = 0x10000, /* scale = 1x, uscale = 0 */ + .min_frequency = TCS3400_LIGHT_MIN_FREQ, + .max_frequency = TCS3400_LIGHT_MAX_FREQ, + .config = { + /* Run ALS sensor in S0 */ [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, + .odr = 1000, }, + }, }, - [LID_GYRO] = { - .name = "Gyro", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_LID, - .drv = &lsm6dsm_drv, - .mutex = &g_lid_mutex, - .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, - MOTIONSENSE_TYPE_GYRO), - .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = &lid_standard_ref, - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, + [RGB_ALS] = { + .name = "RGB Light", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_TCS3400, + .type = MOTIONSENSE_TYPE_LIGHT_RGB, + .location = MOTIONSENSE_LOC_LID, + .drv = &tcs3400_rgb_drv, + .drv_data = &g_tcs3400_rgb_data, + /*.port = I2C_PORT_ALS,*/ /* Unused. RGB channels read by CLEAR_ALS. */ + .rot_standard_ref = NULL, + .default_range = 0x10000, /* scale = 1x, uscale = 0 */ + .min_frequency = 0, /* 0 indicates we should not use sensor directly */ + .max_frequency = 0, /* 0 indicates we should not use sensor directly */ }, [VSYNC] = { - .name = "Camera vsync", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_GPIO, - .type = MOTIONSENSE_TYPE_SYNC, - .location = MOTIONSENSE_LOC_CAMERA, - .drv = &sync_drv, - .default_range = 0, - .min_frequency = 0, - .max_frequency = 1, + .name = "Camera vsync", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_GPIO, + .type = MOTIONSENSE_TYPE_SYNC, + .location = MOTIONSENSE_LOC_CAMERA, + .drv = &sync_drv, + .default_range = 0, + .min_frequency = 0, + .max_frequency = 1, }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +const struct motion_sensor_t *motion_als_sensors[] = { + &motion_sensors[CLEAR_ALS], +}; #endif /* VARIANT_KUKUI_NO_SENSORS */ /* |