1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for NXP FXAS21002C Gyroscope - I2C
5 * Copyright (C) 2018 Linaro Ltd.
10 #include <linux/mod_devicetable.h>
11 #include <linux/module.h>
12 #include <linux/regmap.h>
14 #include "fxas21002c.h"
16 static const struct regmap_config fxas21002c_regmap_i2c_conf
= {
19 .max_register
= FXAS21002C_REG_CTRL3
,
22 static int fxas21002c_i2c_probe(struct i2c_client
*i2c
)
24 struct regmap
*regmap
;
26 regmap
= devm_regmap_init_i2c(i2c
, &fxas21002c_regmap_i2c_conf
);
28 dev_err(&i2c
->dev
, "Failed to register i2c regmap: %ld\n",
30 return PTR_ERR(regmap
);
33 return fxas21002c_core_probe(&i2c
->dev
, regmap
, i2c
->irq
, i2c
->name
);
36 static int fxas21002c_i2c_remove(struct i2c_client
*i2c
)
38 fxas21002c_core_remove(&i2c
->dev
);
43 static const struct i2c_device_id fxas21002c_i2c_id
[] = {
47 MODULE_DEVICE_TABLE(i2c
, fxas21002c_i2c_id
);
49 static const struct of_device_id fxas21002c_i2c_of_match
[] = {
50 { .compatible
= "nxp,fxas21002c", },
53 MODULE_DEVICE_TABLE(of
, fxas21002c_i2c_of_match
);
55 static struct i2c_driver fxas21002c_i2c_driver
= {
57 .name
= "fxas21002c_i2c",
58 .pm
= &fxas21002c_pm_ops
,
59 .of_match_table
= fxas21002c_i2c_of_match
,
61 .probe_new
= fxas21002c_i2c_probe
,
62 .remove
= fxas21002c_i2c_remove
,
63 .id_table
= fxas21002c_i2c_id
,
65 module_i2c_driver(fxas21002c_i2c_driver
);
67 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
68 MODULE_LICENSE("GPL v2");
69 MODULE_DESCRIPTION("FXAS21002C I2C Gyro driver");