File Index
Files and directories
Sign in
FILE

tps65912-i2c.c

File preview with syntax highlighting.

linux-6.19.14/drivers/mfd/tps65912-i2c.c C
 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 const struct i2c_device_id tps65912_i2c_id_table[] = {
46	{ "tps65912" },
47	{ /* sentinel */ }
48};
49MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id_table);
50
51static struct i2c_driver tps65912_i2c_driver = {
52	.driver		= {
53		.name	= "tps65912",
54		.of_match_table = tps65912_i2c_of_match_table,
55	},
56	.probe		= tps65912_i2c_probe,
57	.id_table       = tps65912_i2c_id_table,
58};
59module_i2c_driver(tps65912_i2c_driver);
60
61MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
62MODULE_DESCRIPTION("TPS65912x I2C Interface Driver");
63MODULE_LICENSE("GPL v2");
~/ Read-only file preview.