1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2016 Texas Instruments Incorporated - https://www.ti.com/
5 * Author: Keerthy <j-keerthy@ti.com>
8 #include <linux/interrupt.h>
9 #include <linux/mfd/core.h>
10 #include <linux/module.h>
11 #include <linux/of_device.h>
12 #include <linux/regmap.h>
14 #include <linux/mfd/lp873x.h>
16 static const struct regmap_config lp873x_regmap_config = {
19 .max_register = LP873X_REG_MAX,
22 static const struct mfd_cell lp873x_cells[] = {
23 { .name = "lp873x-regulator", },
24 { .name = "lp873x-gpio", },
27 static int lp873x_probe(struct i2c_client *client,
28 const struct i2c_device_id *ids)
34 lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
38 lp873->dev = &client->dev;
40 lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
41 if (IS_ERR(lp873->regmap)) {
42 ret = PTR_ERR(lp873->regmap);
44 "Failed to initialize register map: %d\n", ret);
48 ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
50 dev_err(lp873->dev, "Failed to read OTP ID\n");
54 lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
56 i2c_set_clientdata(client, lp873);
58 ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
59 ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
64 static const struct of_device_id of_lp873x_match_table[] = {
65 { .compatible = "ti,lp8733", },
66 { .compatible = "ti,lp8732", },
69 MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
71 static const struct i2c_device_id lp873x_id_table[] = {
75 MODULE_DEVICE_TABLE(i2c, lp873x_id_table);
77 static struct i2c_driver lp873x_driver = {
80 .of_match_table = of_lp873x_match_table,
82 .probe = lp873x_probe,
83 .id_table = lp873x_id_table,
85 module_i2c_driver(lp873x_driver);
87 MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
88 MODULE_DESCRIPTION("LP873X chip family Multi-Function Device driver");
89 MODULE_LICENSE("GPL v2");