1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for NXP Fxas21002c Gyroscope - SPI
5 * Copyright (C) 2019 Linaro Ltd.
9 #include <linux/mod_devicetable.h>
10 #include <linux/module.h>
11 #include <linux/regmap.h>
12 #include <linux/spi/spi.h>
14 #include "fxas21002c.h"
16 static const struct regmap_config fxas21002c_regmap_spi_conf
= {
19 .max_register
= FXAS21002C_REG_CTRL3
,
22 static int fxas21002c_spi_probe(struct spi_device
*spi
)
24 const struct spi_device_id
*id
= spi_get_device_id(spi
);
25 struct regmap
*regmap
;
27 regmap
= devm_regmap_init_spi(spi
, &fxas21002c_regmap_spi_conf
);
29 dev_err(&spi
->dev
, "Failed to register spi regmap: %ld\n",
31 return PTR_ERR(regmap
);
34 return fxas21002c_core_probe(&spi
->dev
, regmap
, spi
->irq
, id
->name
);
37 static void fxas21002c_spi_remove(struct spi_device
*spi
)
39 fxas21002c_core_remove(&spi
->dev
);
42 static const struct spi_device_id fxas21002c_spi_id
[] = {
46 MODULE_DEVICE_TABLE(spi
, fxas21002c_spi_id
);
48 static const struct of_device_id fxas21002c_spi_of_match
[] = {
49 { .compatible
= "nxp,fxas21002c", },
52 MODULE_DEVICE_TABLE(of
, fxas21002c_spi_of_match
);
54 static struct spi_driver fxas21002c_spi_driver
= {
56 .name
= "fxas21002c_spi",
57 .pm
= pm_ptr(&fxas21002c_pm_ops
),
58 .of_match_table
= fxas21002c_spi_of_match
,
60 .probe
= fxas21002c_spi_probe
,
61 .remove
= fxas21002c_spi_remove
,
62 .id_table
= fxas21002c_spi_id
,
64 module_spi_driver(fxas21002c_spi_driver
);
66 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
67 MODULE_LICENSE("GPL v2");
68 MODULE_DESCRIPTION("FXAS21002C SPI Gyro driver");
69 MODULE_IMPORT_NS("IIO_FXAS21002C");