diff options
author | Koro Chen <koro.chen@mediatek.com> | 2016-03-07 21:53:14 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-04-20 01:40:00 -0700 |
commit | f00d4621a480f12293214f14716ac33a90281ce7 (patch) | |
tree | 7ca0a72d7cf3b0ea93371b70a603d3b24edf4be4 /driver/accel_kionix.h | |
parent | ee5d09823f3f26ab5d31a32c96d550bb28ace808 (diff) | |
download | chrome-ec-f00d4621a480f12293214f14716ac33a90281ce7.tar.gz |
elm: kionix: allow dynamic selection of SPI or I2C transport
This CL ports c9832e04f1528 to Kionix accel driver. And also enables SPI
access of Elm's base kx022.
BUG=none
BRANCH=none
TEST=manual
Change-Id: I0c1de028c82fc62a124bb5b930a3882c4b368d71
Signed-off-by: Koro Chen <koro.chen@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/331851
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Diffstat (limited to 'driver/accel_kionix.h')
-rw-r--r-- | driver/accel_kionix.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/driver/accel_kionix.h b/driver/accel_kionix.h index e326dd3cb3..3dc7f314a4 100644 --- a/driver/accel_kionix.h +++ b/driver/accel_kionix.h @@ -44,6 +44,20 @@ struct kionix_accel_data { extern const struct accelgyro_drv kionix_accel_drv; +/* + * The addr field of motion_sensor support both SPI and I2C: + * + * +-------------------------------+---+ + * | 7 bit i2c address | 0 | + * +-------------------------------+---+ + * Or + * +-------------------------------+---+ + * | SPI device ID | 1 | + * +-------------------------------+---+ + */ +#define KIONIX_IS_SPI(_addr) ((_addr) & 1) +#define KIONIX_SPI_ADDRESS(_addr) ((_addr) >> 1) + #define KIONIX_CTRL1_REG(v) (KX022_CNTL1 + \ (v) * (KXCJ9_CTRL1 - KX022_CNTL1)) #define KIONIX_CTRL2_REG(v) (KX022_CNTL2 + \ |