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