| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/* |
| 3 |
* 3-axis magnetometer driver support following SPI Bosch-Sensortec chips: |
| 4 |
* - BMC150 |
| 5 |
* - BMC156 |
| 6 |
* - BMM150 |
| 7 |
* |
| 8 |
* Copyright (c) 2016, Intel Corporation. |
| 9 |
*/ |
| 10 |
#include <linux/module.h> |
| 11 |
#include <linux/mod_devicetable.h> |
| 12 |
#include <linux/spi/spi.h> |
| 13 |
#include <linux/regmap.h> |
| 14 |
|
| 15 |
#include "bmc150_magn.h" |
| 16 |
|
| 17 |
static int bmc150_magn_spi_probe(struct spi_device *spi) |
| 18 |
{ |
| 19 |
struct regmap *regmap; |
| 20 |
const struct spi_device_id *id = spi_get_device_id(spi); |
| 21 |
|
| 22 |
regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config); |
| 23 |
if (IS_ERR(regmap)) { |
| 24 |
dev_err(&spi->dev, "Failed to register spi regmap: %pe\n", |
| 25 |
regmap); |
| 26 |
return PTR_ERR(regmap); |
| 27 |
} |
| 28 |
return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name); |
| 29 |
} |
| 30 |
|
| 31 |
static void bmc150_magn_spi_remove(struct spi_device *spi) |
| 32 |
{ |
| 33 |
bmc150_magn_remove(&spi->dev); |
| 34 |
} |
| 35 |
|
| 36 |
static const struct spi_device_id bmc150_magn_spi_id[] = { |
| 37 |
{"bmc150_magn", 0}, |
| 38 |
{"bmc156_magn", 0}, |
| 39 |
{"bmm150_magn", 0}, |
| 40 |
{ } |
| 41 |
}; |
| 42 |
MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id); |
| 43 |
|
| 44 |
static struct spi_driver bmc150_magn_spi_driver = { |
| 45 |
.probe = bmc150_magn_spi_probe, |
| 46 |
.remove = bmc150_magn_spi_remove, |
| 47 |
.id_table = bmc150_magn_spi_id, |
| 48 |
.driver = { |
| 49 |
.name = "bmc150_magn_spi", |
| 50 |
}, |
| 51 |
}; |
| 52 |
module_spi_driver(bmc150_magn_spi_driver); |
| 53 |
|
| 54 |
MODULE_AUTHOR("Daniel Baluta <[email protected]"); |
| 55 |
MODULE_DESCRIPTION("BMC150 magnetometer SPI driver"); |
| 56 |
MODULE_LICENSE("GPL v2"); |
| 57 |
MODULE_IMPORT_NS("IIO_BMC150_MAGN"); |