]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
b25c6b7d WY |
2 | /* |
3 | * MFD driver for Active-semi ACT8945a PMIC | |
4 | * | |
5 | * Copyright (C) 2015 Atmel Corporation. | |
6 | * | |
7 | * Author: Wenyou Yang <[email protected]> | |
b25c6b7d WY |
8 | */ |
9 | ||
10 | #include <linux/i2c.h> | |
11 | #include <linux/mfd/core.h> | |
12 | #include <linux/module.h> | |
dc0c386e | 13 | #include <linux/of.h> |
b25c6b7d WY |
14 | #include <linux/regmap.h> |
15 | ||
16 | static const struct mfd_cell act8945a_devs[] = { | |
17 | { | |
18 | .name = "act8945a-regulator", | |
19 | }, | |
20 | { | |
21 | .name = "act8945a-charger", | |
7235711a | 22 | .of_compatible = "active-semi,act8945a-charger", |
b25c6b7d WY |
23 | }, |
24 | }; | |
25 | ||
26 | static const struct regmap_config act8945a_regmap_config = { | |
27 | .reg_bits = 8, | |
28 | .val_bits = 8, | |
29 | }; | |
30 | ||
75a4504e | 31 | static int act8945a_i2c_probe(struct i2c_client *i2c) |
b25c6b7d WY |
32 | { |
33 | int ret; | |
34 | struct regmap *regmap; | |
35 | ||
36 | regmap = devm_regmap_init_i2c(i2c, &act8945a_regmap_config); | |
37 | if (IS_ERR(regmap)) { | |
38 | ret = PTR_ERR(regmap); | |
39 | dev_err(&i2c->dev, "regmap init failed: %d\n", ret); | |
40 | return ret; | |
41 | } | |
42 | ||
43 | i2c_set_clientdata(i2c, regmap); | |
44 | ||
f9932c6e LD |
45 | ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE, |
46 | act8945a_devs, ARRAY_SIZE(act8945a_devs), | |
47 | NULL, 0, NULL); | |
b25c6b7d WY |
48 | if (ret) { |
49 | dev_err(&i2c->dev, "Failed to add sub devices\n"); | |
50 | return ret; | |
51 | } | |
52 | ||
53 | return 0; | |
54 | } | |
55 | ||
b25c6b7d WY |
56 | static const struct i2c_device_id act8945a_i2c_id[] = { |
57 | { "act8945a", 0 }, | |
58 | {} | |
59 | }; | |
60 | MODULE_DEVICE_TABLE(i2c, act8945a_i2c_id); | |
61 | ||
62 | static const struct of_device_id act8945a_of_match[] = { | |
63 | { .compatible = "active-semi,act8945a", }, | |
64 | {}, | |
65 | }; | |
66 | MODULE_DEVICE_TABLE(of, act8945a_of_match); | |
67 | ||
68 | static struct i2c_driver act8945a_i2c_driver = { | |
69 | .driver = { | |
70 | .name = "act8945a", | |
00037323 | 71 | .of_match_table = act8945a_of_match, |
b25c6b7d | 72 | }, |
9816d859 | 73 | .probe = act8945a_i2c_probe, |
b25c6b7d WY |
74 | .id_table = act8945a_i2c_id, |
75 | }; | |
76 | ||
77 | static int __init act8945a_i2c_init(void) | |
78 | { | |
79 | return i2c_add_driver(&act8945a_i2c_driver); | |
80 | } | |
81 | subsys_initcall(act8945a_i2c_init); | |
82 | ||
83 | static void __exit act8945a_i2c_exit(void) | |
84 | { | |
85 | i2c_del_driver(&act8945a_i2c_driver); | |
86 | } | |
87 | module_exit(act8945a_i2c_exit); | |
88 | ||
89 | MODULE_DESCRIPTION("ACT8945A PMIC multi-function driver"); | |
90 | MODULE_AUTHOR("Wenyou Yang <[email protected]>"); | |
91 | MODULE_LICENSE("GPL"); |