summaryrefslogtreecommitdiffstats
path: root/drivers/iio/accel/mma7455_i2c.c
diff options
context:
space:
mode:
authorJoachim Eastwood <manabian@gmail.com>2015-10-31 13:49:16 +0100
committerJonathan Cameron <jic23@kernel.org>2015-11-01 18:00:35 +0000
commita84ef0d181d917125f1f16cffe53f84c19968969 (patch)
treed0d1d0475bdb1c9e4b399560a2b6ff102df948a2 /drivers/iio/accel/mma7455_i2c.c
parent18fb1ab0eb81a08ecb00065f3e6c037a37d8e917 (diff)
downloadlinux-a84ef0d181d917125f1f16cffe53f84c19968969.tar.bz2
iio: accel: add Freescale MMA7455L/MMA7456L 3-axis accelerometer driver
Add support for Freescale MMA7455L/MMA7456L 3-axis in 10-bit mode for I2C and SPI bus. This rather simple driver that currently doesn't support all the hardware features of MMA7455L/MMA7456L. Tested on Embedded Artist's LPC4357 Dev Kit with MMA7455L on I2C bus. Data sheets for the two devices can be found here: http://cache.freescale.com/files/sensors/doc/data_sheet/MMA7455L.pdf http://cache.freescale.com/files/sensors/doc/data_sheet/MMA7456L.pdf Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/accel/mma7455_i2c.c')
-rw-r--r--drivers/iio/accel/mma7455_i2c.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/iio/accel/mma7455_i2c.c b/drivers/iio/accel/mma7455_i2c.c
new file mode 100644
index 000000000000..3cab5fb4a3c4
--- /dev/null
+++ b/drivers/iio/accel/mma7455_i2c.c
@@ -0,0 +1,56 @@
+/*
+ * IIO accel I2C driver for Freescale MMA7455L 3-axis 10-bit accelerometer
+ * Copyright 2015 Joachim Eastwood <manabian@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+
+#include "mma7455.h"
+
+static int mma7455_i2c_probe(struct i2c_client *i2c,
+ const struct i2c_device_id *id)
+{
+ struct regmap *regmap;
+ const char *name = NULL;
+
+ regmap = devm_regmap_init_i2c(i2c, &mma7455_core_regmap);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ if (id)
+ name = id->name;
+
+ return mma7455_core_probe(&i2c->dev, regmap, name);
+}
+
+static int mma7455_i2c_remove(struct i2c_client *i2c)
+{
+ return mma7455_core_remove(&i2c->dev);
+}
+
+static const struct i2c_device_id mma7455_i2c_ids[] = {
+ { "mma7455", 0 },
+ { "mma7456", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
+
+static struct i2c_driver mma7455_i2c_driver = {
+ .probe = mma7455_i2c_probe,
+ .remove = mma7455_i2c_remove,
+ .id_table = mma7455_i2c_ids,
+ .driver = {
+ .name = "mma7455-i2c",
+ },
+};
+module_i2c_driver(mma7455_i2c_driver);
+
+MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
+MODULE_DESCRIPTION("Freescale MMA7455L I2C accelerometer driver");
+MODULE_LICENSE("GPL v2");