summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gonzalez <daniel.d.gonzalez@intel.corp-partner.google.com>2019-08-16 11:25:20 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-05 00:49:17 +0000
commit3c65c607e3e4df250d89f9b66f943942dd2bf0fa (patch)
tree7dd2606b2209e297fb50ce1f140a898f1cc1dfc5
parentf7a32618bcacfb3b3ecba62d338aa24dc4a211d1 (diff)
downloadchrome-ec-3c65c607e3e4df250d89f9b66f943942dd2bf0fa.tar.gz
ish: Added board for drallion_ish based on arcada_ish
"drallion_ish" is already included in devicetree.cb for drallion. Shim loading needs to be configured in OS for drallion. BRANCH=none BUG=b:140311300 TEST=Successfully loaded ISH on drallion board with arcada ish ec code Change-Id: I31274554859a77c6446330c253c994ce8e21734b Signed-off-by: Daniel Gonzalez <daniel.d.gonzalez@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1758538 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--board/drallion_ish/board.c198
-rw-r--r--board/drallion_ish/board.h123
-rw-r--r--board/drallion_ish/build.mk13
-rw-r--r--board/drallion_ish/ec.tasklist17
-rw-r--r--board/drallion_ish/gpio.inc22
5 files changed, 373 insertions, 0 deletions
diff --git a/board/drallion_ish/board.c b/board/drallion_ish/board.c
new file mode 100644
index 0000000000..84cda81be4
--- /dev/null
+++ b/board/drallion_ish/board.c
@@ -0,0 +1,198 @@
+/* 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.
+ */
+
+/* Drallion 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",
+ /* SDA and SCL gpio must be set correctly in coreboot gpio */
+ .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_flags = LSM6DSM_ADDR1_FLAGS,
+ .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_flags = LSM6DSM_ADDR1_FLAGS,
+ .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_flags = LNG2DM_ADDR0_FLAGS,
+ .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_flags = LIS2MDL_ADDR_FLAGS,
+ .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)
+{
+ return lid_is_open();
+}
+
+/* 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/drallion_ish/board.h b/board/drallion_ish/board.h
new file mode 100644
index 0000000000..f8e6683a20
--- /dev/null
+++ b/board/drallion_ish/board.h
@@ -0,0 +1,123 @@
+/* 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.
+ */
+
+/* Drallion ISH board configuration */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+/*
+ * By default, enable all console messages except HC, ACPI and event
+ * The sensor stack is generating a lot of activity.
+ */
+#undef CONFIG_HOSTCMD_DEBUG_MODE
+#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
+
+/* ISH specific */
+#undef CONFIG_DEBUG_ASSERT
+#define CONFIG_CLOCK_CRYSTAL
+/* EC */
+#define CONFIG_FLASH_SIZE 0x80000
+#define CONFIG_FPU
+#define CONFIG_I2C
+#define CONFIG_I2C_MASTER
+
+/* Base sensor: LNG2DM (uses LIS2DH driver) */
+#define CONFIG_ACCEL_LNG2DM
+/* Lid sensor: LSM6DS3 (uses LSM6DSM driver) */
+#define CONFIG_ACCELGYRO_LSM6DSM
+/* Lid sensor: LIS2DML */
+#define CONFIG_MAG_LIS2MDL
+#define CONFIG_MAG_CALIBRATE
+
+#define CONFIG_ACCEL_INTERRUPTS
+/* Enable sensor fifo, must also define the _SIZE and _THRES */
+#define CONFIG_ACCEL_FIFO
+/* FIFO size is a power of 2. */
+#define CONFIG_ACCEL_FIFO_SIZE 256
+/* Depends on how fast the AP boots and typical ODRs. */
+#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3)
+/* Sensors without hardware FIFO are in forced mode */
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(BASE_ACCEL) | BIT(LID_MAG))
+
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
+
+#define CONFIG_MKBP_EVENT
+#define CONFIG_MKBP_USE_HECI
+
+#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
+
+#define CONFIG_TABLET_MODE
+#define CONFIG_HALL_SENSOR
+#define CONFIG_HALL_SENSOR_CUSTOM
+#define HALL_SENSOR_GPIO_L GPIO_TABLET_MODE_L
+
+/* DMA paging between SRAM and DRAM */
+#define CONFIG_DMA_PAGING
+
+/* Host command over HECI */
+#define CONFIG_HOSTCMD_HECI
+
+/* I2C ports */
+#define I2C_PORT_SENSOR ISH_I2C0
+#define CONFIG_CMD_I2C_XFER
+
+/* EC Console Commands */
+#define CONFIG_CMD_ACCELS
+#define CONFIG_CMD_ACCEL_INFO
+#define CONFIG_CMD_TIMERINFO
+
+/* Undefined features */
+#undef CONFIG_EXTPOWER
+#undef CONFIG_KEYBOARD_KSO_BASE
+#undef CONFIG_FLASH
+#undef CONFIG_FMAP
+#undef CONFIG_SWITCH
+
+/* Undefined console commands */
+#undef CONFIG_CMD_HASH
+#undef CONFIG_CMD_TEMP_SENSOR
+#undef CONFIG_CMD_I2C_SCAN
+#undef CONFIG_CMD_KEYBOARD
+#undef CONFIG_CMD_POWER_AP
+#undef CONFIG_CMD_POWERINDEBUG
+#undef CONFIG_CMD_SHMEM
+
+/* power management definitions */
+#define CONFIG_LOW_POWER_IDLE
+
+#define CONFIG_ISH_PM_D0I1
+#define CONFIG_ISH_PM_D0I2
+#define CONFIG_ISH_PM_D0I3
+#define CONFIG_ISH_PM_D3
+#define CONFIG_ISH_PM_RESET_PREP
+
+#define CONFIG_ISH_D0I2_MIN_USEC (15*MSEC)
+#define CONFIG_ISH_D0I3_MIN_USEC (100*MSEC)
+
+#ifndef __ASSEMBLER__
+
+#include "gpio_signal.h"
+#include "registers.h"
+
+/* Motion sensors
+ *
+ * Note: Since we aren't using LPC memory map to transmit sensor data, the
+ * order of this enum does not need to be accel, accel, gyro
+ */
+enum sensor_id {
+ LID_ACCEL,
+ LID_GYRO,
+ BASE_ACCEL,
+ LID_MAG,
+ SENSOR_COUNT
+};
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/drallion_ish/build.mk b/board/drallion_ish/build.mk
new file mode 100644
index 0000000000..51bd96d339
--- /dev/null
+++ b/board/drallion_ish/build.mk
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+# 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.
+#
+# Board specific files build
+#
+
+CHIP:=ish
+CHIP_FAMILY:=ish5
+CHIP_VARIANT:=ish5p0
+
+board-y=board.o
diff --git a/board/drallion_ish/ec.tasklist b/board/drallion_ish/ec.tasklist
new file mode 100644
index 0000000000..a4db486e9a
--- /dev/null
+++ b/board/drallion_ish/ec.tasklist
@@ -0,0 +1,17 @@
+/* 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.
+ */
+
+/*
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+
+#define CONFIG_TASK_LIST \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, HUGE_TASK_STACK_SIZE, 0) \
+ TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE, 0) \
+ TASK_NOTEST(CHIPSET, board_idle_task, NULL, IDLE_TASK_STACK_SIZE, 0) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE, 0) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE, 0) \
+ TASK_ALWAYS(HECI_RX, heci_rx_task, NULL, HUGE_TASK_STACK_SIZE, 0) \
+ TASK_ALWAYS(IPC_MNG, ipc_mng_task, NULL, LARGER_TASK_STACK_SIZE, 0)
diff --git a/board/drallion_ish/gpio.inc b/board/drallion_ish/gpio.inc
new file mode 100644
index 0000000000..89b025e178
--- /dev/null
+++ b/board/drallion_ish/gpio.inc
@@ -0,0 +1,22 @@
+/* -*- mode:c -*-
+ *
+ * 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.
+ */
+
+GPIO_INT(ACCEL_GYRO_INT_L, PIN(0), GPIO_INT_FALLING, lsm6dsm_interrupt)
+GPIO_INT(LID_OPEN, PIN(5), GPIO_INT_BOTH, lid_interrupt) /* LID_CL_NB_L */
+GPIO_INT(TABLET_MODE_L, PIN(6), GPIO_INT_BOTH, hall_sensor_isr) /* LID_CL_TAB_L */
+
+GPIO(NB_MODE_L, PIN(4), GPIO_OUT_LOW)
+
+/*
+ * We don't have a ENTERING_RW signal wired to the cr50 but common code needs
+ * it to be defined.
+ */
+UNIMPLEMENTED(ENTERING_RW)
+
+/*
+ * SDA and SCL gpio must be set correctly in coreboot gpio
+ */