0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/kernel.h>
0011 #include <linux/module.h>
0012 #include <linux/mod_devicetable.h>
0013 #include <linux/i2c.h>
0014 #include <linux/slab.h>
0015 #include <linux/regmap.h>
0016
0017 #include "st_uvis25.h"
0018
0019 #define UVIS25_I2C_AUTO_INCREMENT BIT(7)
0020
0021 static const struct regmap_config st_uvis25_i2c_regmap_config = {
0022 .reg_bits = 8,
0023 .val_bits = 8,
0024 .write_flag_mask = UVIS25_I2C_AUTO_INCREMENT,
0025 .read_flag_mask = UVIS25_I2C_AUTO_INCREMENT,
0026 };
0027
0028 static int st_uvis25_i2c_probe(struct i2c_client *client,
0029 const struct i2c_device_id *id)
0030 {
0031 struct regmap *regmap;
0032
0033 regmap = devm_regmap_init_i2c(client, &st_uvis25_i2c_regmap_config);
0034 if (IS_ERR(regmap)) {
0035 dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
0036 PTR_ERR(regmap));
0037 return PTR_ERR(regmap);
0038 }
0039
0040 return st_uvis25_probe(&client->dev, client->irq, regmap);
0041 }
0042
0043 static const struct of_device_id st_uvis25_i2c_of_match[] = {
0044 { .compatible = "st,uvis25", },
0045 {},
0046 };
0047 MODULE_DEVICE_TABLE(of, st_uvis25_i2c_of_match);
0048
0049 static const struct i2c_device_id st_uvis25_i2c_id_table[] = {
0050 { ST_UVIS25_DEV_NAME },
0051 {},
0052 };
0053 MODULE_DEVICE_TABLE(i2c, st_uvis25_i2c_id_table);
0054
0055 static struct i2c_driver st_uvis25_driver = {
0056 .driver = {
0057 .name = "st_uvis25_i2c",
0058 .pm = &st_uvis25_pm_ops,
0059 .of_match_table = st_uvis25_i2c_of_match,
0060 },
0061 .probe = st_uvis25_i2c_probe,
0062 .id_table = st_uvis25_i2c_id_table,
0063 };
0064 module_i2c_driver(st_uvis25_driver);
0065
0066 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>");
0067 MODULE_DESCRIPTION("STMicroelectronics uvis25 i2c driver");
0068 MODULE_LICENSE("GPL v2");
0069 MODULE_IMPORT_NS(IIO_UVIS25);