summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-06-25 12:44:16 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-23 00:12:30 +0000
commitee8d481a027b78796ce30a48224e043fdf5f7491 (patch)
treebe23edd0a16a6548302c45da04740ba19809a40e /board
parent220205c8480433cb72f7c738ba141d5afa6d1968 (diff)
downloadchrome-ec-ee8d481a027b78796ce30a48224e043fdf5f7491.tar.gz
Use 7bit I2C/SPI slave addresses in EC
Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1767525 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/ampton/board.c57
-rw-r--r--board/arcada_ish/board.c203
-rw-r--r--board/atlas/board.c213
-rw-r--r--board/atlas/board.h8
-rw-r--r--board/bloog/board.c329
-rw-r--r--board/bobba/board.c6
-rw-r--r--board/casta/board.c154
-rw-r--r--board/chell/board.c25
-rw-r--r--board/cheza/board.c39
-rw-r--r--board/cheza/board.h36
-rw-r--r--board/coral/board.c20
-rw-r--r--board/elm/board.c15
-rw-r--r--board/elm/board.h4
-rw-r--r--board/eve/board.c98
-rw-r--r--board/eve/board.h22
-rw-r--r--board/fizz/board.c8
-rw-r--r--board/fizz/board.h4
-rw-r--r--board/flapjack/battery.c468
-rw-r--r--board/flapjack/board.c20
-rw-r--r--board/flapjack/board.h331
-rw-r--r--board/fleex/board.c129
-rw-r--r--board/fluffy/board.c405
-rw-r--r--board/garg/board.c337
-rw-r--r--board/glados/battery.c8
-rw-r--r--board/glados/board.c18
-rw-r--r--board/glados/board.h2
-rw-r--r--board/glados_pd/board.h2
-rw-r--r--board/glkrvp/battery.c6
-rw-r--r--board/glkrvp/board.c16
-rw-r--r--board/glkrvp/chg_usb_pd.c8
-rw-r--r--board/glkrvp_ite/battery.c4
-rw-r--r--board/glkrvp_ite/board.c41
-rw-r--r--board/glkrvp_ite/board.h2
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c8
-rw-r--r--board/hammer/board.h2
-rw-r--r--board/hatch/board.c82
-rw-r--r--board/helios/board.c49
-rw-r--r--board/helios/board.h146
-rw-r--r--board/host/battery.c7
-rw-r--r--board/kindred/board.c445
-rw-r--r--board/kindred/board.h176
-rw-r--r--board/kohaku/board.c99
-rw-r--r--board/kukui/board.c382
-rw-r--r--board/kukui/board.h4
-rw-r--r--board/mchpevb1/battery.c8
-rw-r--r--board/mchpevb1/board.c34
-rw-r--r--board/mchpevb1/board.h2
-rw-r--r--board/meep/board.c6
-rw-r--r--board/nami/board.c22
-rw-r--r--board/nami/board.h4
-rw-r--r--board/nautilus/board.c96
-rw-r--r--board/nautilus/board.h4
-rw-r--r--board/nocturne/board.c132
-rw-r--r--board/nocturne/board.h29
-rw-r--r--board/nucleo-f411re/board.c4
-rw-r--r--board/oak/battery.c8
-rw-r--r--board/oak/board.c16
-rw-r--r--board/oak/board.h2
-rw-r--r--board/pdeval-stm32f072/board.c4
-rw-r--r--board/pdeval-stm32f072/usb_pd_policy.c2
-rw-r--r--board/phaser/board.c168
-rw-r--r--board/plankton/board.c30
-rw-r--r--board/poppy/board.c125
-rw-r--r--board/poppy/board.h8
-rw-r--r--board/rainier/board.c15
-rw-r--r--board/rammus/board.c147
-rw-r--r--board/rammus/board.h6
-rw-r--r--board/reef/board.c73
-rw-r--r--board/reef/board.h2
-rw-r--r--board/reef_it8320/board.c4
-rw-r--r--board/reef_mchp/board.c97
-rw-r--r--board/reef_mchp/board.h2
-rw-r--r--board/samus/battery.c8
-rw-r--r--board/samus/board.c56
-rw-r--r--board/samus/extpower.c4
-rw-r--r--board/samus/panel.c10
-rw-r--r--board/samus_pd/board.h2
-rw-r--r--board/scarlet/board.c6
-rw-r--r--board/scarlet/board.h2
-rw-r--r--board/servo_micro/board.c17
-rw-r--r--board/servo_v4/board.c18
-rw-r--r--board/strago/board.c8
-rw-r--r--board/sweetberry/board.c2
-rw-r--r--board/yorp/board.c68
84 files changed, 4476 insertions, 1213 deletions
diff --git a/board/ampton/board.c b/board/ampton/board.c
index 941aab7f00..15b3af652a 100644
--- a/board/ampton/board.c
+++ b/board/ampton/board.c
@@ -17,7 +17,7 @@
#include "driver/sync.h"
#include "driver/tcpm/it83xx_pd.h"
#include "driver/tcpm/ps8xxx.h"
-#include "driver/usb_mux_it5205.h"
+#include "driver/usb_mux/it5205.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -66,25 +66,41 @@ int ppc_get_alert_status(int port)
#define USB_PD_PORT_ITE_0 0
#define USB_PD_PORT_ITE_1 1
+static int tune_mux(int port);
+
struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
/* Use PS8751 as mux only */
.port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC0, PS8751_I2C_ADDR1),
+ I2C_PORT_USBC0, PS8751_I2C_ADDR1__7bf),
.flags = USB_MUX_FLAG_NOT_TCPC,
- .driver = &tcpci_tcpm_usb_mux_driver,
+ .driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .board_init = &tune_mux,
},
[USB_PD_PORT_ITE_1] = {
/* Use PS8751 as mux only */
.port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC1, PS8751_I2C_ADDR1),
+ I2C_PORT_USBC1, PS8751_I2C_ADDR1__7bf),
.flags = USB_MUX_FLAG_NOT_TCPC,
- .driver = &tcpci_tcpm_usb_mux_driver,
+ .driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .board_init = &tune_mux,
}
};
+/* Some external monitors can't display content normally (eg. ViewSonic VX2880).
+ * We need to turn the mux for monitors to function normally.
+ */
+static int tune_mux(int port)
+{
+ /* Auto EQ disabled, compensate for channel lost up to 3.6dB */
+ mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ /* DP output swing adjustment +15% */
+ mux_write(port, PS8XXX_REG_MUX_DP_OUTPUT_CONFIGURATION, 0xc0);
+
+ return EC_SUCCESS;
+}
/******************************************************************************/
/* ADC channels */
const struct adc_t adc_channels[] = {
@@ -115,13 +131,6 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-static int read_charger_temp(int idx, int *temp_ptr)
-{
- if (!gpio_get_level(GPIO_AC_PRESENT))
- return EC_ERROR_NOT_POWERED;
- return get_temp_3v3_13k7_47k_4050b(idx, temp_ptr);
-}
-
const struct temp_sensor_t temp_sensors[] = {
[TEMP_SENSOR_BATTERY] = {.name = "Battery",
.type = TEMP_SENSOR_TYPE_BATTERY,
@@ -134,7 +143,7 @@ const struct temp_sensor_t temp_sensors[] = {
.action_delay_sec = 5},
[TEMP_SENSOR_CHARGER] = {.name = "Charger",
.type = TEMP_SENSOR_TYPE_BOARD,
- .read = read_charger_temp,
+ .read = get_temp_3v3_13k7_47k_4050b,
.idx = ADC_TEMP_SENSOR_CHARGER,
.action_delay_sec = 1},
};
@@ -151,6 +160,18 @@ const mat33_fp_t lid_standard_ref = {
{ 0, 0, FLOAT_TO_FP(1)}
};
+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)}
+};
+
+const mat33_fp_t gyro_standard_ref = {
+ { 0, FLOAT_TO_FP(-1), 0},
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, 0, FLOAT_TO_FP(1)}
+};
+
/* sensor private data */
static struct kionix_accel_data g_kx022_data;
static struct bmi160_drv_data_t g_bmi160_data;
@@ -167,7 +188,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.config = {
@@ -191,8 +212,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
- .rot_standard_ref = NULL, /* Identity matrix. */
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -219,9 +240,9 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
- .rot_standard_ref = NULL, /* Identity matrix. */
+ .rot_standard_ref = &gyro_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
diff --git a/board/arcada_ish/board.c b/board/arcada_ish/board.c
new file mode 100644
index 0000000000..f18a530568
--- /dev/null
+++ b/board/arcada_ish/board.c
@@ -0,0 +1,203 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Arcada ISH board-specific configuration */
+
+#include "console.h"
+#include "driver/accel_lis2dh.h"
+#include "driver/accelgyro_lsm6dsm.h"
+#include "driver/mag_lis2mdl.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "i2c.h"
+#include "lid_switch.h"
+#include "motion_sense.h"
+#include "power.h"
+#include "tablet_mode.h"
+#include "task.h"
+
+#include "gpio_list.h" /* has to be included last */
+
+/* I2C port map */
+const struct i2c_port_t i2c_ports[] = {
+ {
+ .name = "sensor",
+ .port = I2C_PORT_SENSOR,
+ .kbps = 400,
+ },
+};
+const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+/* Sensor config */
+static struct mutex g_lid_mutex;
+static struct mutex g_lid_mag_mutex;
+static struct mutex g_base_mutex;
+
+/* sensor private data */
+static struct lsm6dsm_data lsm6dsm_a_data;
+static struct stprivate_data g_lis2dh_data;
+static struct lis2mdl_private_data lis2mdl_a_data;
+
+/* Matrix to rotate lid sensor into standard reference frame */
+const mat33_fp_t lid_rot_ref = {
+ { FLOAT_TO_FP(-1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
+};
+
+/* Drivers */
+struct motion_sensor_t motion_sensors[] = {
+ [LID_ACCEL] = {
+ .name = "Lid Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_LSM6DS3,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &lsm6dsm_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_a_data,
+ MOTIONSENSE_TYPE_ACCEL),
+ .int_signal = GPIO_ACCEL_GYRO_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR1__7bf,
+ .rot_standard_ref = &lid_rot_ref,
+ .default_range = 4, /* g */
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 13000 | ROUND_UP_FLAG,
+ },
+ /* Sensor on for lid angle detection */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 13000 | ROUND_UP_FLAG,
+ },
+ },
+ },
+
+ [LID_GYRO] = {
+ .name = "Lid Gyro",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_LSM6DS3,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &lsm6dsm_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_a_data,
+ MOTIONSENSE_TYPE_GYRO),
+ .int_signal = GPIO_ACCEL_GYRO_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR1__7bf,
+ .default_range = 1000 | ROUND_UP_FLAG, /* dps */
+ .rot_standard_ref = &lid_rot_ref,
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ },
+
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_LNG2DM,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &lis2dh_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = &g_lis2dh_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LNG2DM_ADDR0__7bf,
+ .rot_standard_ref = NULL, /* Identity matrix */
+ /* We only use 2g because its resolution is only 8-bits */
+ .default_range = 2, /* g */
+ .min_frequency = LIS2DH_ODR_MIN_VAL,
+ .max_frequency = LIS2DH_ODR_MAX_VAL,
+ .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,
+ },
+ },
+ },
+
+ [LID_MAG] = {
+ .name = "Lid Mag",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_LIS2MDL,
+ .type = MOTIONSENSE_TYPE_MAG,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &lis2mdl_drv,
+ .mutex = &g_lid_mag_mutex,
+ .drv_data = LIS2MDL_ST_DATA(lis2mdl_a_data),
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LIS2MDL_ADDR__7bf,
+ .default_range = 1 << 11, /* 16LSB / uT, fixed */
+ .rot_standard_ref = &lid_rot_ref,
+ .min_frequency = LIS2MDL_ODR_MIN_VAL,
+ .max_frequency = LIS2MDL_ODR_MAX_VAL,
+ },
+};
+
+const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+int board_sensor_at_360(void)
+{
+ /*
+ * The 360 degree sensor is too sensitive and is active when the lid is
+ * closed at 0 degrees. Ignore the hall sensor when the lid close is
+ * also active.
+ */
+ return lid_is_open() &&
+ !gpio_get_level(HALL_SENSOR_GPIO_L);
+}
+
+/* Initialize board. */
+static void board_init(void)
+{
+ /* Enable interrupt for LSM6DS3 sensor */
+ gpio_enable_interrupt(GPIO_ACCEL_GYRO_INT_L);
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+/*
+ * The only use for chipset state is sensors, so we hard code the AP state to on
+ * and make the sensor on in S0. The sensors are always on when the ISH is
+ * powered.
+ */
+int chipset_in_state(int state_mask)
+{
+ return state_mask & CHIPSET_STATE_ON;
+}
+
+int chipset_in_or_transitioning_to_state(int state_mask)
+{
+ return chipset_in_state(state_mask);
+}
+
+void chipset_force_shutdown(enum chipset_shutdown_reason reason)
+{
+ /* Required, but nothing to do */
+}
+
+/* Needed for empty chipset task */
+int board_idle_task(void *unused)
+{
+ while (1)
+ task_wait_event(-1);
+}
+
+static void board_tablet_mode_change(void)
+{
+ /* Update GPIO to EC letting it know that we entered tablet mode */
+ gpio_set_level(GPIO_NB_MODE_L, tablet_get_mode());
+}
+DECLARE_HOOK(HOOK_TABLET_MODE_CHANGE, board_tablet_mode_change,
+ HOOK_PRIO_DEFAULT);
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 85b2e0bb93..3d6e52ed89 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -51,34 +51,24 @@
static void tcpc_alert_event(enum gpio_signal signal)
{
- if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C0_PD_RST_L))
- return;
- else if ((signal == GPIO_USB_C1_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_L))
+ int port = -1;
+
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
return;
+ }
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ schedule_deferred_pd_interrupt(port);
}
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
- {GPIO_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
- {VW_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {VW_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
- {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"},
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"},
- {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* Keyboard scan. Increase output_settle_us to 80us from default 50us. */
struct keyboard_scan_config keyscan_config = {
.output_settle_us = 80,
@@ -151,16 +141,14 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
const struct i2c_port_t i2c_ports[] = {
{"power", I2C_PORT_POWER, 100,
GPIO_EC_I2C0_POWER_SCL, GPIO_EC_I2C0_POWER_SDA},
- {"tcpc0", I2C_PORT_TCPC0, 400,
+ {"tcpc0", I2C_PORT_TCPC0, 1000,
GPIO_EC_I2C1_USB_C0_SCL, GPIO_EC_I2C1_USB_C0_SDA},
- {"tcpc1", I2C_PORT_TCPC1, 400,
+ {"tcpc1", I2C_PORT_TCPC1, 1000,
GPIO_EC_I2C2_USB_C1_SCL, GPIO_EC_I2C2_USB_C1_SDA},
{"sensor", I2C_PORT_SENSOR, 100,
GPIO_EC_I2C3_SENSOR_3V3_SCL, GPIO_EC_I2C3_SENSOR_3V3_SDA},
{"battery", I2C_PORT_BATTERY, 100,
GPIO_EC_I2C4_BATTERY_SCL, GPIO_EC_I2C4_BATTERY_SDA},
- {"gyro", I2C_PORT_GYRO, 100,
- GPIO_EC_I2C5_GYRO_SCL, GPIO_EC_I2C5_GYRO_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -171,7 +159,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = I2C_ADDR_TCPC,
+ .addr__7bf = I2C_ADDR_TCPC__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -182,7 +170,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = I2C_ADDR_TCPC,
+ .addr__7bf = I2C_ADDR_TCPC__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -259,7 +247,6 @@ const struct temp_sensor_t temp_sensors[] = {
BD99992GW_ADC_CHANNEL_SYSTHERM2, 4},
{"eMMC", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
BD99992GW_ADC_CHANNEL_SYSTHERM3, 4},
- {"gyro", TEMP_SENSOR_TYPE_BOARD, bmi160_get_sensor_temp, BASE_GYRO, 1},
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
@@ -275,29 +262,34 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
- != EC_SUCCESS)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_RESETIRQ1, &vrfault) != EC_SUCCESS)
return;
- if (!(vrfault & (1 << 4)))
+ if (!(vrfault & BIT(4)))
return;
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_PWRSTAT1, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_PWRSTAT2, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, (1 << 4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_RESETIRQ1, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_PWRSTAT1, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_PWRSTAT2, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -312,11 +304,12 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
/*
* VCCIOCNT:
* Bit 6 (0) - Disable decay of VCCIO on SLP_S0# assertion
- * Bits 5:4 (00) - Nominal output voltage: 0.850V
+ * Bits 5:4 (11) - Nominal output voltage: 0.850V
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_VCCIOCNT, 0x3a);
/*
* V18ACNT:
@@ -325,25 +318,18 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
-
- /*
- * V100ACNT:
- * Bits 7:6 (00) - Disable low power mode on SLP_S0# assertion
- * Bits 5:4 (01) - Nominal voltage 1.0V
- * Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
- * Bits 1:0 (10) - VR set to AUTO operating mode
- */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_V18ACNT, 0x2a);
/*
* V085ACNT:
* Bits 7:6 (00) - Disable low power mode on SLP_S0# assertion
- * Bits 5:4 (11) - Nominal voltage 0.85V
+ * Bits 5:4 (10) - Nominal voltage 0.85V
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_V085ACNT, 0x2a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -351,11 +337,12 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
/*
* VCCIOCNT:
* Bit 6 (1) - Enable decay of VCCIO on SLP_S0# assertion
- * Bits 5:4 (00) - Nominal output voltage: 0.850V
+ * Bits 5:4 (11) - Nominal output voltage: 0.850V
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_VCCIOCNT, 0x7a);
/*
* V18ACNT:
@@ -364,25 +351,18 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
-
- /*
- * V100ACNT:
- * Bits 7:6 (01) - Enable low power mode on SLP_S0# assertion
- * Bits 5:4 (01) - Nominal voltage 1.0V
- * Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
- * Bits 1:0 (10) - VR set to AUTO operating mode
- */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_V18ACNT, 0x6a);
/*
* V085ACNT:
* Bits 7:6 (01) - Enable low power mode on SLP_S0# assertion
- * Bits 5:4 (11) - Nominal voltage 0.85V
+ * Bits 5:4 (10) - Nominal voltage 0.85V
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_V085ACNT, 0x6a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -398,34 +378,49 @@ static void board_pmic_init(void)
board_report_pmic_fault("SYSJUMP");
/* Clear power source events */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PWRSRCINT, 0xff);
/* Disable power button shutdown timer */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_PBCONFIG, 0x00);
if (system_jumped_to_this_image())
return;
- /* DISCHGCNT2 - enable 100 ohm discharge on V5.0A, V3.3A and V1.8A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
- BD99992GW_REG_DISCHGCNT2, 0x45);
+ /* DISCHGCNT1 - enable 100 ohm discharge on VCCIO */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_DISCHGCNT1, 0x01);
- /* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
- BD99992GW_REG_DISCHGCNT3, 0x04);
+ /*
+ * DISCHGCNT2 - enable 100 ohm discharge on
+ * V5.0A, V3.3DSW, V3.3A and V1.8A
+ */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_DISCHGCNT2, 0x55);
/*
- * Set V085ACNT / V0.85A Control Register:
- * Nominal output = 0.85V.
+ * DISCHGCNT3 - enable 500 ohm discharge on
+ * V1.8U_2.5U
+ * DISCHGCNT3 - enable 100 ohm discharge on
+ * V12U, V1.00A, V0.85A
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
- BD99992GW_REG_V085ACNT, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_DISCHGCNT3, 0xd5);
+
+ /* DISCHGCNT4 - enable 100 ohm discharge on V33S, V18S, V100S */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_DISCHGCNT4, 0x15);
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_VRMODECTRL, 0x1f);
+
+ /* V5ADS3CNT - boost V5A_DS3 by 2% */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ BD99992GW_REG_V5ADS3CNT, 0x1a);
+
+ board_pmic_disable_slp_s0_vr_decay();
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
@@ -445,7 +440,7 @@ void board_hibernate(void)
system_enter_psl_mode();
/* Cut off DSW power via the ROP PMIC. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992,
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
BD99992GW_REG_SDWNCTRL, BD99992GW_SDWNCTRL_SWDN);
/* Wait for power to be cut. */
@@ -456,11 +451,16 @@ void board_hibernate(void)
/* Initialize board. */
static void board_init(void)
{
+ if (system_get_board_version() < ATLAS_REV_FIXED_EC_WP) {
+ int dflags;
+
+ CPRINTS("Applying EC_WP_L workaround");
+ dflags = gpio_get_default_flags(GPIO_EC_WP_L);
+ gpio_set_flags(GPIO_EC_WP_L, dflags | GPIO_PULL_UP);
+ }
+
/* Provide AC status to the PCH */
gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
-
- /* Enable interrupts from BMI160 sensor. */
- gpio_enable_interrupt(GPIO_ACCELGYRO3_INT_L);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
@@ -532,14 +532,12 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
static void board_chipset_suspend(void)
{
- gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
gpio_set_level(GPIO_KBD_BL_EN, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
static void board_chipset_resume(void)
{
- gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
gpio_set_level(GPIO_KBD_BL_EN, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
@@ -572,10 +570,6 @@ int board_get_version(void)
return ver;
}
-/* Base Sensor mutex */
-static struct mutex g_base_mutex;
-
-static struct bmi160_drv_data_t g_bmi160_data;
static struct opt3001_drv_data_t g_opt3001_data = {
.scale = 1,
.uscale = 0,
@@ -590,47 +584,6 @@ const mat33_fp_t base_standard_ref = {
};
struct motion_sensor_t motion_sensors[] = {
- [BASE_ACCEL] = {
- .name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .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_GYRO,
- .addr = BMI160_ADDR0,
- .rot_standard_ref = &base_standard_ref,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = BMI160_ACCEL_MIN_FREQ,
- .max_frequency = BMI160_ACCEL_MAX_FREQ,
- .config = {
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- },
- },
- [BASE_GYRO] = {
- .name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .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_GYRO,
- .addr = BMI160_ADDR0,
- .default_range = 1000, /* dps */
- .rot_standard_ref = &base_standard_ref,
- .min_frequency = BMI160_GYRO_MIN_FREQ,
- .max_frequency = BMI160_GYRO_MAX_FREQ,
- },
[LID_ALS] = {
.name = "Light",
.active_mask = SENSOR_ACTIVE_S0,
@@ -640,7 +593,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_SENSOR,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x2b11a1, /* from nocturne */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/atlas/board.h b/board/atlas/board.h
index 07f6debc60..a6c6bd6396 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -119,7 +119,7 @@
#define CONFIG_ALS
#define CONFIG_ALS_OPT3001
#define ALS_COUNT 1
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
#define CONFIG_ACCEL_FIFO 1024
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_ACCEL_INTERRUPTS
@@ -174,9 +174,9 @@
#define I2C_PORT_THERMAL I2C_PORT_POWER
/* I2C addresses */
-#define I2C_ADDR_TCPC 0x16
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_TCPC__7bf 0x0B
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_BD99992__7bf 0x30
#ifndef __ASSEMBLER__
diff --git a/board/bloog/board.c b/board/bloog/board.c
new file mode 100644
index 0000000000..f14989ad73
--- /dev/null
+++ b/board/bloog/board.c
@@ -0,0 +1,329 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Bloog/Blooguard board-specific configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "battery.h"
+#include "button.h"
+#include "charge_manager.h"
+#include "charge_state.h"
+#include "common.h"
+#include "console.h"
+#include "cros_board_info.h"
+#include "driver/accel_kionix.h"
+#include "driver/accelgyro_lsm6dsm.h"
+#include "driver/charger/bd9995x.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/tcpm/anx7447.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/tcpci.h"
+#include "driver/tcpm/tcpm.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "keyboard_scan.h"
+#include "lid_switch.h"
+#include "motion_sense.h"
+#include "power.h"
+#include "power_button.h"
+#include "switch.h"
+#include "system.h"
+#include "tablet_mode.h"
+#include "tcpci.h"
+#include "temp_sensor.h"
+#include "thermistor.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+
+#define USB_PD_PORT_ANX7447 0
+#define USB_PD_PORT_PS8751 1
+
+static uint8_t sku_id;
+
+static void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_PD_C0_INT_ODL:
+ nx20p348x_interrupt(0);
+ break;
+
+ case GPIO_USB_PD_C1_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* Must come after other header files and GPIO interrupts*/
+#include "gpio_list.h"
+
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_AMB] = {
+ "TEMP_AMB", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ [ADC_TEMP_SENSOR_CHARGER] = {
+ "TEMP_CHARGER", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ /* Vbus C0 sensing (10x voltage divider). PPVAR_USB_C0_VBUS */
+ [ADC_VBUS_C0] = {
+ "VBUS_C0", NPCX_ADC_CH9, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
+ /* Vbus C1 sensing (10x voltage divider). PPVAR_USB_C1_VBUS */
+ [ADC_VBUS_C1] = {
+ "VBUS_C1", NPCX_ADC_CH4, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_BATTERY] = {.name = "Battery",
+ .type = TEMP_SENSOR_TYPE_BATTERY,
+ .read = charge_get_battery_temp,
+ .idx = 0,
+ .action_delay_sec = 1},
+ [TEMP_SENSOR_AMBIENT] = {.name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_AMB,
+ .action_delay_sec = 5},
+ [TEMP_SENSOR_CHARGER] = {.name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_13k7_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_CHARGER,
+ .action_delay_sec = 1},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+/* Motion sensors */
+/* Mutexes */
+static struct mutex g_lid_mutex;
+static struct mutex g_base_mutex;
+
+/* Matrix to rotate accelrator into standard reference frame */
+const mat33_fp_t lid_standrd_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)}
+};
+
+/* sensor private data */
+static struct kionix_accel_data kx022_data;
+static struct lsm6dsm_data lsm6dsm_data;
+
+/* Drivers */
+struct motion_sensor_t motion_sensors[] = {
+ [LID_ACCEL] = {
+ .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 = &kx022_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
+ .rot_standard_ref = &lid_standrd_ref,
+ .default_range = 2, /* g */
+ .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,
+ },
+ },
+ },
+
+ [BASE_ACCEL] = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &lsm6dsm_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data,
+ MOTIONSENSE_TYPE_ACCEL),
+ .int_signal = GPIO_BASE_SIXAXIS_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
+ .rot_standard_ref = &base_standard_ref,
+ .default_range = 2, /* g */
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 13000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ /* Sensor on for angle detection */
+ [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_LSM6DSM,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &lsm6dsm_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data,
+ MOTIONSENSE_TYPE_GYRO),
+ .int_signal = GPIO_BASE_SIXAXIS_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
+ .default_range = 1000 | ROUND_UP_FLAG, /* dps */
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ },
+};
+
+unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+/*
+ * Returns 1 for boards that are convertible into tablet mode, and zero for
+ * clamshells.
+ */
+int board_is_convertible(void)
+{
+ /*
+ * Bloog: 33, 34, 35, 36
+ * Blooguard: 49, 50, 51, 52
+ * Unprovisioned: 255
+ */
+ return sku_id == 33 || sku_id == 34 || sku_id == 35 || sku_id == 36
+ || sku_id == 49 || sku_id == 50 || sku_id == 51 || sku_id == 52
+ || sku_id == 255;
+}
+
+static void board_update_sensor_config_from_sku(void)
+{
+ if (board_is_convertible()) {
+ motion_sensor_count = ARRAY_SIZE(motion_sensors);
+ /* Enable Base Accel interrupt */
+ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ } else {
+ motion_sensor_count = 0;
+ hall_sensor_disable();
+ /* Base accel is not stuffed, don't allow line to float */
+ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L,
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ }
+}
+
+static void cbi_init(void)
+{
+ uint32_t val;
+
+ if (cbi_get_sku_id(&val) == EC_SUCCESS)
+ sku_id = val;
+ ccprints("SKU: 0x%04x", sku_id);
+
+ board_update_sensor_config_from_sku();
+}
+DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
+
+void board_hibernate_late(void)
+{
+ int i;
+
+ const uint32_t hibernate_pins[][2] = {
+ /* Turn off LEDs before going to hibernate */
+ {GPIO_LED_WHITE_C0_L, GPIO_INPUT | GPIO_PULL_UP},
+ {GPIO_LED_AMBER_C0_L, GPIO_INPUT | GPIO_PULL_UP},
+ {GPIO_LED_WHITE_C1_L, GPIO_INPUT | GPIO_PULL_UP},
+ {GPIO_LED_AMBER_C1_L, GPIO_INPUT | GPIO_PULL_UP},
+ };
+
+ for (i = 0; i < ARRAY_SIZE(hibernate_pins); ++i)
+ gpio_set_flags(hibernate_pins[i][0], hibernate_pins[i][1]);
+}
+
+#ifndef TEST_BUILD
+/* This callback disables keyboard when convertibles are fully open */
+void lid_angle_peripheral_enable(int enable)
+{
+ /*
+ * If the lid is in tablet position via other sensors,
+ * ignore the lid angle, which might be faulty then
+ * disable keyboard.
+ */
+ if (tablet_get_mode())
+ enable = 0;
+
+ if (board_is_convertible())
+ keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
+}
+#endif
+
+#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 24 pins total, and there is no pin 0.
+ */
+const int keyboard_factory_scan_pins[][2] = {
+ {-1, -1}, {0, 5}, {1, 1}, {1, 0}, {0, 6},
+ {0, 7}, {1, 4}, {1, 3}, {1, 6}, {1, 7},
+ {3, 1}, {2, 0}, {1, 5}, {2, 6}, {2, 7},
+ {2, 1}, {2, 4}, {2, 5}, {1, 2}, {2, 3},
+ {2, 2}, {3, 0}, {-1, -1}, {-1, -1}, {-1, -1},
+};
+
+const int keyboard_factory_scan_pins_used =
+ ARRAY_SIZE(keyboard_factory_scan_pins);
+#endif
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
+
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
+}
+
+uint32_t board_override_feature_flags0(uint32_t flags0)
+{
+ /*
+ * Remove keyboard backlight feature for devices that don't support it.
+ */
+ if (sku_id == 33 || sku_id == 36 || sku_id == 51 || sku_id == 52)
+ return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
+ else
+ return flags0;
+}
+
+uint32_t board_override_feature_flags1(uint32_t flags1)
+{
+ return flags1;
+}
diff --git a/board/bobba/board.c b/board/bobba/board.c
index 4cc3d3f678..aaf31187a7 100644
--- a/board/bobba/board.c
+++ b/board/bobba/board.c
@@ -130,7 +130,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 4, /* g */
.config = {
@@ -154,7 +154,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -182,7 +182,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/casta/board.c b/board/casta/board.c
new file mode 100644
index 0000000000..ae3f61e0c1
--- /dev/null
+++ b/board/casta/board.c
@@ -0,0 +1,154 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Casta board-specific configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "battery.h"
+#include "charge_manager.h"
+#include "charge_state.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "driver/charger/bd9995x.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/tcpm/anx7447.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/tcpci.h"
+#include "driver/tcpm/tcpm.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "keyboard_scan.h"
+#include "lid_switch.h"
+#include "power.h"
+#include "power_button.h"
+#include "switch.h"
+#include "system.h"
+#include "tcpci.h"
+#include "temp_sensor.h"
+#include "thermistor.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+
+static void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_PD_C0_INT_ODL:
+ nx20p348x_interrupt(0);
+ break;
+
+ case GPIO_USB_PD_C1_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* Must come after other header files and GPIO interrupts*/
+#include "gpio_list.h"
+
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_AMB] = {
+ "TEMP_AMB", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ [ADC_TEMP_SENSOR_CHARGER] = {
+ "TEMP_CHARGER", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* TODO(b/119872005): Casta: confirm thermistor parts */
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_BATTERY] = {.name = "Battery",
+ .type = TEMP_SENSOR_TYPE_BATTERY,
+ .read = charge_get_battery_temp,
+ .idx = 0,
+ .action_delay_sec = 1},
+ [TEMP_SENSOR_AMBIENT] = {.name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_AMB,
+ .action_delay_sec = 5},
+ [TEMP_SENSOR_CHARGER] = {.name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_13k7_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_CHARGER,
+ .action_delay_sec = 1},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+/*
+ * I2C callbacks to ensure bus free time for battery I2C transactions is at
+ * least 5ms.
+ */
+#define BATTERY_FREE_MIN_DELTA_US (5 * MSEC)
+static timestamp_t battery_last_i2c_time;
+
+static int is_battery_i2c__7bf(const int port, const uint16_t slave_addr__7bf)
+{
+ return (port == I2C_PORT_BATTERY)
+ && (slave_addr__7bf == BATTERY_ADDR__7bf);
+}
+
+static int is_battery_port(int port)
+{
+ return (port == I2C_PORT_BATTERY);
+}
+
+void i2c_start_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
+{
+ unsigned int time_delta_us;
+
+ if (!is_battery_i2c__7bf(port, slave_addr__7bf))
+ return;
+
+ time_delta_us = time_since32(battery_last_i2c_time);
+ if (time_delta_us >= BATTERY_FREE_MIN_DELTA_US)
+ return;
+
+ usleep(BATTERY_FREE_MIN_DELTA_US - time_delta_us);
+}
+
+void i2c_end_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
+{
+ /*
+ * The bus free time needs to be maintained from last transaction
+ * on I2C bus to any device on it to the next transaction to battery.
+ */
+ if (!is_battery_port(port))
+ return;
+
+ battery_last_i2c_time = get_time();
+}
+
+/* TODO: Casta: remove this routine after rev0 is not supported */
+static void board_init(void)
+{
+ uint32_t val;
+ if (cbi_get_board_version(&val) == EC_SUCCESS && val > 0)
+ return;
+
+ gpio_set_flags(GPIO_USB_C0_MUX_INT_ODL, GPIO_INT_FALLING | GPIO_PULL_UP);
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
+
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
+}
diff --git a/board/chell/board.c b/board/chell/board.c
index 14b1e56d2c..659f3ecb02 100644
--- a/board/chell/board.c
+++ b/board/chell/board.c
@@ -42,7 +42,7 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_BD99992__7bf 0x30
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
@@ -126,7 +126,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -134,7 +134,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
},
.drv = &tcpci_tcpm_drv,
@@ -198,12 +198,12 @@ static int ps874x_tune_mux(int port)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x34,
+ .port_addr = 0x1A,
.driver = &ps874x_usb_mux_driver,
.board_init = &ps874x_tune_mux,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
.board_init = &ps874x_tune_mux,
}
@@ -245,7 +245,7 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
static void board_pmic_init(void)
{
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
/*
* No need to re-init below settings since they are present on all MP
@@ -255,23 +255,23 @@ static void board_pmic_init(void)
return;
/* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x4a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x4a);
/*
* Set V100ACNT / V1.00A Control Register:
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
/* VRMODECTRL - enable low-power mode for VCCIO and V0.85A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x18);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x18);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
@@ -409,7 +409,7 @@ void board_hibernate(void)
uart_flush_output();
/* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -481,7 +481,8 @@ void chipset_set_pmic_slp_sus_l(int level)
if (!level)
msleep(25);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x43, val);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ 0x43, val);
previous_level = level;
}
}
diff --git a/board/cheza/board.c b/board/cheza/board.c
index be505d1a0e..8f11d0150b 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -6,12 +6,14 @@
/* Cheza board-specific configuration */
#include "adc_chip.h"
+#include "als.h"
#include "button.h"
#include "charge_manager.h"
#include "charge_state.h"
#include "chipset.h"
#include "extpower.h"
#include "driver/accelgyro_bmi160.h"
+#include "driver/als_opt3001.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/anx74xx.h"
#include "driver/tcpm/ps8xxx.h"
@@ -129,7 +131,7 @@ static void ppc_interrupt(enum gpio_signal signal)
static void usb1_oc_evt_deferred(void)
{
/* Only port-1 has overcurrent GPIO interrupt */
- board_overcurrent_event(0, 1);
+ board_overcurrent_event(1, 1);
}
DECLARE_DEFERRED(usb1_oc_evt_deferred);
@@ -240,7 +242,7 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
struct ppc_config_t ppc_chips[] = {
{
.i2c_port = I2C_PORT_TCPC0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
/*
@@ -259,7 +261,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = 0x50,
+ .addr__7bf = 0x28,
},
.drv = &anx74xx_tcpm_drv,
.flags = TCPC_FLAGS_ALERT_OD,
@@ -268,7 +270,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = 0x16,
+ .addr__7bf = 0x0B,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -618,6 +620,11 @@ uint16_t tcpc_get_alert_status(void)
static struct mutex g_lid_mutex;
static struct bmi160_drv_data_t g_bmi160_data;
+static struct opt3001_drv_data_t g_opt3001_data = {
+ .scale = 1,
+ .uscale = 0,
+ .offset = 0,
+};
/* Matrix to rotate accelerometer into standard reference frame */
const mat33_fp_t base_standard_ref = {
@@ -642,7 +649,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -663,11 +670,31 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_SENSOR,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
+ [LID_ALS] = {
+ .name = "Light",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_OPT3001,
+ .type = MOTIONSENSE_TYPE_LIGHT,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &opt3001_drv,
+ .drv_data = &g_opt3001_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
+ .rot_standard_ref = NULL,
+ .default_range = 0x10000, /* scale = 1; uscale = 0 */
+ .min_frequency = OPT3001_LIGHT_MIN_FREQ,
+ .max_frequency = OPT3001_LIGHT_MAX_FREQ,
+ .config = {
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 1000,
+ },
+ },
+ },
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/board/cheza/board.h b/board/cheza/board.h
index ed1dcd9c72..e35502fa57 100644
--- a/board/cheza/board.h
+++ b/board/cheza/board.h
@@ -12,6 +12,8 @@
#define CONFIG_BRINGUP
#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands. */
#define CONFIG_USB_PD_DEBUG_LEVEL 3
+#define CONFIG_CMD_AP_RESET_LOG
+#define CONFIG_HOSTCMD_AP_RESET
/*
* By default, enable all console messages excepted event and HC:
@@ -26,20 +28,26 @@
#define NPCX7_PWM1_SEL 0 /* GPIO C2 is not used as PWM1. */
/* Internal SPI flash on NPCX7 */
-#define CONFIG_FLASH_SIZE (512 * 1024) /* It's really 1MB. */
+#define CONFIG_FLASH_SIZE (1024 * 1024) /* 1MB internal spi flash */
#define CONFIG_SPI_FLASH_REGS
#define CONFIG_SPI_FLASH_W25Q80 /* Internal SPI flash type. */
+#define CONFIG_HOSTCMD_FLASH_SPI_INFO
/* EC Modules */
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
#define CONFIG_LED_COMMON
+#define CONFIG_LOW_POWER_IDLE
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
#define CONFIG_FPU
#define CONFIG_PWM
#define CONFIG_PWM_DISPLIGHT
+#define CONFIG_VBOOT_HASH
+
+#define CONFIG_DETACHABLE_BASE
+
#undef CONFIG_PECI
#define CONFIG_HOSTCMD_SPS
@@ -79,7 +87,6 @@
#define CONFIG_CHARGER_PSYS_READ
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-/* TODO(b/79163120): Use correct charger values, copied from Lux for rev-0 */
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 7500
@@ -109,11 +116,16 @@
#define CONFIG_USB_PD_TRY_SRC
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
#define CONFIG_USB_PD_5V_EN_CUSTOM
+#define CONFIG_USB_MUX_VIRTUAL
#define CONFIG_USBC_PPC_SN5S330
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
#define CONFIG_USBC_VCONN_SWAP
+/* RTC */
+#define CONFIG_CMD_RTC
+#define CONFIG_HOSTCMD_RTC
+
/* Sensors */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
@@ -123,25 +135,29 @@
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
+#define CONFIG_ALS
+#define CONFIG_ALS_OPT3001
+#define ALS_COUNT 1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
-/* TODO(b/79163120): Use correct PD delay values, copied from Lux for rev-0 */
+/* PD */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */
#define PD_VCONN_SWAP_DELAY 5000 /* us */
-/* TODO(b/79163120): Use correct PD power values, copied from Lux for rev-0 */
#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 45000
+#define PD_MAX_POWER_MW ((PD_MAX_VOLTAGE_MV * PD_MAX_CURRENT_MA) / 1000)
#define PD_MAX_CURRENT_MA 3000
#define PD_MAX_VOLTAGE_MV 20000
+/* Chipset */
#define CONFIG_CHIPSET_SDM845
#define CONFIG_CHIPSET_RESET_HOOK
#define CONFIG_POWER_COMMON
#define CONFIG_POWER_PP5000_CONTROL
-/* TODO(b/79348203): Enable EC hibernate */
-#undef CONFIG_HIBERNATE
+/* NPCX Features */
+#define CONFIG_HIBERNATE_PSL
/* I2C Ports */
#define I2C_PORT_BATTERY I2C_PORT_POWER
@@ -159,10 +175,11 @@
#include "registers.h"
enum power_signal {
- SDM845_AP_RST_L = 0,
+ SDM845_AP_RST_ASSERTED = 0,
SDM845_PS_HOLD,
SDM845_PMIC_FAULT_L,
SDM845_POWER_GOOD,
+ SDM845_WARM_RESET,
/* Number of power signals */
POWER_SIGNAL_COUNT
};
@@ -197,6 +214,9 @@ void board_reset_pd_mcu(void);
/* Base detection interrupt handler */
void base_detect_interrupt(enum gpio_signal signal);
+/* Sensors without hardware FIFO are in forced mode */
+#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS)
+
#endif /* !defined(__ASSEMBLER__) */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/coral/board.c b/board/coral/board.c
index 012e3a8038..8a027e73d9 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -191,7 +191,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
.i2c_test = &anx74xx_i2c_stress_test_dev,
},
#endif
@@ -200,7 +200,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
.i2c_test = &ps8xxx_i2c_stress_test_dev,
},
#endif
@@ -209,7 +209,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .addr__7bf = BMI160_ADDR0__7bf,
.i2c_test = &bmi160_i2c_stress_test_dev,
},
#endif
@@ -218,7 +218,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .addr__7bf = KX022_ADDR1__7bf,
.i2c_test = &kionix_i2c_stress_test_dev,
},
#endif
@@ -243,7 +243,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -251,7 +251,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -390,7 +390,7 @@ static void board_tcpc_init(void)
*
* NOTE: PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(NPCX_I2C_PORT0_1, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(NPCX_I2C_PORT0_1, 0x08, 0xA0, &reg);
/* Enable TCPC0 interrupt */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -740,7 +740,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.config = {
@@ -765,7 +765,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.config = {
@@ -792,7 +792,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
},
diff --git a/board/elm/board.c b/board/elm/board.c
index 5f00866350..b92aa14c7d 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -95,13 +95,14 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-int anx7688_passthru_allowed(const struct i2c_port_t *port, uint16_t address)
+int anx7688_passthru_allowed__7bf(const struct i2c_port_t *port,
+ const uint16_t addr__7bf)
{
/* Allow access to 0x2c (TCPC) */
- if (address == 0x2c)
+ if (I2C_GET_ADDR__7b(addr__7bf) == 0x2c)
return 1;
- CPRINTF("Passthru rejected on %x", address);
+ CPRINTF("Passthru rejected on %x", I2C_GET_ADDR__7b(addr__7bf));
return 0;
}
@@ -110,7 +111,7 @@ int anx7688_passthru_allowed(const struct i2c_port_t *port, uint16_t address)
const struct i2c_port_t i2c_ports[] = {
{"battery", I2C_PORT_BATTERY, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA},
{"pd", I2C_PORT_PD_MCU, 1000, GPIO_I2C1_SCL, GPIO_I2C1_SDA,
- anx7688_passthru_allowed}
+ anx7688_passthru_allowed__7bf}
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -128,7 +129,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &anx7688_tcpm_drv,
},
@@ -469,7 +470,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &kionix_accel_drv,
.mutex = &g_kx022_mutex[0],
.drv_data = &g_kx022_data[0],
- .addr = 1, /* SPI, device ID 0 */
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(0),
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -492,7 +493,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &kionix_accel_drv,
.mutex = &g_kx022_mutex[1],
.drv_data = &g_kx022_data[1],
- .addr = 3, /* SPI, device ID 1 */
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(1),
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
diff --git a/board/elm/board.h b/board/elm/board.h
index 0de9730454..359bd7e279 100644
--- a/board/elm/board.h
+++ b/board/elm/board.h
@@ -99,8 +99,8 @@
#define CONFIG_USB_PD_TCPM_TCPCI
#define CONFIG_USB_PD_TRY_SRC
#define CONFIG_USB_PD_VBUS_DETECT_TCPC
-#undef CONFIG_TCPC_I2C_BASE_ADDR
-#define CONFIG_TCPC_I2C_BASE_ADDR 0x58
+#undef CONFIG_TCPC_I2C_BASE_ADDR__7BF
+#define CONFIG_TCPC_I2C_BASE_ADDR__7BF 0x2C
#define CONFIG_USB_PD_ANX7688
/* UART DMA */
diff --git a/board/eve/board.c b/board/eve/board.c
index 4c5fa8ce89..72877fd100 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -5,6 +5,7 @@
/* Eve board-specific configuration */
+#include "acpi.h"
#include "adc_chip.h"
#include "bd99992gw.h"
#include "board_config.h"
@@ -62,17 +63,20 @@
static void tcpc_alert_event(enum gpio_signal signal)
{
- if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C0_PD_RST_L))
- return;
- else if ((signal == GPIO_USB_C1_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_L))
+ int port = -1;
+
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
return;
+ }
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ schedule_deferred_pd_interrupt(port);
}
/*
@@ -153,17 +157,6 @@ void anx74xx_cable_det_interrupt(enum gpio_signal signal)
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
- {GPIO_PCH_SLP_S0_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S0_DEASSERTED"},
- {VW_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {VW_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
- {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"},
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"},
- {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* Keyboard scan. Increase output_settle_us to 80us from default 50us. */
struct keyboard_scan_config keyscan_config = {
.output_settle_us = 80,
@@ -214,7 +207,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -222,7 +215,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -370,29 +363,29 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
- if (!(vrfault & (1 << 4)))
+ if (!(vrfault & BIT(4)))
return;
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, (1 << 4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -410,38 +403,46 @@ static void board_pmic_init(void)
return;
/* DISCHGCNT2 - enable 100 ohm discharge on V3.3A and V1.8A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3d, 0x05);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3d, 0x05);
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
/* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* Set V100ACNT / V1.00A Control Register:
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
/* Clear power source events */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x04, 0xff);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x04, 0xff);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
static void board_set_tablet_mode(void)
{
- tablet_set_mode(!gpio_get_level(GPIO_TABLET_MODE_L));
+ int flipped_360_mode = !gpio_get_level(GPIO_TABLET_MODE_L);
+
+ tablet_set_mode(flipped_360_mode);
+
+ /* Update DPTF profile based on mode */
+ if (flipped_360_mode)
+ acpi_dptf_set_profile_num(DPTF_PROFILE_FLIPPED_360_MODE);
+ else
+ acpi_dptf_set_profile_num(DPTF_PROFILE_CLAMSHELL);
}
int board_has_working_reset_flags(void)
@@ -491,7 +492,10 @@ static void board_init(void)
if (board_get_version() == 4) {
/* Set F13 to new defined key on EVT */
CPRINTS("Overriding F13 scan code");
- scancode_set2[3][9] = 0xe007;
+ scancode_set2[9][3] = 0xe007;
+#ifdef CONFIG_KEYBOARD_DEBUG
+ keycap_label[9][3] = KLLI_F13;
+#endif
}
#endif
}
@@ -718,7 +722,7 @@ void board_hibernate(void)
/* Shut down PMIC */
CPRINTS("Triggering PMIC shutdown");
uart_flush_output();
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -811,7 +815,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kxcj9_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -838,7 +842,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = NULL,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -864,7 +868,7 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_GYRO] = {
.name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0,
+ .active_mask = SENSOR_ACTIVE_S0_S3_S5,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
@@ -872,7 +876,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = NULL,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -881,7 +885,7 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_MAG] = {
.name = "Base Mag",
- .active_mask = SENSOR_ACTIVE_S0,
+ .active_mask = SENSOR_ACTIVE_S0_S3_S5,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_MAG,
.location = MOTIONSENSE_LOC_BASE,
@@ -889,8 +893,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
- .default_range = 1 << 11, /* 16LSB / uT, fixed */
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
.max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
@@ -906,7 +910,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_si114x_data,
.port = I2C_PORT_ALS,
- .addr = SI114X_ADDR,
+ .i2c_spi_addr__7bf = SI114X_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 3088, /* 30.88%: int = 0 - frac = 3088/10000 */
.min_frequency = SI114X_LIGHT_MIN_FREQ,
diff --git a/board/eve/board.h b/board/eve/board.h
index f329cb2557..88938e9719 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -29,6 +29,7 @@
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_DEVICE_EVENT
#define CONFIG_DPTF
+#define CONFIG_DPTF_MULTI_PROFILE
#define CONFIG_FLASH_SIZE 0x80000
#define CONFIG_FPU
#define CONFIG_I2C
@@ -127,7 +128,8 @@
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
+#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT /* Unused */
#define CONFIG_MAG_CALIBRATE
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
@@ -148,7 +150,7 @@
#define CONFIG_GESTURE_TAP_THRES_MG 100
#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
#define CONFIG_GESTURE_DETECTION_MASK \
- (1 << CONFIG_GESTURE_SENSOR_BATTERY_TAP)
+ BIT(CONFIG_GESTURE_SENSOR_BATTERY_TAP)
/* USB */
#define CONFIG_USB_CHARGER
@@ -193,8 +195,8 @@
#define I2C_PORT_MP2949 NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
#ifndef __ASSEMBLER__
@@ -211,16 +213,6 @@ enum board_version_list {
BOARD_VERSION_PVT,
};
-enum power_signal {
- X86_SLP_S0_DEASSERTED,
- X86_SLP_S3_DEASSERTED,
- X86_SLP_S4_DEASSERTED,
- X86_SLP_SUS_DEASSERTED,
- X86_RSMRST_L_PGOOD,
- X86_PMIC_DPWROK,
- POWER_SIGNAL_COUNT
-};
-
enum temp_sensor_id {
TEMP_SENSOR_BATTERY, /* BD99956GW TSENSE */
TEMP_SENSOR_AMBIENT, /* BD99992GW SYSTHERM0 */
@@ -298,7 +290,7 @@ void led_register_double_tap(void);
void board_update_ac_status(void);
/* Sensors without hardware FIFO are in forced mode */
-#define CONFIG_ACCEL_FORCE_MODE_MASK ((1 << LID_ACCEL) | (1 << LID_LIGHT))
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_LIGHT))
#endif /* !__ASSEMBLER__ */
diff --git a/board/fizz/board.c b/board/fizz/board.c
index f278da3107..069c6450e8 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -201,7 +201,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = I2C_ADDR_TCPC0,
+ .addr__7bf = I2C_ADDR_TCPC0__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -251,7 +251,7 @@ void board_tcpc_init(void)
* TCPM_INIT will fail due to not able to access PS8751.
* Note PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(I2C_PORT_TCPC0, I2C_ADDR_TCPC0, 0xA0, &reg);
+ i2c_read8__7bf(I2C_PORT_TCPC0, I2C_ADDR_TCPC0__7bf, 0xA0, &reg);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -312,10 +312,10 @@ BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
/* Initialize PMIC */
#define I2C_PMIC_READ(reg, data) \
- i2c_read8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_read8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf, (reg), (data))
#define I2C_PMIC_WRITE(reg, data) \
- i2c_write8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_write8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf, (reg), (data))
static void board_pmic_init(void)
{
diff --git a/board/fizz/board.h b/board/fizz/board.h
index fd6646fec1..8009b1cdbd 100644
--- a/board/fizz/board.h
+++ b/board/fizz/board.h
@@ -137,8 +137,8 @@
#define I2C_PORT_THERMAL NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_TCPC0 0x16
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_TCPC0__7bf 0x0b
+#define I2C_ADDR_EEPROM__7bf 0x50
/* Verify and jump to RW image on boot */
#define CONFIG_VBOOT_EFS
diff --git a/board/flapjack/battery.c b/board/flapjack/battery.c
new file mode 100644
index 0000000000..5bb6b07a9f
--- /dev/null
+++ b/board/flapjack/battery.c
@@ -0,0 +1,468 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Battery pack vendor provided charging profile
+ */
+
+#include "battery.h"
+#include "battery_smart.h"
+#include "charge_state.h"
+#include "console.h"
+#include "driver/battery/max17055.h"
+#include "driver/charger/rt946x.h"
+#include "driver/tcpm/mt6370.h"
+#include "ec_commands.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "usb_pd.h"
+#include "util.h"
+#include "board.h"
+#include "adc.h"
+#include "adc_chip.h"
+#include "math_util.h"
+#include "p9221.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+
+#define BAT_LEVEL_PD_LIMIT 85
+
+#define BATTERY_ATL_CHARGE_MIN_TEMP 0
+#define BATTERY_ATL_CHARGE_MAX_TEMP 60
+
+#define BATTERY_SUNWODA_CHARGE_MIN_TEMP 0
+#define BATTERY_SUNWODA_CHARGE_MAX_TEMP 60
+
+static const uint16_t full_model_ocv_table[][MAX17055_OCV_TABLE_SIZE] = {
+ [BATTERY_C18_ATL] = {
+ 0x8fc0, 0xb6c0, 0xb910, 0xbb30, 0xbcb0, 0xbdd0, 0xbef0, 0xc050,
+ 0xc1a0, 0xc460, 0xc750, 0xca40, 0xcd10, 0xd070, 0xd560, 0xda20,
+ 0x0060, 0x0f20, 0x0f40, 0x16c0, 0x17f0, 0x15c0, 0x1050, 0x10e0,
+ 0x09f0, 0x0850, 0x0730, 0x07a0, 0x0730, 0x0700, 0x0710, 0x0710,
+ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800,
+ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800,
+ },
+ [BATTERY_C19_ATL] = {
+ 0xa260, 0xb5d0, 0xb840, 0xb940, 0xbbb0, 0xbcb0, 0xbdb0, 0xbf80,
+ 0xc0a0, 0xc1e0, 0xc520, 0xc840, 0xcdb0, 0xd150, 0xd590, 0xd9e0,
+ 0x0030, 0x0cd0, 0x1100, 0x0f30, 0x19e0, 0x19f0, 0x14f0, 0x1160,
+ 0x0dc0, 0x0980, 0x0850, 0x0780, 0x0730, 0x0700, 0x0710, 0x0710,
+ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800,
+ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800,
+ },
+ [BATTERY_C18_SUNWODA] = {
+ 0x9d70, 0xaf80, 0xb6b0, 0xb830, 0xb990, 0xbc00, 0xbcd0, 0xbea0,
+ 0xc080, 0xc2e0, 0xc5f0, 0xc890, 0xcb90, 0xcf10, 0xd270, 0xd9e0,
+ 0x0060, 0x0240, 0x0b20, 0x1210, 0x0f20, 0x2200, 0x1650, 0x14f0,
+ 0x0980, 0x09c0, 0x07b0, 0x07f0, 0x06f0, 0x07e0, 0x05c0, 0x05c0,
+ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
+ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
+ },
+ [BATTERY_C19_SUNWODA] = {
+ 0x8590, 0xb1d0, 0xb810, 0xbae0, 0xbc30, 0xbd70, 0xbeb0, 0xbfa0,
+ 0xc0f0, 0xc330, 0xc640, 0xc890, 0xcb50, 0xce20, 0xd370, 0xd950,
+ 0x0020, 0x0520, 0x0d80, 0x1860, 0x1910, 0x2040, 0x0be0, 0x0dd0,
+ 0x0cb0, 0x07b0, 0x08f0, 0x07c0, 0x0790, 0x06e0, 0x0620, 0x0620,
+ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
+ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(full_model_ocv_table) == BATTERY_COUNT);
+
+/*
+ * TODO: Only precharge_current is different. We should consolidate these
+ * and apply 294 or 327 at run-time.when we need more rom space later.
+ */
+static const struct battery_info info[] = {
+ [BATTERY_C18_ATL] = {
+ .voltage_max = 4400,
+ .voltage_normal = 3850,
+ .voltage_min = 3000,
+ .precharge_current = 294,
+ .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,
+ },
+ [BATTERY_C19_ATL] = {
+ .voltage_max = 4400,
+ .voltage_normal = 3850,
+ .voltage_min = 3000,
+ .precharge_current = 327,
+ .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,
+ },
+ [BATTERY_C18_SUNWODA] = {
+ .voltage_max = 4400,
+ .voltage_normal = 3850,
+ .voltage_min = 3000,
+ .precharge_current = 294,
+ .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,
+ },
+ [BATTERY_C19_SUNWODA] = {
+ .voltage_max = 4400,
+ .voltage_normal = 3850,
+ .voltage_min = 3000,
+ .precharge_current = 327,
+ .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,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(info) == BATTERY_COUNT);
+
+static const struct max17055_batt_profile batt_profile[] = {
+ [BATTERY_C18_ATL] = {
+ .is_ez_config = 0,
+ .design_cap = 0x2e78, /* 5948mAh */
+ .ichg_term = 0x03c0, /* 150 mA */
+ /* Empty voltage = 3400mV, Recovery voltage = 4000mV */
+ .v_empty_detect = 0xaa64,
+ .learn_cfg = 0x4402,
+ .dpacc = 0x0c7d,
+ .rcomp0 = 0x0011,
+ .tempco = 0x0209,
+ .qr_table00 = 0x5a00,
+ .qr_table10 = 0x2980,
+ .qr_table20 = 0x1100,
+ .qr_table30 = 0x1000,
+ .ocv_table = full_model_ocv_table[BATTERY_C18_ATL],
+ },
+ [BATTERY_C19_ATL] = {
+ .is_ez_config = 0,
+ .design_cap = 0x3407, /* 6659mAh */
+ .ichg_term = 0x03c0, /* 150 mA */
+ /* Empty voltage = 3400mV, Recovery voltage = 4000mV */
+ .v_empty_detect = 0xaa64,
+ .learn_cfg = 0x4402,
+ .dpacc = 0x0c7e,
+ .rcomp0 = 0x000f,
+ .tempco = 0x000b,
+ .qr_table00 = 0x5800,
+ .qr_table10 = 0x2680,
+ .qr_table20 = 0x0d00,
+ .qr_table30 = 0x0b00,
+ .ocv_table = full_model_ocv_table[BATTERY_C19_ATL],
+ },
+ [BATTERY_C18_SUNWODA] = {
+ .is_ez_config = 0,
+ .design_cap = 0x2fcc, /* 6118mAh */
+ .ichg_term = 0x03c0, /* 150 mA */
+ /* Empty voltage = 3400mV, Recovery voltage = 4000mV */
+ .v_empty_detect = 0xaa64,
+ .learn_cfg = 0x4402,
+ .dpacc = 0x0c7c,
+ .rcomp0 = 0x0024,
+ .tempco = 0x0c1f,
+ .qr_table00 = 0x9f00,
+ .qr_table10 = 0x4480,
+ .qr_table20 = 0x1600,
+ .qr_table30 = 0x1400,
+ .ocv_table = full_model_ocv_table[BATTERY_C18_SUNWODA],
+ },
+ [BATTERY_C19_SUNWODA] = {
+ .is_ez_config = 0,
+ .design_cap = 0x34b1, /* 6744mAh */
+ .ichg_term = 0x03c0, /* 150 mA */
+ /* Empty voltage = 3400mV, Recovery voltage = 4000mV */
+ .v_empty_detect = 0xaa64,
+ .learn_cfg = 0x4402,
+ .dpacc = 0x0c80,
+ .rcomp0 = 0x001f,
+ .tempco = 0x051f,
+ .qr_table00 = 0x9100,
+ .qr_table10 = 0x3d00,
+ .qr_table20 = 0x1200,
+ .qr_table30 = 0x1002,
+ .ocv_table = full_model_ocv_table[BATTERY_C19_SUNWODA],
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(batt_profile) == BATTERY_COUNT);
+
+static const struct max17055_alert_profile alert_profile[] = {
+ [BATTERY_C18_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,
+ },
+ [BATTERY_C19_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,
+ },
+ [BATTERY_C18_SUNWODA] = {
+ .v_alert_mxmn = VALRT_DISABLE,
+ .t_alert_mxmn = MAX17055_TALRTTH_REG(
+ BATTERY_SUNWODA_CHARGE_MIN_TEMP,
+ BATTERY_SUNWODA_CHARGE_MAX_TEMP),
+ .s_alert_mxmn = SALRT_DISABLE,
+ .i_alert_mxmn = IALRT_DISABLE,
+ },
+ [BATTERY_C19_SUNWODA] = {
+ .v_alert_mxmn = VALRT_DISABLE,
+ .t_alert_mxmn = MAX17055_TALRTTH_REG(
+ BATTERY_SUNWODA_CHARGE_MIN_TEMP,
+ BATTERY_SUNWODA_CHARGE_MAX_TEMP),
+ .s_alert_mxmn = SALRT_DISABLE,
+ .i_alert_mxmn = IALRT_DISABLE,
+ },
+
+};
+BUILD_ASSERT(ARRAY_SIZE(alert_profile) == BATTERY_COUNT);
+
+enum temp_zone {
+ TEMP_ZONE_0, /* t0 <= bat_temp_c < t1 */
+ TEMP_ZONE_1, /* t1 <= bat_temp_c < t2 */
+ TEMP_ZONE_2, /* t2 <= bat_temp_c < t3 */
+ TEMP_ZONE_3, /* t3 <= bat_temp_c < t4 */
+ TEMP_ZONE_COUNT,
+ TEMP_OUT_OF_RANGE = TEMP_ZONE_COUNT,
+};
+
+/*
+ * TODO: Many value in temp_zones are pretty similar, we should consolidate
+ * these and modify the value when we need more rom space later.
+ */
+static const struct {
+ int temp_min; /* 0.1 deg C */
+ int temp_max; /* 0.1 deg C */
+ int desired_current; /* mA */
+ int desired_voltage; /* mV */
+} temp_zones[BATTERY_COUNT][TEMP_ZONE_COUNT] = {
+ [BATTERY_C18_ATL] = {
+ {BATTERY_ATL_CHARGE_MIN_TEMP * 10, 100, 1170, 4400},
+ {100, 200, 1755, 4400},
+ {200, 450, 2925, 4400},
+ {450, BATTERY_ATL_CHARGE_MAX_TEMP * 10, 2925, 4100},
+ },
+ [BATTERY_C19_ATL] = {
+ {BATTERY_ATL_CHARGE_MIN_TEMP * 10, 100, 1300, 4400},
+ {100, 200, 1950, 4400},
+ {200, 450, 3250, 4400},
+ {450, BATTERY_ATL_CHARGE_MAX_TEMP * 10, 3250, 4100},
+ },
+ [BATTERY_C18_SUNWODA] = {
+ {BATTERY_SUNWODA_CHARGE_MIN_TEMP * 10, 100, 1170, 4400},
+ {100, 200, 1755, 4400},
+ {200, 450, 2925, 4400},
+ {450, BATTERY_SUNWODA_CHARGE_MAX_TEMP * 10, 2925, 4100},
+ },
+ [BATTERY_C19_SUNWODA] = {
+ {BATTERY_SUNWODA_CHARGE_MIN_TEMP * 10, 100, 1300, 4400},
+ {100, 200, 1950, 4400},
+ {200, 450, 3250, 4400},
+ {450, BATTERY_SUNWODA_CHARGE_MAX_TEMP * 10, 3250, 4100},
+ },
+};
+
+/* BOARD_VERSION < 5: Pull-up = 1800 mV. */
+static const struct mv_to_id batteries0[] = {
+ { BATTERY_C18_ATL, 900 }, /* 100K ohm */
+ { BATTERY_C19_ATL, 576 }, /* 47K ohm */
+ { BATTERY_C18_SUNWODA, 1484 }, /* 470K ohm */
+ { BATTERY_C19_SUNWODA, 1200 }, /* 200K ohm */
+};
+BUILD_ASSERT(ARRAY_SIZE(batteries0) < BATTERY_COUNT);
+
+/* BOARD_VERSION >= 5: Pull-up = 3300 mV. */
+static const struct mv_to_id batteries1[] = {
+ { BATTERY_C18_ATL, 1650 }, /* 100K ohm */
+ { BATTERY_C19_ATL, 1055 }, /* 47K ohm */
+ { BATTERY_C18_SUNWODA, 2721 }, /* 470K ohm */
+ { BATTERY_C19_SUNWODA, 2200 }, /* 200K ohm */
+};
+BUILD_ASSERT(ARRAY_SIZE(batteries1) < BATTERY_COUNT);
+
+static enum battery_type batt_type = BATTERY_UNKNOWN;
+
+static void board_get_battery_type(void)
+{
+ const struct mv_to_id *table = batteries0;
+ int size = ARRAY_SIZE(batteries0);
+ int id;
+
+ if (board_version >= 5) {
+ table = batteries1;
+ size = ARRAY_SIZE(batteries1);
+ }
+ id = board_read_id(ADC_BATT_ID, table, size);
+ if (id != ADC_READ_ERROR)
+ batt_type = id;
+ CPRINTS("Battery Type: %d", batt_type);
+}
+/* It has to run after BOARD_VERSION is read */
+DECLARE_HOOK(HOOK_INIT, board_get_battery_type, HOOK_PRIO_INIT_I2C + 2);
+
+const struct battery_info *battery_get_info(void)
+{
+ return &info[batt_type];
+}
+
+const struct max17055_batt_profile *max17055_get_batt_profile(void)
+{
+ return &batt_profile[batt_type];
+}
+
+const struct max17055_alert_profile *max17055_get_alert_profile(void)
+{
+ return &alert_profile[batt_type];
+}
+
+int get_battery_manufacturer_name(char *dest, int size)
+{
+ static const char * const name[] = {
+ [BATTERY_UNKNOWN] = "UNKNOWN",
+ [BATTERY_C18_ATL] = "C18_ATL",
+ [BATTERY_C19_ATL] = "C19_ATL",
+ [BATTERY_C18_SUNWODA] = "C18_SWD",
+ [BATTERY_C19_SUNWODA] = "C19_SWD",
+ };
+ ASSERT(dest);
+ strzcpy(dest, name[batt_type], size);
+ return EC_SUCCESS;
+}
+
+int board_cut_off_battery(void)
+{
+ /* The cut-off procedure is recommended by Richtek. b/116682788 */
+ rt946x_por_reset();
+ mt6370_vconn_discharge(0);
+ rt946x_cutoff_battery();
+
+ return EC_SUCCESS;
+}
+
+enum battery_disconnect_state battery_get_disconnect_state(void)
+{
+ if (battery_is_present() == BP_YES)
+ return BATTERY_NOT_DISCONNECTED;
+ return BATTERY_DISCONNECTED;
+}
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ /* battery temp in 0.1 deg C */
+ int temp = curr->batt.temperature - 2731;
+ enum temp_zone zone;
+ int usb_mv, wpc_mv;
+ static int previous_usb_mv;
+ int val;
+
+ if (curr->state != ST_CHARGE)
+ return 0;
+
+ /* Limit input (=VBUS) to 5V when soc > 85% and charge current < 1A. */
+ if (!(curr->batt.flags & BATT_FLAG_BAD_CURRENT) &&
+ charge_get_percent() > BAT_LEVEL_PD_LIMIT &&
+ curr->batt.current < 1000 &&
+ curr->batt.current > 0) {
+ usb_mv = 5500;
+ wpc_mv = 5500;
+ } else {
+ usb_mv = PD_MAX_VOLTAGE_MV;
+ wpc_mv = P9221_DC_IVL_EPP_MV;
+ }
+
+ if (usb_mv != previous_usb_mv)
+ CPRINTS("VBUS limited to %dmV", usb_mv);
+ previous_usb_mv = usb_mv;
+
+ /* Pull down USB VBUS */
+ if (pd_get_max_voltage() != usb_mv)
+ pd_set_external_voltage_limit(0, usb_mv);
+
+ /*
+ * Pull down WPC VBUS. Need to use raw i2c APIs because RO
+ * doesn't have p9221 driver. If WPC is off, this is a no-op.
+ */
+ if (i2c_read_offset16__7bf(I2C_PORT_WPC, P9221_R7_ADDR__7bf,
+ P9221R7_VOUT_SET_REG, &val, 1) == EC_SUCCESS
+ && val * 100 != wpc_mv)
+ i2c_write_offset16__7bf(I2C_PORT_WPC, P9221_R7_ADDR__7bf,
+ P9221R7_VOUT_SET_REG, wpc_mv / 100, 1);
+
+ if ((curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE) ||
+ (temp < temp_zones[batt_type][TEMP_ZONE_0].temp_min)) {
+ zone = TEMP_OUT_OF_RANGE;
+ } else {
+ for (zone = TEMP_ZONE_0; zone < TEMP_ZONE_COUNT; zone++) {
+ if (temp < temp_zones[batt_type][zone].temp_max)
+ break;
+ }
+ }
+
+ if (zone == TEMP_OUT_OF_RANGE || zone >= TEMP_ZONE_COUNT) {
+ curr->requested_current = curr->requested_voltage = 0;
+ curr->batt.flags &= ~BATT_FLAG_WANT_CHARGE;
+ curr->state = ST_IDLE;
+ } else {
+ curr->requested_current =
+ temp_zones[batt_type][zone].desired_current;
+ curr->requested_voltage =
+ temp_zones[batt_type][zone].desired_voltage;
+ }
+
+ /*
+ * When the charger says it's done charging, even if fuel gauge says
+ * SOC < BATTERY_LEVEL_NEAR_FULL, we'll overwrite SOC with
+ * BATTERY_LEVEL_NEAR_FULL. So we can ensure both Chrome OS UI
+ * and battery LED indicate full charge.
+ */
+ if (rt946x_is_charge_done()) {
+ curr->batt.state_of_charge = MAX(BATTERY_LEVEL_NEAR_FULL,
+ curr->batt.state_of_charge);
+ }
+
+ return 0;
+}
+
+static void board_charge_termination(void)
+{
+ static uint8_t te;
+ /* Enable charge termination when we are sure battery is present. */
+ if (!te && battery_is_present() == BP_YES) {
+ if (!rt946x_enable_charge_termination(1))
+ te = 1;
+ }
+}
+DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE,
+ board_charge_termination,
+ HOOK_PRIO_DEFAULT);
+
+/* Customs options controllable by host command. */
+#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0)
+
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value)
+{
+ return EC_RES_INVALID_PARAM;
+}
diff --git a/board/flapjack/board.c b/board/flapjack/board.c
index c8524dca4e..b5be3ff1d6 100644
--- a/board/flapjack/board.c
+++ b/board/flapjack/board.c
@@ -138,12 +138,12 @@ static void board_setup_panel(void)
dim = sku & SKU_ID_PANEL_SIZE_MASK ? 0xc4 : 0xc8;
}
- rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLEN,
- channel);
- rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLDIM,
- dim);
- rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLPWM,
- 0xac);
+ rv |= i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf,
+ MT6370_BACKLIGHT_BLEN, channel);
+ rv |= i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf,
+ MT6370_BACKLIGHT_BLDIM, dim);
+ rv |= i2c_write8__7bf(I2C_PORT_CHARGER, RT946X_ADDR__7bf,
+ MT6370_BACKLIGHT_BLPWM, 0xac);
if (rv)
CPRINTS("Board setup panel failed\n");
}
@@ -287,7 +287,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = MT6370_TCPC_I2C_ADDR,
+ .addr__7bf = MT6370_TCPC_I2C_ADDR__7bf,
},
.drv = &mt6370_tcpm_drv},
};
@@ -499,7 +499,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -522,7 +522,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -537,7 +537,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &tcs3400_drv,
.drv_data = &g_tcs3400_data,
.port = I2C_PORT_ALS,
- .addr = TCS3400_I2C_ADDR,
+ .i2c_spi_addr__7bf = TCS3400_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
.min_frequency = TCS3400_LIGHT_MIN_FREQ,
diff --git a/board/flapjack/board.h b/board/flapjack/board.h
new file mode 100644
index 0000000000..13a010f416
--- /dev/null
+++ b/board/flapjack/board.h
@@ -0,0 +1,331 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Configuration for Kukui */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+/* Optional modules */
+#define CONFIG_ADC
+#undef CONFIG_ADC_WATCHDOG
+#define CONFIG_BOARD_VERSION_CBI
+#define CONFIG_CHIPSET_MT8183
+#define CONFIG_CMD_ACCELS
+#define CONFIG_CRC8
+#define CONFIG_CROS_BOARD_INFO
+#define CONFIG_EMULATED_SYSRQ
+#undef CONFIG_HIBERNATE
+#define CONFIG_I2C
+#define CONFIG_I2C_MASTER
+#define CONFIG_I2C_VIRTUAL_BATTERY
+#define CONFIG_I2C_PASSTHRU_RESTRICTED
+#define CONFIG_LED_COMMON
+#define CONFIG_LOW_POWER_IDLE
+#define CONFIG_POWER_COMMON
+#define CONFIG_SPI
+#define CONFIG_SPI_MASTER
+#define CONFIG_STM_HWTIMER32
+#define CONFIG_SWITCH
+#define CONFIG_WATCHDOG_HELP
+
+#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands for testing */
+
+#undef CONFIG_UART_CONSOLE
+#define CONFIG_UART_CONSOLE 1
+#define CONFIG_UART_RX_DMA
+
+/* Bootblock */
+#ifdef SECTION_IS_RO
+#define CONFIG_BOOTBLOCK
+
+#define EMMC_SPI_PORT 2
+#endif
+
+/* Optional features */
+#define CONFIG_BOARD_PRE_INIT
+#define CONFIG_BUTTON_TRIGGERED_RECOVERY
+#define CONFIG_CHARGER_ILIM_PIN_DISABLED
+#define CONFIG_FORCE_CONSOLE_RESUME
+#define CONFIG_HOST_COMMAND_STATUS
+#define CONFIG_CMD_AP_RESET_LOG
+
+/* Required for FAFT */
+#define CONFIG_CMD_BUTTON
+
+/* By default, set hcdebug to off */
+#undef CONFIG_HOSTCMD_DEBUG_MODE
+#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
+#define CONFIG_LTO
+#define CONFIG_POWER_BUTTON
+#define CONFIG_POWER_BUTTON_IGNORE_LID
+#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
+#define CONFIG_SOFTWARE_PANIC
+#define CONFIG_VBOOT_HASH
+#define CONFIG_VOLUME_BUTTONS
+
+#define CONFIG_CHARGER
+#define CONFIG_CHARGER_MT6370
+#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_V2
+#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
+#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2
+#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
+#define CONFIG_CHARGER_PROFILE_OVERRIDE
+#define CONFIG_CHARGER_DISCHARGE_ON_AC
+#define CONFIG_CHARGER_OTG
+#define CONFIG_USB_CHARGER
+#define CONFIG_USB_MUX_VIRTUAL
+
+/* Increase tx buffer size, as we'd like to stream EC log to AP. */
+#undef CONFIG_UART_TX_BUF_SIZE
+#define CONFIG_UART_TX_BUF_SIZE 4096
+
+/* Motion Sensors */
+#ifdef SECTION_IS_RW
+#define CONFIG_ACCELGYRO_BMI160
+#define CONFIG_ACCEL_INTERRUPTS
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
+
+#define CONFIG_ALS
+#define ALS_COUNT 1
+
+/* TSC3400 ALS */
+#define CONFIG_ALS_TCS3400
+#define CONFIG_ALS_TCS3400_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(CLEAR_ALS)
+
+/* ALS needs to be polled */
+#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(CLEAR_ALS)
+
+/* Camera VSYNC */
+#define CONFIG_SYNC
+#define CONFIG_SYNC_COMMAND
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
+#endif /* SECTION_IS_RW */
+
+/* To be able to indicate the device is in tablet mode. */
+#define CONFIG_TABLET_MODE
+#define CONFIG_TABLET_MODE_SWITCH
+
+/* FIFO size is in power of 2. */
+#define CONFIG_ACCEL_FIFO 256
+#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
+
+/* Wireless Power Charger Config */
+#ifdef SECTION_IS_RW
+#define CONFIG_WIRELESS_CHARGER_P9221_R7
+#endif
+
+
+/* USB PD config */
+#define CONFIG_CHARGE_MANAGER
+#define CONFIG_USB_POWER_DELIVERY
+#define CONFIG_USB_PD_ALT_MODE
+#define CONFIG_USB_PD_ALT_MODE_DFP
+#define CONFIG_USB_PD_DISCHARGE_TCPC
+#define CONFIG_USB_PD_DUAL_ROLE
+#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
+#define CONFIG_USB_PD_LOGGING
+#define CONFIG_USB_PD_PORT_COUNT 1
+#define CONFIG_USB_PD_TCPC_LOW_POWER
+#define CONFIG_USB_PD_TCPM_MT6370
+#define CONFIG_USB_PD_TCPM_TCPCI
+#define CONFIG_USB_PD_VBUS_DETECT_TCPC
+#define CONFIG_USB_PD_5V_CHARGER_CTRL
+#define CONFIG_USBC_SS_MUX
+#define CONFIG_USBC_VCONN
+#define CONFIG_USBC_VCONN_SWAP
+#define CONFIG_USB_PD_COMM_LOCKED
+#define CONFIG_USBC_DISABLE_CHARGE_FROM_RP_DEF
+#ifdef SECTION_IS_RO
+#define CONFIG_USB_PD_DEBUG_LEVEL 0
+#endif
+
+#define CONFIG_BATTERY_CUT_OFF
+#define CONFIG_BATTERY_PRESENT_CUSTOM
+#define CONFIG_BATTERY_REVIVE_DISCONNECT
+#define CONFIG_BATTERY_MAX17055
+#define CONFIG_BATTERY_MAX17055_ALERT
+#define CONFIG_BATTERY_MAX17055_FULL_MODEL
+
+/* Battery parameters for max17055 ModelGauge m5 algorithm. */
+#define BATTERY_MAX17055_RSENSE 10 /* m-ohm */
+#define BATTERY_DESIRED_CHARGING_CURRENT 2000 /* mA */
+
+#define PD_OPERATING_POWER_MW 15000
+#define PD_MAX_VOLTAGE_MV 9000
+#define PD_MAX_CURRENT_MA 3000
+#define PD_MAX_POWER_MW 18000
+
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */
+#define PD_VCONN_SWAP_DELAY 5000 /* us */
+
+/* Timer selection */
+#define TIM_CLOCK32 2
+#define TIM_WATCHDOG 7
+
+/* 48 MHz SYSCLK clock frequency */
+#define CPU_CLOCK 48000000
+
+/* Optional for testing */
+#undef CONFIG_PECI
+#undef CONFIG_PSTORE
+
+/* Modules we want to exclude */
+#undef CONFIG_CMD_ACCELSPOOF
+#undef CONFIG_CMD_APTHROTTLE
+#undef CONFIG_CMD_BATTFAKE
+#undef CONFIG_CMD_DEVICE_EVENT
+#undef CONFIG_CMD_FASTCHARGE
+#undef CONFIG_CMD_FLASH
+#undef CONFIG_CMD_GETTIME
+#undef CONFIG_CMD_HASH
+#undef CONFIG_CMD_HCDEBUG
+#undef CONFIG_CMD_MD
+#undef CONFIG_CMD_MEM
+#undef CONFIG_CMD_POWERINDEBUG
+#undef CONFIG_CMD_TIMERINFO
+
+#ifdef SECTION_IS_RO
+#undef CONFIG_CMD_ADC
+#undef CONFIG_CMD_APTHROTTLE
+#undef CONFIG_CMD_CBI
+#undef CONFIG_CMD_I2C_SCAN
+#undef CONFIG_CMD_I2C_XFER
+#undef CONFIG_CMD_IDLE_STATS
+#undef CONFIG_CMD_INA
+#undef CONFIG_CMD_MMAPINFO
+#undef CONFIG_CMD_PD
+#undef CONFIG_CMD_PWR_AVG
+#undef CONFIG_CMD_REGULATOR
+#undef CONFIG_CMD_RW
+#undef CONFIG_CMD_SHMEM
+/* TODO: Consider put these back when FSI is (about to be) done. */
+#undef CONFIG_CMD_SLEEPMASK
+#undef CONFIG_CMD_SLEEPMASK_SET
+#undef CONFIG_CMD_SYSLOCK
+#endif
+
+#define CONFIG_TASK_PROFILING
+
+/* I2C ports */
+#define I2C_PORT_CHARGER 0
+#define I2C_PORT_TCPC0 0
+#define I2C_PORT_WPC 0
+#define I2C_PORT_BATTERY 1
+#define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY
+#define I2C_PORT_ACCEL 1
+#define I2C_PORT_ALS 1
+#define I2C_PORT_EEPROM 1
+
+/* I2C addresses */
+#define I2C_ADDR_EEPROM__7bf 0x50
+
+/* Route sbs host requests to virtual battery driver */
+#define VIRTUAL_BATTERY_ADDR__7bf 0x0B
+
+/* Enable Accel over SPI */
+#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */
+
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
+#define CONFIG_MKBP_EVENT
+#define CONFIG_MKBP_USE_GPIO
+/* Define the host events which are allowed to wakeup AP in S3. */
+#define CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK \
+ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\
+ EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC))
+
+/* Define panel size mask according to skuid */
+#define SKU_ID_PANEL_SIZE_MASK BIT(1)
+
+#ifndef __ASSEMBLER__
+
+enum oem_id {
+ PROJECT_FLAPJACK = 0,
+ PROJECT_COUNT,
+};
+
+enum adc_channel {
+ /* Real ADC channels begin here */
+ ADC_LCM_ID = 0,
+ ADC_EC_SKU_ID,
+ ADC_BATT_ID,
+ ADC_USBC_THERM,
+ ADC_CH_COUNT
+};
+
+/* Panel ID bit position inside sku_id */
+#define PANEL_ID_BIT_POSITION 16
+
+/* Refer to coreboot/src/mainboard/google/kukui/display.h */
+enum panel_id {
+ PANEL_DEFAULT = 0,
+ PANEL_BOE_TV101WUM_NG0,
+ PANEL_BOE_TV080WUM_NG0,
+ PANEL_STA_10P,
+ PANEL_STA_08P,
+ PANEL_COUNT,
+ PANEL_UNINITIALIZED = 0xf,
+};
+
+/* power signal definitions */
+enum power_signal {
+ AP_IN_S3_L,
+ PMIC_PWR_GOOD,
+
+ /* Number of signals */
+ POWER_SIGNAL_COUNT,
+};
+
+/* Motion sensors */
+enum sensor_id {
+ LID_ACCEL = 0,
+ LID_GYRO,
+ CLEAR_ALS,
+ RGB_ALS,
+ VSYNC,
+ SENSOR_COUNT,
+};
+
+/* Batteries */
+enum battery_type {
+ BATTERY_UNKNOWN = 0,
+ BATTERY_C18_ATL,
+ BATTERY_C19_ATL,
+ BATTERY_C18_SUNWODA,
+ BATTERY_C19_SUNWODA,
+ BATTERY_COUNT,
+};
+
+#include "gpio_signal.h"
+#include "registers.h"
+
+#ifdef SECTION_IS_RO
+/* Interrupt handler for emmc task */
+void emmc_cmd_interrupt(enum gpio_signal signal);
+#endif
+
+void board_reset_pd_mcu(void);
+
+#define ADC_MARGIN_MV 56 /* Simply assume 1800/16/2 */
+
+struct mv_to_id {
+ int id;
+ int median_mv;
+};
+
+int board_read_id(enum adc_channel, const struct mv_to_id *table, int size);
+
+extern uint8_t board_version;
+extern uint8_t oem;
+extern uint32_t sku;
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/fleex/board.c b/board/fleex/board.c
index 9406e1b2c9..444d585308 100644
--- a/board/fleex/board.c
+++ b/board/fleex/board.c
@@ -48,17 +48,7 @@
#define USB_PD_PORT_ANX7447 0
#define USB_PD_PORT_PS8751 1
-static void tcpc_alert_event(enum gpio_signal signal)
-{
- if ((signal == GPIO_USB_C1_MUX_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
- return;
-
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
-}
+static uint8_t sku_id;
static void ppc_interrupt(enum gpio_signal signal)
{
@@ -90,15 +80,6 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-enum adc_channel board_get_vbus_adc(int port)
-{
- if (port == USB_PD_PORT_ANX7447)
- return ADC_VBUS_C0;
- if (port == USB_PD_PORT_PS8751)
- return ADC_VBUS_C1;
- return ADC_VBUS_C0;
-}
-
const struct temp_sensor_t temp_sensors[] = {
[TEMP_SENSOR_BATTERY] = {.name = "Battery",
.type = TEMP_SENSOR_TYPE_BATTERY,
@@ -140,35 +121,34 @@ const mat33_fp_t lid_standard_ref = {
static struct stprivate_data g_lis2dh_data;
static struct lsm6dsm_data lsm6dsm_data;
-static uint16_t sku_id;
/* Drivers */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LIS2DE,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &lis2dh_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_lis2dh_data,
- .port = I2C_PORT_SENSOR,
- .addr = LIS2DH_ADDR1,
- .rot_standard_ref = &lid_standard_ref,
- .default_range = 2, /* g */
- /* We only use 2g because its resolution is only 8-bits */
- .min_frequency = LIS2DH_ODR_MIN_VAL,
- .max_frequency = LIS2DH_ODR_MAX_VAL,
- .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_LIS2DE,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &lis2dh_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_lis2dh_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LIS2DH_ADDR1__7bf,
+ .rot_standard_ref = &lid_standard_ref,
+ .default_range = 2, /* g */
+ /* We only use 2g because its resolution is only 8-bits */
+ .min_frequency = LIS2DH_ODR_MIN_VAL,
+ .max_frequency = LIS2DH_ODR_MAX_VAL,
+ .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,
+ },
},
- },
},
[BASE_ACCEL] = {
@@ -184,7 +164,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -216,7 +196,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -231,12 +211,19 @@ static int board_is_convertible(void)
return sku_id == 0x21 || sku_id == 0x22 || sku_id == 0xff;
}
-static void board_set_motion_sensor_count(void)
+static void board_update_sensor_config_from_sku(void)
{
- if (board_is_convertible())
+ if (board_is_convertible()) {
motion_sensor_count = ARRAY_SIZE(motion_sensors);
- else
+ /* Enable Base Accel interrupt */
+ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ } else {
motion_sensor_count = 0;
+ hall_sensor_disable();
+ /* Base accel is not stuffed, don't allow line to float */
+ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L,
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ }
}
static void cbi_init(void)
@@ -247,18 +234,10 @@ static void cbi_init(void)
sku_id = val;
ccprints("SKU: 0x%04x", sku_id);
- board_set_motion_sensor_count();
+ board_update_sensor_config_from_sku();
}
DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
-/* Initialize board. */
-static void board_init(void)
-{
- /* Enable Base Accel interrupt */
- gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
#ifndef TEST_BUILD
/* This callback disables keyboard when convertibles are fully open */
void lid_angle_peripheral_enable(int enable)
@@ -275,32 +254,12 @@ void lid_angle_peripheral_enable(int enable)
}
#endif
-/*
- * Set gpio flags based on board ID, can be removed when proto is no longer
- * supported
- */
-static void update_gpios_from_board_id(void)
+void board_overcurrent_event(int port, int is_overcurrented)
{
- uint32_t board_id = 0;
-
- /* Errors will count as board_id 0 */
- cbi_get_board_version(&board_id);
-
- if (board_id == 0) {
- /*
- * USB2_OTG_ID is a 1.8V pin on the SoC side with an internal
- * pull-up. However, it is 3.3V on the EC side. So, configure
- * it as ODR so that the EC never drives it high.
- */
- gpio_set_flags(GPIO_USB_C0_PD_RST, GPIO_ODR_LOW);
- } else {
- int flags = GPIO_OUTPUT;
-
- if (!system_is_reboot_warm() && !system_jumped_to_this_image())
- flags |= GPIO_LOW;
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
- gpio_set_flags(GPIO_USB_C0_PD_RST, flags);
- }
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
}
-
-DECLARE_HOOK(HOOK_INIT, update_gpios_from_board_id, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/fluffy/board.c b/board/fluffy/board.c
new file mode 100644
index 0000000000..4631b4a851
--- /dev/null
+++ b/board/fluffy/board.c
@@ -0,0 +1,405 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Fluffy configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "common.h"
+#include "console.h"
+#include "ec_version.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "usb_descriptor.h"
+#include "registers.h"
+#include "timer.h"
+#include "usb_pd.h"
+#include "util.h"
+
+#include "gpio_list.h"
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
+
+/******************************************************************************
+ * Define the strings used in our USB descriptors.
+ */
+
+const void *const usb_strings[] = {
+ [USB_STR_DESC] = usb_string_desc,
+ [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."),
+ [USB_STR_PRODUCT] = USB_STRING_DESC("Fluffy"),
+ /* This gets filled in at runtime. */
+ [USB_STR_SERIALNO] = USB_STRING_DESC(""),
+ [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
+ [USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Fluffy Shell"),
+};
+
+BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
+
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ /* Sensing the VBUS voltage at the DUT side. Converted to mV. */
+ [ADC_PPVAR_VBUS_DUT] = {
+ .name = "PPVAR_VBUS_DUT",
+ .factor_mul = 3300,
+ .factor_div = 4096,
+ .shift = 0,
+ .channel = STM32_AIN(0),
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* I2C ports */
+const struct i2c_port_t i2c_ports[] = {
+ {
+ .name = "master",
+ .port = 1,
+ .kbps = 400,
+ .scl = GPIO_I2C_SCL,
+ .sda = GPIO_I2C_SDA,
+ },
+};
+const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+static enum gpio_signal enabled_port = GPIO_EN_C0;
+static uint8_t output_en;
+
+static void print_port_status(void)
+{
+ if (!output_en)
+ CPRINTS("No ports enabled. zZZ");
+ else
+ CPRINTS("Port %d is ON", enabled_port - GPIO_EN_C0);
+
+ CPRINTS("CC Flip: %s", gpio_get_level(GPIO_EN_CC_FLIP) ? "YES" : "NO");
+ CPRINTS("USB MUX: %s", gpio_get_level(GPIO_EN_USB_MUX2) ? "ON" : "OFF");
+}
+
+static int command_cc_flip(int argc, char *argv[])
+{
+ int enable;
+
+ if (argc != 2)
+ return EC_ERROR_PARAM_COUNT;
+
+ if (!parse_bool(argv[1], &enable))
+ return EC_ERROR_INVAL;
+
+ if (output_en) {
+ gpio_set_level(enabled_port, 0);
+ gpio_set_level(GPIO_EN_USB_MUX2, 0);
+ /* Wait long enough for CC to discharge. */
+ usleep(500 * MSEC);
+ }
+
+ gpio_set_level(GPIO_EN_CC_FLIP, enable);
+ /* Allow some time for new CC configuration to settle. */
+ usleep(500 * MSEC);
+
+ if (output_en) {
+ gpio_set_level(enabled_port, 1);
+ gpio_set_level(GPIO_EN_USB_MUX2, 1);
+ }
+
+ print_port_status();
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(ccflip, command_cc_flip,
+ "<enable/disable>",
+ "enable or disable flipping CC orientation");
+/*
+ * Support tca6416 I2C ioexpander.
+ */
+#define GPIOX_I2C_ADDR__7bf 0x20
+#define GPIOX_IN_PORT_A 0x0
+#define GPIOX_IN_PORT_B 0x1
+#define GPIOX_OUT_PORT_A 0x2
+#define GPIOX_OUT_PORT_B 0x3
+#define GPIOX_DIR_PORT_A 0x6
+#define GPIOX_DIR_PORT_B 0x7
+#define I2C_PORT_MASTER 1
+
+static void i2c_expander_init(void)
+{
+ gpio_set_level(GPIO_XP_RESET_L, 1);
+
+ /*
+ * Setup P00, P02, P04, P10, and P12 on the I/O expander as an output.
+ */
+ i2c_write8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ GPIOX_DIR_PORT_A, 0xea);
+ i2c_write8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ GPIOX_DIR_PORT_B, 0xfa);
+}
+DECLARE_HOOK(HOOK_INIT, i2c_expander_init, HOOK_PRIO_INIT_I2C+1);
+
+/* Write to a GPIO register on the tca6416 I2C ioexpander. */
+static void write_ioexpander(int bank, int gpio, int reg, int val)
+{
+ int tmp;
+
+ /* Read output port register */
+ i2c_read8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ reg + bank, &tmp);
+ if (val)
+ tmp |= BIT(gpio);
+ else
+ tmp &= ~BIT(gpio);
+ /* Write back modified output port register */
+ i2c_write8__7bf(I2C_PORT_MASTER, GPIOX_I2C_ADDR__7bf,
+ reg + bank, tmp);
+}
+
+enum led_ch {
+ LED_5V = 0,
+ LED_9V,
+ LED_12V,
+ LED_15V,
+ LED_20V,
+ LED_COUNT,
+};
+
+static void set_led(enum led_ch led, int enable)
+{
+ int bank;
+ int gpio;
+
+ switch (led) {
+ case LED_5V:
+ bank = 0;
+ gpio = 0;
+ break;
+
+ case LED_9V:
+ bank = 0;
+ gpio = 2;
+ break;
+
+ case LED_12V:
+ bank = 0;
+ gpio = 4;
+ break;
+
+ case LED_15V:
+ bank = 1;
+ gpio = 0;
+ break;
+
+ case LED_20V:
+ bank = 1;
+ gpio = 2;
+ break;
+
+ default:
+ return;
+ }
+
+ /*
+ * Setup the LED as an output if enabled, otherwise as an input to keep
+ * the LEDs off.
+ */
+ write_ioexpander(bank, gpio, GPIOX_DIR_PORT_A, !enable);
+
+ /* The LEDs are active low. */
+ if (enable)
+ write_ioexpander(bank, gpio, GPIOX_OUT_PORT_A, 0);
+}
+
+void show_output_voltage_on_leds(void);
+DECLARE_DEFERRED(show_output_voltage_on_leds);
+
+static void board_init(void)
+{
+ /* Do a sweeping LED dance. */
+ for (enum led_ch led = 0; led < LED_COUNT; led++) {
+ set_led(led, 1);
+ msleep(100);
+ }
+
+ msleep(500);
+
+ for (enum led_ch led = 0; led < LED_COUNT; led++)
+ set_led(led, 0);
+
+ show_output_voltage_on_leds();
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+
+enum usb_mux {
+ USB_MUX0 = 0,
+ USB_MUX1,
+ USB_MUX2,
+ USB_MUX_COUNT,
+};
+
+static void set_mux(enum usb_mux mux, uint8_t val)
+{
+ enum gpio_signal c0;
+ enum gpio_signal c1;
+ enum gpio_signal c2;
+
+ switch (mux) {
+ case USB_MUX0:
+ c0 = GPIO_USB_MUX0_C0;
+ c1 = GPIO_USB_MUX0_C1;
+ c2 = GPIO_USB_MUX0_C2;
+ break;
+
+ case USB_MUX1:
+ c0 = GPIO_USB_MUX1_C0;
+ c1 = GPIO_USB_MUX1_C1;
+ c2 = GPIO_USB_MUX1_C2;
+ break;
+
+ case USB_MUX2:
+ c0 = GPIO_USB_MUX2_C0;
+ c1 = GPIO_USB_MUX2_C1;
+ c2 = GPIO_USB_MUX2_C2;
+ break;
+
+ default:
+ break;
+ }
+
+ val &= 0x7;
+
+ gpio_set_level(c0, val & BIT(0));
+ gpio_set_level(c1, val & BIT(1));
+ gpio_set_level(c2, val & BIT(2));
+}
+
+/* This function assumes only 1 port works at a time. */
+static int command_portctl(int argc, char **argv)
+{
+ int port;
+ int enable;
+
+ if (argc < 2)
+ return EC_ERROR_PARAM_COUNT;
+
+ port = atoi(argv[1]);
+ if ((port < 0) || (port > 19) || !parse_bool(argv[2], &enable))
+ return EC_ERROR_INVAL;
+
+ gpio_set_level(GPIO_EN_USB_MUX2, 0);
+
+ /*
+ * For each port, we must configure the USB 2.0 muxes and make sure that
+ * the power enables are configured as desired.
+ */
+
+ gpio_set_level(enabled_port, 0);
+ if (enabled_port != GPIO_EN_C0 + port)
+ CPRINTS("Port %d: disabled", enabled_port-GPIO_EN_C0);
+
+ /* Allow time for an "unplug" to allow VBUS and CC to fall. */
+ usleep(1 * SECOND);
+
+ /*
+ * The USB 2.0 lines are arranged using 3x 8:1 muxes. Ports 0-7 are
+ * handled by the first mux, ports 8-15 are handled by the 2nd mux, then
+ * the outputs of those muxes are fed into the third mux along with
+ * ports 16-19. The schematic contains the truth table.
+ */
+ if (enable) {
+ enabled_port = GPIO_EN_C0 + port;
+ gpio_set_level(enabled_port, 1);
+
+ if (port < 8) {
+ set_mux(USB_MUX0, 7-port);
+ set_mux(USB_MUX2, 3);
+ } else if (port < 16) {
+ if (port < 14)
+ set_mux(USB_MUX1, 5-(port-8));
+ else
+ set_mux(USB_MUX1, 7-(port-14));
+
+ set_mux(USB_MUX2, 1);
+ } else {
+ set_mux(USB_MUX2, 7-(port-16));
+ }
+
+ gpio_set_level(GPIO_EN_USB_MUX2, 1);
+ output_en = 1;
+ } else {
+ gpio_set_level(enabled_port, 0);
+ output_en = 0;
+ }
+
+ print_port_status();
+ return EC_SUCCESS;
+}
+
+DECLARE_CONSOLE_COMMAND(portctl, command_portctl,
+ "<port# 0-19> <enable/disable>",
+ "enable or disable a port");
+
+static int command_status(int argc, char **argv)
+{
+ int vbus_mv = adc_read_channel(ADC_PPVAR_VBUS_DUT);
+
+ CPRINTS("PPVAR_VBUS_DUT: %dmV (raw: %d)", vbus_mv*7692/1000,
+ vbus_mv);
+ print_port_status();
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(status, command_status, NULL, "show current status");
+
+/*
+ * According to the USB PD Spec, the minimum voltage for a fixed source is 95%
+ * of the new source voltage with an additional 500mV drop.
+ *
+ * vSrcNew | min | vSrcNew(min) + vSrcValid
+ * 5V | 4.75V | 4.25V | 553mV
+ * 9V | 8.55V | 8.05V | 1047mV
+ * 12V | 11.4V | 10.9V | 1417mV
+ * 15V | 14.25V | 13.75V | 1788mV
+ * 20V | 19V | 18.5V | 2405mV
+ *
+ * With the resistor divider that fluffy has, the ADC is only seeing 0.13 of the
+ * actual voltage.
+ */
+void show_output_voltage_on_leds(void)
+{
+ int vbus_mv = adc_read_channel(ADC_PPVAR_VBUS_DUT);
+ static int prev_vbus_mv;
+ int i;
+ int act;
+ enum led_ch max_on_exclusive = LED_5V;
+
+ if (vbus_mv != ADC_READ_ERROR) {
+ if (vbus_mv >= 2405)
+ max_on_exclusive = LED_COUNT;
+ else if (vbus_mv >= 1788)
+ max_on_exclusive = LED_20V;
+ else if (vbus_mv >= 1417)
+ max_on_exclusive = LED_15V;
+ else if (vbus_mv >= 1047)
+ max_on_exclusive = LED_12V;
+ else if (vbus_mv >= 553)
+ max_on_exclusive = LED_9V;
+
+ for (i = 0; i < LED_COUNT; i++)
+ set_led(i, i < max_on_exclusive);
+
+ act = (vbus_mv * 7692) / 1000;
+ if ((vbus_mv > prev_vbus_mv+2) || (vbus_mv < prev_vbus_mv-2)) {
+ CPRINTS("PPVAR_VBUS_DUT: %d mV (raw: %d)", act,
+ vbus_mv);
+ prev_vbus_mv = vbus_mv;
+ }
+ }
+
+ /*
+ * The reason we reschedule this ourselves as opposed to declaring it as
+ * a hook with a HOOK_TICK period is to allow the LED sweep sequence
+ * when the board boots up.
+ */
+ hook_call_deferred(&show_output_voltage_on_leds_data,
+ 500 * MSEC);
+}
diff --git a/board/garg/board.c b/board/garg/board.c
new file mode 100644
index 0000000000..b0ec0ef955
--- /dev/null
+++ b/board/garg/board.c
@@ -0,0 +1,337 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Garg board-specific configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "battery.h"
+#include "button.h"
+#include "charge_manager.h"
+#include "charge_state.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "driver/accel_kionix.h"
+#include "driver/accelgyro_bmi160.h"
+#include "driver/charger/bd9995x.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/sync.h"
+#include "driver/tcpm/anx7447.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/tcpci.h"
+#include "driver/tcpm/tcpm.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "keyboard_scan.h"
+#include "lid_switch.h"
+#include "motion_sense.h"
+#include "power.h"
+#include "power_button.h"
+#include "switch.h"
+#include "system.h"
+#include "tablet_mode.h"
+#include "tcpci.h"
+#include "temp_sensor.h"
+#include "thermistor.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+
+#define USB_PD_PORT_ANX7447 0
+#define USB_PD_PORT_PS8751 1
+
+static uint8_t sku_id;
+
+/*
+ * We have total 30 pins for keyboard connecter {-1, -1} mean
+ * the N/A pin that don't consider it and reserve index 0 area
+ * that we don't have pin 0.
+ */
+const int keyboard_factory_scan_pins[][2] = {
+ {-1, -1}, {0, 5}, {1, 1}, {1, 0}, {0, 6},
+ {0, 7}, {-1, -1}, {-1, -1}, {1, 4}, {1, 3},
+ {-1, -1}, {1, 6}, {1, 7}, {3, 1}, {2, 0},
+ {1, 5}, {2, 6}, {2, 7}, {2, 1}, {2, 4},
+ {2, 5}, {1, 2}, {2, 3}, {2, 2}, {3, 0},
+ {-1, -1}, {0, 4}, {-1, -1}, {8, 2}, {-1, -1},
+ {-1, -1},
+};
+
+const int keyboard_factory_scan_pins_used =
+ ARRAY_SIZE(keyboard_factory_scan_pins);
+
+static void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_PD_C0_INT_ODL:
+ nx20p348x_interrupt(0);
+ break;
+
+ case GPIO_USB_PD_C1_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* Must come after other header files and GPIO interrupts*/
+#include "gpio_list.h"
+
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_AMB] = {
+ "TEMP_AMB", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ [ADC_TEMP_SENSOR_CHARGER] = {
+ "TEMP_CHARGER", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ /* Vbus sensing (1/10 voltage divider). */
+ [ADC_VBUS_C0] = {
+ "VBUS_C0", NPCX_ADC_CH9, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
+ [ADC_VBUS_C1] = {
+ "VBUS_C1", NPCX_ADC_CH4, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_BATTERY] = {.name = "Battery",
+ .type = TEMP_SENSOR_TYPE_BATTERY,
+ .read = charge_get_battery_temp,
+ .idx = 0,
+ .action_delay_sec = 1},
+ [TEMP_SENSOR_AMBIENT] = {.name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_AMB,
+ .action_delay_sec = 5},
+ [TEMP_SENSOR_CHARGER] = {.name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_13k7_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_CHARGER,
+ .action_delay_sec = 1},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+/* Motion sensors */
+/* Mutexes */
+static struct mutex g_lid_mutex;
+static struct mutex g_base_mutex;
+
+/* Matrix to rotate accelrator into standard reference frame */
+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)}
+};
+
+/* TODO: Tune the rot_standard_ref values after got mockup or system */
+const mat33_fp_t base_ar_cam_ref = {
+ { 0, FLOAT_TO_FP(-0.96126), FLOAT_TO_FP(0.27564)},
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(0.27564), FLOAT_TO_FP(0.96126)}
+};
+
+/* sensor private data */
+static struct kionix_accel_data g_kx022_data;
+static struct bmi160_drv_data_t g_bmi160_data;
+
+/* Drivers */
+struct motion_sensor_t motion_sensors[] = {
+ [LID_ACCEL] = {
+ .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__7bf = KX022_ADDR1__7bf,
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 4, /* g */
+ .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,
+ },
+ },
+ },
+ [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__7bf = BMI160_ADDR0__7bf,
+ .rot_standard_ref = &base_standard_ref,
+ .default_range = 4, /* g */
+ .min_frequency = BMI160_ACCEL_MIN_FREQ,
+ .max_frequency = BMI160_ACCEL_MAX_FREQ,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 13000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ /* Sensor on for angle detection */
+ [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_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__7bf = BMI160_ADDR0__7bf,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = BMI160_GYRO_MIN_FREQ,
+ .max_frequency = BMI160_GYRO_MAX_FREQ,
+ },
+ [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,
+ },
+};
+
+unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+static int board_is_convertible(void)
+{
+ /* Garg: TBD */
+ return sku_id == 255;
+}
+
+static int board_with_ar_cam(void)
+{
+ /* SKU ID of Garg with AR Cam: TBD */
+ return 255;
+}
+
+static void board_update_sensor_config_from_sku(void)
+{
+ if (board_is_convertible()) {
+ motion_sensor_count = ARRAY_SIZE(motion_sensors);
+ /* Enable Base Accel interrupt */
+ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ } else {
+ motion_sensor_count = 0;
+ hall_sensor_disable();
+ /* Base accel is not stuffed, don't allow line to float */
+ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L,
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ }
+
+ /* TODO: Garg has AR camera? Remove it if not support */
+ if (board_with_ar_cam()) {
+ /* Enable interrupt from camera */
+ gpio_enable_interrupt(GPIO_WFCAM_VSYNC);
+
+ motion_sensors[BASE_ACCEL].rot_standard_ref = &base_ar_cam_ref;
+ motion_sensors[BASE_GYRO].rot_standard_ref = &base_ar_cam_ref;
+ } else {
+ /* Camera isn't stuffed, don't allow line to float */
+ gpio_set_flags(GPIO_WFCAM_VSYNC, GPIO_INPUT | GPIO_PULL_DOWN);
+ }
+}
+
+/* Read CBI from i2c eeprom and initialize variables for board variants */
+static void cbi_init(void)
+{
+ uint32_t val;
+
+ if (cbi_get_sku_id(&val) != EC_SUCCESS || val > UINT8_MAX)
+ return;
+ sku_id = val;
+ CPRINTSUSB("SKU: %d", sku_id);
+
+ board_update_sensor_config_from_sku();
+}
+DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
+
+uint32_t board_override_feature_flags0(uint32_t flags0)
+{
+ /*
+ * Remove keyboard backlight feature for devices that don't support it.
+ */
+ if (sku_id == 255)
+ return flags0;
+ else
+ return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
+}
+
+uint32_t board_override_feature_flags1(uint32_t flags1)
+{
+ return flags1;
+}
+
+void board_hibernate_late(void)
+{
+ int i;
+
+ const uint32_t hibernate_pins[][2] = {
+ /* Turn off LEDs before going to hibernate */
+ {GPIO_BAT_LED_BLUE_L, GPIO_INPUT | GPIO_PULL_UP},
+ {GPIO_BAT_LED_ORANGE_L, GPIO_INPUT | GPIO_PULL_UP},
+ };
+
+ for (i = 0; i < ARRAY_SIZE(hibernate_pins); ++i)
+ gpio_set_flags(hibernate_pins[i][0], hibernate_pins[i][1]);
+}
+
+#ifndef TEST_BUILD
+/* This callback disables keyboard when convertibles are fully open */
+void lid_angle_peripheral_enable(int enable)
+{
+ /*
+ * If the lid is in tablet position via other sensors,
+ * ignore the lid angle, which might be faulty then
+ * disable keyboard.
+ */
+ if (tablet_get_mode())
+ enable = 0;
+ if (board_is_convertible())
+ keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
+}
+#endif
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
+
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
+}
diff --git a/board/glados/battery.c b/board/glados/battery.c
index 016d225950..d6c702127e 100644
--- a/board/glados/battery.c
+++ b/board/glados/battery.c
@@ -47,10 +47,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/glados/board.c b/board/glados/board.c
index c24c3ebef6..46dd4de814 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -48,7 +48,7 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_BD99992__7bf 0x30
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
@@ -133,7 +133,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -141,7 +141,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
},
.drv = &tcpci_tcpm_drv,
},
@@ -176,11 +176,11 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xa8,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
@@ -223,23 +223,23 @@ static void board_pmic_init(void)
return;
/* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x4a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x4a);
/*
* Set V100ACNT / V1.00A Control Register:
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* Set V085ACNT / V0.85A Control Register:
* Lower power mode = 0.7V.
* Nominal output = 1.0V.
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
/* VRMODECTRL - enable low-power mode for VCCIO and V0.85A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x18);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x18);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
diff --git a/board/glados/board.h b/board/glados/board.h
index 0cff78ba60..7393952873 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -134,7 +134,7 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* Ambient Light Sensor address */
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* Modules we want to exclude */
#undef CONFIG_CMD_HASH
diff --git a/board/glados_pd/board.h b/board/glados_pd/board.h
index 9310ee8715..0d513b6e67 100644
--- a/board/glados_pd/board.h
+++ b/board/glados_pd/board.h
@@ -97,7 +97,7 @@
/* slave address for host commands */
#ifdef HAS_TASK_HOSTCMD
-#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR CONFIG_USB_PD_I2C_SLAVE_ADDR
+#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF
#endif
#ifndef __ASSEMBLER__
diff --git a/board/glkrvp/battery.c b/board/glkrvp/battery.c
index bb49336ecf..36dec46702 100644
--- a/board/glkrvp/battery.c
+++ b/board/glkrvp/battery.c
@@ -14,10 +14,10 @@
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
#define I2C_PORT_PCA555_BATT_PRESENT_GPIO NPCX_I2C_PORT0_0
-#define I2C_ADDR_PCA555_BATT_PRESENT_GPIO 0x42
+#define I2C_ADDR_PCA555_BATT_PRESENT_GPIO__7bf 0x21
#define PCA555_BATT_PRESENT_GPIO_READ(reg, data) \
- pca9555_read(I2C_PORT_PCA555_BATT_PRESENT_GPIO, \
- I2C_ADDR_PCA555_BATT_PRESENT_GPIO, (reg), (data))
+ pca9555_read__7bf(I2C_PORT_PCA555_BATT_PRESENT_GPIO, \
+ I2C_ADDR_PCA555_BATT_PRESENT_GPIO__7bf, (reg), (data))
/* Shutdown mode parameter to write to manufacturer access register */
#define SB_SHUTDOWN_DATA 0x0010
diff --git a/board/glkrvp/board.c b/board/glkrvp/board.c
index 898c53971c..1ee956f522 100644
--- a/board/glkrvp/board.c
+++ b/board/glkrvp/board.c
@@ -29,19 +29,19 @@
#include "gpio_list.h"
#define I2C_PORT_PCA555_PMIC_GPIO NPCX_I2C_PORT0_0
-#define I2C_ADDR_PCA555_PMIC_GPIO 0x42
+#define I2C_ADDR_PCA555_PMIC_GPIO__7bf 0x21
#define PCA555_PMIC_GPIO_WRITE(reg, data) \
- pca9555_write(I2C_PORT_PCA555_PMIC_GPIO, \
- I2C_ADDR_PCA555_PMIC_GPIO, (reg), (data))
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_GPIO, \
+ I2C_ADDR_PCA555_PMIC_GPIO__7bf, (reg), (data))
#define PCA555_PMIC_GPIO_READ(reg, data) \
- pca9555_read(I2C_PORT_PCA555_PMIC_GPIO, \
- I2C_ADDR_PCA555_PMIC_GPIO, (reg), (data))
+ pca9555_read__7bf(I2C_PORT_PCA555_PMIC_GPIO, \
+ I2C_ADDR_PCA555_PMIC_GPIO__7bf, (reg), (data))
#define I2C_PORT_PCA555_BOARD_ID_GPIO NPCX_I2C_PORT0_0
-#define I2C_ADDR_PCA555_BOARD_ID_GPIO 0x40
+#define I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf 0x20
#define PCA555_BOARD_ID_GPIO_READ(reg, data) \
- pca9555_read(I2C_PORT_PCA555_BOARD_ID_GPIO, \
- I2C_ADDR_PCA555_BOARD_ID_GPIO, (reg), (data))
+ pca9555_read__7bf(I2C_PORT_PCA555_BOARD_ID_GPIO, \
+ I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf, (reg), (data))
/* power signal list. Must match order of enum power_signal. */
const struct power_signal_info power_signal_list[] = {
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index f1b5b810e5..ac32349cff 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -35,7 +35,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT7_0,
- .addr = 0xa0,
+ .addr__7bf = 0x50,
},
.drv = &tcpci_tcpm_drv,
},
@@ -43,7 +43,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT7_0,
- .addr = 0xa4,
+ .addr__7bf = 0x52,
},
.drv = &tcpci_tcpm_drv,
},
@@ -52,11 +52,11 @@ BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
},
{
- .port_addr = 0x22,
+ .port_addr = 0x11,
.driver = &ps874x_usb_mux_driver,
},
};
diff --git a/board/glkrvp_ite/battery.c b/board/glkrvp_ite/battery.c
index d9d4bf9bf3..5665b1f557 100644
--- a/board/glkrvp_ite/battery.c
+++ b/board/glkrvp_ite/battery.c
@@ -199,8 +199,8 @@ enum battery_present battery_hw_present(void)
int data;
int rv;
- rv = pca9555_read(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ rv = pca9555_read__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_INPUT_PORT_0, &data);
/* GPIO is low when the battery is physically present */
diff --git a/board/glkrvp_ite/board.c b/board/glkrvp_ite/board.c
index fab4e8dde7..21e712b266 100644
--- a/board/glkrvp_ite/board.c
+++ b/board/glkrvp_ite/board.c
@@ -31,7 +31,7 @@
#include "gpio_list.h"
#define I2C_PORT_PCA555_BOARD_ID_GPIO IT83XX_I2C_CH_C
-#define I2C_ADDR_PCA555_BOARD_ID_GPIO 0x40
+#define I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf 0x20
/* power signal list. Must match order of enum power_signal. */
const struct power_signal_info power_signal_list[] = {
@@ -70,8 +70,8 @@ void chipset_pre_init_callback(void)
{
int data;
- if (pca9555_read(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ if (pca9555_read__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, &data))
return;
@@ -85,16 +85,17 @@ void chipset_pre_init_callback(void)
/* Enable SOC_3P3_EN_L: Set the Output port O0.1 to low level */
data &= ~PCA9555_IO_1;
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, data);
/* TODO: Find out from the spec */
msleep(10);
/* Enable PMIC_EN: Set the Output port O0.0 to high level */
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO, PCA9555_CMD_OUTPUT_PORT_0,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
+ PCA9555_CMD_OUTPUT_PORT_0,
data | PCA9555_IO_0);
}
@@ -120,23 +121,24 @@ void chipset_do_shutdown(void)
{
int data;
- if (pca9555_read(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ if (pca9555_read__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, &data))
return;
/* Disable SOC_3P3_EN_L: Set the Output port O0.1 to high level */
data |= PCA9555_IO_1;
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, data);
/* TODO: Find out from the spec */
msleep(10);
/* Disable PMIC_EN: Set the Output port O0.0 to low level */
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO, PCA9555_CMD_OUTPUT_PORT_0,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
+ PCA9555_CMD_OUTPUT_PORT_0,
data & ~PCA9555_IO_0);
}
@@ -160,8 +162,9 @@ int board_get_version(void)
{
int data;
- if (pca9555_read(I2C_PORT_PCA555_BOARD_ID_GPIO,
- I2C_ADDR_PCA555_BOARD_ID_GPIO, PCA9555_CMD_INPUT_PORT_1, &data))
+ if (pca9555_read__7bf(I2C_PORT_PCA555_BOARD_ID_GPIO,
+ I2C_ADDR_PCA555_BOARD_ID_GPIO__7bf,
+ PCA9555_CMD_INPUT_PORT_1, &data))
return -1;
return data & 0x0f;
@@ -178,8 +181,8 @@ static void pmic_init(void)
* Configure Port O0.0 as Output port - PMIC_EN
* Configure Port O0.1 as Output port - SOC_3P3_EN_L
*/
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_CONFIGURATION_PORT_0, 0xfc);
/*
@@ -189,8 +192,8 @@ static void pmic_init(void)
* POR of PCA9555 port is input with high impedance hence explicitly
* configure the SOC_3P3_EN_L to high level.
*/
- pca9555_write(I2C_PORT_PCA555_PMIC_BATT_GPIO,
- I2C_ADDR_PCA555_PMIC_BATT_GPIO,
+ pca9555_write__7bf(I2C_PORT_PCA555_PMIC_BATT_GPIO,
+ I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf,
PCA9555_CMD_OUTPUT_PORT_0, 0xfe);
}
DECLARE_HOOK(HOOK_INIT, pmic_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/glkrvp_ite/board.h b/board/glkrvp_ite/board.h
index 4209a06bf8..bc5147045b 100644
--- a/board/glkrvp_ite/board.h
+++ b/board/glkrvp_ite/board.h
@@ -114,7 +114,7 @@
#define I2C_PORT_USB_MUX IT83XX_I2C_CH_B
#define I2C_PORT_PCA555_PMIC_BATT_GPIO IT83XX_I2C_CH_C
-#define I2C_ADDR_PCA555_PMIC_BATT_GPIO 0x42
+#define I2C_ADDR_PCA555_PMIC_BATT_GPIO__7bf 0x21
/* EC exclude modules */
#undef CONFIG_ADC
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 129117614f..dbf20fdbbc 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -35,7 +35,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = IT83XX_I2C_CH_B,
- .addr = 0xa0,
+ .addr__7bf = 0x50,
},
.drv = &tcpci_tcpm_drv,
},
@@ -43,7 +43,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = IT83XX_I2C_CH_B,
- .addr = 0xa4,
+ .addr__7bf = 0x52,
},
.drv = &tcpci_tcpm_drv,
},
@@ -52,11 +52,11 @@ BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
},
{
- .port_addr = 0x22,
+ .port_addr = 0x11,
.driver = &ps874x_usb_mux_driver,
},
};
diff --git a/board/hammer/board.h b/board/hammer/board.h
index e9ba1dabb5..81f51fa8a2 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -275,7 +275,7 @@
#define CONFIG_TOUCHPAD
#define CONFIG_TOUCHPAD_ELAN
#define CONFIG_TOUCHPAD_I2C_PORT I2C_PORT_MASTER
-#define CONFIG_TOUCHPAD_I2C_ADDR (0x15 << 1)
+#define CONFIG_TOUCHPAD_I2C_ADDR__7BF 0x15
#endif /* BOARD_WHISKERS */
#define CONFIG_CURVE25519
diff --git a/board/hatch/board.c b/board/hatch/board.c
index 4737239042..364c9e3d31 100644
--- a/board/hatch/board.c
+++ b/board/hatch/board.c
@@ -12,7 +12,7 @@
#include "cros_board_info.h"
#include "driver/accel_bma2x2.h"
#include "driver/accelgyro_bmi160.h"
-#include "driver/als_opt3001.h"
+#include "driver/als_tcs3400.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/anx7447.h"
@@ -130,7 +130,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC0_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC0_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
.flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
@@ -139,7 +139,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -159,12 +159,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
};
@@ -180,10 +180,28 @@ static struct bmi160_drv_data_t g_bmi160_data;
/* BMA255 private data */
static struct accelgyro_saved_data_t g_bma255_data;
-static struct opt3001_drv_data_t g_opt3001_data = {
- .scale = 1,
- .uscale = 0,
- .offset = 0,
+/* ALS private data */
+static struct als_drv_data_t g_tcs3400_data = {
+ .als_cal.scale = 1,
+ .als_cal.uscale = 0,
+ .als_cal.offset = 0,
+};
+
+static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = {
+ .device_scale = 1,
+ .device_uscale = 0,
+ .rgb_cal[X] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Y] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Z] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
};
/* Matrix to rotate accelrator into standard reference frame */
@@ -215,7 +233,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -242,7 +260,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -268,27 +286,27 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
- [LID_ALS] = {
- .name = "Light",
+ [CLEAR_ALS] = {
+ .name = "Clear Light",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_OPT3001,
+ .chip = MOTIONSENSE_CHIP_TCS3400,
.type = MOTIONSENSE_TYPE_LIGHT,
.location = MOTIONSENSE_LOC_LID,
- .drv = &opt3001_drv,
- .drv_data = &g_opt3001_data,
- .port = I2C_PORT_ACCEL,
- .addr = OPT3001_I2C_ADDR,
+ .drv = &tcs3400_drv,
+ .drv_data = &g_tcs3400_data,
+ .port = I2C_PORT_ALS,
+ .i2c_spi_addr__7bf = TCS3400_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
- .default_range = 0x2b11a1,
- .min_frequency = OPT3001_LIGHT_MIN_FREQ,
- .max_frequency = OPT3001_LIGHT_MAX_FREQ,
+ .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] = {
@@ -296,12 +314,28 @@ struct motion_sensor_t motion_sensors[] = {
},
},
},
+
+ [RGB_ALS] = {
+ /*
+ * RGB channels read by CLEAR_ALS and so the i2c port and
+ * address do not need to be defined for 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,
+ .rot_standard_ref = NULL,
+ .default_range = 0x10000, /* scale = 1x, uscale = 0 */
+ },
};
unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */
const struct motion_sensor_t *motion_als_sensors[] = {
- &motion_sensors[LID_ALS],
+ &motion_sensors[CLEAR_ALS],
};
BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
@@ -426,6 +460,8 @@ static void board_init(void)
setup_fans();
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ /* Enable interrupt for the TCS3400 color light sensor */
+ gpio_enable_interrupt(GPIO_TCS3400_INT_ODL);
/* Enable HDMI HPD interrupt. */
gpio_enable_interrupt(GPIO_HDMI_CONN_HPD);
/* Select correct gpio signal for PP5000_A control */
diff --git a/board/helios/board.c b/board/helios/board.c
index 55359affdb..6a47979565 100644
--- a/board/helios/board.c
+++ b/board/helios/board.c
@@ -15,7 +15,6 @@
#include "driver/als_opt3001.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/ppc/sn5s330.h"
-#include "driver/tcpm/anx7447.h"
#include "driver/tcpm/ps8xxx.h"
#include "driver/tcpm/tcpci.h"
#include "ec_commands.h"
@@ -46,11 +45,6 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-/* GPIO to enable/disable the USB Type-A port. */
-const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = {
- GPIO_EN_USB_A_5V,
-};
-
static void ppc_interrupt(enum gpio_signal signal)
{
switch (signal) {
@@ -125,16 +119,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC0_I2C_ADDR,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
- .drv = &anx7447_tcpm_drv,
- .flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
+ .drv = &ps8xxx_tcpm_drv,
},
[USB_PD_PORT_TCPC_1] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -142,8 +135,8 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
- .driver = &anx7447_usb_mux_driver,
- .hpd_update = &anx7447_tcpc_update_hpd_status,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
.driver = &tcpci_tcpm_usb_mux_driver,
@@ -154,12 +147,12 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
},
};
@@ -184,18 +177,13 @@ static struct opt3001_drv_data_t g_opt3001_data = {
/* Matrix to rotate accelrator into standard reference frame */
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)}
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, 0, FLOAT_TO_FP(-1)}
};
-/*
- * TODO(b/124337208): P0 boards don't have this sensor mounted so the rotation
- * matrix can't be tested properly. This needs to be revisited after EVT to make
- * sure the rotaiton matrix for the lid sensor is correct.
- */
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},
+ { FLOAT_TO_FP(1), 0, 0},
{ 0, 0, FLOAT_TO_FP(-1)}
};
@@ -210,7 +198,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -237,7 +225,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -263,7 +251,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -279,7 +267,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ACCEL,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x2b11a1,
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
@@ -399,3 +387,10 @@ void board_overcurrent_event(int port, int is_overcurrented)
/* Note that the level is inverted because the pin is active low. */
gpio_set_level(GPIO_USB_C_OC_ODL, !is_overcurrented);
}
+
+int board_tcpc_post_init(int port)
+{
+ return port == USB_PD_PORT_TCPC_1 ?
+ tcpc_write(port, PS8XXX_REG_MUX_USB_C2SS_HS_THRESHOLD, 0x80) :
+ EC_SUCCESS;
+}
diff --git a/board/helios/board.h b/board/helios/board.h
new file mode 100644
index 0000000000..b85299e19d
--- /dev/null
+++ b/board/helios/board.h
@@ -0,0 +1,146 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Helios board configuration */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+/* Baseboard features */
+#include "baseboard.h"
+
+/* Optional features */
+#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
+
+#define CONFIG_POWER_BUTTON
+#define CONFIG_KEYBOARD_BOARD_CONFIG
+#define CONFIG_KEYBOARD_PROTOCOL_8042
+#define CONFIG_LED_COMMON
+#define CONFIG_LED_POWER_LED
+#define CONFIG_LOW_POWER_IDLE
+
+#define CONFIG_HOSTCMD_ESPI
+/* #define CONFIG_HOSTCMD_ESPI_VW_SIGNALS */
+
+#undef CONFIG_UART_TX_BUF_SIZE
+#define CONFIG_UART_TX_BUF_SIZE 4096
+
+/* Keyboard features */
+#define CONFIG_PWM_KBLIGHT
+
+/* Sensors */
+/* BMI160 Base accel/gyro */
+#define CONFIG_ACCEL_INTERRUPTS
+#define CONFIG_ACCELGYRO_BMI160
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
+/* BMA253 Lid accel */
+#define CONFIG_ACCEL_BMA255
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_ALS))
+#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
+#define CONFIG_LID_ANGLE_UPDATE
+/* OPT3001 ALS */
+#define CONFIG_ALS
+#define ALS_COUNT 1
+#define CONFIG_ALS_OPT3001
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
+
+/* USB Type C and USB PD defines */
+#define CONFIG_USB_PD_TCPM_PS8751
+#define BOARD_TCPC_C0_RESET_HOLD_DELAY PS8XXX_RESET_DELAY_MS
+#define BOARD_TCPC_C0_RESET_POST_DELAY 0
+#define BOARD_TCPC_C1_RESET_HOLD_DELAY PS8XXX_RESET_DELAY_MS
+#define BOARD_TCPC_C1_RESET_POST_DELAY 0
+#define GPIO_USB_C0_TCPC_RST GPIO_USB_C0_TCPC_RST_ODL
+#define GPIO_USB_C1_TCPC_RST GPIO_USB_C1_TCPC_RST_ODL
+
+/* BC 1.2 */
+#define CONFIG_BC12_DETECT_PI3USB9201
+
+/* Volume Button feature */
+#define CONFIG_VOLUME_BUTTONS
+#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
+#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
+
+/* Fan features */
+#define CONFIG_FANS 1
+#undef CONFIG_FAN_INIT_SPEED
+#define CONFIG_FAN_INIT_SPEED 50
+#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_A_RAILS
+#define CONFIG_THERMISTOR
+#define CONFIG_THROTTLE_AP
+#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
+
+/*
+ * Macros for GPIO signals used in common code that don't match the
+ * schematic names. Signal names in gpio.inc match the schematic and are
+ * then redefined here to so it's more clear which signal is being used for
+ * which purpose.
+ */
+#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L
+#define GPIO_PCH_SLP_S0_L GPIO_SLP_S0_L
+#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL
+#define GPIO_AC_PRESENT GPIO_ACOK_OD
+#define GPIO_RSMRST_L_PGOOD GPIO_PG_EC_RSMRST_L
+#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_PCH_SLP_S4_L GPIO_SLP_S4_L
+#define GPIO_EN_PP5000 GPIO_EN_PP5000_A
+
+#ifndef __ASSEMBLER__
+
+#include "gpio_signal.h"
+#include "registers.h"
+
+enum adc_channel {
+ ADC_TEMP_SENSOR_1, /* ADC0 */
+ ADC_TEMP_SENSOR_2, /* ADC1 */
+ ADC_CH_COUNT
+};
+
+enum sensor_id {
+ LID_ACCEL = 0,
+ BASE_ACCEL,
+ BASE_GYRO,
+ LID_ALS,
+ SENSOR_COUNT,
+};
+
+enum pwm_channel {
+ PWM_CH_KBLIGHT,
+ PWM_CH_FAN,
+ PWM_CH_COUNT
+};
+
+enum fan_channel {
+ FAN_CH_0 = 0,
+ /* Number of FAN channels */
+ FAN_CH_COUNT,
+};
+
+enum mft_channel {
+ MFT_CH_0 = 0,
+ /* Number of MFT channels */
+ MFT_CH_COUNT,
+};
+
+enum temp_sensor_id {
+ TEMP_SENSOR_1,
+ TEMP_SENSOR_2,
+ TEMP_SENSOR_COUNT
+};
+
+/* List of possible batteries */
+enum battery_type {
+ BATTERY_SIMPLO_C424,
+ BATTERY_SIMPLO_C436,
+ BATTERY_TYPE_COUNT,
+};
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/host/battery.c b/board/host/battery.c
index 9dcde241ab..0056c23e6d 100644
--- a/board/host/battery.c
+++ b/board/host/battery.c
@@ -14,13 +14,14 @@
static uint16_t mock_smart_battery[SB_MANUFACTURER_DATA + 1];
-int sb_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+int sb_i2c_xfer__7bf(int port, uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
if (out_size == 0)
return EC_SUCCESS;
- if (port != I2C_PORT_BATTERY || slave_addr != BATTERY_ADDR)
+ if (port != I2C_PORT_BATTERY || slave_addr__7bf != BATTERY_ADDR__7bf)
return EC_ERROR_INVAL;
if (out[0] >= ARRAY_SIZE(mock_smart_battery))
return EC_ERROR_UNIMPLEMENTED;
@@ -41,7 +42,7 @@ int sb_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
}
return EC_SUCCESS;
}
-DECLARE_TEST_I2C_XFER(sb_i2c_xfer);
+DECLARE_TEST_I2C_XFER(sb_i2c_xfer__7bf);
int battery_time_at_rate(int rate, int *minutes)
{
diff --git a/board/kindred/board.c b/board/kindred/board.c
new file mode 100644
index 0000000000..66862f706a
--- /dev/null
+++ b/board/kindred/board.c
@@ -0,0 +1,445 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Hatch board-specific configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "button.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "driver/accel_bma2x2.h"
+#include "driver/accelgyro_bmi160.h"
+#include "driver/als_opt3001.h"
+#include "driver/bc12/pi3usb9201.h"
+#include "driver/ppc/sn5s330.h"
+#include "driver/tcpm/anx7447.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/tcpci.h"
+#include "ec_commands.h"
+#include "extpower.h"
+#include "fan.h"
+#include "fan_chip.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "lid_switch.h"
+#include "power.h"
+#include "power_button.h"
+#include "pwm.h"
+#include "pwm_chip.h"
+#include "spi.h"
+#include "switch.h"
+#include "system.h"
+#include "task.h"
+#include "temp_sensor.h"
+#include "thermal.h"
+#include "thermistor.h"
+#include "uart.h"
+#include "usb_charge.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+
+/* GPIO to enable/disable the USB Type-A port. */
+const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = {
+ GPIO_EN_USB_A_5V,
+};
+
+static void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ sn5s330_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ sn5s330_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void tcpc_alert_event(enum gpio_signal signal)
+{
+ int port = -1;
+
+ switch (signal) {
+ case GPIO_USB_C0_TCPC_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_TCPC_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+static void hdmi_hpd_interrupt(enum gpio_signal signal)
+{
+ baseboard_mst_enable_control(MST_HDMI, gpio_get_level(signal));
+}
+
+static void bc12_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_BC12_INT_ODL:
+ task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12, 0);
+ break;
+
+ case GPIO_USB_C1_BC12_INT_ODL:
+ task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0);
+ break;
+
+ default:
+ break;
+ }
+}
+
+#include "gpio_list.h" /* Must come after other header files. */
+
+/******************************************************************************/
+/* SPI devices */
+const struct spi_device_t spi_devices[] = {
+};
+const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
+
+/******************************************************************************/
+/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
+const struct pwm_t pwm_channels[] = {
+ [PWM_CH_KBLIGHT] = { .channel = 3, .flags = 0, .freq = 10000 },
+ [PWM_CH_FAN] = {.channel = 5, .flags = PWM_CONFIG_OPEN_DRAIN,
+ .freq = 25000},
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+
+/******************************************************************************/
+/* USB-C TPCP Configuration */
+const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
+ [USB_PD_PORT_TCPC_0] = {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr__7bf = AN7447_TCPC0_I2C_ADDR__7bf,
+ },
+ .drv = &anx7447_tcpm_drv,
+ .flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
+ },
+ [USB_PD_PORT_TCPC_1] = {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
+ },
+ .drv = &ps8xxx_tcpm_drv,
+ .flags = 0,
+ },
+};
+
+struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
+ [USB_PD_PORT_TCPC_0] = {
+ .driver = &anx7447_usb_mux_driver,
+ .hpd_update = &anx7447_tcpc_update_hpd_status,
+ },
+ [USB_PD_PORT_TCPC_1] = {
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ }
+};
+
+const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
+ [USB_PD_PORT_TCPC_0] = {
+ .i2c_port = I2C_PORT_PPC0,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
+ },
+
+ [USB_PD_PORT_TCPC_1] = {
+ .i2c_port = I2C_PORT_TCPC1,
+ .i2c_addr__7bf = PI3USB9201_I2C_ADDR_3__7bf,
+ },
+};
+
+/******************************************************************************/
+/* Sensors */
+/* Base Sensor mutex */
+static struct mutex g_base_mutex;
+static struct mutex g_lid_mutex;
+
+/* Base accel private data */
+static struct bmi160_drv_data_t g_bmi160_data;
+
+/* BMA255 private data */
+static struct accelgyro_saved_data_t g_bma255_data;
+
+static struct opt3001_drv_data_t g_opt3001_data = {
+ .scale = 1,
+ .uscale = 0,
+ .offset = 0,
+};
+
+/* Matrix to rotate accelrator into standard reference frame */
+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)}
+};
+
+/*
+ * TODO(b/124337208): P0 boards don't have this sensor mounted so the rotation
+ * matrix can't be tested properly. This needs to be revisited after EVT to make
+ * sure the rotaiton matrix for the lid sensor is correct.
+ */
+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)}
+};
+
+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_ACCEL,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
+ .rot_standard_ref = &lid_standard_ref,
+ .min_frequency = BMA255_ACCEL_MIN_FREQ,
+ .max_frequency = BMA255_ACCEL_MAX_FREQ,
+ .default_range = 2, /* g, to support tablet mode */
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ /* Sensor on in S3 */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+ },
+
+ [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_ACCEL,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = BMI160_ACCEL_MIN_FREQ,
+ .max_frequency = BMI160_ACCEL_MAX_FREQ,
+ .default_range = 2, /* g, to support tablet mode */
+ .config = {
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ /* Sensor on in S3 */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+ },
+
+ [BASE_GYRO] = {
+ .name = "Base 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_ACCEL,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = BMI160_GYRO_MIN_FREQ,
+ .max_frequency = BMI160_GYRO_MAX_FREQ,
+ },
+
+ [LID_ALS] = {
+ .name = "Light",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_OPT3001,
+ .type = MOTIONSENSE_TYPE_LIGHT,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &opt3001_drv,
+ .drv_data = &g_opt3001_data,
+ .port = I2C_PORT_ACCEL,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
+ .rot_standard_ref = NULL,
+ .default_range = 0x2b11a1,
+ .min_frequency = OPT3001_LIGHT_MIN_FREQ,
+ .max_frequency = OPT3001_LIGHT_MAX_FREQ,
+ .config = {
+ /* Run ALS sensor in S0 */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 1000,
+ },
+ },
+ },
+};
+unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+
+/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */
+const struct motion_sensor_t *motion_als_sensors[] = {
+ &motion_sensors[LID_ALS],
+};
+BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
+
+/******************************************************************************/
+/* Physical fans. These are logically separate from pwm_channels. */
+
+const struct fan_conf fan_conf_0 = {
+ .flags = FAN_USE_RPM_MODE,
+ .ch = MFT_CH_0, /* Use MFT id to control fan */
+ .pgood_gpio = -1,
+ .enable_gpio = GPIO_EN_PP5000_FAN,
+};
+
+/* Default */
+const struct fan_rpm fan_rpm_0 = {
+ .rpm_min = 3100,
+ .rpm_start = 3100,
+ .rpm_max = 6900,
+};
+
+struct fan_t fans[FAN_CH_COUNT] = {
+ [FAN_CH_0] = { .conf = &fan_conf_0, .rpm = &fan_rpm_0, },
+};
+
+/******************************************************************************/
+/* MFT channels. These are logically separate from pwm_channels. */
+const struct mft_t mft_channels[] = {
+ [MFT_CH_0] = {NPCX_MFT_MODULE_1, TCKC_LFCLK, PWM_CH_FAN},
+};
+BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT);
+
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_1] = {
+ "TEMP_AMB", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ [ADC_TEMP_SENSOR_2] = {
+ "TEMP_CHARGER", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_1] = {.name = "Temp1",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1,
+ .action_delay_sec = 1},
+ [TEMP_SENSOR_2] = {.name = "Temp2",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2,
+ .action_delay_sec = 1},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+
+/* Hatch Temperature sensors */
+/*
+ * TODO(b/124316213): These setting need to be reviewed and set appropriately
+ * for Hatch. They matter when the EC is controlling the fan as opposed to DPTF
+ * control.
+ */
+const static struct ec_thermal_config thermal_a = {
+ .temp_host = {
+ [EC_TEMP_THRESH_WARN] = 0,
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(80),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_WARN] = 0,
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
+ [EC_TEMP_THRESH_HALT] = 0,
+ },
+ .temp_fan_off = C_TO_K(25),
+ .temp_fan_max = C_TO_K(50),
+};
+
+struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT];
+
+static void setup_fans(void)
+{
+ thermal_params[TEMP_SENSOR_1] = thermal_a;
+ thermal_params[TEMP_SENSOR_2] = thermal_a;
+}
+
+/* Sets the gpio flags correct taking into account warm resets */
+static void reset_gpio_flags(enum gpio_signal signal, int flags)
+{
+ /*
+ * If the system was already on, we cannot set the value otherwise we
+ * may change the value from the previous image which could cause a
+ * brownout.
+ */
+ if (system_is_reboot_warm() || system_jumped_to_this_image())
+ flags &= ~(GPIO_LOW | GPIO_HIGH);
+
+ gpio_set_flags(signal, flags);
+}
+
+/* Runtime GPIO defaults */
+enum gpio_signal gpio_en_pp5000_a = GPIO_EN_PP5000_A_V1;
+
+static void board_gpio_set_pp5000(void)
+{
+ uint32_t board_id = 0;
+
+ /* Errors will count as board_id 0 */
+ cbi_get_board_version(&board_id);
+
+ if (board_id == 0) {
+ reset_gpio_flags(GPIO_EN_PP5000_A_V0, GPIO_OUT_LOW);
+ /* Change runtime default for V0 */
+ gpio_en_pp5000_a = GPIO_EN_PP5000_A_V0;
+ } else if (board_id >= 1) {
+ reset_gpio_flags(GPIO_EN_PP5000_A_V1, GPIO_OUT_LOW);
+ }
+
+}
+
+static void board_init(void)
+{
+ /* Initialize Fans */
+ setup_fans();
+ /* Enable gpio interrupt for base accelgyro sensor */
+ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ /* Enable HDMI HPD interrupt. */
+ gpio_enable_interrupt(GPIO_HDMI_CONN_HPD);
+ /* Select correct gpio signal for PP5000_A control */
+ board_gpio_set_pp5000();
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
+
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC_ODL, !is_overcurrented);
+}
diff --git a/board/kindred/board.h b/board/kindred/board.h
new file mode 100644
index 0000000000..1d327abbcf
--- /dev/null
+++ b/board/kindred/board.h
@@ -0,0 +1,176 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Hatch board configuration */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+/* Baseboard features */
+#include "baseboard.h"
+
+/* Optional features */
+#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
+
+#define CONFIG_POWER_BUTTON
+#define CONFIG_KEYBOARD_BOARD_CONFIG
+#define CONFIG_KEYBOARD_PROTOCOL_8042
+#define CONFIG_LED_COMMON
+#define CONFIG_LOW_POWER_IDLE
+
+#define CONFIG_HOSTCMD_ESPI
+/* #define CONFIG_HOSTCMD_ESPI_VW_SIGNALS */
+
+#undef CONFIG_UART_TX_BUF_SIZE
+#define CONFIG_UART_TX_BUF_SIZE 4096
+
+/* Keyboard features */
+#define CONFIG_PWM_KBLIGHT
+
+/* Sensors */
+/* BMI160 Base accel/gyro */
+#define CONFIG_ACCEL_INTERRUPTS
+#define CONFIG_ACCELGYRO_BMI160
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
+/* BMA253 Lid accel */
+#define CONFIG_ACCEL_BMA255
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_ALS))
+#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
+#define CONFIG_LID_ANGLE_UPDATE
+/* OPT3001 ALS */
+#define CONFIG_ALS
+#define ALS_COUNT 1
+#define CONFIG_ALS_OPT3001
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
+
+/* USB Type C and USB PD defines */
+#define CONFIG_USB_PD_TCPM_ANX7447
+#define CONFIG_USB_PD_TCPM_PS8751
+#define BOARD_TCPC_C0_RESET_HOLD_DELAY ANX74XX_RESET_HOLD_MS
+#define BOARD_TCPC_C0_RESET_POST_DELAY ANX74XX_RESET_HOLD_MS
+#define BOARD_TCPC_C1_RESET_HOLD_DELAY PS8XXX_RESET_DELAY_MS
+#define BOARD_TCPC_C1_RESET_POST_DELAY 0
+#define GPIO_USB_C1_TCPC_RST GPIO_USB_C1_TCPC_RST_ODL
+
+/* USB Type A Features */
+#define CONFIG_USB_PORT_POWER_SMART
+#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
+#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
+#define CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY
+#define GPIO_USB1_ILIM_SEL GPIO_EN_USB_A_LOW_PWR_OD
+
+/* BC 1.2 */
+#define CONFIG_BC12_DETECT_PI3USB9201
+
+/* Charger features */
+/*
+ * The IDCHG current limit is set in 512 mA steps. The value set here is
+ * somewhat specific to the battery pack being currently used. The limit here
+ * was set based on the battery's discharge current limit and what was tested to
+ * prevent the AP rebooting with low charge level batteries.
+ *
+ * TODO(b/133447140): Revisit this threshold once peak power consumption tuning
+ * for the AP is completed.
+ */
+#define CONFIG_CHARGER_BQ25710_IDCHG_LIMIT_MA 8192
+
+/* Volume Button feature */
+#define CONFIG_VOLUME_BUTTONS
+#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
+#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
+
+/* Fan features */
+#define CONFIG_FANS 1
+#undef CONFIG_FAN_INIT_SPEED
+#define CONFIG_FAN_INIT_SPEED 50
+#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_A_RAILS
+#define CONFIG_THERMISTOR
+#define CONFIG_THROTTLE_AP
+#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
+
+/* MST */
+/*
+ * TDOD (b/124068003): This inherently assumes the MST chip is connected to only
+ * one Type C port. This will need to be chagned to support 2 Type C ports
+ * connected to the same MST chip.
+ */
+#define USB_PD_PORT_TCPC_MST USB_PD_PORT_TCPC_1
+
+/*
+ * Macros for GPIO signals used in common code that don't match the
+ * schematic names. Signal names in gpio.inc match the schematic and are
+ * then redefined here to so it's more clear which signal is being used for
+ * which purpose.
+ */
+#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L
+#define GPIO_PCH_SLP_S0_L GPIO_SLP_S0_L
+#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL
+#define GPIO_AC_PRESENT GPIO_ACOK_OD
+#define GPIO_RSMRST_L_PGOOD GPIO_PG_EC_RSMRST_L
+#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_PCH_SLP_S4_L GPIO_SLP_S4_L
+#define GPIO_EN_PP5000 GPIO_EN_PP5000_A
+
+#ifndef __ASSEMBLER__
+
+#include "gpio_signal.h"
+#include "registers.h"
+
+/* GPIO signals updated base on board version. */
+#define GPIO_EN_PP5000_A gpio_en_pp5000_a
+extern enum gpio_signal gpio_en_pp5000_a;
+
+enum adc_channel {
+ ADC_TEMP_SENSOR_1, /* ADC0 */
+ ADC_TEMP_SENSOR_2, /* ADC1 */
+ ADC_CH_COUNT
+};
+
+enum sensor_id {
+ LID_ACCEL = 0,
+ BASE_ACCEL,
+ BASE_GYRO,
+ LID_ALS,
+ SENSOR_COUNT,
+};
+
+enum pwm_channel {
+ PWM_CH_KBLIGHT,
+ PWM_CH_FAN,
+ PWM_CH_COUNT
+};
+
+enum fan_channel {
+ FAN_CH_0 = 0,
+ /* Number of FAN channels */
+ FAN_CH_COUNT,
+};
+
+enum mft_channel {
+ MFT_CH_0 = 0,
+ /* Number of MFT channels */
+ MFT_CH_COUNT,
+};
+
+enum temp_sensor_id {
+ TEMP_SENSOR_1,
+ TEMP_SENSOR_2,
+ TEMP_SENSOR_COUNT
+};
+
+/* List of possible batteries */
+enum battery_type {
+ BATTERY_LGC_AP18C8K,
+ BATTERY_MURATA_AP18C4K,
+ BATTERY_TYPE_COUNT,
+};
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/kohaku/board.c b/board/kohaku/board.c
index 23b6124ad7..0fa7b42ac7 100644
--- a/board/kohaku/board.c
+++ b/board/kohaku/board.c
@@ -13,8 +13,10 @@
#include "driver/accel_bma2x2.h"
#include "driver/accelgyro_bmi160.h"
#include "driver/als_bh1730.h"
+#include "driver/als_tcs3400.h"
#include "driver/ppc/sn5s330.h"
#include "driver/bc12/max14637.h"
+#include "driver/sync.h"
#include "driver/tcpm/ps8xxx.h"
#include "driver/tcpm/tcpci.h"
#include "ec_commands.h"
@@ -115,7 +117,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -123,7 +125,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -169,6 +171,30 @@ static struct accelgyro_saved_data_t g_bma255_data;
/* BH1730 private data */
struct bh1730_drv_data_t g_bh1730_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,
+};
+
+static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = {
+ .device_scale = 1,
+ .device_uscale = 0,
+ .rgb_cal[X] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Y] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Z] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+};
+
/* Matrix to rotate accelrator into standard reference frame */
static const mat33_fp_t base_standard_ref = {
{ 0, FLOAT_TO_FP(1), 0},
@@ -182,9 +208,9 @@ static const mat33_fp_t base_standard_ref = {
* sure the rotaiton matrix for the lid sensor is correct.
*/
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)}
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
};
struct motion_sensor_t motion_sensors[] = {
@@ -198,7 +224,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -225,7 +251,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -251,7 +277,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -267,7 +293,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bh1730_drv,
.drv_data = &g_bh1730_data,
.port = I2C_PORT_ACCEL,
- .addr = BH1730_I2C_ADDR,
+ .i2c_spi_addr__7bf = BH1730_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 65535,
.min_frequency = 10,
@@ -279,12 +305,63 @@ struct motion_sensor_t motion_sensors[] = {
},
},
},
+
+ [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,
+ },
+
+ [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__7bf = TCS3400_I2C_ADDR__7bf,
+ .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] = {
+ /*
+ * RGB channels read by CLEAR_ALS and so the i2c port and
+ * address do not need to be defined for 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,
+ .rot_standard_ref = NULL,
+ .default_range = 0x10000, /* scale = 1x, uscale = 0 */
+ },
};
unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */
const struct motion_sensor_t *motion_als_sensors[] = {
&motion_sensors[LID_ALS],
+ &motion_sensors[CLEAR_ALS],
};
BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
@@ -320,6 +397,10 @@ static void board_init(void)
{
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ /* Enable gpio interrupt for camera vsync */
+ gpio_enable_interrupt(GPIO_WFCAM_VSYNC);
+ /* Enable interrupt for the TCS3400 color light sensor */
+ gpio_enable_interrupt(GPIO_TCS3400_INT_ODL);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 8b6649e288..95f177bf6b 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -8,35 +8,35 @@
#include "backlight.h"
#include "button.h"
#include "charge_manager.h"
+#include "charge_ramp.h"
#include "charge_state.h"
#include "charger.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "driver/accelgyro_bmi160.h"
+#include "driver/als_tcs3400.h"
+#include "driver/battery/max17055.h"
+#include "driver/bc12/pi3usb9201.h"
#include "driver/charger/rt946x.h"
#include "driver/sync.h"
#include "driver/tcpm/mt6370.h"
-#include "driver/temp_sensor/tmp432.h"
#include "ec_commands.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
#include "i2c.h"
+#include "lid_switch.h"
#include "power.h"
#include "power_button.h"
#include "pwm.h"
#include "pwm_chip.h"
#include "registers.h"
#include "spi.h"
-#include "switch.h"
#include "system.h"
#include "task.h"
#include "tcpm.h"
-#include "temp_sensor.h"
-#include "temp_sensor_chip.h"
-#include "thermal.h"
#include "timer.h"
#include "usb_charge.h"
#include "usb_mux.h"
@@ -48,41 +48,13 @@
static void tcpc_alert_event(enum gpio_signal signal)
{
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
-}
-
-static void warm_reset_request_interrupt(enum gpio_signal signal)
-{
- CPRINTS("AP wants warm reset");
- chipset_reset(CHIPSET_RESET_AP_REQ);
-}
-
-static void ap_watchdog_interrupt(enum gpio_signal signal)
-{
- int level = gpio_get_level(GPIO_AP_EC_WATCHDOG_L);
-
- CPRINTS("AP watchdog level %d", level);
- /*
- * TODO(b:109900671): Handle AP watchdog, when necessary, for now, just
- * mirror input to output.
- */
- gpio_set_level(GPIO_PMIC_WATCHDOG_L, level);
-}
-
-#if BOARD_REV >= 1
-static void hall_interrupt(enum gpio_signal signal)
-{
- /* TODO(b/111378000): Implement hall_interrupt */
+ schedule_deferred_pd_interrupt(0 /* port */);
}
static void gauge_interrupt(enum gpio_signal signal)
{
- /* TODO(b/111378620): Impelement gauge_interrupt */
+ task_wake(TASK_ID_CHARGER);
}
-#endif
#include "gpio_list.h"
@@ -90,6 +62,9 @@ static void gauge_interrupt(enum gpio_signal signal)
/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
const struct adc_t adc_channels[] = {
[ADC_BOARD_ID] = {"BOARD_ID", 3300, 4096, 0, STM32_AIN(10)},
+ [ADC_EC_SKU_ID] = {"EC_SKU_ID", 3300, 4096, 0, STM32_AIN(8)},
+ [ADC_BATT_ID] = {"BATT_ID", 3300, 4096, 0, STM32_AIN(7)},
+ [ADC_POGO_ADC_INT_L] = {"POGO_ADC_INT_L", 3300, 4096, 0, STM32_AIN(6)},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
@@ -100,9 +75,13 @@ const struct i2c_port_t i2c_ports[] = {
{"tcpc0", I2C_PORT_TCPC0, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
{"battery", I2C_PORT_BATTERY, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
{"accelgyro", I2C_PORT_ACCEL, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
+ {"bc12", I2C_PORT_BC12, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
+ {"als", I2C_PORT_ALS, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+#define BC12_I2C_ADDR__7bf PI3USB9201_I2C_ADDR_3__7bf
+
/* 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"},
@@ -110,30 +89,6 @@ const struct power_signal_info power_signal_list[] = {
};
BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-#ifdef CONFIG_TEMP_SENSOR_TMP432
-/* Temperature sensors data; must be in same order as enum temp_sensor_id. */
-const struct temp_sensor_t temp_sensors[] = {
- {"TMP432_Internal", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
- TMP432_IDX_LOCAL, 4},
- {"TMP432_Sensor_1", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
- TMP432_IDX_REMOTE1, 4},
- {"TMP432_Sensor_2", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
- TMP432_IDX_REMOTE2, 4},
-};
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-
-/*
- * Thermal limits for each temp sensor. All temps are in degrees K. Must be in
- * same order as enum temp_sensor_id. To always ignore any temp, use 0.
- */
-struct ec_thermal_config thermal_params[] = {
- {{0, 0, 0}, 0, 0}, /* TMP432_Internal */
- {{0, 0, 0}, 0, 0}, /* TMP432_Sensor_1 */
- {{0, 0, 0}, 0, 0}, /* TMP432_Sensor_2 */
-};
-BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
-#endif
-
/******************************************************************************/
/* SPI devices */
const struct spi_device_t spi_devices[] = {
@@ -146,7 +101,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = MT6370_TCPC_I2C_ADDR,
+ .addr__7bf = MT6370_TCPC_I2C_ADDR__7bf,
},
.drv = &mt6370_tcpm_drv,
},
@@ -173,15 +128,38 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
+static void board_pogo_charge_init(void)
+{
+ int i;
+
+ /* Initialize all charge suppliers to 0 */
+ for (i = 0; i < CHARGE_SUPPLIER_COUNT; i++)
+ charge_manager_update_charge(i, CHARGE_PORT_POGO, NULL);
+}
+DECLARE_HOOK(HOOK_INIT, board_pogo_charge_init,
+ HOOK_PRIO_CHARGE_MANAGER_INIT + 1);
+
+static int force_discharge;
+
int board_set_active_charge_port(int charge_port)
{
CPRINTS("New chg p%d", charge_port);
+ /* ignore all request when discharge mode is on */
+ if (force_discharge)
+ return EC_SUCCESS;
+
switch (charge_port) {
- case 0:
+ case CHARGE_PORT_USB_C:
/* Don't charge from a source port */
if (board_vbus_source_enabled(charge_port))
return -1;
+ gpio_set_level(GPIO_EN_POGO_CHARGE_L, 1);
+ gpio_set_level(GPIO_EN_USBC_CHARGE_L, 0);
+ break;
+ case CHARGE_PORT_POGO:
+ gpio_set_level(GPIO_EN_USBC_CHARGE_L, 1);
+ gpio_set_level(GPIO_EN_POGO_CHARGE_L, 0);
break;
case CHARGE_PORT_NONE:
/*
@@ -189,6 +167,8 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
+ gpio_set_level(GPIO_EN_POGO_CHARGE_L, 1);
+ gpio_set_level(GPIO_EN_USBC_CHARGE_L, 1);
charger_set_current(0);
break;
default:
@@ -206,16 +186,41 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
+int board_discharge_on_ac(int enable)
+{
+ int ret, port;
+
+ if (enable) {
+ port = CHARGE_PORT_NONE;
+ } else {
+ /* restore the charge port state */
+ port = charge_manager_get_override();
+ if (port == OVERRIDE_OFF)
+ port = charge_manager_get_active_charge_port();
+ }
+
+ ret = board_set_active_charge_port(port);
+ if (ret)
+ return ret;
+ force_discharge = enable;
+
+ return charger_discharge_on_ac(enable);
+}
+
int extpower_is_present(void)
{
/*
* The charger will indicate VBUS presence if we're sourcing 5V,
* so exclude such ports.
*/
- if (board_vbus_source_enabled(0))
- return 0;
+ int usb_c_extpower_present;
+
+ if (board_vbus_source_enabled(CHARGE_PORT_USB_C))
+ usb_c_extpower_present = 0;
else
- return tcpm_get_vbus_level(0);
+ usb_c_extpower_present = tcpm_get_vbus_level(CHARGE_PORT_USB_C);
+
+ return usb_c_extpower_present || gpio_get_level(GPIO_POGO_VBUS_PRESENT);
}
int pd_snk_is_vbus_provided(int port)
@@ -226,8 +231,22 @@ int pd_snk_is_vbus_provided(int port)
return rt946x_is_vbus_ready();
}
+#if defined(BOARD_KUKUI) || defined(BOARD_KODAMA)
+/* dummy interrupt function for kukui */
+void pogo_adc_interrupt(enum gpio_signal signal)
+{
+}
+#endif
+
static void board_init(void)
{
+ /* If the reset cause is external, pulse PMIC force reset. */
+ if (system_get_reset_flags() == RESET_FLAG_RESET_PIN) {
+ gpio_set_level(GPIO_PMIC_FORCE_RESET_ODL, 0);
+ msleep(100);
+ gpio_set_level(GPIO_PMIC_FORCE_RESET_ODL, 1);
+ }
+
/* Set SPI1 PB13/14/15 pins to high speed */
STM32_GPIO_OSPEEDR(GPIO_B) |= 0xfc000000;
@@ -237,11 +256,6 @@ static void board_init(void)
/* Enable charger interrupts */
gpio_enable_interrupt(GPIO_CHARGER_INT_ODL);
- /* Enable reboot / shutdown / sleep control inputs from AP */
- gpio_enable_interrupt(GPIO_WARM_RESET_REQ);
- gpio_enable_interrupt(GPIO_AP_EC_WATCHDOG_L);
- gpio_enable_interrupt(GPIO_AP_IN_SLEEP_L);
-
#ifdef SECTION_IS_RW
/* Enable interrupts from BMI160 sensor. */
gpio_enable_interrupt(GPIO_ACCEL_INT_ODL);
@@ -252,9 +266,51 @@ static void board_init(void)
/* Enable interrupt from PMIC. */
gpio_enable_interrupt(GPIO_PMIC_EC_RESETB);
+
+ /* Enable gauge interrupt from max17055 */
+ gpio_enable_interrupt(GPIO_GAUGE_INT_ODL);
+
+ /* Enable pogo interrupt */
+ gpio_enable_interrupt(GPIO_POGO_ADC_INT_L);
+
+ if (IS_ENABLED(BOARD_KRANE))
+ /* Display bias settings. */
+ mt6370_db_set_voltages(6000, 5800, 5800);
+
+ /* Enable pogo charging signal */
+ gpio_enable_interrupt(GPIO_POGO_VBUS_PRESENT);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+static void board_rev_init(void)
+{
+ /* Board revision specific configs. */
+
+ /*
+ * It's a P1 pin BOOTBLOCK_MUX_OE, also a P2 pin BC12_DET_EN.
+ * Keep this pin defaults to P1 setting since that eMMC enabled with
+ * High-Z stat.
+ */
+ if (IS_ENABLED(BOARD_KUKUI) && board_get_version() == 1)
+ gpio_set_flags(GPIO_BC12_DET_EN, GPIO_ODR_HIGH);
+
+ if (board_get_version() >= 2) {
+ /*
+ * Enable MT6370 DB_POSVOUT/DB_NEGVOUT (controlled by _EN pins).
+ */
+ mt6370_db_external_control(1);
+ }
+
+ if (board_get_version() == 2) {
+ /* configure PI3USB9201 to USB Path ON Mode */
+ i2c_write8__7bf(I2C_PORT_BC12, BC12_I2C_ADDR__7bf,
+ PI3USB9201_REG_CTRL_1,
+ (PI3USB9201_USB_PATH_ON <<
+ PI3USB9201_REG_CTRL_1_MODE_SHIFT));
+ }
+}
+DECLARE_HOOK(HOOK_INIT, board_rev_init, HOOK_PRIO_INIT_ADC + 1);
+
void board_config_pre_init(void)
{
STM32_RCC_AHBENR |= STM32_RCC_HB_DMA1;
@@ -340,30 +396,63 @@ int board_get_version(void)
}
}
- /*
- * Disable ADC module after we detect the board version,
- * since this is the only thing ADC module needs to do
- * for this board.
- */
- if (version != BOARD_VERSION_UNKNOWN)
- adc_disable();
-
return version;
}
/* Motion sensors */
/* Mutexes */
#ifdef SECTION_IS_RW
-static struct mutex g_base_mutex;
+static struct mutex g_lid_mutex;
static struct bmi160_drv_data_t g_bmi160_data;
+static struct als_drv_data_t g_tcs3400_data = {
+ .als_cal.scale = 1,
+ .als_cal.uscale = 0,
+ .als_cal.offset = 0,
+};
+
+static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = {
+ .device_scale = 1,
+ .device_uscale = 0,
+ .rgb_cal[X] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Y] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Z] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+};
+
+#ifdef BOARD_KRANE
/* 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)}
+static const mat33_fp_t lid_standard_ref_rev3 = {
+ {0, FLOAT_TO_FP(-1), 0},
+ {FLOAT_TO_FP(1), 0, 0},
+ {0, 0, FLOAT_TO_FP(1)}
+};
+#endif /* BOARD_KRANE */
+
+/* Matrix to rotate accelerometer into standard reference frame */
+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)}
+};
+
+#ifdef CONFIG_MAG_BMI160_BMM150
+/* Matrix to rotate accelrator into standard reference frame */
+static const mat33_fp_t mag_standard_ref = {
+ {0, FLOAT_TO_FP(-1), 0},
+ {FLOAT_TO_FP(-1), 0, 0},
+ {0, 0, FLOAT_TO_FP(-1)}
};
+#endif /* CONFIG_MAG_BMI160_BMM150 */
struct motion_sensor_t motion_sensors[] = {
/*
@@ -378,11 +467,11 @@ struct motion_sensor_t motion_sensors[] = {
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
.drv = &bmi160_drv,
- .mutex = &g_base_mutex,
+ .mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
- .rot_standard_ref = &base_standard_ref,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -401,15 +490,68 @@ struct motion_sensor_t motion_sensors[] = {
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_LID,
.drv = &bmi160_drv,
- .mutex = &g_base_mutex,
+ .mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
- .rot_standard_ref = &base_standard_ref,
+ .rot_standard_ref = &lid_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
+#ifdef CONFIG_MAG_BMI160_BMM150
+ [LID_MAG] = {
+ .name = "Lid Mag",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMI160,
+ .type = MOTIONSENSE_TYPE_MAG,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &bmi160_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_bmi160_data,
+ .port = I2C_PORT_ACCEL,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .default_range = BIT(11), /* 16LSB / uT, fixed */
+ .rot_standard_ref = &mag_standard_ref,
+ .min_frequency = BMM150_MAG_MIN_FREQ,
+ .max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
+ },
+#endif /* CONFIG_MAG_BMI160_BMM150 */
+ [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__7bf = TCS3400_I2C_ADDR__7bf,
+ .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,
@@ -423,8 +565,33 @@ struct motion_sensor_t motion_sensors[] = {
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+const struct motion_sensor_t *motion_als_sensors[] = {
+ &motion_sensors[CLEAR_ALS],
+};
+
#endif /* SECTION_IS_RW */
+#ifdef BOARD_KRANE
+static void fix_krane(void)
+{
+ if (board_get_version() != 3)
+ return;
+
+ /*
+ * Fix backlight led maximum current: tolerance 120mA * 0.75 = 90mA.
+ * (b/133655155)
+ */
+ mt6370_backlight_set_dim(MT6370_BLDIM_DEFAULT * 3 / 4);
+
+#ifdef SECTION_IS_RW
+ /* Fix reference point */
+ motion_sensors[LID_ACCEL].rot_standard_ref = &lid_standard_ref_rev3;
+ motion_sensors[LID_GYRO].rot_standard_ref = &lid_standard_ref_rev3;
+#endif /* SECTION_IS_RW */
+}
+DECLARE_HOOK(HOOK_INIT, fix_krane, HOOK_PRIO_INIT_ADC + 1);
+#endif /* BOARD_KRANE */
+
int board_allow_i2c_passthru(int port)
{
return (port == I2C_PORT_VIRTUAL_BATTERY);
@@ -433,3 +600,42 @@ int board_allow_i2c_passthru(int port)
void usb_charger_set_switches(int port, enum usb_switch setting)
{
}
+
+/*
+ * Return if VBUS is sagging too low
+ */
+int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
+{
+ /*
+ * Though we have a more tolerant range (3.9V~13.4V), setting 4400 to
+ * prevent from a bad charger crashed.
+ *
+ * TODO(b:131284131): mt6370 VBUS reading is not accurate currently.
+ * Vendor will provide a workaround solution to fix the gap between ADC
+ * reading and actual voltage. After the workaround applied, we could
+ * try to raise this value to 4600. (when it says it read 4400, it is
+ * actually close to 4600)
+ */
+ return charger_get_vbus_voltage(port) < 4400;
+}
+
+int board_charge_port_is_sink(int port)
+{
+ /* TODO(b:128386458): Check POGO_ADC_INT_L */
+ return 1;
+}
+
+int board_charge_port_is_connected(int port)
+{
+ return gpio_get_level(GPIO_POGO_VBUS_PRESENT);
+}
+
+void board_fill_source_power_info(int port,
+ struct ec_response_usb_pd_power_info *r)
+{
+ r->meas.voltage_now = 3300;
+ r->meas.voltage_max = 3300;
+ r->meas.current_max = 1500;
+ r->meas.current_lim = 1500;
+ r->max_power = r->meas.voltage_now * r->meas.current_max;
+}
diff --git a/board/kukui/board.h b/board/kukui/board.h
index b0b9396ab5..2ca8428142 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -91,7 +91,7 @@
/* Motion Sensors */
#ifdef SECTION_IS_RW
#define CONFIG_MAG_BMI160_BMM150
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
@@ -184,7 +184,7 @@
#define I2C_PORT_ACCEL 1
/* Route sbs host requests to virtual battery driver */
-#define VIRTUAL_BATTERY_ADDR 0x16
+#define VIRTUAL_BATTERY_ADDR__7bf 0x0B
/* Enable Accel over SPI */
#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */
diff --git a/board/mchpevb1/battery.c b/board/mchpevb1/battery.c
index 016d225950..d6c702127e 100644
--- a/board/mchpevb1/battery.c
+++ b/board/mchpevb1/battery.c
@@ -47,10 +47,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index a87ca3fdcf..cf4f9a8eef 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -66,14 +66,14 @@
/* NOTE: MEC17xx EVB + SKL RVP3 does not use BD99992 PMIC.
* RVP3 PMIC controlled by RVP3 logic.
*/
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_BD99992__7bf 0x30
/*
* Maxim DS1624 I2C temperature sensor used for testing I2C.
* DS1624 contains one internal temperature sensor
* and EEPROM. It has no external temperature inputs.
*/
-#define DS1624_I2C_ADDR 0x90 /* 7-bit address is 0x48 */
+#define DS1624_I2C_ADDR__7bf (0x48 | I2C_FLAG_BIG_ENDIAN)
#define DS1624_IDX_LOCAL 0
#define DS1624_READ_TEMP16 0xAA /* read 16-bit temperature */
#define DS1624_ACCESS_CFG 0xAC /* read/write 8-bit config */
@@ -275,8 +275,13 @@ int board_i2c_p2c(int port)
#ifdef CONFIG_USB_POWER_DELIVERY
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &tcpci_tcpm_drv},
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR + 2, &tcpci_tcpm_drv},
+ {I2C_PORT_TCPC,
+ CONFIG_TCPC_I2C_BASE_ADDR__7BF,
+ &tcpci_tcpm_drv},
+
+ {I2C_PORT_TCPC,
+ CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
+ &tcpci_tcpm_drv},
};
#endif
@@ -395,11 +400,11 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xa8,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
@@ -516,14 +521,14 @@ static void board_pmic_init(void)
/* Config DS1624 temperature sensor for continuous conversion */
cfg = 0x66;
- rv = i2c_read8(I2C_PORT_THERMAL, DS1624_I2C_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_ACCESS_CFG, &cfg);
trace2(0, BRD, 0, "Read DS1624 Config rv = %d cfg = 0x%02X",
rv, cfg);
if ((rv == EC_SUCCESS) && (cfg & (1u << 0))) {
/* one-shot mode switch to continuous */
- rv = i2c_write8(I2C_PORT_THERMAL, DS1624_I2C_ADDR,
+ rv = i2c_write8__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_ACCESS_CFG, 0);
trace1(0, BRD, 0, "Write DS1624 Config to 0, rv = %d", rv);
/* writes to config require 10ms until next I2C command */
@@ -532,7 +537,7 @@ static void board_pmic_init(void)
}
/* Send start command */
- rv = i2c_write8(I2C_PORT_THERMAL, DS1624_I2C_ADDR,
+ rv = i2c_write8__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_CMD_START, 1);
trace1(0, BRD, 0, "Send Start command to DS1624 rv = %d", rv);
@@ -875,8 +880,7 @@ static void ds1624_update(void)
int temp;
int rv __attribute__((unused));
- rv = i2c_read16(I2C_PORT_THERMAL,
- (DS1624_I2C_ADDR | I2C_FLAG_BIG_ENDIAN),
+ rv = i2c_read16__7bf(I2C_PORT_THERMAL, DS1624_I2C_ADDR__7bf,
DS1624_READ_TEMP16, &temp);
d = (temp & 0x7FFF) >> 8;
@@ -939,7 +943,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(
+ CONFIG_SPI_ACCEL_PORT),
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -963,7 +968,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(
+ CONFIG_SPI_ACCEL_PORT),
.default_range = 1000, /* dps */
.rot_standard_ref = NULL, /* Identity Matrix. */
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -980,7 +986,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h
index ee6f9d92ba..3445537007 100644
--- a/board/mchpevb1/board.h
+++ b/board/mchpevb1/board.h
@@ -400,7 +400,7 @@
#endif
/* Ambient Light Sensor address */
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* Modules we want to exclude */
#undef CONFIG_CMD_HASH
diff --git a/board/meep/board.c b/board/meep/board.c
index 2bd17d9d5f..19b13eb08d 100644
--- a/board/meep/board.c
+++ b/board/meep/board.c
@@ -153,7 +153,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &kx022_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &lid_standrd_ref,
.default_range = 2, /* g */
.config = {
@@ -186,7 +186,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -218,7 +218,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
diff --git a/board/nami/board.c b/board/nami/board.c
index 3085db8420..4804c8d2a0 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -216,7 +216,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -226,7 +226,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = AN7447_TCPC3_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC3_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -460,9 +460,11 @@ const static struct ec_thermal_config thermal_d2 = {
};
#define I2C_PMIC_READ(reg, data) \
- i2c_read8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_read8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf,\
+ (reg), (data))
#define I2C_PMIC_WRITE(reg, data) \
- i2c_write8(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1, (reg), (data))
+ i2c_write8__7bf(I2C_PORT_PMIC, TPS650X30_I2C_ADDR1__7bf,\
+ (reg), (data))
static void board_pmic_init(void)
{
@@ -717,7 +719,7 @@ const struct motion_sensor_t lid_accel_1 = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = &rotation_x180_z90,
.min_frequency = KX022_ACCEL_MIN_FREQ,
.max_frequency = KX022_ACCEL_MAX_FREQ,
@@ -745,7 +747,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -773,7 +775,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -801,7 +803,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -930,10 +932,10 @@ static void board_init(void)
gpio_set_level(GPIO_PCH_ACPRESENT, extpower_is_present());
/* Reduce Buck-boost mode switching frequency to reduce heat */
- if (i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER,
+ if (i2c_read16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf,
ISL9238_REG_CONTROL3, &reg) == EC_SUCCESS) {
reg |= ISL9238_C3_BB_SWITCHING_PERIOD;
- if (i2c_write16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER,
+ if (i2c_write16__7bf(I2C_PORT_CHARGER, I2C_ADDR_CHARGER__7bf,
ISL9238_REG_CONTROL3, reg))
CPRINTF("Failed to set isl9238\n");
}
diff --git a/board/nami/board.h b/board/nami/board.h
index 5ac9b94666..c7254a281d 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -205,8 +205,8 @@
#define I2C_PORT_ALS NPCX_I2C_PORT3
/* I2C addresses */
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_EEPROM__7bf 0x50
#ifndef __ASSEMBLER__
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index 2e3d8be848..bf89d0edad 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -112,26 +112,6 @@ void usb1_evt(enum gpio_signal signal)
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
-#ifdef CONFIG_POWER_S0IX
- {GPIO_PCH_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
-#endif
-#ifdef CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS
- {VW_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {VW_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
-#else
- {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {GPIO_PCH_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
-#endif
- {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"},
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"},
- {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* Hibernate wake configuration */
const enum gpio_signal hibernate_wake_pins[] = {
GPIO_AC_PRESENT,
@@ -171,7 +151,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -179,7 +159,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -288,29 +268,29 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
- if (!(vrfault & (1 << 4)))
+ if (!(vrfault & BIT(4)))
return;
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, (1 << 4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -329,7 +309,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -338,7 +318,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V100ACNT:
@@ -347,7 +327,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* V085ACNT:
@@ -356,7 +336,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x3a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -368,7 +348,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -377,7 +357,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V100ACNT:
@@ -386,7 +366,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x5a);
/*
* V085ACNT:
@@ -395,7 +375,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -414,12 +394,12 @@ static void board_pmic_init(void)
return;
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
board_pmic_disable_slp_s0_vr_decay();
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
}
DECLARE_DEFERRED(board_pmic_init);
@@ -432,7 +412,7 @@ static void board_init(void)
* floating SPI buffer input (MISO), which causes power leakage (see
* b/64797021).
*/
- NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN);
+ NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN);
/* Provide AC status to the PCH */
gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
@@ -532,21 +512,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
}
/**
- * Return whether ramping is allowed for given supplier
- */
-int board_is_ramp_allowed(int supplier)
-{
- /* Don't allow ramping in RO when write protected */
- if (!system_is_in_rw() && system_is_locked())
- return 0;
- else
- return (supplier == CHARGE_SUPPLIER_BC12_DCP ||
- supplier == CHARGE_SUPPLIER_BC12_SDP ||
- supplier == CHARGE_SUPPLIER_BC12_CDP ||
- supplier == CHARGE_SUPPLIER_OTHER);
-}
-
-/**
* Return the maximum allowed input current
*/
int board_get_ramp_current_limit(int supplier, int sup_curr)
@@ -570,7 +535,7 @@ void board_hibernate(void)
uart_flush_output();
/* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -646,7 +611,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -672,7 +637,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -699,7 +664,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -782,16 +747,17 @@ int board_has_working_reset_flags(void)
#define BATTERY_FREE_MIN_DELTA_US (5 * MSEC)
static timestamp_t battery_last_i2c_time;
-static int is_battery_i2c(int port, int slave_addr)
+static int is_battery_i2c__7bf(const int port, const uint16_t slave_addr__7bf)
{
- return (port == I2C_PORT_BATTERY) && (slave_addr == BATTERY_ADDR);
+ return (port == I2C_PORT_BATTERY)
+ && (slave_addr__7bf == BATTERY_ADDR__7bf);
}
-void i2c_start_xfer_notify(int port, int slave_addr)
+void i2c_start_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
{
unsigned int time_delta_us;
- if (!is_battery_i2c(port, slave_addr))
+ if (!is_battery_i2c__7bf(port, slave_addr__7bf))
return;
time_delta_us = time_since32(battery_last_i2c_time);
@@ -801,9 +767,9 @@ void i2c_start_xfer_notify(int port, int slave_addr)
usleep(BATTERY_FREE_MIN_DELTA_US - time_delta_us);
}
-void i2c_end_xfer_notify(int port, int slave_addr)
+void i2c_end_xfer_notify__7bf(const int port, const uint16_t slave_addr__7bf)
{
- if (!is_battery_i2c(port, slave_addr))
+ if (!is_battery_i2c__7bf(port, slave_addr__7bf))
return;
battery_last_i2c_time = get_time();
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index 858247b817..12945e1f98 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -179,8 +179,8 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
#ifndef __ASSEMBLER__
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index 293604c0e3..5df9e338ed 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -26,6 +26,8 @@
#include "hooks.h"
#include "i2c.h"
#include "lid_switch.h"
+#include "lpc.h"
+#include "mkbp_event.h"
#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
@@ -48,10 +50,20 @@
static void tcpc_alert_event(enum gpio_signal s)
{
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ int port = -1;
+
+ switch (s) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
}
/*
@@ -66,6 +78,21 @@ static void usb_c_interrupt(enum gpio_signal s)
sn5s330_interrupt(port);
}
+static void board_connect_c0_sbu_deferred(void)
+{
+ /*
+ * If CCD_MODE_ODL asserts, it means there's a debug accessory connected
+ * and we should enable the SBU FETs.
+ */
+ ppc_set_sbu(0, 1);
+}
+DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
+
+static void board_connect_c0_sbu(enum gpio_signal s)
+{
+ hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
+}
+
#include "gpio_list.h"
const enum gpio_signal hibernate_wake_pins[] = {
@@ -85,19 +112,6 @@ const struct adc_t adc_channels[] = {
},
};
-/* Power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
- {GPIO_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
- {GPIO_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {GPIO_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
- {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"},
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"},
- {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
[PWM_CH_DB0_LED_RED] = { 3, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
@@ -176,7 +190,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ALS_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -199,7 +213,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ALS_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 1000, /* dps */
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -215,7 +229,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS_GYRO,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
/* scale = 43.4513 http://b/111528815#comment14 */
.default_range = 0x2b11a1,
@@ -273,12 +287,12 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, enable_sensor_irqs, HOOK_PRIO_DEFAULT);
struct ppc_config_t ppc_chips[] = {
{
.i2c_port = I2C_PORT_USB_C0,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv
},
{
.i2c_port = I2C_PORT_USB_C1,
- .i2c_addr = SN5S330_ADDR0,
+ .i2c_addr__7bf = SN5S330_ADDR0__7bf,
.drv = &sn5s330_drv,
},
};
@@ -289,7 +303,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_USB_C0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &tcpci_tcpm_drv,
},
@@ -297,7 +311,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_USB_C1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &tcpci_tcpm_drv,
},
@@ -328,7 +342,8 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
static void imvp8_tune_deferred(void)
{
/* For the IMVP8, reduce the steps during decay from 3 to 1. */
- if (i2c_write16(I2C_PORT_POWER, I2C_ADDR_MP2949, 0xFA, 0x0AC5))
+ if (i2c_write16__7bf(I2C_PORT_POWER, I2C_ADDR_MP2949__7bf,
+ 0xFA, 0x0AC5))
CPRINTS("Failed to change step decay!");
}
DECLARE_DEFERRED(imvp8_tune_deferred);
@@ -386,7 +401,7 @@ void board_hibernate(void)
system_enter_psl_mode();
/* Cut off DSW power via the ROP PMIC. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x1);
/* Wait for power to be cut. */
while (1)
@@ -436,7 +451,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -445,7 +460,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V100ACNT:
@@ -454,7 +469,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* V085ACNT:
@@ -463,7 +478,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x2a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -475,7 +490,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -484,7 +499,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V100ACNT:
@@ -493,7 +508,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x5a);
/*
* V085ACNT:
@@ -502,7 +517,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x6a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -518,15 +533,16 @@ static void board_pmic_init(void)
int pgmask1;
/* Mask V5A_DS3_PG from PMIC PGMASK1. */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x18, &pgmask1))
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ 0x18, &pgmask1))
return;
- pgmask1 |= (1 << 2);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x18, pgmask1);
+ pgmask1 |= BIT(2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x18, pgmask1);
board_pmic_disable_slp_s0_vr_decay();
/* Enable active discharge (100 ohms) on V33A_PCH and V1.8A. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3D, 0x5);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3D, 0x5);
}
DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT);
@@ -540,6 +556,14 @@ static void board_quirks(void)
gpio_set_flags(GPIO_USB_C0_PD_INT_ODL, GPIO_INT_FALLING);
gpio_set_flags(GPIO_USB_C1_PD_INT_ODL, GPIO_INT_FALLING);
}
+
+ /*
+ * Older boards don't have the SBU bypass circuitry needed for CCD, so
+ * enable the CCD_MODE_ODL interrupt such that we can help in making
+ * sure the SBU FETs are connected.
+ */
+ if (board_get_version() < 2)
+ gpio_enable_interrupt(GPIO_CCD_MODE_ODL);
}
DECLARE_HOOK(HOOK_INIT, board_quirks, HOOK_PRIO_DEFAULT);
@@ -609,29 +633,29 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
- if (!(vrfault & (1 << 4)))
+ if (!(vrfault & BIT(4)))
return;
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, (1 << 4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -674,10 +698,13 @@ int board_set_active_charge_port(int port)
port < CONFIG_USB_PD_PORT_COUNT);
int i;
int rv;
+ int old_port;
if (!is_real_port && port != CHARGE_PORT_NONE)
return EC_ERROR_INVAL;
+ old_port = charge_manager_get_active_charge_port();
+
CPRINTS("New chg p%d", port);
if (port == CHARGE_PORT_NONE) {
@@ -713,12 +740,23 @@ int board_set_active_charge_port(int port)
CPRINTS("p%d: sink path disable failed.", i);
}
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
/* Enable requested charge port. */
if (ppc_vbus_sink_enable(port, 1)) {
CPRINTS("p%d: sink path enable failed.");
+ charger_discharge_on_ac(0);
return EC_ERROR_UNKNOWN;
}
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
return EC_SUCCESS;
}
@@ -753,7 +791,7 @@ uint16_t tcpc_get_alert_status(void)
if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL)) {
if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
/* The TCPCI spec says to ignore bits 14:12. */
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+ regval &= ~(BIT(14) | BIT(13) | BIT(12));
if (regval)
status |= PD_STATUS_TCPC_ALERT_0;
@@ -763,7 +801,7 @@ uint16_t tcpc_get_alert_status(void)
if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) {
if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
/* TCPCI spec says to ignore bits 14:12. */
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+ regval &= ~(BIT(14) | BIT(13) | BIT(12));
if (regval)
status |= PD_STATUS_TCPC_ALERT_1;
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index fc43a119ed..d678f70a3e 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -44,6 +44,8 @@
#define CONFIG_VSTORE
#define CONFIG_VSTORE_SLOT_COUNT 1
+#define CONFIG_DETACHABLE_BASE
+
/* EC console commands */
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
@@ -83,18 +85,18 @@
/* MKBP */
#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_HOST_EVENT
+#define CONFIG_MKBP_EVENT_WAKEUP_MASK 0
#define CONFIG_KEYBOARD_PROTOCOL_MKBP
-#define CONFIG_MKBP_USE_GPIO
+#define CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT
/* Sensors */
#define CONFIG_ALS
#define ALS_COUNT 1
#define CONFIG_ALS_OPT3001
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
-#define CONFIG_ACCEL_FIFO 1024 /* Must be a power of 2 */
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
+#define CONFIG_ACCEL_FIFO 512 /* Must be a power of 2 */
/* Depends on how fast the AP boots and typical ODRs */
-#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 100)
+#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
@@ -127,7 +129,6 @@
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
#define CONFIG_USB_PD_LOGGING
-#define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPM_PS8805
@@ -174,8 +175,8 @@
#define GPIO_USB_C1_SCL GPIO_EC_I2C2_USB_C1_SCL
#define GPIO_USB_C1_SDA GPIO_EC_I2C2_USB_C1_SDA
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_BD99992 0x60
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_BD99992__7bf 0x30
/*
* Remapping of schematic GPIO names to common GPIO names expected (hardcoded)
@@ -213,16 +214,6 @@ enum adc_channel {
ADC_CH_COUNT
};
-enum power_signal {
- X86_SLP_S0_DEASSERTED,
- X86_SLP_S3_DEASSERTED,
- X86_SLP_S4_DEASSERTED,
- X86_SLP_SUS_DEASSERTED,
- X86_RSMRST_L_PGOOD,
- X86_PMIC_DPWROK,
- POWER_SIGNAL_COUNT
-};
-
enum temp_sensor_id {
TEMP_SENSOR_BATTERY, /* BD99956GW TSENSE */
TEMP_SENSOR_AMBIENT, /* BD99992GW SYSTHERM0 */
@@ -257,7 +248,7 @@ enum sensor_id {
SENSOR_COUNT,
};
-#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS)
+#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS)
void base_pwr_fault_interrupt(enum gpio_signal s);
int board_get_version(void);
diff --git a/board/nucleo-f411re/board.c b/board/nucleo-f411re/board.c
index 0f7c57f1e3..d2f587321f 100644
--- a/board/nucleo-f411re/board.c
+++ b/board/nucleo-f411re/board.c
@@ -75,7 +75,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = NULL,
.default_range = 2, /* g, enough for laptop. */
.config = {
@@ -102,7 +102,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = NULL,
},
diff --git a/board/oak/battery.c b/board/oak/battery.c
index a868e20bc0..25d6b6e46d 100644
--- a/board/oak/battery.c
+++ b/board/oak/battery.c
@@ -57,10 +57,10 @@ static int cutoff(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/oak/board.c b/board/oak/board.c
index 476ef90b76..41ad3a5526 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -117,7 +117,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -125,7 +125,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF + 1,
},
.drv = &tcpci_tcpm_drv,
},
@@ -176,17 +176,17 @@ BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0x54 << 1,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
},
#if (BOARD_REV <= OAK_REV4)
{
- .port_addr = 0x55 << 1,
+ .port_addr = 0x55,
.driver = &pi3usb30532_usb_mux_driver,
},
#else
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
},
#endif
@@ -647,7 +647,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = 1,
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(0),
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -671,7 +671,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = 1,
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(0),
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -689,7 +689,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
diff --git a/board/oak/board.h b/board/oak/board.h
index e4ae567b29..af68701ab1 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -160,7 +160,7 @@
#define CONFIG_SPI_ACCEL_PORT 0 /* First SPI master port (SPI2) */
/* Ambient Light Sensor address */
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
/* Timer selection */
#define TIM_CLOCK32 2
diff --git a/board/pdeval-stm32f072/board.c b/board/pdeval-stm32f072/board.c
index 5a632ced06..e2e6bc63b6 100644
--- a/board/pdeval-stm32f072/board.c
+++ b/board/pdeval-stm32f072/board.c
@@ -4,8 +4,8 @@
*/
/* STM32F072-discovery board based USB PD evaluation configuration */
-#include "anx7447.h"
#include "common.h"
+#include "anx7447.h"
#include "ec_version.h"
#include "gpio.h"
#include "hooks.h"
@@ -62,7 +62,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = AN7447_TCPC3_I2C_ADDR,
+ .addr__7bf = AN7447_TCPC3_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
},
diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c
index ba899f5efb..4b1e7ca6f7 100644
--- a/board/pdeval-stm32f072/usb_pd_policy.c
+++ b/board/pdeval-stm32f072/usb_pd_policy.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "anx7447.h"
#include "common.h"
+#include "anx7447.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
diff --git a/board/phaser/board.c b/board/phaser/board.c
index 90f5c3e30a..353eeed9e5 100644
--- a/board/phaser/board.c
+++ b/board/phaser/board.c
@@ -30,20 +30,15 @@
#include "temp_sensor.h"
#include "thermistor.h"
#include "util.h"
+#include "battery_smart.h"
-static uint16_t sku_id;
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-static void tcpc_alert_event(enum gpio_signal signal)
-{
- if ((signal == GPIO_USB_C1_MUX_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
- return;
+#define USB_PD_PORT_ANX7447 0
+#define USB_PD_PORT_PS8751 1
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
-}
+static uint8_t sku_id;
static void ppc_interrupt(enum gpio_signal signal)
{
@@ -70,6 +65,11 @@ const struct adc_t adc_channels[] = {
"TEMP_AMB", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
[ADC_TEMP_SENSOR_CHARGER] = {
"TEMP_CHARGER", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+ /* Vbus sensing (1/10 voltage divider). */
+ [ADC_VBUS_C0] = {
+ "VBUS_C0", NPCX_ADC_CH9, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
+ [ADC_VBUS_C1] = {
+ "VBUS_C1", NPCX_ADC_CH4, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
@@ -92,20 +92,6 @@ const struct temp_sensor_t temp_sensors[] = {
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-static void customize_based_on_board_id(void)
-{
- uint32_t board_id = 0;
-
- /* Errors will count as board_id 0 */
- cbi_get_board_version(&board_id);
-
- if (board_id == 0) {
- if (anx7447_flash_erase(0 /* C0: ANX7447 */))
- ccprints("Failed to erase OCM flash!");
- }
-}
-DECLARE_HOOK(HOOK_INIT, customize_based_on_board_id, HOOK_PRIO_INIT_I2C + 1);
-
/* Motion sensors */
/* Mutexes */
static struct mutex g_lid_mutex;
@@ -125,31 +111,31 @@ static struct lsm6dsm_data lsm6dsm_data;
/* Drivers */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LIS2DE,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &lis2dh_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_lis2dh_data,
- .port = I2C_PORT_SENSOR,
- .addr = LIS2DH_ADDR1,
- .rot_standard_ref = &standard_rot_ref,
- /* We only use 2g because its resolution is only 8-bits */
- .default_range = 2, /* g */
- .min_frequency = LIS2DH_ODR_MIN_VAL,
- .max_frequency = LIS2DH_ODR_MAX_VAL,
- .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_LIS2DE,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &lis2dh_drv,
+ .mutex = &g_lid_mutex,
+ .drv_data = &g_lis2dh_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr__7bf = LIS2DH_ADDR1__7bf,
+ .rot_standard_ref = &standard_rot_ref,
+ /* We only use 2g because its resolution is only 8-bits */
+ .default_range = 2, /* g */
+ .min_frequency = LIS2DH_ODR_MIN_VAL,
+ .max_frequency = LIS2DH_ODR_MAX_VAL,
+ .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,
+ },
},
- },
},
[BASE_ACCEL] = {
@@ -165,7 +151,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &standard_rot_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -182,7 +168,6 @@ struct motion_sensor_t motion_sensors[] = {
.ec_rate = 100 * MSEC,
},
},
- },
},
[BASE_GYRO] = {
@@ -198,7 +183,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &standard_rot_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -210,15 +195,23 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
static int board_is_convertible(void)
{
- return sku_id == 2 || sku_id == 3 || sku_id == 255;
+ return sku_id == 2 || sku_id == 3 || sku_id == 4 || sku_id == 5 || \
+ sku_id == 255;
}
-static void board_set_motion_sensor_count(void)
+static void board_update_sensor_config_from_sku(void)
{
- if (board_is_convertible())
+ if (board_is_convertible()) {
motion_sensor_count = ARRAY_SIZE(motion_sensors);
- else
+ /* Enable Base Accel interrupt */
+ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ } else {
motion_sensor_count = 0;
+ hall_sensor_disable();
+ /* Base accel is not stuffed, don't allow line to float */
+ gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L,
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ }
}
static void cbi_init(void)
@@ -229,18 +222,10 @@ static void cbi_init(void)
sku_id = val;
ccprints("SKU: 0x%04x", sku_id);
- board_set_motion_sensor_count();
+ board_update_sensor_config_from_sku();
}
DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
-/* Initialize board. */
-static void board_init(void)
-{
- /* Enable Base Accel interrupt */
- gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
#ifndef TEST_BUILD
/* This callback disables keyboard when convertibles are fully open */
void lid_angle_peripheral_enable(int enable)
@@ -262,3 +247,56 @@ int board_is_lid_angle_tablet_mode(void)
{
return board_is_convertible();
}
+
+/* Battery functions */
+#define SB_OPTIONALMFG_FUNCTION2 0x3e
+/* Optional mfg function2 */
+#define SMART_QUICK_CHARGE (1<<12)
+/* Quick charge support */
+#define MODE_QUICK_CHARGE_SUPPORT (1<<4)
+
+static void sb_quick_charge_mode(int enable)
+{
+ int val, rv;
+
+ rv = sb_read(SB_BATTERY_MODE, &val);
+ if (rv || !(val & MODE_QUICK_CHARGE_SUPPORT))
+ return;
+
+ rv = sb_read(SB_OPTIONALMFG_FUNCTION2, &val);
+ if (rv)
+ return;
+
+ if (enable)
+ val |= SMART_QUICK_CHARGE;
+ else
+ val &= ~SMART_QUICK_CHARGE;
+
+ sb_write(SB_OPTIONALMFG_FUNCTION2, val);
+}
+
+/* Called on AP S3/S0ix -> S0 transition */
+static void board_chipset_resume(void)
+{
+ /* Normal charge current */
+ sb_quick_charge_mode(0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
+
+/* Called on AP S0 -> S3/S0ix transition */
+static void board_chipset_suspend(void)
+{
+ /* Quick charge current */
+ sb_quick_charge_mode(1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
+
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
+}
diff --git a/board/plankton/board.c b/board/plankton/board.c
index 5cd9e54486..c6c65ce789 100644
--- a/board/plankton/board.c
+++ b/board/plankton/board.c
@@ -467,7 +467,7 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* 8-bit address */
-#define SN75DP130_I2C_ADDR 0x5c
+#define SN75DP130_I2C_ADDR__7bf 0x2e
/*
* Pin number for active-high reset from PCA9534 to CMOS pull-down to
* SN75DP130's RSTN (active-low)
@@ -476,7 +476,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
static int sn75dp130_i2c_write(uint8_t index, uint8_t value)
{
- return i2c_write8(I2C_PORT_MASTER, SN75DP130_I2C_ADDR, index, value);
+ return i2c_write8__7bf(I2C_PORT_MASTER, SN75DP130_I2C_ADDR__7bf,
+ index, value);
}
/**
@@ -489,15 +490,17 @@ static int sn75dp130_reset(void)
{
int rv;
- rv = pca9534_config_pin(I2C_PORT_MASTER, 0x40, REDRIVER_RST_PIN,
- PCA9534_OUTPUT);
+ rv = pca9534_config_pin__7bf(I2C_PORT_MASTER, 0x20,
+ REDRIVER_RST_PIN, PCA9534_OUTPUT);
/* Assert (its active high) */
- rv |= pca9534_set_level(I2C_PORT_MASTER, 0x40, REDRIVER_RST_PIN, 1);
+ rv |= pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ REDRIVER_RST_PIN, 1);
/* datasheet recommends > 100usec */
usleep(200);
/* De-assert */
- rv |= pca9534_set_level(I2C_PORT_MASTER, 0x40, REDRIVER_RST_PIN, 0);
+ rv |= pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ REDRIVER_RST_PIN, 0);
/* datasheet recommends > 400msec */
usleep(450 * MSEC);
return rv;
@@ -593,10 +596,12 @@ int board_in_hub_mode(void)
int ret;
int level;
- ret = pca9534_config_pin(I2C_PORT_MASTER, 0x40, 6, PCA9534_INPUT);
+ ret = pca9534_config_pin__7bf(I2C_PORT_MASTER, 0x20,
+ 6, PCA9534_INPUT);
if (ret)
return -1;
- ret = pca9534_get_level(I2C_PORT_MASTER, 0x40, 6, &level);
+ ret = pca9534_get_level__7bf(I2C_PORT_MASTER, 0x20,
+ 6, &level);
if (ret)
return -1;
return level;
@@ -606,14 +611,17 @@ static int board_usb_hub_reset(void)
{
int ret;
- ret = pca9534_config_pin(I2C_PORT_MASTER, 0x40, 7, PCA9534_OUTPUT);
+ ret = pca9534_config_pin__7bf(I2C_PORT_MASTER, 0x20,
+ 7, PCA9534_OUTPUT);
if (ret)
return ret;
- ret = pca9534_set_level(I2C_PORT_MASTER, 0x40, 7, 0);
+ ret = pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ 7, 0);
if (ret)
return ret;
usleep(100 * MSEC);
- return pca9534_set_level(I2C_PORT_MASTER, 0x40, 7, 1);
+ return pca9534_set_level__7bf(I2C_PORT_MASTER, 0x20,
+ 7, 1);
}
void board_maybe_reset_usb_hub(void)
diff --git a/board/poppy/board.c b/board/poppy/board.c
index 189452bf97..90e56b6fa8 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -142,44 +142,8 @@ void anx74xx_cable_det_interrupt(enum gpio_signal signal)
}
#endif
-static int command_attach_base(int argc, char **argv)
-{
- tablet_set_mode(0);
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(attachbase, command_attach_base,
- NULL, "Simulate attach base");
-
-static int command_detach_base(int argc, char **argv)
-{
- tablet_set_mode(1);
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(detachbase, command_detach_base,
- NULL, "Simulate detach base");
-
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
-#ifdef CONFIG_POWER_S0IX
- {GPIO_PCH_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
-#endif
-#ifdef CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS
- {VW_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {VW_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
-#else
- {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {GPIO_PCH_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
-#endif
- {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"},
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"},
- {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* Hibernate wake configuration */
const enum gpio_signal hibernate_wake_pins[] = {
GPIO_AC_PRESENT,
@@ -229,7 +193,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -237,7 +201,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -327,7 +291,7 @@ void board_tcpc_init(void)
*
* NOTE: PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(NPCX_I2C_PORT0_1, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(NPCX_I2C_PORT0_1, 0x08, 0xA0, &reg);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -394,29 +358,29 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
- if (!(vrfault & (1 << 4)))
+ if (!(vrfault & BIT(4)))
return;
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, (1 << 4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -435,7 +399,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -444,7 +408,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V100ACNT:
@@ -453,7 +417,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x1a);
/*
* V085ACNT:
@@ -462,7 +426,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x3a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -474,7 +438,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -483,7 +447,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V100ACNT:
@@ -492,7 +456,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x37, 0x5a);
/*
* V085ACNT:
@@ -501,7 +465,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -520,15 +484,15 @@ static void board_pmic_init(void)
return;
/* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x04);
board_pmic_disable_slp_s0_vr_decay();
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
/* Disable power button shutdown timer. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x14, 0x00);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x14, 0x00);
}
DECLARE_DEFERRED(board_pmic_init);
@@ -541,7 +505,7 @@ static void board_init(void)
* floating SPI buffer input (MISO), which causes power leakage (see
* b/64797021).
*/
- NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN);
+ NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN);
/* Provide AC status to the PCH */
gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
@@ -688,23 +652,24 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
void board_hibernate(void)
{
- CPRINTS("Triggering PMIC shutdown.");
- uart_flush_output();
-
- /* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
- /*
- * If we can't tell the PMIC to shutdown, instead reset
- * and don't start the AP. Hopefully we'll be able to
- * communicate with the PMIC next time.
- */
- CPRINTS("PMIC i2c failed.");
- system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
- }
-
- /* Await shutdown. */
- while (1)
- ;
+ CPRINTS("Triggering PMIC shutdown.");
+ uart_flush_output();
+
+ /* Trigger PMIC shutdown. */
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf,
+ 0x49, 0x01)) {
+ /*
+ * If we can't tell the PMIC to shutdown, instead reset
+ * and don't start the AP. Hopefully we'll be able to
+ * communicate with the PMIC next time.
+ */
+ CPRINTS("PMIC i2c failed.");
+ system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
+ }
+
+ /* Await shutdown. */
+ while (1)
+ ;
}
int board_get_version(void)
@@ -786,7 +751,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -810,7 +775,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -827,8 +792,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
- .default_range = 1 << 11, /* 16LSB / uT, fixed */
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
.max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
@@ -842,7 +807,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/poppy/board.h b/board/poppy/board.h
index 78beb1b5f1..3a90d35483 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -111,7 +111,7 @@
#define CONFIG_ALS
#define CONFIG_ALS_OPT3001
#define ALS_COUNT 1
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+#define OPT3001_I2C_ADDR__7bf OPT3001_I2C_ADDR1__7bf
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_BD99992GW
#define CONFIG_THERMISTOR_NCP15WB
@@ -124,7 +124,7 @@
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
/* Lower maximal ODR to 100Hz */
#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 100000
@@ -188,8 +188,8 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
#ifndef __ASSEMBLER__
diff --git a/board/rainier/board.c b/board/rainier/board.c
index 7022b4076a..8173414bf7 100644
--- a/board/rainier/board.c
+++ b/board/rainier/board.c
@@ -46,10 +46,7 @@
static void tcpc_alert_event(enum gpio_signal signal)
{
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ schedule_deferred_pd_interrupt(0 /* port */);
}
static void overtemp_interrupt(enum gpio_signal signal)
@@ -134,7 +131,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = FUSB302_I2C_SLAVE_ADDR,
+ .addr__7bf = FUSB302_I2C_SLAVE_ADDR__7bf,
},
.drv = &fusb302_tcpm_drv,
},
@@ -380,7 +377,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -403,7 +400,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -425,8 +422,8 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bmp280_drv,
.drv_data = &bmp280_drv_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
- .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
+ .default_range = BIT(18), /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
.min_frequency = BMP280_BARO_MIN_FREQ,
.max_frequency = BMP280_BARO_MAX_FREQ,
},
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 485cf3cc48..82af7a2667 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -62,17 +62,20 @@
static void tcpc_alert_event(enum gpio_signal signal)
{
- if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_PD_RST_C0_L))
- return;
- else if ((signal == GPIO_USB_C1_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
+ int port = -1;
+
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
return;
+ }
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ schedule_deferred_pd_interrupt(port);
}
/* Set PD discharge whenever VBUS detection is high (i.e. below threshold). */
@@ -111,21 +114,6 @@ void usb1_evt(enum gpio_signal signal)
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
-#ifdef CONFIG_POWER_S0IX
- {GPIO_PCH_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
-#endif
- {VW_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {VW_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
- {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"},
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"},
- {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* Hibernate wake configuration */
const enum gpio_signal hibernate_wake_pins[] = {
GPIO_AC_PRESENT,
@@ -163,7 +151,7 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -171,7 +159,8 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
+ /* Verified on v1.1 */
+ .addr__7bf = AN7447_TCPC3_I2C_ADDR__7bf,
},
.drv = &anx7447_tcpm_drv,
},
@@ -208,10 +197,10 @@ const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = {
void board_reset_pd_mcu(void)
{
/* Assert reset */
- gpio_set_level(GPIO_USB_PD_RST_C0_L, 0);
+ gpio_set_level(GPIO_USB_PD_RST_C0, 1);
gpio_set_level(GPIO_USB_C1_PD_RST_ODL, 0);
msleep(1);
- gpio_set_level(GPIO_USB_PD_RST_C0_L, 1);
+ gpio_set_level(GPIO_USB_PD_RST_C0, 0);
gpio_set_level(GPIO_USB_C1_PD_RST_ODL, 1);
/* After TEST_R release, anx7447/3447 needs 2ms to finish eFuse
* loading.
@@ -270,7 +259,7 @@ uint16_t tcpc_get_alert_status(void)
uint16_t status = 0;
if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL)) {
- if (gpio_get_level(GPIO_USB_PD_RST_C0_L))
+ if (!gpio_get_level(GPIO_USB_PD_RST_C0))
status |= PD_STATUS_TCPC_ALERT_0;
}
@@ -309,29 +298,29 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, &vrfault)
+ if (i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, &vrfault)
!= EC_SUCCESS)
return;
- if (!(vrfault & (1 << 4)))
+ if (!(vrfault & BIT(4)))
return;
/* VRFAULT has occurred, print VRFAULT status bits. */
/* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, &pwrstat1);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, &pwrstat1);
/* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, &pwrstat2);
+ i2c_read8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, &pwrstat2);
CPRINTS("PMIC VRFAULT: %s", str);
CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
pwrstat2);
/* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x8, (1 << 4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x17, pwrstat2);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x8, BIT(4));
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x16, pwrstat1);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x17, pwrstat2);
/*
* Status of the fault registers can be checked in the OS by looking at
@@ -350,7 +339,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x3a);
/*
* V18ACNT:
@@ -359,16 +348,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x2a);
-
- /*
- * V100ACNT:
- * Bits 7:6 (00) - Disable low power mode on SLP_S0# assertion
- * Bits 5:4 (01) - Nominal voltage 1.0V
- * Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
- * Bits 1:0 (10) - VR set to AUTO operating mode
- */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x2a);
/*
* V085ACNT:
@@ -377,7 +357,7 @@ static void board_pmic_disable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x3a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x3a);
}
static void board_pmic_enable_slp_s0_vr_decay(void)
@@ -389,7 +369,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x30, 0x7a);
/*
* V18ACNT:
@@ -398,16 +378,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x34, 0x6a);
-
- /*
- * V100ACNT:
- * Bits 7:6 (01) - Enable low power mode on SLP_S0# assertion
- * Bits 5:4 (01) - Nominal voltage 1.0V
- * Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
- * Bits 1:0 (10) - VR set to AUTO operating mode
- */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x5a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x34, 0x6a);
/*
* V085ACNT:
@@ -416,7 +387,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
* Bits 3:2 (10) - VR set to AUTO on SLP_S0# de-assertion
* Bits 1:0 (10) - VR set to AUTO operating mode
*/
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x38, 0x7a);
}
void power_board_handle_host_sleep_event(enum host_sleep_event state)
@@ -434,13 +405,20 @@ static void board_pmic_init(void)
if (system_jumped_to_this_image())
return;
- /* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3e, 0x04);
+ /*
+ * DISCHGCNT2 - enable 100 ohm discharge on
+ * V5A_DS3/V33A_DSW/V33A_PCH/V1.8A
+ */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3d, 0x55);
+ /* DISCHGCNT3 - enable 100 ohm discharge on V1.8U_25U/V1.00A */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3e, 0x44);
+ /* DISCHGCNT4 - enable 100 ohm discharge on v1.8S */
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3f, 0x04);
board_pmic_disable_slp_s0_vr_decay();
/* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x1f);
+ i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x3b, 0x1f);
}
DECLARE_DEFERRED(board_pmic_init);
@@ -453,7 +431,7 @@ static void board_init(void)
* floating SPI buffer input (MISO), which causes power leakage (see
* b/64797021).
*/
- NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN);
+ NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN);
/* Provide AC status to the PCH */
gpio_set_level(GPIO_PCH_ACPRESENT, extpower_is_present());
@@ -477,6 +455,19 @@ static void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+static void usb_charge_mode_init(void)
+{
+ /*
+ * By default, turn the charging off when system suspends.
+ * If system power on with connecting a USB device,
+ * the OS must send an event to EC to clear the
+ * inhibit_charging_in_suspend.
+ */
+ usb_charge_set_mode(0, CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE,
+ USB_DISALLOW_SUSPEND_CHARGE);
+}
+DECLARE_HOOK(HOOK_INIT, usb_charge_mode_init, HOOK_PRIO_DEFAULT + 1);
+
/**
* Buffer the AC present GPIO to the PCH.
*/
@@ -553,7 +544,7 @@ void board_hibernate(void)
uart_flush_output();
/* Trigger PMIC shutdown. */
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
+ if (i2c_write8__7bf(I2C_PORT_PMIC, I2C_ADDR_BD99992__7bf, 0x49, 0x01)) {
/*
* If we can't tell the PMIC to shutdown, instead reset
* and don't start the AP. Hopefully we'll be able to
@@ -589,8 +580,8 @@ static struct accelgyro_saved_data_t g_bma255_data;
/* Matrix to rotate accelrator into standard reference frame */
const mat33_fp_t base_standard_ref = {
- { FLOAT_TO_FP(-1), 0, 0 },
- { 0, FLOAT_TO_FP(1), 0 },
+ { FLOAT_TO_FP(1), 0, 0 },
+ { 0, FLOAT_TO_FP(-1), 0 },
{ 0, 0, FLOAT_TO_FP(-1) }
};
@@ -611,7 +602,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_bma255_data,
.port = I2C_PORT_ACCEL,
- .addr = BMA2x2_I2C_ADDR1,
+ .i2c_spi_addr__7bf = BMA2x2_I2C_ADDR1__7bf,
.rot_standard_ref = &lid_standard_ref,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -639,7 +630,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
@@ -667,7 +658,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -699,6 +690,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESET, board_chipset_reset, HOOK_PRIO_DEFAULT);
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
+ gpio_set_level(GPIO_KB_BL_EN, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
@@ -706,5 +698,20 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
+ gpio_set_level(GPIO_KB_BL_EN, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
+
+/* Called on AP S5 -> S3 transition */
+static void board_chipset_startup(void)
+{
+ gpio_set_level(GPIO_EN_PP3300_TRACKPAD, 1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
+
+/* Called on AP S3 -> S5 transition */
+static void board_chipset_shutdown(void)
+{
+ gpio_set_level(GPIO_EN_PP3300_TRACKPAD, 0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
diff --git a/board/rammus/board.h b/board/rammus/board.h
index 1088858a99..766e03d0af 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -189,9 +189,9 @@
#define I2C_PORT_THERMAL I2C_PORT_PMIC
/* I2C addresses */
-#define I2C_ADDR_BD99992 0x60
-#define I2C_ADDR_MP2949 0x40
-#define I2C_ADDR_EEPROM 0xa0
+#define I2C_ADDR_BD99992__7bf 0x30
+#define I2C_ADDR_MP2949__7bf 0x20
+#define I2C_ADDR_EEPROM__7bf 0x50
/* Rename GPIOs */
#define GPIO_PCH_SLP_S0_L GPIO_SLP_S0_L
diff --git a/board/reef/board.c b/board/reef/board.c
index 515d2da071..ea9e8e9e43 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -66,18 +66,20 @@
static void tcpc_alert_event(enum gpio_signal signal)
{
- if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C0_PD_RST_L))
- return;
+ int port = -1;
- if ((signal == GPIO_USB_C1_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
return;
+ }
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ schedule_deferred_pd_interrupt(port);
}
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
@@ -123,25 +125,6 @@ void tablet_mode_interrupt(enum gpio_signal signal)
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
-#ifdef CONFIG_POWER_S0IX
- {GPIO_PCH_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
-#endif
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L"},
- {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {GPIO_PCH_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"},
- {GPIO_SUSPWRNACK, POWER_SIGNAL_ACTIVE_HIGH,
- "SUSPWRNACK_DEASSERTED"},
-
- {GPIO_ALL_SYS_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "ALL_SYS_PGOOD"},
- {GPIO_PP3300_PG, POWER_SIGNAL_ACTIVE_HIGH, "PP3300_PG"},
- {GPIO_PP5000_PG, POWER_SIGNAL_ACTIVE_HIGH, "PP5000_PG"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* ADC channels */
const struct adc_t adc_channels[] = {
/* Vfs = Vref = 2.816V, 10-bit unsigned reading */
@@ -184,7 +167,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
.i2c_test = &anx74xx_i2c_stress_test_dev,
},
#endif
@@ -193,7 +176,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
.i2c_test = &ps8xxx_i2c_stress_test_dev,
},
#endif
@@ -202,7 +185,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .addr__7bf = BMI160_ADDR0__7bf,
.i2c_test = &bmi160_i2c_stress_test_dev,
},
#endif
@@ -211,19 +194,19 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
+ .addr__7bf = BMP280_I2C_ADDRESS1__7bf,
.i2c_test = &bmp280_i2c_stress_test_dev,
},
{
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .addr__7bf = KX022_ADDR1__7bf,
.i2c_test = &kionix_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ALS
{
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .addr__7bf = OPT3001_I2C_ADDR1__7bf,
.i2c_test = &opt3001_i2c_stress_test_dev,
},
#endif
@@ -248,7 +231,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_0,
- .addr = ANX74XX_I2C_ADDR1,
+ .addr__7bf = ANX74XX_I2C_ADDR1__7bf,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -256,7 +239,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = NPCX_I2C_PORT0_1,
- .addr = PS8751_I2C_ADDR1,
+ .addr__7bf = PS8751_I2C_ADDR1__7bf,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -384,7 +367,7 @@ void board_tcpc_init(void)
*
* NOTE: PS8751 A3 will wake on any I2C access.
*/
- i2c_read8(NPCX_I2C_PORT0_1, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(NPCX_I2C_PORT0_1, 0x08, 0xA0, &reg);
/* Enable TCPC0 interrupt */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -732,7 +715,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -759,7 +742,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -788,7 +771,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -804,8 +787,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
- .default_range = 1 << 11, /* 16LSB / uT, fixed */
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
.max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
@@ -819,8 +802,8 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bmp280_drv,
.drv_data = &bmp280_drv_data,
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
- .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
+ .i2c_spi_addr__7bf = BMP280_I2C_ADDRESS1__7bf,
+ .default_range = BIT(18), /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
.min_frequency = BMP280_BARO_MIN_FREQ,
.max_frequency = BMP280_BARO_MAX_FREQ,
},
@@ -833,7 +816,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/reef/board.h b/board/reef/board.h
index ba31d0556c..143cdfea12 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -196,7 +196,7 @@
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_BMI160_BMM150
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index 47c63c0599..83e9b3fefa 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -181,12 +181,12 @@ static void it83xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xa8,
+ .port_addr = 0x54,
.driver = &pi3usb30532_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
{
- .port_addr = 0x20,
+ .port_addr = 0x10,
.driver = &ps874x_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c
index 4e3b1368c6..206d6dd1d0 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -100,18 +100,20 @@ void board_config_pre_init(void)
*/
static void tcpc_alert_event(enum gpio_signal signal)
{
- if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C0_PD_RST_L))
- return;
+ int port = -1;
- if ((signal == GPIO_USB_C1_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
return;
+ }
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
+ schedule_deferred_pd_interrupt(port);
}
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
@@ -159,28 +161,6 @@ void tablet_mode_interrupt(enum gpio_signal signal)
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
-#ifdef CONFIG_POWER_S0IX
- {GPIO_PCH_SLP_S0_L,
- POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT,
- "SLP_S0_DEASSERTED"},
-#endif
- {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH,
- "RSMRST_L"},
- {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH,
- "SLP_S3_DEASSERTED"},
- {GPIO_PCH_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH,
- "SLP_S4_DEASSERTED"},
- {GPIO_SUSPWRNACK, POWER_SIGNAL_ACTIVE_HIGH,
- "SUSPWRNACK_DEASSERTED"},
- {GPIO_ALL_SYS_PGOOD, POWER_SIGNAL_ACTIVE_HIGH,
- "ALL_SYS_PGOOD"},
- {GPIO_PP3300_PG, POWER_SIGNAL_ACTIVE_HIGH, "PP3300_PG"},
- {GPIO_PP5000_PG, POWER_SIGNAL_ACTIVE_HIGH, "PP5000_PG"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
/* SPI devices */
const struct spi_device_t spi_devices[] = {
{ QMSPI0_PORT, 4, GPIO_QMSPI_CS0},
@@ -303,7 +283,7 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = MCHP_I2C_PORT0,
- .addr = 0x50,
+ .addr__7bf = 0x28,
.i2c_test = &anx74xx_i2c_stress_test_dev,
},
#endif
@@ -311,33 +291,33 @@ struct i2c_stress_test i2c_stress_tests[] = {
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
{
.port = MCHP_I2C_PORT2,
- .addr = 0x16,
+ .addr__7bf = 0x0B,
.i2c_test = &ps8xxx_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .addr__7bf = BMI160_ADDR0__7bf,
.i2c_test = &bmi160_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
{
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
+ .addr__7bf = BMP280_I2C_ADDRESS1__7bf,
.i2c_test = &bmp280_i2c_stress_test_dev,
},
{
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .addr__7bf = KX022_ADDR1__7bf,
.i2c_test = &kionix_i2c_stress_test_dev,
},
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ALS
{
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .addr__7bf = OPT3001_I2C_ADDR1__7bf,
.i2c_test = &opt3001_i2c_stress_test_dev,
},
#endif
@@ -362,7 +342,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = MCHP_I2C_PORT0,
- .addr = 0x50,
+ .addr__7bf = 0x28,
},
.drv = &anx74xx_tcpm_drv,
},
@@ -370,7 +350,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = MCHP_I2C_PORT2,
- .addr = 0x16,
+ .addr__7bf = 0x0B,
},
.drv = &ps8xxx_tcpm_drv,
},
@@ -533,7 +513,7 @@ void board_tcpc_init(void)
* address 0x10. Is this another attempt at waking PS8751
* from DRP low power idle mode?
*/
- i2c_read8(MCHP_I2C_PORT2, 0x10, 0xA0, &reg);
+ i2c_read8__7bf(MCHP_I2C_PORT2, 0x08, 0xA0, &reg);
/* Enable TCPC0 interrupt */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -786,27 +766,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
-/*
- * MCHP next two functions from production firmware-reef-9042.B
- * Have changes to USB PD common and TCPCI driver code deprecated
- * these functions?
- */
-/**
- * Return whether ramping is allowed for given supplier
- */
-int board_is_ramp_allowed(int supplier)
-{
- /* Don't allow ramping in RO when write protected */
- if (system_get_image_copy() != SYSTEM_IMAGE_RW
- && system_is_locked())
- return 0;
- else
- return (supplier == CHARGE_SUPPLIER_BC12_DCP ||
- supplier == CHARGE_SUPPLIER_BC12_SDP ||
- supplier == CHARGE_SUPPLIER_BC12_CDP ||
- supplier == CHARGE_SUPPLIER_OTHER);
-}
-
/**
* Return if board is consuming full amount of input current
*/
@@ -1002,7 +961,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kx022_data,
.port = I2C_PORT_LID_ACCEL,
- .addr = KX022_ADDR1,
+ .i2c_spi_addr__7bf = KX022_ADDR1__7bf,
.rot_standard_ref = NULL, /* Identity matrix. */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KX022_ACCEL_MIN_FREQ,
@@ -1029,7 +988,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -1058,7 +1017,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
@@ -1074,8 +1033,8 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_GYRO,
- .addr = BMI160_ADDR0,
- .default_range = 1 << 11, /* 16LSB / uT, fixed */
+ .i2c_spi_addr__7bf = BMI160_ADDR0__7bf,
+ .default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
.max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
@@ -1089,8 +1048,8 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &bmp280_drv,
.drv_data = &bmp280_drv_data,
.port = I2C_PORT_BARO,
- .addr = BMP280_I2C_ADDRESS1,
- .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
+ .i2c_spi_addr__7bf = BMP280_I2C_ADDRESS1__7bf,
+ .default_range = BIT(18), /* 1bit = 4 Pa, 16bit ~= 2600 hPa */
.min_frequency = BMP280_BARO_MIN_FREQ,
.max_frequency = BMP280_BARO_MAX_FREQ,
},
@@ -1103,7 +1062,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &opt3001_drv,
.drv_data = &g_opt3001_data,
.port = I2C_PORT_ALS,
- .addr = OPT3001_I2C_ADDR1,
+ .i2c_spi_addr__7bf = OPT3001_I2C_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1; uscale = 0 */
.min_frequency = OPT3001_LIGHT_MIN_FREQ,
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index de3a36a291..78269f05b6 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -203,7 +203,7 @@
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_BMI160_BMM150
-#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
+#define CONFIG_ACCELGYRO_SEC_ADDR__7BF BMM150_ADDR0__7bf
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
diff --git a/board/samus/battery.c b/board/samus/battery.c
index f3c78e9d96..6990db853b 100644
--- a/board/samus/battery.c
+++ b/board/samus/battery.c
@@ -290,10 +290,10 @@ int board_cut_off_battery(void)
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
- rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
- I2C_XFER_SINGLE);
+ rv = i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
+ rv |= i2c_xfer_unlocked__7bf(I2C_PORT_BATTERY, BATTERY_ADDR__7bf,
+ buf, 3, NULL, 0, I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
diff --git a/board/samus/board.c b/board/samus/board.c
index b8f66ca101..e8a25205a6 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -132,29 +132,35 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-#define TEMP_U40_REG_ADDR ((0x40 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U41_REG_ADDR ((0x44 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U42_REG_ADDR ((0x41 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U43_REG_ADDR ((0x45 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U115_REG_ADDR ((0x42 << 1) | I2C_FLAG_BIG_ENDIAN)
-#define TEMP_U116_REG_ADDR ((0x43 << 1) | I2C_FLAG_BIG_ENDIAN)
-
-#define TEMP_U40_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U40_REG_ADDR)
-#define TEMP_U41_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U41_REG_ADDR)
-#define TEMP_U42_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U42_REG_ADDR)
-#define TEMP_U43_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U43_REG_ADDR)
-#define TEMP_U115_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U115_REG_ADDR)
-#define TEMP_U116_ADDR TMP006_ADDR(I2C_PORT_THERMAL, TEMP_U116_REG_ADDR)
-
-const struct tmp006_t tmp006_sensors[TMP006_COUNT] = {
- {"Charger", TEMP_U40_ADDR},
- {"CPU", TEMP_U41_ADDR},
- {"Left C", TEMP_U42_ADDR},
- {"Right C", TEMP_U43_ADDR},
- {"Right D", TEMP_U115_ADDR},
- {"Left D", TEMP_U116_ADDR},
+#define TEMP_U40_REG_ADDR__7bf (0x40 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U41_REG_ADDR__7bf (0x44 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U42_REG_ADDR__7bf (0x41 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U43_REG_ADDR__7bf (0x45 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U115_REG_ADDR__7bf (0x42 | I2C_FLAG_BIG_ENDIAN)
+#define TEMP_U116_REG_ADDR__7bf (0x43 | I2C_FLAG_BIG_ENDIAN)
+
+#define TEMP_U40_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U40_REG_ADDR__7bf)
+#define TEMP_U41_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U41_REG_ADDR__7bf)
+#define TEMP_U42_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U42_REG_ADDR__7bf)
+#define TEMP_U43_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U43_REG_ADDR__7bf)
+#define TEMP_U115_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U115_REG_ADDR__7bf)
+#define TEMP_U116_ADDR__7bf TMP006_ADDR__7bf(I2C_PORT_THERMAL,\
+ TEMP_U116_REG_ADDR__7bf)
+
+const struct tmp006_t tmp006_sensors__7bf[TMP006_COUNT] = {
+ {"Charger", TEMP_U40_ADDR__7bf},
+ {"CPU", TEMP_U41_ADDR__7bf},
+ {"Left C", TEMP_U42_ADDR__7bf},
+ {"Right C", TEMP_U43_ADDR__7bf},
+ {"Right D", TEMP_U115_ADDR__7bf},
+ {"Left D", TEMP_U116_ADDR__7bf},
};
-BUILD_ASSERT(ARRAY_SIZE(tmp006_sensors) == TMP006_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(tmp006_sensors__7bf) == TMP006_COUNT);
/* Temperature sensors data; must be in same order as enum temp_sensor_id. */
const struct temp_sensor_t temp_sensors[] = {
@@ -326,7 +332,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_saved_data[0],
.port = I2C_PORT_ACCEL,
- .addr = LSM6DS0_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DS0_ADDR1__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = LSM6DS0_ACCEL_MIN_FREQ,
@@ -358,7 +364,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_lid_mutex,
.drv_data = &g_kxcj9_data,
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -381,7 +387,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_saved_data[1],
.port = I2C_PORT_ACCEL,
- .addr = LSM6DS0_ADDR1,
+ .i2c_spi_addr__7bf = LSM6DS0_ADDR1__7bf,
.rot_standard_ref = NULL,
.default_range = 2000, /* g, enough for laptop. */
.min_frequency = LSM6DS0_GYRO_MIN_FREQ,
diff --git a/board/samus/extpower.c b/board/samus/extpower.c
index c2fabbd35e..a803171e7a 100644
--- a/board/samus/extpower.c
+++ b/board/samus/extpower.c
@@ -159,7 +159,7 @@ static void allow_max_request(void)
int prochot_status;
if (charge_circuit_state == CHARGE_CIRCUIT_WEDGED) {
/* Read PROCHOT status register to clear it */
- i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
+ i2c_read8__7bf(I2C_PORT_CHARGER, BQ24773_ADDR__7bf,
BQ24773_PROCHOT_STATUS, &prochot_status);
charge_circuit_state = CHARGE_CIRCUIT_OK;
}
@@ -301,7 +301,7 @@ static void check_charge_wedged(void)
if (charge_circuit_state == CHARGE_CIRCUIT_OK) {
/* Check PROCHOT warning */
- rv = i2c_read8(I2C_PORT_CHARGER, BQ24773_ADDR,
+ rv = i2c_read8__7bf(I2C_PORT_CHARGER, BQ24773_ADDR__7bf,
BQ24773_PROCHOT_STATUS, &prochot_status);
if (rv)
prochot_status = 0;
diff --git a/board/samus/panel.c b/board/samus/panel.c
index 970197b9c8..bead90cdcd 100644
--- a/board/samus/panel.c
+++ b/board/samus/panel.c
@@ -15,7 +15,7 @@
#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
-#define I2C_ADDR_BACKLIGHT ((0x2C << 1) | I2C_FLAG_BIG_ENDIAN)
+#define I2C_ADDR_BACKLIGHT__7bf (0x2C | I2C_FLAG_BIG_ENDIAN)
#define I2C_RETRIES 3
#define I2C_RETRY_DELAY (5*MSEC)
@@ -61,7 +61,8 @@ static int lp8555_read_with_retry(int reg, int *data)
int i, rv;
for (i = 0; i < I2C_RETRIES; i++) {
- rv = i2c_read8(I2C_PORT_BACKLIGHT, I2C_ADDR_BACKLIGHT,
+ rv = i2c_read8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_BACKLIGHT__7bf,
reg, data);
if (rv == EC_SUCCESS)
return EC_SUCCESS;
@@ -78,8 +79,9 @@ static int lp8555_write_with_retry(int reg, int data)
int i, rv;
for (i = 0; i < I2C_RETRIES; i++) {
- rv = i2c_write8(I2C_PORT_BACKLIGHT, I2C_ADDR_BACKLIGHT,
- reg, data);
+ rv = i2c_write8__7bf(I2C_PORT_BACKLIGHT,
+ I2C_ADDR_BACKLIGHT__7bf,
+ reg, data);
if (rv == EC_SUCCESS)
return EC_SUCCESS;
usleep(I2C_RETRY_DELAY);
diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h
index 2efeb35d56..d3f4a0b3f5 100644
--- a/board/samus_pd/board.h
+++ b/board/samus_pd/board.h
@@ -89,7 +89,7 @@
/* slave address for host commands */
#ifdef HAS_TASK_HOSTCMD
-#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR CONFIG_USB_PD_I2C_SLAVE_ADDR
+#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF CONFIG_USB_PD_I2C_SLAVE_ADDR__7BF
#endif
#ifndef __ASSEMBLER__
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index bf308266bf..1dbb815dff 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -130,7 +130,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
- .addr = FUSB302_I2C_SLAVE_ADDR,
+ .addr__7bf = FUSB302_I2C_SLAVE_ADDR__7bf,
},
.drv = &fusb302_tcpm_drv,
},
@@ -400,7 +400,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = BMI160_ACCEL_MIN_FREQ,
@@ -423,7 +423,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = CONFIG_SPI_ACCEL_PORT,
- .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT),
+ .i2c_spi_addr__7bf = SLAVE_MK_SPI_ADDR__7bf(CONFIG_SPI_ACCEL_PORT),
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index 842c6d546c..89071f2423 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -176,7 +176,7 @@
#define I2C_PORT_TCPC0 1
/* Route sbs host requests to virtual battery driver */
-#define VIRTUAL_BATTERY_ADDR 0x16
+#define VIRTUAL_BATTERY_ADDR__7bf 0x0B
/* Enable Accel over SPI */
#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c
index a06978b84d..cbc5f18f95 100644
--- a/board/servo_micro/board.c
+++ b/board/servo_micro/board.c
@@ -248,8 +248,8 @@ DECLARE_CONSOLE_COMMAND(baud, command_uart_baud,
* enable_ite_dfu stops working, or does not work on a new ITE EC chip revision.
*/
-#define ITE_DFU_I2C_CMD_ADDR 0xB4 /* 7 bit form is 0x5A */
-#define ITE_DFU_I2C_DATA_ADDR 0x6A /* 7 bit form is 0x35 */
+#define ITE_DFU_I2C_CMD_ADDR__7bf 0x5A
+#define ITE_DFU_I2C_DATA_ADDR__7bf 0x35
#define SMCLK_WAVEFORM_PERIOD_HZ (100 * KHz)
#define SMDAT_WAVEFORM_PERIOD_HZ (200 * KHz)
@@ -287,14 +287,17 @@ static int ite_i2c_read_register(uint8_t register_offset, uint8_t *output)
*/
int ret;
/* Tell the ITE EC which register we want to read. */
- ret = i2c_xfer_unlocked(I2C_PORT_MASTER, ITE_DFU_I2C_CMD_ADDR,
- &register_offset, sizeof(register_offset),
- NULL, 0, I2C_XFER_SINGLE);
+ ret = i2c_xfer_unlocked__7bf(I2C_PORT_MASTER,
+ ITE_DFU_I2C_CMD_ADDR__7bf,
+ &register_offset, sizeof(register_offset),
+ NULL, 0, I2C_XFER_SINGLE);
if (ret != EC_SUCCESS)
return ret;
/* Read in the 1 byte register value. */
- ret = i2c_xfer_unlocked(I2C_PORT_MASTER, ITE_DFU_I2C_DATA_ADDR, NULL, 0,
- output, sizeof(*output), I2C_XFER_SINGLE);
+ ret = i2c_xfer_unlocked__7bf(I2C_PORT_MASTER,
+ ITE_DFU_I2C_DATA_ADDR__7bf,
+ NULL, 0,
+ output, sizeof(*output), I2C_XFER_SINGLE);
return ret;
}
diff --git a/board/servo_v4/board.c b/board/servo_v4/board.c
index 982ed9ccfb..b95ae2e3e9 100644
--- a/board/servo_v4/board.c
+++ b/board/servo_v4/board.c
@@ -197,7 +197,7 @@ int usb_i2c_board_is_enabled(void) { return 1; }
/*
* Support tca6416 I2C ioexpander.
*/
-#define GPIOX_I2C_ADDR 0x40
+#define GPIOX_I2C_ADDR__7bf 0x20
#define GPIOX_IN_PORT_A 0x0
#define GPIOX_IN_PORT_B 0x1
#define GPIOX_OUT_PORT_A 0x2
@@ -212,13 +212,13 @@ static void write_ioexpander(int bank, int gpio, int val)
int tmp;
/* Read output port register */
- i2c_read8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A + bank, &tmp);
+ i2c_read8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_A + bank, &tmp);
if (val)
tmp |= (1 << gpio);
else
tmp &= ~(1 << gpio);
/* Write back modified output port register */
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A + bank, tmp);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_A + bank, tmp);
}
/* Read a single GPIO input on the tca6416 I2C ioexpander. */
@@ -228,7 +228,7 @@ static int read_ioexpander_bit(int bank, int bit)
int mask = 1 << bit;
/* Read input port register */
- i2c_read8(1, GPIOX_I2C_ADDR, GPIOX_IN_PORT_A + bank, &tmp);
+ i2c_read8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_IN_PORT_A + bank, &tmp);
return (tmp & mask) >> bit;
}
@@ -257,15 +257,15 @@ static void init_usb3_port(void)
static void init_ioexpander(void)
{
/* Write all GPIO to output 0 */
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A, 0x0);
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_B, 0x0);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_A, 0x0);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_OUT_PORT_B, 0x0);
/*
* Write GPIO direction: strap resistors to input,
* all others to output.
*/
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_DIR_PORT_A, 0x0);
- i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_DIR_PORT_B, 0x18);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_DIR_PORT_A, 0x0);
+ i2c_write8__7bf(1, GPIOX_I2C_ADDR__7bf, GPIOX_DIR_PORT_B, 0x18);
}
/* Define voltage thresholds for SBU USB detection */
@@ -429,7 +429,7 @@ static void board_init(void)
* Write USB3 Mode to PS8742 USB/DP Mux.
* 0x0:disable 0x20:enable.
*/
- i2c_write8(1, 0x20, 0x0, 0x0);
+ i2c_write8__7bf(1, 0x10, 0x0, 0x0);
/* Enable uservo USB by default. */
init_ioexpander();
diff --git a/board/strago/board.c b/board/strago/board.c
index f1852bb9ab..6e336ac3ca 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -110,7 +110,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC,
- .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ .addr__7bf = CONFIG_TCPC_I2C_BASE_ADDR__7BF,
},
.drv = &tcpci_tcpm_drv,
},
@@ -141,7 +141,7 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .port_addr = 0xaa,
+ .port_addr = 0x55,
.driver = &pi3usb30532_usb_mux_driver,
},
};
@@ -213,7 +213,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_kxcj9_mutex[0],
.drv_data = &g_kxcj9_data[0],
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR1,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR1__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
@@ -236,7 +236,7 @@ struct motion_sensor_t motion_sensors[] = {
.mutex = &g_kxcj9_mutex[1],
.drv_data = &g_kxcj9_data[1],
.port = I2C_PORT_ACCEL,
- .addr = KXCJ9_ADDR0,
+ .i2c_spi_addr__7bf = KXCJ9_ADDR0__7bf,
.rot_standard_ref = &lid_standard_ref,
.default_range = 2, /* g, enough for laptop. */
.min_frequency = KXCJ9_ACCEL_MIN_FREQ,
diff --git a/board/sweetberry/board.c b/board/sweetberry/board.c
index 2d94f06f76..1085a048de 100644
--- a/board/sweetberry/board.c
+++ b/board/sweetberry/board.c
@@ -121,6 +121,6 @@ static void board_init(void)
uint8_t tmp;
/* i2c 0 has a tendancy to get wedged. TODO(nsanders): why? */
- i2c_xfer(0, 0, NULL, 0, &tmp, 1);
+ i2c_xfer__7bf(0, 0, NULL, 0, &tmp, 1);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/board/yorp/board.c b/board/yorp/board.c
index f00a95dd65..409914c898 100644
--- a/board/yorp/board.c
+++ b/board/yorp/board.c
@@ -44,18 +44,6 @@
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-static void tcpc_alert_event(enum gpio_signal signal)
-{
- if ((signal == GPIO_USB_C1_MUX_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
- return;
-
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
-}
-
static void ppc_interrupt(enum gpio_signal signal)
{
switch (signal) {
@@ -122,28 +110,28 @@ static struct lsm6dsm_data lsm6dsm_data;
/* Drivers */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
- .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,
- .addr = KX022_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 4, /* g */
- .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__7bf = KX022_ADDR1__7bf,
+ .rot_standard_ref = NULL, /* Identity matrix. */
+ .default_range = 4, /* g */
+ .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,
+ },
},
- },
},
[BASE_ACCEL] = {
@@ -159,7 +147,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -191,7 +179,7 @@ struct motion_sensor_t motion_sensors[] = {
.int_signal = GPIO_BASE_SIXAXIS_INT_L,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
- .addr = LSM6DSM_ADDR0,
+ .i2c_spi_addr__7bf = LSM6DSM_ADDR0__7bf,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
@@ -257,3 +245,13 @@ static void post_old_board_warning(void)
}
DECLARE_HOOK(HOOK_INIT, post_old_board_warning, HOOK_PRIO_INIT_I2C + 1);
#endif
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Sanity check the port. */
+ if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
+ return;
+
+ /* Note that the level is inverted because the pin is active low. */
+ gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
+}