Linux Audio

Check our new training course

Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * I2C access driver for TI TPS65912x PMICs
 4 *
 5 * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
 6 *	Andrew F. Davis <afd@ti.com>
 7 *
 
 
 
 
 
 
 
 
 
 8 * Based on the TPS65218 driver and the previous TPS65912 driver by
 9 * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
10 */
11
12#include <linux/i2c.h>
13#include <linux/module.h>
14#include <linux/regmap.h>
15
16#include <linux/mfd/tps65912.h>
17
18static const struct of_device_id tps65912_i2c_of_match_table[] = {
19	{ .compatible = "ti,tps65912", },
20	{ /* sentinel */ }
21};
22MODULE_DEVICE_TABLE(of, tps65912_i2c_of_match_table);
23
24static int tps65912_i2c_probe(struct i2c_client *client)
 
25{
26	struct tps65912 *tps;
27
28	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
29	if (!tps)
30		return -ENOMEM;
31
32	i2c_set_clientdata(client, tps);
33	tps->dev = &client->dev;
34	tps->irq = client->irq;
35
36	tps->regmap = devm_regmap_init_i2c(client, &tps65912_regmap_config);
37	if (IS_ERR(tps->regmap)) {
38		dev_err(tps->dev, "Failed to initialize register map\n");
39		return PTR_ERR(tps->regmap);
40	}
41
42	return tps65912_device_init(tps);
43}
44
45static void tps65912_i2c_remove(struct i2c_client *client)
46{
47	struct tps65912 *tps = i2c_get_clientdata(client);
48
49	tps65912_device_exit(tps);
50}
51
52static const struct i2c_device_id tps65912_i2c_id_table[] = {
53	{ "tps65912", 0 },
54	{ /* sentinel */ }
55};
56MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id_table);
57
58static struct i2c_driver tps65912_i2c_driver = {
59	.driver		= {
60		.name	= "tps65912",
61		.of_match_table = tps65912_i2c_of_match_table,
62	},
63	.probe		= tps65912_i2c_probe,
64	.remove		= tps65912_i2c_remove,
65	.id_table       = tps65912_i2c_id_table,
66};
67module_i2c_driver(tps65912_i2c_driver);
68
69MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
70MODULE_DESCRIPTION("TPS65912x I2C Interface Driver");
71MODULE_LICENSE("GPL v2");
v4.6
 
 1/*
 2 * I2C access driver for TI TPS65912x PMICs
 3 *
 4 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
 5 *	Andrew F. Davis <afd@ti.com>
 6 *
 7 * This program is free software; you can redistribute it and/or
 8 * modify it under the terms of the GNU General Public License version 2 as
 9 * published by the Free Software Foundation.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether expressed or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License version 2 for more details.
15 *
16 * Based on the TPS65218 driver and the previous TPS65912 driver by
17 * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
18 */
19
20#include <linux/i2c.h>
21#include <linux/module.h>
22#include <linux/regmap.h>
23
24#include <linux/mfd/tps65912.h>
25
26static const struct of_device_id tps65912_i2c_of_match_table[] = {
27	{ .compatible = "ti,tps65912", },
28	{ /* sentinel */ }
29};
 
30
31static int tps65912_i2c_probe(struct i2c_client *client,
32			      const struct i2c_device_id *ids)
33{
34	struct tps65912 *tps;
35
36	tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
37	if (!tps)
38		return -ENOMEM;
39
40	i2c_set_clientdata(client, tps);
41	tps->dev = &client->dev;
42	tps->irq = client->irq;
43
44	tps->regmap = devm_regmap_init_i2c(client, &tps65912_regmap_config);
45	if (IS_ERR(tps->regmap)) {
46		dev_err(tps->dev, "Failed to initialize register map\n");
47		return PTR_ERR(tps->regmap);
48	}
49
50	return tps65912_device_init(tps);
51}
52
53static int tps65912_i2c_remove(struct i2c_client *client)
54{
55	struct tps65912 *tps = i2c_get_clientdata(client);
56
57	return tps65912_device_exit(tps);
58}
59
60static const struct i2c_device_id tps65912_i2c_id_table[] = {
61	{ "tps65912", 0 },
62	{ /* sentinel */ }
63};
64MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id_table);
65
66static struct i2c_driver tps65912_i2c_driver = {
67	.driver		= {
68		.name	= "tps65912",
69		.of_match_table = tps65912_i2c_of_match_table,
70	},
71	.probe		= tps65912_i2c_probe,
72	.remove		= tps65912_i2c_remove,
73	.id_table       = tps65912_i2c_id_table,
74};
75module_i2c_driver(tps65912_i2c_driver);
76
77MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
78MODULE_DESCRIPTION("TPS65912x I2C Interface Driver");
79MODULE_LICENSE("GPL v2");