0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/i2c.h>
0010 #include <linux/mfd/atc260x/core.h>
0011 #include <linux/module.h>
0012 #include <linux/of.h>
0013 #include <linux/regmap.h>
0014
0015 static int atc260x_i2c_probe(struct i2c_client *client,
0016 const struct i2c_device_id *id)
0017 {
0018 struct atc260x *atc260x;
0019 struct regmap_config regmap_cfg;
0020 int ret;
0021
0022 atc260x = devm_kzalloc(&client->dev, sizeof(*atc260x), GFP_KERNEL);
0023 if (!atc260x)
0024 return -ENOMEM;
0025
0026 atc260x->dev = &client->dev;
0027 atc260x->irq = client->irq;
0028
0029 ret = atc260x_match_device(atc260x, ®map_cfg);
0030 if (ret)
0031 return ret;
0032
0033 i2c_set_clientdata(client, atc260x);
0034
0035 atc260x->regmap = devm_regmap_init_i2c(client, ®map_cfg);
0036 if (IS_ERR(atc260x->regmap)) {
0037 ret = PTR_ERR(atc260x->regmap);
0038 dev_err(&client->dev, "failed to init regmap: %d\n", ret);
0039 return ret;
0040 }
0041
0042 return atc260x_device_probe(atc260x);
0043 }
0044
0045 static const struct of_device_id atc260x_i2c_of_match[] = {
0046 { .compatible = "actions,atc2603c", .data = (void *)ATC2603C },
0047 { .compatible = "actions,atc2609a", .data = (void *)ATC2609A },
0048 { }
0049 };
0050 MODULE_DEVICE_TABLE(of, atc260x_i2c_of_match);
0051
0052 static struct i2c_driver atc260x_i2c_driver = {
0053 .driver = {
0054 .name = "atc260x",
0055 .of_match_table = of_match_ptr(atc260x_i2c_of_match),
0056 },
0057 .probe = atc260x_i2c_probe,
0058 };
0059 module_i2c_driver(atc260x_i2c_driver);
0060
0061 MODULE_DESCRIPTION("ATC260x PMICs I2C bus interface");
0062 MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
0063 MODULE_AUTHOR("Cristian Ciocaltea <cristian.ciocaltea@gmail.com>");
0064 MODULE_LICENSE("GPL");