xref: /openbmc/linux/drivers/iio/accel/mma7455_spi.c (revision 9a29f5fc)
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 void mma7455_spi_remove(struct spi_device *spi)
26 {
27 	mma7455_core_remove(&spi->dev);
28 }
29 
30 static const struct spi_device_id mma7455_spi_ids[] = {
31 	{ "mma7455", 0 },
32 	{ "mma7456", 0 },
33 	{ }
34 };
35 MODULE_DEVICE_TABLE(spi, mma7455_spi_ids);
36 
37 static struct spi_driver mma7455_spi_driver = {
38 	.probe = mma7455_spi_probe,
39 	.remove = mma7455_spi_remove,
40 	.id_table = mma7455_spi_ids,
41 	.driver = {
42 		.name = "mma7455-spi",
43 	},
44 };
45 module_spi_driver(mma7455_spi_driver);
46 
47 MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
48 MODULE_DESCRIPTION("Freescale MMA7455L SPI accelerometer driver");
49 MODULE_LICENSE("GPL v2");
50 MODULE_IMPORT_NS(IIO_MMA7455);
51