summaryrefslogtreecommitdiff
path: root/drivers/iio/accel/mma9551_core.h
diff options
context:
space:
mode:
authorIrina Tirdea <irina.tirdea@intel.com>2015-01-11 21:10:15 +0200
committerJonathan Cameron <jic23@kernel.org>2015-01-27 18:49:56 +0000
commitd5b97f5c7dfcad98927fb4f3b2e99d4c3beeec9a (patch)
treebe9edae8271a45921155e7dee3ea72ba8258eceb /drivers/iio/accel/mma9551_core.h
parent6da93a6710a3b1eb3d15b88bf96efaac322c893f (diff)
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: Irina Tirdea <irina.tirdea@intel.com> Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/accel/mma9551_core.h')
-rw-r--r--drivers/iio/accel/mma9551_core.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/iio/accel/mma9551_core.h b/drivers/iio/accel/mma9551_core.h
new file mode 100644
index 000000000000..e6efd027f49a
--- /dev/null
+++ b/drivers/iio/accel/mma9551_core.h
@@ -0,0 +1,66 @@
+/*
+ * 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_ */