Commit d5b97f5c authored by Irina Tirdea's avatar Irina Tirdea Committed by Jonathan Cameron

iio: accel: mma9551: split driver to expose mma955x api

Freescale has the MMA955xL family of devices that use the
same communication protocol (based on i2c messages):
http://www.freescale.com/files/sensors/doc/data_sheet/MMA955xL.pdf.

To support more devices from this family, we need to split the
mma9551 driver so we can export the common functions that will
be used by other mma955x drivers.
Signed-off-by: default avatarIrina Tirdea <irina.tirdea@intel.com>
Reviewed-by: default avatarVlad Dogaru <vlad.dogaru@intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 6da93a67
...@@ -111,9 +111,14 @@ config KXCJK1013 ...@@ -111,9 +111,14 @@ config KXCJK1013
To compile this driver as a module, choose M here: the module will To compile this driver as a module, choose M here: the module will
be called kxcjk-1013. be called kxcjk-1013.
config MMA9551_CORE
tristate
config MMA9551 config MMA9551
tristate "Freescale MMA9551L Intelligent Motion-Sensing Platform Driver" tristate "Freescale MMA9551L Intelligent Motion-Sensing Platform Driver"
depends on I2C depends on I2C
select MMA9551_CORE
help help
Say yes here to build support for the Freescale MMA9551L Say yes here to build support for the Freescale MMA9551L
Intelligent Motion-Sensing Platform Driver. Intelligent Motion-Sensing Platform Driver.
......
...@@ -9,7 +9,9 @@ obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o ...@@ -9,7 +9,9 @@ obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o
obj-$(CONFIG_KXCJK1013) += kxcjk-1013.o obj-$(CONFIG_KXCJK1013) += kxcjk-1013.o
obj-$(CONFIG_KXSD9) += kxsd9.o obj-$(CONFIG_KXSD9) += kxsd9.o
obj-$(CONFIG_MMA8452) += mma8452.o obj-$(CONFIG_MMA8452) += mma8452.o
obj-$(CONFIG_MMA9551) += mma9551.o
obj-$(CONFIG_MMA9551_CORE) += mma9551_core.o
obj-$(CONFIG_MMA9551) += mma9551.o
obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
st_accel-y := st_accel_core.o st_accel-y := st_accel_core.o
......
This diff is collapsed.
This diff is collapsed.
/*
* Common code for Freescale MMA955x Intelligent Sensor Platform drivers
* Copyright (c) 2014, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
#ifndef _MMA9551_CORE_H_
#define _MMA9551_CORE_H_
/* Applications IDs */
#define MMA9551_APPID_VERSION 0x00
#define MMA9551_APPID_GPIO 0x03
#define MMA9551_APPID_AFE 0x06
#define MMA9551_APPID_TILT 0x0B
#define MMA9551_APPID_SLEEP_WAKE 0x12
#define MMA9551_APPID_RESET 0x17
#define MMA9551_APPID_NONE 0xff
#define MMA9551_AUTO_SUSPEND_DELAY_MS 2000
enum mma9551_gpio_pin {
mma9551_gpio6 = 0,
mma9551_gpio7,
mma9551_gpio8,
mma9551_gpio9,
mma9551_gpio_max = mma9551_gpio9,
};
#define MMA9551_ACCEL_CHANNEL(axis) { \
.type = IIO_ACCEL, \
.modified = 1, \
.channel2 = axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
}
int mma9551_read_config_byte(struct i2c_client *client, u8 app_id,
u16 reg, u8 *val);
int mma9551_write_config_byte(struct i2c_client *client, u8 app_id,
u16 reg, u8 val);
int mma9551_read_status_byte(struct i2c_client *client, u8 app_id,
u16 reg, u8 *val);
int mma9551_read_status_word(struct i2c_client *client, u8 app_id,
u16 reg, u16 *val);
int mma9551_update_config_bits(struct i2c_client *client, u8 app_id,
u16 reg, u8 mask, u8 val);
int mma9551_gpio_config(struct i2c_client *client, enum mma9551_gpio_pin pin,
u8 app_id, u8 bitnum, int polarity);
int mma9551_read_version(struct i2c_client *client);
int mma9551_set_device_state(struct i2c_client *client, bool enable);
int mma9551_set_power_state(struct i2c_client *client, bool on);
void mma9551_sleep(int freq);
int mma9551_read_accel_chan(struct i2c_client *client,
const struct iio_chan_spec *chan,
int *val, int *val2);
int mma9551_read_accel_scale(int *val, int *val2);
#endif /* _MMA9551_CORE_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment