1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * 3-axis accelerometer driver supporting SPI Bosch-Sensortec accelerometer chip
4 * Copyright © 2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
7 #include <linux/device.h>
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 #include <linux/regmap.h>
11 #include <linux/spi/spi.h>
13 #include "bmc150-accel.h"
15 static int bmc150_accel_probe(struct spi_device
*spi
)
17 struct regmap
*regmap
;
18 const char *name
= NULL
;
19 enum bmc150_type type
= BOSCH_UNKNOWN
;
20 const struct spi_device_id
*id
= spi_get_device_id(spi
);
22 regmap
= devm_regmap_init_spi(spi
, &bmc150_regmap_conf
);
24 dev_err(&spi
->dev
, "Failed to initialize spi regmap\n");
25 return PTR_ERR(regmap
);
30 type
= id
->driver_data
;
33 return bmc150_accel_core_probe(&spi
->dev
, regmap
, spi
->irq
, type
, name
,
37 static void bmc150_accel_remove(struct spi_device
*spi
)
39 bmc150_accel_core_remove(&spi
->dev
);
42 static const struct acpi_device_id bmc150_accel_acpi_match
[] = {
53 MODULE_DEVICE_TABLE(acpi
, bmc150_accel_acpi_match
);
55 static const struct spi_device_id bmc150_accel_id
[] = {
63 {"bmc156_accel", BOSCH_BMC156
},
67 MODULE_DEVICE_TABLE(spi
, bmc150_accel_id
);
69 static struct spi_driver bmc150_accel_driver
= {
71 .name
= "bmc150_accel_spi",
72 .acpi_match_table
= bmc150_accel_acpi_match
,
73 .pm
= &bmc150_accel_pm_ops
,
75 .probe
= bmc150_accel_probe
,
76 .remove
= bmc150_accel_remove
,
77 .id_table
= bmc150_accel_id
,
79 module_spi_driver(bmc150_accel_driver
);
81 MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>");
82 MODULE_LICENSE("GPL v2");
83 MODULE_DESCRIPTION("BMC150 SPI accelerometer driver");
84 MODULE_IMPORT_NS(IIO_BMC150
);