Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * I2C access driver for TI TPS65912x PMICs
0004  *
0005  * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
0006  *  Andrew F. Davis <afd@ti.com>
0007  *
0008  * Based on the TPS65218 driver and the previous TPS65912 driver by
0009  * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
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     { /* sentinel */ }
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     { /* sentinel */ }
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");