0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/i2c.h>
0013 #include <linux/module.h>
0014 #include <linux/regmap.h>
0015
0016 #include <linux/mfd/tps65912.h>
0017
0018 static const struct of_device_id tps65912_i2c_of_match_table[] = {
0019 { .compatible = "ti,tps65912", },
0020 { }
0021 };
0022 MODULE_DEVICE_TABLE(of, tps65912_i2c_of_match_table);
0023
0024 static int tps65912_i2c_probe(struct i2c_client *client,
0025 const struct i2c_device_id *ids)
0026 {
0027 struct tps65912 *tps;
0028
0029 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
0030 if (!tps)
0031 return -ENOMEM;
0032
0033 i2c_set_clientdata(client, tps);
0034 tps->dev = &client->dev;
0035 tps->irq = client->irq;
0036
0037 tps->regmap = devm_regmap_init_i2c(client, &tps65912_regmap_config);
0038 if (IS_ERR(tps->regmap)) {
0039 dev_err(tps->dev, "Failed to initialize register map\n");
0040 return PTR_ERR(tps->regmap);
0041 }
0042
0043 return tps65912_device_init(tps);
0044 }
0045
0046 static int tps65912_i2c_remove(struct i2c_client *client)
0047 {
0048 struct tps65912 *tps = i2c_get_clientdata(client);
0049
0050 tps65912_device_exit(tps);
0051
0052 return 0;
0053 }
0054
0055 static const struct i2c_device_id tps65912_i2c_id_table[] = {
0056 { "tps65912", 0 },
0057 { }
0058 };
0059 MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id_table);
0060
0061 static struct i2c_driver tps65912_i2c_driver = {
0062 .driver = {
0063 .name = "tps65912",
0064 .of_match_table = tps65912_i2c_of_match_table,
0065 },
0066 .probe = tps65912_i2c_probe,
0067 .remove = tps65912_i2c_remove,
0068 .id_table = tps65912_i2c_id_table,
0069 };
0070 module_i2c_driver(tps65912_i2c_driver);
0071
0072 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
0073 MODULE_DESCRIPTION("TPS65912x I2C Interface Driver");
0074 MODULE_LICENSE("GPL v2");