Skip to content

Commit 64b285a

Browse files
committed
Merge remote-tracking branches 'regulator/topic/max1586', 'regulator/topic/max77802' and 'regulator/topic/of' into regulator-next
4 parents a81bf3c + 5ccedf0 + da0bb55 + ef126a4 commit 64b285a

8 files changed

Lines changed: 767 additions & 3 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Maxim MAX1586 voltage regulator
2+
3+
Required properties:
4+
- compatible: must be "maxim,max1586"
5+
- reg: I2C slave address, usually 0x14
6+
- v3-gain: integer specifying the V3 gain as per datasheet
7+
(1 + R24/R25 + R24/185.5kOhm)
8+
- any required generic properties defined in regulator.txt
9+
10+
Example:
11+
12+
i2c_master {
13+
max1586@14 {
14+
compatible = "maxim,max1586";
15+
reg = <0x14>;
16+
v3-gain = <1000000>;
17+
18+
regulators {
19+
vcc_core: v3 {
20+
regulator-name = "vcc_core";
21+
regulator-compatible = "Output_V3";
22+
regulator-min-microvolt = <1000000>;
23+
regulator-max-microvolt = <1705000>;
24+
regulator-always-on;
25+
};
26+
};
27+
};
28+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Binding for Maxim MAX77802 regulators
2+
3+
This is a part of device tree bindings of MAX77802 multi-function device.
4+
More information can be found in bindings/mfd/max77802.txt file.
5+
6+
The MAX77802 PMIC has 10 high-efficiency Buck and 32 Low-dropout (LDO)
7+
regulators that can be controlled over I2C.
8+
9+
Following properties should be present in main device node of the MFD chip.
10+
11+
Optional node:
12+
- regulators : The regulators of max77802 have to be instantiated
13+
under subnode named "regulators" using the following format.
14+
15+
regulator-name {
16+
standard regulator constraints....
17+
};
18+
refer Documentation/devicetree/bindings/regulator/regulator.txt
19+
20+
The regulator node name should be initialized with a string to get matched
21+
with their hardware counterparts as follow. The valid names are:
22+
23+
-LDOn : for LDOs, where n can lie in ranges 1-15, 17-21, 23-30
24+
and 32-35.
25+
example: LDO1, LDO2, LDO35.
26+
-BUCKn : for BUCKs, where n can lie in range 1 to 10.
27+
example: BUCK1, BUCK5, BUCK10.
28+
Example:
29+
30+
max77802@09 {
31+
compatible = "maxim,max77802";
32+
interrupt-parent = <&wakeup_eint>;
33+
interrupts = <26 0>;
34+
reg = <0x09>;
35+
#address-cells = <1>;
36+
#size-cells = <0>;
37+
38+
regulators {
39+
ldo11_reg: LDO11 {
40+
regulator-name = "vdd_ldo11";
41+
regulator-min-microvolt = <1900000>;
42+
regulator-max-microvolt = <1900000>;
43+
regulator-always-on;
44+
};
45+
46+
buck1_reg: BUCK1 {
47+
regulator-name = "vdd_mif";
48+
regulator-min-microvolt = <950000>;
49+
regulator-max-microvolt = <1300000>;
50+
regulator-always-on;
51+
regulator-boot-on;
52+
};
53+
};

‎drivers/regulator/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,15 @@ config REGULATOR_MAX77693
405405
and one current regulator 'CHARGER'. This is suitable for
406406
Exynos-4x12 chips.
407407

408+
config REGULATOR_MAX77802
409+
tristate "Maxim 77802 regulator"
410+
depends on MFD_MAX77686
411+
help
412+
This driver controls a Maxim 77802 regulator
413+
via I2C bus. The provided regulator is suitable for
414+
Exynos5420/Exynos5800 SoCs to control various voltages.
415+
It includes support for control of voltage and ramp speed.
416+
408417
config REGULATOR_MC13XXX_CORE
409418
tristate
410419

‎drivers/regulator/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o
5454
obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
5555
obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o
5656
obj-$(CONFIG_REGULATOR_MAX77693) += max77693.o
57+
obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o
5758
obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
5859
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
5960
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o

‎drivers/regulator/internal.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@ struct regulator {
3535
struct dentry *debugfs;
3636
};
3737

38+
#ifdef CONFIG_OF
3839
struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
3940
const struct regulator_desc *desc,
4041
struct device_node **node);
42+
#else
43+
static inline struct regulator_init_data *
44+
regulator_of_get_init_data(struct device *dev,
45+
const struct regulator_desc *desc,
46+
struct device_node **node)
47+
{
48+
return NULL;
49+
}
50+
#endif
4151

4252
#endif

‎drivers/regulator/max1586.c‎

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <linux/regulator/driver.h>
2525
#include <linux/slab.h>
2626
#include <linux/regulator/max1586.h>
27+
#include <linux/of_device.h>
28+
#include <linux/regulator/of_regulator.h>
2729

2830
#define MAX1586_V3_MAX_VSEL 31
2931
#define MAX1586_V6_MAX_VSEL 3
@@ -157,13 +159,87 @@ static struct regulator_desc max1586_reg[] = {
157159
},
158160
};
159161

162+
static int of_get_max1586_platform_data(struct device *dev,
163+
struct max1586_platform_data *pdata)
164+
{
165+
struct max1586_subdev_data *sub;
166+
struct of_regulator_match rmatch[ARRAY_SIZE(max1586_reg)];
167+
struct device_node *np = dev->of_node;
168+
int i, matched;
169+
170+
if (of_property_read_u32(np, "v3-gain",
171+
&pdata->v3_gain) < 0) {
172+
dev_err(dev, "%s has no 'v3-gain' property\n", np->full_name);
173+
return -EINVAL;
174+
}
175+
176+
np = of_get_child_by_name(np, "regulators");
177+
if (!np) {
178+
dev_err(dev, "missing 'regulators' subnode in DT\n");
179+
return -EINVAL;
180+
}
181+
182+
for (i = 0; i < ARRAY_SIZE(rmatch); i++)
183+
rmatch[i].name = max1586_reg[i].name;
184+
185+
matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch));
186+
of_node_put(np);
187+
/*
188+
* If matched is 0, ie. neither Output_V3 nor Output_V6 have been found,
189+
* return 0, which signals the normal situation where no subregulator is
190+
* available. This is normal because the max1586 doesn't provide any
191+
* readback support, so the subregulators can't report any status
192+
* anyway. If matched < 0, return the error.
193+
*/
194+
if (matched <= 0)
195+
return matched;
196+
197+
pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) *
198+
matched, GFP_KERNEL);
199+
if (!pdata->subdevs)
200+
return -ENOMEM;
201+
202+
pdata->num_subdevs = matched;
203+
sub = pdata->subdevs;
204+
205+
for (i = 0; i < matched; i++) {
206+
sub->id = i;
207+
sub->name = rmatch[i].of_node->name;
208+
sub->platform_data = rmatch[i].init_data;
209+
sub++;
210+
}
211+
212+
return 0;
213+
}
214+
215+
static const struct of_device_id max1586_of_match[] = {
216+
{ .compatible = "maxim,max1586", },
217+
{},
218+
};
219+
MODULE_DEVICE_TABLE(of, max1586_of_match);
220+
160221
static int max1586_pmic_probe(struct i2c_client *client,
161222
const struct i2c_device_id *i2c_id)
162223
{
163-
struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
224+
struct max1586_platform_data *pdata, pdata_of;
164225
struct regulator_config config = { };
165226
struct max1586_data *max1586;
166-
int i, id;
227+
int i, id, ret;
228+
const struct of_device_id *match;
229+
230+
pdata = dev_get_platdata(&client->dev);
231+
if (client->dev.of_node && !pdata) {
232+
match = of_match_device(of_match_ptr(max1586_of_match),
233+
&client->dev);
234+
if (!match) {
235+
dev_err(&client->dev, "Error: No device match found\n");
236+
return -ENODEV;
237+
}
238+
ret = of_get_max1586_platform_data(&client->dev, &pdata_of);
239+
if (ret < 0)
240+
return ret;
241+
pdata = &pdata_of;
242+
}
167243

168244
max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data),
169245
GFP_KERNEL);
@@ -229,6 +305,7 @@ static struct i2c_driver max1586_pmic_driver = {
229305
.driver = {
230306
.name = "max1586",
231307
.owner = THIS_MODULE,
308+
.of_match_table = of_match_ptr(max1586_of_match),
232309
},
233310
.id_table = max1586_id,
234311
};

0 commit comments

Comments
 (0)