0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/err.h>
0009 #include <linux/mod_devicetable.h>
0010 #include <linux/module.h>
0011 #include <linux/regmap.h>
0012 #include <linux/spi/spi.h>
0013
0014 #include "fxas21002c.h"
0015
0016 static const struct regmap_config fxas21002c_regmap_spi_conf = {
0017 .reg_bits = 8,
0018 .val_bits = 8,
0019 .max_register = FXAS21002C_REG_CTRL3,
0020 };
0021
0022 static int fxas21002c_spi_probe(struct spi_device *spi)
0023 {
0024 const struct spi_device_id *id = spi_get_device_id(spi);
0025 struct regmap *regmap;
0026
0027 regmap = devm_regmap_init_spi(spi, &fxas21002c_regmap_spi_conf);
0028 if (IS_ERR(regmap)) {
0029 dev_err(&spi->dev, "Failed to register spi regmap: %ld\n",
0030 PTR_ERR(regmap));
0031 return PTR_ERR(regmap);
0032 }
0033
0034 return fxas21002c_core_probe(&spi->dev, regmap, spi->irq, id->name);
0035 }
0036
0037 static void fxas21002c_spi_remove(struct spi_device *spi)
0038 {
0039 fxas21002c_core_remove(&spi->dev);
0040 }
0041
0042 static const struct spi_device_id fxas21002c_spi_id[] = {
0043 { "fxas21002c", 0 },
0044 { }
0045 };
0046 MODULE_DEVICE_TABLE(spi, fxas21002c_spi_id);
0047
0048 static const struct of_device_id fxas21002c_spi_of_match[] = {
0049 { .compatible = "nxp,fxas21002c", },
0050 { }
0051 };
0052 MODULE_DEVICE_TABLE(of, fxas21002c_spi_of_match);
0053
0054 static struct spi_driver fxas21002c_spi_driver = {
0055 .driver = {
0056 .name = "fxas21002c_spi",
0057 .pm = &fxas21002c_pm_ops,
0058 .of_match_table = fxas21002c_spi_of_match,
0059 },
0060 .probe = fxas21002c_spi_probe,
0061 .remove = fxas21002c_spi_remove,
0062 .id_table = fxas21002c_spi_id,
0063 };
0064 module_spi_driver(fxas21002c_spi_driver);
0065
0066 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
0067 MODULE_LICENSE("GPL v2");
0068 MODULE_DESCRIPTION("FXAS21002C SPI Gyro driver");