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>
This commit is contained in:
parent
7106989353
commit
1172759baa
|
@ -15,23 +15,15 @@
|
|||
|
||||
#define TEMP_OUT_OF_RANGE TEMP_ZONE_COUNT
|
||||
|
||||
#ifdef BOARD_KAKADU
|
||||
#define BATT_ID 1
|
||||
#else
|
||||
#define BATT_ID 0
|
||||
#endif
|
||||
|
||||
#define BATTERY_SIMPLO_CHARGE_MIN_TEMP 0
|
||||
#define BATTERY_SIMPLO_CHARGE_MAX_TEMP 60
|
||||
|
||||
#define BATTERY_ATL_CHARGE_MIN_TEMP -20
|
||||
#define BATTERY_ATL_CHARGE_MAX_TEMP 60
|
||||
|
||||
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
|
||||
|
||||
enum battery_type {
|
||||
BATTERY_SIMPLO = 0,
|
||||
BATTERY_ATL,
|
||||
BATTERY_COUNT
|
||||
};
|
||||
|
||||
|
@ -48,18 +40,6 @@ static const struct battery_info info[] = {
|
|||
.discharging_min_c = -20,
|
||||
.discharging_max_c = 60,
|
||||
},
|
||||
[BATTERY_ATL] = {
|
||||
.voltage_max = 4370,
|
||||
.voltage_normal = 3860,
|
||||
.voltage_min = 3150,
|
||||
.precharge_current = 256,
|
||||
.start_charging_min_c = 0,
|
||||
.start_charging_max_c = 45,
|
||||
.charging_min_c = 0,
|
||||
.charging_max_c = 60,
|
||||
.discharging_min_c = -20,
|
||||
.discharging_max_c = 60,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct max17055_batt_profile batt_profile[] = {
|
||||
|
@ -69,12 +49,6 @@ static const struct max17055_batt_profile batt_profile[] = {
|
|||
.ichg_term = MAX17055_ICHGTERM_REG(235),
|
||||
.v_empty_detect = MAX17055_VEMPTY_REG(3000, 3600),
|
||||
},
|
||||
[BATTERY_ATL] = {
|
||||
.is_ez_config = 1,
|
||||
.design_cap = MAX17055_DESIGNCAP_REG(7270),
|
||||
.ichg_term = MAX17055_ICHGTERM_REG(500),
|
||||
.v_empty_detect = MAX17055_VEMPTY_REG(3000, 3600),
|
||||
},
|
||||
};
|
||||
|
||||
static const struct max17055_alert_profile alert_profile[] = {
|
||||
|
@ -86,14 +60,6 @@ static const struct max17055_alert_profile alert_profile[] = {
|
|||
.s_alert_mxmn = SALRT_DISABLE,
|
||||
.i_alert_mxmn = IALRT_DISABLE,
|
||||
},
|
||||
[BATTERY_ATL] = {
|
||||
.v_alert_mxmn = VALRT_DISABLE,
|
||||
.t_alert_mxmn = MAX17055_TALRTTH_REG(
|
||||
BATTERY_ATL_CHARGE_MAX_TEMP,
|
||||
BATTERY_ATL_CHARGE_MIN_TEMP),
|
||||
.s_alert_mxmn = SALRT_DISABLE,
|
||||
.i_alert_mxmn = IALRT_DISABLE,
|
||||
},
|
||||
};
|
||||
|
||||
const struct max17055_batt_profile *max17055_get_batt_profile(void)
|
||||
|
@ -120,11 +86,6 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
|
|||
|
||||
int charger_profile_override(struct charge_state_data *curr)
|
||||
{
|
||||
#ifdef BOARD_KAKADU
|
||||
static timestamp_t deadline_48;
|
||||
static timestamp_t deadline_2;
|
||||
int cycle_count = 0, rv, val;
|
||||
#endif
|
||||
/* battery temp in 0.1 deg C */
|
||||
int bat_temp_c = curr->batt.temperature - 2731;
|
||||
|
||||
|
@ -160,16 +121,6 @@ int charger_profile_override(struct charge_state_data *curr)
|
|||
/* TEMP_ZONE_3 */
|
||||
{450, BATTERY_SIMPLO_CHARGE_MAX_TEMP * 10, 3350, 4300},
|
||||
},
|
||||
[BATTERY_ATL] = {
|
||||
/* TEMP_ZONE_0 */
|
||||
{BATTERY_ATL_CHARGE_MIN_TEMP * 10, 50, 719, 4370},
|
||||
/* TEMP_ZONE_1 */
|
||||
{50, 100, 2157, 4370},
|
||||
/* TEMP_ZONE_2 */
|
||||
{100, 450, 3595, 4370},
|
||||
/* TEMP_ZONE_3 */
|
||||
{450, BATTERY_ATL_CHARGE_MAX_TEMP * 10, 2516, 4100},
|
||||
},
|
||||
};
|
||||
BUILD_ASSERT(ARRAY_SIZE(temp_zones[BATT_ID]) == TEMP_ZONE_COUNT);
|
||||
BUILD_ASSERT(ARRAY_SIZE(temp_zones) == BATTERY_COUNT);
|
||||
|
@ -206,53 +157,6 @@ int charger_profile_override(struct charge_state_data *curr)
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef BOARD_KAKADU
|
||||
/* Check cycle count to decrease charging voltage. */
|
||||
rv = battery_cycle_count(&val);
|
||||
if (!rv)
|
||||
cycle_count = val;
|
||||
if (cycle_count > 300 && cycle_count <= 600)
|
||||
curr->requested_voltage = 4320;
|
||||
else if (cycle_count > 600 && cycle_count <= 1000)
|
||||
curr->requested_voltage = 4300;
|
||||
else if (cycle_count > 1000)
|
||||
curr->requested_voltage = 4250;
|
||||
/* Should not keep charging voltage > 4250mV for 48hrs. */
|
||||
if ((curr->state == ST_DISCHARGE) ||
|
||||
curr->chg.voltage < 4250) {
|
||||
deadline_48.val = 0;
|
||||
/* Starting count 48hours */
|
||||
} else if (curr->state == ST_CHARGE ||
|
||||
curr->state == ST_PRECHARGE) {
|
||||
if (deadline_48.val == 0)
|
||||
deadline_48.val = get_time().val +
|
||||
CHARGER_LIMIT_TIMEOUT_HOURS * HOUR;
|
||||
/* If charging voltage keep > 4250 for 48hrs,
|
||||
set charging voltage = 4250 */
|
||||
else if (timestamp_expired(deadline_48, NULL))
|
||||
curr->requested_voltage = 4250;
|
||||
}
|
||||
/* Should not keeep battery voltage > 4100mV and
|
||||
battery temperature > 45C for two hour */
|
||||
if (curr->state == ST_DISCHARGE ||
|
||||
curr->batt.voltage < 4100 ||
|
||||
bat_temp_c < 450) {
|
||||
deadline_2.val = 0;
|
||||
} else if (curr->state == ST_CHARGE ||
|
||||
curr->state == ST_PRECHARGE) {
|
||||
if (deadline_2.val == 0)
|
||||
deadline_2.val = get_time().val +
|
||||
CHARGER_LIMIT_TIMEOUT_HOURS_TEMP * HOUR;
|
||||
else if (timestamp_expired(deadline_2, NULL)) {
|
||||
/* Set discharge and charging voltage = 4100mV */
|
||||
if (curr->batt.voltage >= 4100) {
|
||||
curr->requested_current = 0;
|
||||
curr->requested_voltage = 4100;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VARIANT_KUKUI_CHARGER_MT6370
|
||||
mt6370_charger_profile_override(curr);
|
||||
#endif /* CONFIG_CHARGER_MT6370 */
|
||||
|
@ -276,7 +180,6 @@ int get_battery_manufacturer_name(char *dest, int size)
|
|||
{
|
||||
static const char * const name[] = {
|
||||
[BATTERY_SIMPLO] = "SIMPLO",
|
||||
[BATTERY_ATL] = "Celxpert",
|
||||
};
|
||||
ASSERT(dest);
|
||||
strzcpy(dest, name[BATT_ID], size);
|
||||
|
|
|
@ -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 */
|
||||
[SENSOR_CONFIG_EC_S0] = {
|
||||
.odr = 13000 | ROUND_UP_FLAG,
|
||||
.ec_rate = 100 * MSEC,
|
||||
},
|
||||
},
|
||||
.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_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,
|
||||
.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 = 1000,
|
||||
},
|
||||
},
|
||||
},
|
||||
[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 */
|
||||
|
||||
/*
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* Configuration for kakadu */
|
||||
/* Configuration for Kakadu */
|
||||
|
||||
#ifndef __CROS_EC_BOARD_H
|
||||
#define __CROS_EC_BOARD_H
|
||||
|
||||
#define VARIANT_KUKUI_BATTERY_MAX17055
|
||||
#define VARIANT_KUKUI_CHARGER_MT6370
|
||||
#define VARIANT_KUKUI_BATTERY_MM8013
|
||||
#define VARIANT_KUKUI_POGO_KEYBOARD
|
||||
|
||||
#define VARIANT_KUKUI_CHARGER_MT6370
|
||||
#define VARIANT_KUKUI_TABLET_PWRBTN
|
||||
|
||||
#ifndef SECTION_IS_RW
|
||||
|
@ -21,22 +22,28 @@
|
|||
|
||||
#define CONFIG_USB_MUX_IT5205
|
||||
#define CONFIG_VOLUME_BUTTONS
|
||||
#define CONFIG_USB_MUX_RUNTIME_CONFIG
|
||||
|
||||
/* Battery */
|
||||
#define BATTERY_DESIRED_CHARGING_CURRENT 3500 /* mA */
|
||||
|
||||
#define CONFIG_CHARGER_MT6370_BACKLIGHT
|
||||
#ifdef BOARD_KAKADU
|
||||
#define CHARGER_LIMIT_TIMEOUT_HOURS 48
|
||||
#define CHARGER_LIMIT_TIMEOUT_HOURS_TEMP 2
|
||||
#endif
|
||||
|
||||
|
||||
/* Motion Sensors */
|
||||
#ifdef SECTION_IS_RW
|
||||
#define CONFIG_ACCELGYRO_LSM6DSM
|
||||
#define CONFIG_ACCELGYRO_BMI160
|
||||
#define CONFIG_ACCEL_INTERRUPTS
|
||||
#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
|
||||
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
|
||||
TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
|
||||
#define CONFIG_ALS
|
||||
|
||||
#define ALS_COUNT 1
|
||||
#define CONFIG_ALS_TCS3400
|
||||
#define CONFIG_ALS_TCS3400_INT_EVENT \
|
||||
TASK_EVENT_MOTION_SENSOR_INTERRUPT(CLEAR_ALS)
|
||||
#define CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT
|
||||
#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(CLEAR_ALS)
|
||||
|
||||
/* Camera VSYNC */
|
||||
#define CONFIG_SYNC
|
||||
|
@ -95,6 +102,8 @@ enum power_signal {
|
|||
enum sensor_id {
|
||||
LID_ACCEL = 0,
|
||||
LID_GYRO,
|
||||
CLEAR_ALS,
|
||||
RGB_ALS,
|
||||
VSYNC,
|
||||
SENSOR_COUNT,
|
||||
};
|
||||
|
@ -117,6 +126,16 @@ int board_is_sourcing_vbus(int port);
|
|||
void pogo_adc_interrupt(enum gpio_signal signal);
|
||||
int board_discharge_on_ac(int enable);
|
||||
|
||||
/* Enable double tap detection */
|
||||
#define CONFIG_GESTURE_DETECTION
|
||||
#define CONFIG_GESTURE_HOST_DETECTION
|
||||
#define CONFIG_GESTURE_SENSOR_DOUBLE_TAP 0
|
||||
#define CONFIG_GESTURE_SENSOR_DOUBLE_TAP_FOR_HOST
|
||||
#define CONFIG_GESTURE_SAMPLING_INTERVAL_MS 5
|
||||
#define CONFIG_GESTURE_TAP_THRES_MG 100
|
||||
#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
|
||||
#define CONFIG_GESTURE_DETECTION_MASK \
|
||||
BIT(CONFIG_GESTURE_SENSOR_DOUBLE_TAP)
|
||||
|
||||
#endif /* !__ASSEMBLER__ */
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ GPIO_INT(AP_EC_WATCHDOG_L, PIN(C, 2), GPIO_INT_FALLING,
|
|||
chipset_watchdog_interrupt)
|
||||
|
||||
GPIO_INT_RW(ACCEL_INT_ODL, PIN(A, 4), GPIO_INT_FALLING | GPIO_SEL_1P8V | GPIO_PULL_UP,
|
||||
lsm6dsm_interrupt)
|
||||
bmi160_interrupt)
|
||||
GPIO_INT(CHARGER_INT_ODL, PIN(C, 13), GPIO_INT_FALLING | GPIO_PULL_UP,
|
||||
rt946x_interrupt)
|
||||
GPIO_INT_RO(EMMC_CMD, PIN(B, 15), GPIO_INT_FALLING,
|
||||
|
@ -48,8 +48,10 @@ GPIO_INT(POGO_ADC_INT_L, PIN(A, 6), GPIO_INT_BOTH,
|
|||
|
||||
/* unused */
|
||||
GPIO(POGO_VBUS_PRESENT, PIN(A, 14), GPIO_INPUT)
|
||||
/* To support Apple dongle b/155242849 */
|
||||
GPIO(USB_C0_VCONN_EN_OD, PIN(C, 14), GPIO_ODR_HIGH)
|
||||
/* unused after board rev 5 */
|
||||
GPIO(USB_C0_DP_POLARITY, PIN(C, 14), GPIO_INPUT)
|
||||
GPIO(USB_C0_DP_OE_L, PIN(A, 5), GPIO_INPUT)
|
||||
|
||||
|
||||
/* Reset pins */
|
||||
GPIO(AP_SYS_RST_L, PIN(C, 11), GPIO_OUT_LOW)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*
|
||||
* Battery LED control for kakadu board.
|
||||
* Battery LED control for Kakadu board.
|
||||
*/
|
||||
|
||||
#include "battery.h"
|
||||
|
@ -20,15 +20,17 @@ static enum charge_state prv_chstate = PWR_STATE_INIT;
|
|||
#define LED_OFF MT6370_LED_ID_OFF
|
||||
#define LED_RED MT6370_LED_ID1
|
||||
#define LED_GREEN MT6370_LED_ID2
|
||||
#define LED_BLUE MT6370_LED_ID3
|
||||
|
||||
#define LED_MASK_OFF 0
|
||||
#define LED_MASK_RED MT6370_MASK_RGB_ISNK1DIM_EN
|
||||
#define LED_MASK_GREEN MT6370_MASK_RGB_ISNK2DIM_EN
|
||||
#define LED_MASK_BLUE MT6370_MASK_RGB_ISNK3DIM_EN
|
||||
|
||||
static void kakadu_led_set_battery(void)
|
||||
{
|
||||
enum charge_state chstate;
|
||||
static uint8_t prv_r, prv_g;
|
||||
static uint8_t prv_r, prv_g, prv_b;
|
||||
uint8_t br[EC_LED_COLOR_COUNT] = { 0 };
|
||||
|
||||
chstate = charge_get_state();
|
||||
|
@ -41,19 +43,19 @@ static void kakadu_led_set_battery(void)
|
|||
|
||||
switch (chstate) {
|
||||
case PWR_STATE_CHARGE:
|
||||
br[EC_LED_COLOR_GREEN] = 255;
|
||||
br[EC_LED_COLOR_RED] = 255;
|
||||
/* RGB(current, duty) = (4mA,1/32)*/
|
||||
br[EC_LED_COLOR_BLUE] = 1;
|
||||
break;
|
||||
case PWR_STATE_DISCHARGE:
|
||||
/* real battery SoC 5%*/
|
||||
if (charge_get_percent() <= 5)
|
||||
br[EC_LED_COLOR_RED] = 255;
|
||||
/* display SoC 10% = real battery SoC 13%*/
|
||||
if (charge_get_percent() <= 13)
|
||||
br[EC_LED_COLOR_RED] = 1;
|
||||
break;
|
||||
case PWR_STATE_CHARGE_NEAR_FULL:
|
||||
br[EC_LED_COLOR_GREEN] = 255;
|
||||
br[EC_LED_COLOR_GREEN] = 1;
|
||||
break;
|
||||
case PWR_STATE_ERROR:
|
||||
br[EC_LED_COLOR_RED] = 255;
|
||||
br[EC_LED_COLOR_RED] = 1;
|
||||
break;
|
||||
default:
|
||||
/* Other states don't alter LED behavior */
|
||||
|
@ -61,11 +63,13 @@ static void kakadu_led_set_battery(void)
|
|||
}
|
||||
|
||||
if (prv_r == br[EC_LED_COLOR_RED] &&
|
||||
prv_g == br[EC_LED_COLOR_GREEN])
|
||||
prv_g == br[EC_LED_COLOR_GREEN] &&
|
||||
prv_b == br[EC_LED_COLOR_BLUE])
|
||||
return;
|
||||
|
||||
prv_r = br[EC_LED_COLOR_RED];
|
||||
prv_g = br[EC_LED_COLOR_GREEN];
|
||||
prv_b = br[EC_LED_COLOR_BLUE];
|
||||
led_set_brightness(EC_LED_ID_BATTERY_LED, br);
|
||||
}
|
||||
|
||||
|
@ -76,23 +80,27 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
|
|||
|
||||
brightness_range[EC_LED_COLOR_RED] = MT6370_LED_BRIGHTNESS_MAX;
|
||||
brightness_range[EC_LED_COLOR_GREEN] = MT6370_LED_BRIGHTNESS_MAX;
|
||||
brightness_range[EC_LED_COLOR_BLUE] = MT6370_LED_BRIGHTNESS_MAX;
|
||||
}
|
||||
|
||||
int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
|
||||
{
|
||||
uint8_t red, green;
|
||||
uint8_t red, green, blue;
|
||||
|
||||
if (led_id != EC_LED_ID_BATTERY_LED)
|
||||
return EC_ERROR_INVAL;
|
||||
|
||||
red = brightness[EC_LED_COLOR_RED];
|
||||
green = brightness[EC_LED_COLOR_GREEN];
|
||||
blue = brightness[EC_LED_COLOR_BLUE];
|
||||
|
||||
mt6370_led_set_brightness(LED_RED, red);
|
||||
mt6370_led_set_brightness(LED_GREEN, green);
|
||||
mt6370_led_set_brightness(LED_BLUE, blue);
|
||||
|
||||
/* Enables LED sink power if necessary. */
|
||||
mt6370_led_set_color((red ? LED_MASK_RED : 0) |
|
||||
(blue ? LED_MASK_BLUE : 0) |
|
||||
(green ? LED_MASK_GREEN : 0));
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
@ -110,14 +118,16 @@ static void kakadu_led_init(void)
|
|||
{
|
||||
const enum mt6370_led_dim_mode dim = MT6370_LED_DIM_MODE_PWM;
|
||||
const enum mt6370_led_pwm_freq freq = MT6370_LED_PWM_FREQ1000;
|
||||
|
||||
mt6370_led_set_color(0);
|
||||
mt6370_led_set_dim_mode(LED_RED, dim);
|
||||
mt6370_led_set_dim_mode(LED_GREEN, dim);
|
||||
mt6370_led_set_dim_mode(LED_BLUE, dim);
|
||||
mt6370_led_set_pwm_frequency(LED_RED, freq);
|
||||
mt6370_led_set_pwm_frequency(LED_GREEN, freq);
|
||||
mt6370_led_set_pwm_dim_duty(LED_RED, 12);
|
||||
mt6370_led_set_pwm_dim_duty(LED_GREEN, 31);
|
||||
mt6370_led_set_pwm_frequency(LED_BLUE, freq);
|
||||
mt6370_led_set_pwm_dim_duty(LED_RED, 0);
|
||||
mt6370_led_set_pwm_dim_duty(LED_GREEN, 0);
|
||||
mt6370_led_set_pwm_dim_duty(LED_BLUE, 0);
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, kakadu_led_init, HOOK_PRIO_DEFAULT);
|
||||
|
||||
|
|
|
@ -109,9 +109,6 @@ static const struct power_seq_op s3s5_power_seq[] = {
|
|||
{ GPIO_AP_SYS_RST_L, 0, 0 },
|
||||
/* Assert watchdog to PMIC (there may be a 1.6ms debounce) */
|
||||
{ GPIO_PMIC_WATCHDOG_L, 0, 3 },
|
||||
#ifdef BOARD_KAKADU
|
||||
{ GPIO_USB_C0_VCONN_EN_OD, 0, 0 },
|
||||
#endif
|
||||
};
|
||||
|
||||
static int forcing_shutdown;
|
||||
|
|
Loading…
Reference in New Issue