aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@intel.com>2016-04-15 10:13:10 -0400
committerJonathan Cameron <jic23@kernel.org>2016-04-18 15:44:47 -0400
commit534536acdb25bae85a5333b7085837b3f1f72b73 (patch)
treeee9dc7fe7b7c9b48740bb88e1f0c82d1aeb1d0ac /drivers/iio
parent761b7910d4b4f0e7d283873b701ca83beacd70a5 (diff)
iio: magn: bmc150: Introduce SPI support
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/magnetometer/Kconfig16
-rw-r--r--drivers/iio/magnetometer/Makefile1
-rw-r--r--drivers/iio/magnetometer/bmc150_magn_spi.c68
3 files changed, 85 insertions, 0 deletions
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig
index 4972f9d17023..84e6559ccc65 100644
--- a/drivers/iio/magnetometer/Kconfig
+++ b/drivers/iio/magnetometer/Kconfig
@@ -47,6 +47,22 @@ config BMC150_MAGN_I2C
47 To compile this driver as a module, choose M here: the module will be 47 To compile this driver as a module, choose M here: the module will be
48 called bmc150_magn_i2c. 48 called bmc150_magn_i2c.
49 49
50config BMC150_MAGN_SPI
51 tristate "Bosch BMC150 SPI Magnetometer Driver"
52 depends on SPI
53 select BMC150_MAGN
54 select REGMAP_SPI
55 help
56 Say yes here to build support for the BMC150 magnetometer with
57 SPI interface.
58
59 This is a combo module with both accelerometer and magnetometer.
60 This driver is only implementing magnetometer part, which has
61 its own address and register map.
62
63 To compile this driver as a module, choose M here: the module will be
64 called bmc150_magn_spi.
65
50config MAG3110 66config MAG3110
51 tristate "Freescale MAG3110 3-Axis Magnetometer" 67 tristate "Freescale MAG3110 3-Axis Magnetometer"
52 depends on I2C 68 depends on I2C
diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile
index 56477737e083..92a745c9a6e8 100644
--- a/drivers/iio/magnetometer/Makefile
+++ b/drivers/iio/magnetometer/Makefile
@@ -6,6 +6,7 @@
6obj-$(CONFIG_AK8975) += ak8975.o 6obj-$(CONFIG_AK8975) += ak8975.o
7obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o 7obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o
8obj-$(CONFIG_BMC150_MAGN_I2C) += bmc150_magn_i2c.o 8obj-$(CONFIG_BMC150_MAGN_I2C) += bmc150_magn_i2c.o
9obj-$(CONFIG_BMC150_MAGN_SPI) += bmc150_magn_spi.o
9 10
10obj-$(CONFIG_MAG3110) += mag3110.o 11obj-$(CONFIG_MAG3110) += mag3110.o
11obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o 12obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o
diff --git a/drivers/iio/magnetometer/bmc150_magn_spi.c b/drivers/iio/magnetometer/bmc150_magn_spi.c
new file mode 100644
index 000000000000..c4c738a07695
--- /dev/null
+++ b/drivers/iio/magnetometer/bmc150_magn_spi.c
@@ -0,0 +1,68 @@
1/*
2 * 3-axis magnetometer driver support following SPI Bosch-Sensortec chips:
3 * - BMC150
4 * - BMC156
5 *
6 * Copyright (c) 2016, Intel Corporation.
7 *
8 * This file is subject to the terms and conditions of version 2 of
9 * the GNU General Public License. See the file COPYING in the main
10 * directory of this archive for more details.
11 */
12#include <linux/module.h>
13#include <linux/mod_devicetable.h>
14#include <linux/spi/spi.h>
15#include <linux/acpi.h>
16#include <linux/regmap.h>
17
18#include "bmc150_magn.h"
19
20static int bmc150_magn_spi_probe(struct spi_device *spi)
21{
22 struct regmap *regmap;
23 const struct spi_device_id *id = spi_get_device_id(spi);
24
25 regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config);
26 if (IS_ERR(regmap)) {
27 dev_err(&spi->dev, "Failed to register spi regmap %d\n",
28 (int)PTR_ERR(regmap));
29 return PTR_ERR(regmap);
30 }
31 return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name);
32}
33
34static int bmc150_magn_spi_remove(struct spi_device *spi)
35{
36 bmc150_magn_remove(&spi->dev);
37
38 return 0;
39}
40
41static const struct spi_device_id bmc150_magn_spi_id[] = {
42 {"bmc150_magn", 0},
43 {"bmc156_magn", 0},
44 {}
45};
46MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id);
47
48static const struct acpi_device_id bmc150_magn_acpi_match[] = {
49 {"BMC150B", 0},
50 {"BMC156B", 0},
51 {},
52};
53MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
54
55static struct spi_driver bmc150_magn_spi_driver = {
56 .probe = bmc150_magn_spi_probe,
57 .remove = bmc150_magn_spi_remove,
58 .id_table = bmc150_magn_spi_id,
59 .driver = {
60 .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match),
61 .name = "bmc150_magn_spi",
62 },
63};
64module_spi_driver(bmc150_magn_spi_driver);
65
66MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
67MODULE_DESCRIPTION("BMC150 magnetometer SPI driver");
68MODULE_LICENSE("GPL v2");