1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/spi/spi.h>
3 #include <linux/regmap.h>
4 #include <linux/iio/iio.h>
5 #include <linux/module.h>
9 static const struct regmap_config bmg160_regmap_spi_conf
= {
15 static int bmg160_spi_probe(struct spi_device
*spi
)
17 struct regmap
*regmap
;
18 const struct spi_device_id
*id
= spi_get_device_id(spi
);
20 regmap
= devm_regmap_init_spi(spi
, &bmg160_regmap_spi_conf
);
22 dev_err(&spi
->dev
, "Failed to register spi regmap %d\n",
23 (int)PTR_ERR(regmap
));
24 return PTR_ERR(regmap
);
27 return bmg160_core_probe(&spi
->dev
, regmap
, spi
->irq
, id
->name
);
30 static int bmg160_spi_remove(struct spi_device
*spi
)
32 bmg160_core_remove(&spi
->dev
);
37 static const struct spi_device_id bmg160_spi_id
[] = {
43 MODULE_DEVICE_TABLE(spi
, bmg160_spi_id
);
45 static struct spi_driver bmg160_spi_driver
= {
50 .probe
= bmg160_spi_probe
,
51 .remove
= bmg160_spi_remove
,
52 .id_table
= bmg160_spi_id
,
54 module_spi_driver(bmg160_spi_driver
);
56 MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>");
57 MODULE_LICENSE("GPL v2");
58 MODULE_DESCRIPTION("BMG160 SPI Gyro driver");