1 #include <linux/spi/spi.h> 2 #include <linux/regmap.h> 3 #include <linux/iio/iio.h> 4 #include <linux/module.h> 5 6 #include "bmg160.h" 7 8 static const struct regmap_config bmg160_regmap_spi_conf = { 9 .reg_bits = 8, 10 .val_bits = 8, 11 .max_register = 0x3f, 12 }; 13 14 static int bmg160_spi_probe(struct spi_device *spi) 15 { 16 struct regmap *regmap; 17 const struct spi_device_id *id = spi_get_device_id(spi); 18 19 regmap = devm_regmap_init_spi(spi, &bmg160_regmap_spi_conf); 20 if (IS_ERR(regmap)) { 21 dev_err(&spi->dev, "Failed to register spi regmap %d\n", 22 (int)PTR_ERR(regmap)); 23 return PTR_ERR(regmap); 24 } 25 26 return bmg160_core_probe(&spi->dev, regmap, spi->irq, id->name); 27 } 28 29 static int bmg160_spi_remove(struct spi_device *spi) 30 { 31 bmg160_core_remove(&spi->dev); 32 33 return 0; 34 } 35 36 static const struct spi_device_id bmg160_spi_id[] = { 37 {"bmg160", 0}, 38 {"bmi055_gyro", 0}, 39 {} 40 }; 41 42 MODULE_DEVICE_TABLE(spi, bmg160_spi_id); 43 44 static struct spi_driver bmg160_spi_driver = { 45 .driver = { 46 .name = "bmg160_spi", 47 .pm = &bmg160_pm_ops, 48 }, 49 .probe = bmg160_spi_probe, 50 .remove = bmg160_spi_remove, 51 .id_table = bmg160_spi_id, 52 }; 53 module_spi_driver(bmg160_spi_driver); 54 55 MODULE_AUTHOR("Markus Pargmann <mpa@pengutronix.de>"); 56 MODULE_LICENSE("GPL v2"); 57 MODULE_DESCRIPTION("BMG160 SPI Gyro driver"); 58