1 // SPDX-License-Identifier: GPL-2.0+
3 * MP2629 parent driver for ADC and battery charger
5 * Copyright 2020 Monolithic Power Systems, Inc
7 * Author: Saravanan Sekar <sravanhome@gmail.com>
10 #include <linux/i2c.h>
11 #include <linux/kernel.h>
12 #include <linux/mfd/core.h>
13 #include <linux/mfd/mp2629.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/regmap.h>
17 #include <linux/slab.h>
19 static const struct mfd_cell mp2629_cell[] = {
22 .of_compatible = "mps,mp2629_adc",
25 .name = "mp2629_charger",
26 .of_compatible = "mps,mp2629_charger",
30 static const struct regmap_config mp2629_regmap_config = {
36 static int mp2629_probe(struct i2c_client *client)
38 struct mp2629_data *ddata;
41 ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL);
45 ddata->dev = &client->dev;
46 i2c_set_clientdata(client, ddata);
48 ddata->regmap = devm_regmap_init_i2c(client, &mp2629_regmap_config);
49 if (IS_ERR(ddata->regmap)) {
50 dev_err(ddata->dev, "Failed to allocate regmap\n");
51 return PTR_ERR(ddata->regmap);
54 ret = devm_mfd_add_devices(ddata->dev, PLATFORM_DEVID_AUTO, mp2629_cell,
55 ARRAY_SIZE(mp2629_cell), NULL, 0, NULL);
57 dev_err(ddata->dev, "Failed to register sub-devices %d\n", ret);
62 static const struct of_device_id mp2629_of_match[] = {
63 { .compatible = "mps,mp2629"},
66 MODULE_DEVICE_TABLE(of, mp2629_of_match);
68 static struct i2c_driver mp2629_driver = {
71 .of_match_table = mp2629_of_match,
73 .probe = mp2629_probe,
75 module_i2c_driver(mp2629_driver);
77 MODULE_AUTHOR("Saravanan Sekar <sravanhome@gmail.com>");
78 MODULE_DESCRIPTION("MP2629 Battery charger parent driver");
79 MODULE_LICENSE("GPL");