Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Joachim Eastwood | a84ef0d | 2015-10-31 13:49:16 +0100 | [diff] [blame] | 2 | /* |
| 3 | * IIO accel I2C driver for Freescale MMA7455L 3-axis 10-bit accelerometer |
| 4 | * Copyright 2015 Joachim Eastwood <manabian@gmail.com> |
Joachim Eastwood | a84ef0d | 2015-10-31 13:49:16 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/i2c.h> |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/regmap.h> |
| 10 | |
| 11 | #include "mma7455.h" |
| 12 | |
| 13 | static int mma7455_i2c_probe(struct i2c_client *i2c, |
| 14 | const struct i2c_device_id *id) |
| 15 | { |
| 16 | struct regmap *regmap; |
| 17 | const char *name = NULL; |
| 18 | |
| 19 | regmap = devm_regmap_init_i2c(i2c, &mma7455_core_regmap); |
| 20 | if (IS_ERR(regmap)) |
| 21 | return PTR_ERR(regmap); |
| 22 | |
| 23 | if (id) |
| 24 | name = id->name; |
| 25 | |
| 26 | return mma7455_core_probe(&i2c->dev, regmap, name); |
| 27 | } |
| 28 | |
| 29 | static int mma7455_i2c_remove(struct i2c_client *i2c) |
| 30 | { |
| 31 | return mma7455_core_remove(&i2c->dev); |
| 32 | } |
| 33 | |
| 34 | static const struct i2c_device_id mma7455_i2c_ids[] = { |
| 35 | { "mma7455", 0 }, |
| 36 | { "mma7456", 0 }, |
| 37 | { } |
| 38 | }; |
| 39 | MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids); |
| 40 | |
Javier Martinez Canillas | f414bb1 | 2017-03-15 01:45:02 -0300 | [diff] [blame] | 41 | static const struct of_device_id mma7455_of_match[] = { |
| 42 | { .compatible = "fsl,mma7455" }, |
| 43 | { .compatible = "fsl,mma7456" }, |
| 44 | { } |
| 45 | }; |
| 46 | MODULE_DEVICE_TABLE(of, mma7455_of_match); |
| 47 | |
Joachim Eastwood | a84ef0d | 2015-10-31 13:49:16 +0100 | [diff] [blame] | 48 | static struct i2c_driver mma7455_i2c_driver = { |
| 49 | .probe = mma7455_i2c_probe, |
| 50 | .remove = mma7455_i2c_remove, |
| 51 | .id_table = mma7455_i2c_ids, |
| 52 | .driver = { |
| 53 | .name = "mma7455-i2c", |
Javier Martinez Canillas | f414bb1 | 2017-03-15 01:45:02 -0300 | [diff] [blame] | 54 | .of_match_table = mma7455_of_match, |
Joachim Eastwood | a84ef0d | 2015-10-31 13:49:16 +0100 | [diff] [blame] | 55 | }, |
| 56 | }; |
| 57 | module_i2c_driver(mma7455_i2c_driver); |
| 58 | |
| 59 | MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>"); |
| 60 | MODULE_DESCRIPTION("Freescale MMA7455L I2C accelerometer driver"); |
| 61 | MODULE_LICENSE("GPL v2"); |