gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / mfd / act8945a.c
blobd3520430997c36ddc4295d4cc2c5bdda1ad5019c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * MFD driver for Active-semi ACT8945a PMIC
5 * Copyright (C) 2015 Atmel Corporation.
7 * Author: Wenyou Yang <wenyou.yang@atmel.com>
8 */
10 #include <linux/i2c.h>
11 #include <linux/mfd/core.h>
12 #include <linux/module.h>
13 #include <linux/of_device.h>
14 #include <linux/regmap.h>
16 static const struct mfd_cell act8945a_devs[] = {
18 .name = "act8945a-regulator",
21 .name = "act8945a-charger",
22 .of_compatible = "active-semi,act8945a-charger",
26 static const struct regmap_config act8945a_regmap_config = {
27 .reg_bits = 8,
28 .val_bits = 8,
31 static int act8945a_i2c_probe(struct i2c_client *i2c,
32 const struct i2c_device_id *id)
34 int ret;
35 struct regmap *regmap;
37 regmap = devm_regmap_init_i2c(i2c, &act8945a_regmap_config);
38 if (IS_ERR(regmap)) {
39 ret = PTR_ERR(regmap);
40 dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
41 return ret;
44 i2c_set_clientdata(i2c, regmap);
46 ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE,
47 act8945a_devs, ARRAY_SIZE(act8945a_devs),
48 NULL, 0, NULL);
49 if (ret) {
50 dev_err(&i2c->dev, "Failed to add sub devices\n");
51 return ret;
54 return 0;
57 static const struct i2c_device_id act8945a_i2c_id[] = {
58 { "act8945a", 0 },
61 MODULE_DEVICE_TABLE(i2c, act8945a_i2c_id);
63 static const struct of_device_id act8945a_of_match[] = {
64 { .compatible = "active-semi,act8945a", },
65 {},
67 MODULE_DEVICE_TABLE(of, act8945a_of_match);
69 static struct i2c_driver act8945a_i2c_driver = {
70 .driver = {
71 .name = "act8945a",
72 .of_match_table = of_match_ptr(act8945a_of_match),
74 .probe = act8945a_i2c_probe,
75 .id_table = act8945a_i2c_id,
78 static int __init act8945a_i2c_init(void)
80 return i2c_add_driver(&act8945a_i2c_driver);
82 subsys_initcall(act8945a_i2c_init);
84 static void __exit act8945a_i2c_exit(void)
86 i2c_del_driver(&act8945a_i2c_driver);
88 module_exit(act8945a_i2c_exit);
90 MODULE_DESCRIPTION("ACT8945A PMIC multi-function driver");
91 MODULE_AUTHOR("Wenyou Yang <wenyou.yang@atmel.com>");
92 MODULE_LICENSE("GPL");