diff options
author | Ben Lok <ben.lok@mediatek.com> | 2015-12-18 19:45:14 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-03-01 08:25:58 -0800 |
commit | a36a6ca96e864b2ce193df0874d84360cfce0c9e (patch) | |
tree | 98ae879250c87458fcb4ddbf1c558592e99ee7d4 | |
parent | 7b43197449dc864c184c28c644d7b6cb62a688a1 (diff) | |
download | chrome-ec-a36a6ca96e864b2ce193df0874d84360cfce0c9e.tar.gz |
oak: Add kx022 lid accelerometer for rev5.
refer to commit 574c8065710432f5a91fd8dd11d1fa28e2be1f3b,
adds the lid accelerometer to the list of motion sensors on the rev5.
Since commit bc404c94b4ab1e6a62e607fd7ef034aa31d6388e,
math_util.c is no longer to include "math.h" header file.
BUG=chrome-os-partner:50312
BRANCH=none
TEST=Build Oak EC with driver enabled and verify that valid
accelerometer data is read, and that range, resolution, and odr can all
be modified.
TEST=Verified that signs of accelerometer data conform to those shown in
the doc.
TEST=make buildall tests
Change-Id: I8df1b2331a1fbea82015b97985541e2ebc393d10
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/319332
Commit-Ready: Rong Chang <rongchang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | board/oak/board.c | 53 | ||||
-rw-r--r-- | board/oak/board.h | 10 | ||||
-rw-r--r-- | board/oak/ec.tasklist | 1 | ||||
-rw-r--r-- | common/math_util.c | 1 |
4 files changed, 60 insertions, 5 deletions
diff --git a/board/oak/board.c b/board/oak/board.c index 33a7bec316..1b08001dd6 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -16,6 +16,8 @@ #include "chipset.h" #include "common.h" #include "console.h" +#include "driver/accel_kionix.h" +#include "driver/accel_kx022.h" #include "driver/als_opt3001.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" @@ -25,6 +27,9 @@ #include "i2c.h" #include "keyboard_raw.h" #include "lid_switch.h" +#include "math_util.h" +#include "motion_lid.h" +#include "motion_sense.h" #include "pi3usb9281.h" #include "power.h" #include "power_button.h" @@ -550,3 +555,51 @@ static void board_chipset_suspend(void) #endif } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); + +#ifdef HAS_TASK_MOTIONSENSE +/* Motion sensors */ +/* Mutexes */ +static struct mutex g_lid_mutex; + +/* KX022 private data */ +struct kionix_accel_data g_kx022_data = { + .variant = KX022, +}; + +struct motion_sensor_t motion_sensors[] = { + {.name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0, + .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, + .addr = KX022_ADDR1, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default use EC settings */ + [SENSOR_CONFIG_AP] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +#endif /* defined(HAS_TASK_MOTIONSENSE) */ diff --git a/board/oak/board.h b/board/oak/board.h index 6336ba16ad..ffa6b53207 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -11,6 +11,7 @@ /* board revision */ #include "board_revs.h" +#define CONFIG_ACCEL_KX022 #define CONFIG_ADC #undef CONFIG_ADC_WATCHDOG @@ -132,15 +133,16 @@ #define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C, GPIO_D /* 2 I2C master ports, connect to battery, charger, pd and USB switches */ -#define I2C_PORT_MASTER 0 +#define I2C_PORT_MASTER 0 +#define I2C_PORT_ACCEL 0 +#define I2C_PORT_ALS 0 #define I2C_PORT_BATTERY 0 #define I2C_PORT_CHARGER 0 #define I2C_PORT_PERICOM 0 #define I2C_PORT_THERMAL 0 -#define I2C_PORT_PD_MCU 1 +#define I2C_PORT_PD_MCU 1 #define I2C_PORT_USB_MUX 1 -#define I2C_PORT_TCPC 1 -#define I2C_PORT_ALS I2C_PORT_MASTER +#define I2C_PORT_TCPC 1 /* Ambient Light Sensor address */ #define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1 diff --git a/board/oak/ec.tasklist b/board/oak/ec.tasklist index 45cb276099..150ac9b3d4 100644 --- a/board/oak/ec.tasklist +++ b/board/oak/ec.tasklist @@ -27,6 +27,7 @@ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_VBUS(VBUS, vbus_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(ALS, als_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P0, usb_charger_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P1, usb_charger_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ diff --git a/common/math_util.c b/common/math_util.c index 79b0f47f5e..247bda6dd9 100644 --- a/common/math_util.c +++ b/common/math_util.c @@ -6,7 +6,6 @@ /* Common math functions. */ #include "common.h" -#include "math.h" #include "math_util.h" #include "util.h" |