xref: /openbmc/linux/drivers/iio/accel/mma7455_spi.c (revision dba52960)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * IIO accel SPI driver for Freescale MMA7455L 3-axis 10-bit accelerometer
4  * Copyright 2015 Joachim Eastwood <manabian@gmail.com>
5  */
6 
7 #include <linux/module.h>
8 #include <linux/regmap.h>
9 #include <linux/spi/spi.h>
10 
11 #include "mma7455.h"
12 
13 static int mma7455_spi_probe(struct spi_device *spi)
14 {
15 	const struct spi_device_id *id = spi_get_device_id(spi);
16 	struct regmap *regmap;
17 
18 	regmap = devm_regmap_init_spi(spi, &mma7455_core_regmap);
19 	if (IS_ERR(regmap))
20 		return PTR_ERR(regmap);
21 
22 	return mma7455_core_probe(&spi->dev, regmap, id->name);
23 }
24 
25 static int mma7455_spi_remove(struct spi_device *spi)
26 {
27 	mma7455_core_remove(&spi->dev);
28 
29 	return 0;
30 }
31 
32 static const struct spi_device_id mma7455_spi_ids[] = {
33 	{ "mma7455", 0 },
34 	{ "mma7456", 0 },
35 	{ }
36 };
37 MODULE_DEVICE_TABLE(spi, mma7455_spi_ids);
38 
39 static struct spi_driver mma7455_spi_driver = {
40 	.probe = mma7455_spi_probe,
41 	.remove = mma7455_spi_remove,
42 	.id_table = mma7455_spi_ids,
43 	.driver = {
44 		.name = "mma7455-spi",
45 	},
46 };
47 module_spi_driver(mma7455_spi_driver);
48 
49 MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
50 MODULE_DESCRIPTION("Freescale MMA7455L SPI accelerometer driver");
51 MODULE_LICENSE("GPL v2");
52