Source
x
static SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume);
/**
* Sensortek STK8BA50 3-Axis Accelerometer
*
* Copyright (c) 2015, Intel Corporation.
*
* This file is subject to the terms and conditions of version 2 of
* the GNU General Public License. See the file COPYING in the main
* directory of this archive for more details.
*
* STK8BA50 7-bit I2C address: 0x18.
*/
/*
* The accelerometer has four measurement ranges:
* +/-2g; +/-4g; +/-8g; +/-16g
*
* Acceleration values are 10-bit, 2's complement.
* Scales are calculated as following:
*
* scale1 = (2 + 2) * 9.81 / (2^10 - 1) = 0.0384
* scale2 = (4 + 4) * 9.81 / (2^10 - 1) = 0.0767
* etc.
*
* Scales are stored in this format:
* { <register value>, <scale value> }
*
* Locally, the range is stored as a table index.
*/
static const struct {
u8 reg_val;
u32 scale_val;
} stk8ba50_scale_table[] = {
{3, 38400}, {5, 76700}, {8, 153400}, {12, 306900}
};
/* Sample rates are stored as { <register value>, <Hz value> } */
static const struct {
u8 reg_val;
u16 samp_freq;
} stk8ba50_samp_freq_table[] = {
{0x08, 14}, {0x09, 25}, {0x0A, 56}, {0x0B, 112},
{0x0C, 224}, {0x0D, 448}, {0x0E, 896}, {0x0F, 1792}
};
/* Used to map scan mask bits to their corresponding channel register. */
static const int stk8ba50_channel_table[] = {
STK8BA50_REG_XOUT,
STK8BA50_REG_YOUT,
STK8BA50_REG_ZOUT
};
struct stk8ba50_data {
struct i2c_client *client;
struct mutex lock;