mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
driver: kionix: Remove variant field.
Field is not required: sensor->chip already has that information. BRANCH=veyron BUG=none TEST=compile (cherry picked from commit 90fcd6be2b5d2104301efef295113d7816e14042) Reviewed-on: https://chromium-review.googlesource.com/379096 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Change-Id: I6c0bc2e71d7c848968caa78c749dd3fb916f6263 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/379541
This commit is contained in:
committed by
chrome-bot
parent
5b54e8c065
commit
5a01bd89ba
@@ -484,9 +484,7 @@ const matrix_3x3_t base_standard_ref = {
|
||||
};
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data = {
|
||||
.variant = KX022,
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data;
|
||||
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
/*
|
||||
|
||||
@@ -496,10 +496,7 @@ const matrix_3x3_t lid_standard_ref = {
|
||||
};
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data[2] = {
|
||||
{.variant = KX022},
|
||||
{.variant = KX022},
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data[2];
|
||||
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
{.name = "Base Accel",
|
||||
|
||||
@@ -473,9 +473,7 @@ static struct mutex g_lid_mutex;
|
||||
static struct mutex g_base_mutex;
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data = {
|
||||
.variant = KX022,
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data;
|
||||
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
/*
|
||||
|
||||
@@ -469,9 +469,7 @@ const matrix_3x3_t lid_standard_ref = {
|
||||
};
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data = {
|
||||
.variant = KX022,
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data;
|
||||
#endif /* BOARD_KEVIN */
|
||||
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
|
||||
@@ -648,9 +648,7 @@ const matrix_3x3_t base_standard_ref = {
|
||||
#endif
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data = {
|
||||
.variant = KX022,
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data;
|
||||
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
#ifdef CONFIG_ACCELGYRO_BMI160
|
||||
|
||||
@@ -722,9 +722,7 @@ const matrix_3x3_t base_standard_ref = {
|
||||
};
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data = {
|
||||
.variant = KX022,
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data;
|
||||
|
||||
/* FIXME(dhendrix): Copied from Amenia, probably need to tweak for Reef */
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
|
||||
@@ -274,9 +274,7 @@ static struct mutex g_base_mutex;
|
||||
static struct mutex g_lid_mutex;
|
||||
|
||||
/* kxcj9 local/private data */
|
||||
struct kionix_accel_data g_kxcj9_data = {
|
||||
.variant = KXCJ9,
|
||||
};
|
||||
struct kionix_accel_data g_kxcj9_data;
|
||||
|
||||
/* lsm6ds0 local sensor data (per-sensor) */
|
||||
struct lsm6ds0_data g_saved_data[2];
|
||||
|
||||
@@ -183,10 +183,7 @@ void board_reset_pd_mcu(void)
|
||||
/* Four Motion sensors */
|
||||
/* kxcj9 mutex and local/private data*/
|
||||
static struct mutex g_kxcj9_mutex[2];
|
||||
struct kionix_accel_data g_kxcj9_data[2] = {
|
||||
{.variant = KXCJ9},
|
||||
{.variant = KXCJ9},
|
||||
};
|
||||
struct kionix_accel_data g_kxcj9_data[2];
|
||||
|
||||
/* Matrix to rotate accelrator into standard reference frame */
|
||||
const matrix_3x3_t base_standard_ref = {
|
||||
|
||||
@@ -453,9 +453,7 @@ static struct mutex g_lid_mutex;
|
||||
static struct mutex g_base_mutex;
|
||||
|
||||
/* KX022 private data */
|
||||
struct kionix_accel_data g_kx022_data = {
|
||||
.variant = KX022,
|
||||
};
|
||||
struct kionix_accel_data g_kx022_data;
|
||||
|
||||
struct motion_sensor_t motion_sensors[] = {
|
||||
/*
|
||||
|
||||
@@ -27,11 +27,18 @@
|
||||
/* Number of times to attempt to enable sensor before giving up. */
|
||||
#define SENSOR_ENABLE_ATTEMPTS 3
|
||||
|
||||
#if defined(CONFIG_ACCEL_KXCJ9) && !defined(CONFIG_ACCEL_KX022)
|
||||
#define V(s_) 1
|
||||
#elif defined(CONFIG_ACCEL_KX022) && !defined(CONFIG_ACCEL_KXCJ9)
|
||||
#define V(s_) 0
|
||||
#else
|
||||
#define V(s_) ((s_)->chip == MOTIONSENSE_CHIP_KXCJ9)
|
||||
#endif
|
||||
/* Index for which table to use. */
|
||||
#if !defined(CONFIG_ACCEL_KXCJ9) || !defined(CONFIG_ACCEL_KX022)
|
||||
#define T 0
|
||||
#define T(s_) 0
|
||||
#else
|
||||
#define T (data->variant)
|
||||
#define T(s_) V(s_)
|
||||
#endif /* !defined(CONFIG_ACCEL_KXCJ9) || !defined(CONFIG_ACCEL_KX022) */
|
||||
|
||||
/* List of range values in +/-G's and their associated register values. */
|
||||
@@ -202,10 +209,9 @@ static int raw_read_multi(const int port, int addr, uint8_t reg,
|
||||
static int disable_sensor(const struct motion_sensor_t *s, int *reg_val)
|
||||
{
|
||||
int i, ret, reg, pc1_field;
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
reg = KIONIX_CTRL1_REG(data->variant);
|
||||
pc1_field = KIONIX_PC1_FIELD(data->variant);
|
||||
reg = KIONIX_CTRL1_REG(V(s));
|
||||
pc1_field = KIONIX_PC1_FIELD(V(s));
|
||||
|
||||
/*
|
||||
* Read the current state of the control register
|
||||
@@ -238,10 +244,9 @@ static int disable_sensor(const struct motion_sensor_t *s, int *reg_val)
|
||||
static int enable_sensor(const struct motion_sensor_t *s, int reg_val)
|
||||
{
|
||||
int i, ret, reg, pc1_field;
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
reg = KIONIX_CTRL1_REG(data->variant);
|
||||
pc1_field = KIONIX_PC1_FIELD(data->variant);
|
||||
reg = KIONIX_CTRL1_REG(V(s));
|
||||
pc1_field = KIONIX_PC1_FIELD(V(s));
|
||||
|
||||
for (i = 0; i < SENSOR_ENABLE_ATTEMPTS; i++) {
|
||||
ret = raw_read8(s->port, s->addr, reg, ®_val);
|
||||
@@ -265,10 +270,11 @@ static int set_range(const struct motion_sensor_t *s, int range, int rnd)
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
/* Find index for interface pair matching the specified range. */
|
||||
index = find_param_index(range, rnd, ranges[T], ARRAY_SIZE(ranges[T]));
|
||||
range_field = KIONIX_RANGE_FIELD(data->variant);
|
||||
reg = KIONIX_CTRL1_REG(data->variant);
|
||||
range_val = ranges[T][index].reg;
|
||||
index = find_param_index(range, rnd, ranges[T(s)],
|
||||
ARRAY_SIZE(ranges[T(s)]));
|
||||
range_field = KIONIX_RANGE_FIELD(V(s));
|
||||
reg = KIONIX_CTRL1_REG(V(s));
|
||||
range_val = ranges[T(s)][index].reg;
|
||||
|
||||
/* Disable the sensor to allow for changing of critical parameters. */
|
||||
mutex_lock(s->mutex);
|
||||
@@ -299,7 +305,7 @@ static int set_range(const struct motion_sensor_t *s, int range, int rnd)
|
||||
static int get_range(const struct motion_sensor_t *s)
|
||||
{
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
return ranges[T][data->sensor_range].val;
|
||||
return ranges[T(s)][data->sensor_range].val;
|
||||
}
|
||||
|
||||
static int set_resolution(const struct motion_sensor_t *s, int res, int rnd)
|
||||
@@ -308,11 +314,11 @@ static int set_resolution(const struct motion_sensor_t *s, int res, int rnd)
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
/* Find index for interface pair matching the specified resolution. */
|
||||
index = find_param_index(res, rnd, resolutions[T],
|
||||
ARRAY_SIZE(resolutions[T]));
|
||||
res_val = resolutions[T][index].reg;
|
||||
res_field = KIONIX_RES_FIELD(data->variant);
|
||||
reg = KIONIX_CTRL1_REG(data->variant);
|
||||
index = find_param_index(res, rnd, resolutions[T(s)],
|
||||
ARRAY_SIZE(resolutions[T(s)]));
|
||||
res_val = resolutions[T(s)][index].reg;
|
||||
res_field = KIONIX_RES_FIELD(V(s));
|
||||
reg = KIONIX_CTRL1_REG(V(s));
|
||||
|
||||
/* Disable the sensor to allow for changing of critical parameters. */
|
||||
mutex_lock(s->mutex);
|
||||
@@ -343,7 +349,7 @@ static int set_resolution(const struct motion_sensor_t *s, int res, int rnd)
|
||||
static int get_resolution(const struct motion_sensor_t *s)
|
||||
{
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
return resolutions[T][data->sensor_resolution].val;
|
||||
return resolutions[T(s)][data->sensor_resolution].val;
|
||||
}
|
||||
|
||||
static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
|
||||
@@ -353,11 +359,11 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
/* Find index for interface pair matching the specified rate. */
|
||||
index = find_param_index(rate, rnd, datarates[T],
|
||||
ARRAY_SIZE(datarates[T]));
|
||||
odr_val = datarates[T][index].reg;
|
||||
reg = KIONIX_ODR_REG(data->variant);
|
||||
odr_field = KIONIX_ODR_FIELD(data->variant);
|
||||
index = find_param_index(rate, rnd, datarates[T(s)],
|
||||
ARRAY_SIZE(datarates[T(s)]));
|
||||
odr_val = datarates[T(s)][index].reg;
|
||||
reg = KIONIX_ODR_REG(V(s));
|
||||
odr_field = KIONIX_ODR_FIELD(V(s));
|
||||
|
||||
/* Disable the sensor to allow for changing of critical parameters. */
|
||||
mutex_lock(s->mutex);
|
||||
@@ -392,7 +398,7 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
|
||||
static int get_data_rate(const struct motion_sensor_t *s)
|
||||
{
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
return datarates[T][data->sensor_datarate].val;
|
||||
return datarates[T(s)][data->sensor_datarate].val;
|
||||
}
|
||||
|
||||
static int set_offset(const struct motion_sensor_t *s, const int16_t *offset,
|
||||
@@ -425,7 +431,7 @@ static int read(const struct motion_sensor_t *s, vector_3_t v)
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
/* Read 6 bytes starting at XOUT_L. */
|
||||
reg = KIONIX_XOUT_L(data->variant);
|
||||
reg = KIONIX_XOUT_L(V(s));
|
||||
mutex_lock(s->mutex);
|
||||
ret = raw_read_multi(s->port, s->addr, reg, acc, 6);
|
||||
mutex_unlock(s->mutex);
|
||||
@@ -448,11 +454,11 @@ static int read(const struct motion_sensor_t *s, vector_3_t v)
|
||||
*/
|
||||
resolution = get_resolution(s);
|
||||
for (i = X; i <= Z; i++) {
|
||||
if (KXCJ9 == data->variant) {
|
||||
if (V(s)) {
|
||||
v[i] = (((int8_t)acc[i * 2 + 1]) << 4) |
|
||||
(acc[i * 2] >> 4);
|
||||
v[i] <<= 16 - resolution;
|
||||
} else if (KX022 == data->variant) {
|
||||
} else {
|
||||
if (resolution == 8)
|
||||
acc[i * 2] = 0;
|
||||
v[i] = (((int8_t)acc[i * 2 + 1]) << 8) | acc[i * 2];
|
||||
@@ -472,10 +478,9 @@ static int init(const struct motion_sensor_t *s)
|
||||
{
|
||||
int ret, val, reg, reset_field;
|
||||
uint8_t timeout;
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
|
||||
reg = KIONIX_CTRL2_REG(data->variant);
|
||||
reset_field = KIONIX_RESET_FIELD(data->variant);
|
||||
reg = KIONIX_CTRL2_REG(V(s));
|
||||
reset_field = KIONIX_RESET_FIELD(V(s));
|
||||
|
||||
/* Issue a software reset. */
|
||||
mutex_lock(s->mutex);
|
||||
@@ -527,9 +532,9 @@ static int init(const struct motion_sensor_t *s)
|
||||
if (ret != EC_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (KXCJ9 == data->variant)
|
||||
if (V(s))
|
||||
ret = set_resolution(s, 12, 1);
|
||||
else if (KX022 == data->variant)
|
||||
else
|
||||
ret = set_resolution(s, 16, 1);
|
||||
if (ret != EC_SUCCESS)
|
||||
return ret;
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
#include "driver/accel_kx022.h"
|
||||
#include "driver/accel_kxcj9.h"
|
||||
|
||||
enum kionix_accel {
|
||||
KX022,
|
||||
KXCJ9,
|
||||
SUPPORTED_KIONIX_ACCELS,
|
||||
};
|
||||
|
||||
/*
|
||||
* Struct for pairing an engineering value with the register value for a
|
||||
* parameter.
|
||||
@@ -28,8 +22,6 @@ struct accel_param_pair {
|
||||
};
|
||||
|
||||
struct kionix_accel_data {
|
||||
/* Variant of Kionix Accelerometer. */
|
||||
uint8_t variant;
|
||||
/* Note, the following are indicies into their respective tables. */
|
||||
/* Current range of accelerometer. */
|
||||
int sensor_range;
|
||||
|
||||
Reference in New Issue
Block a user