Skip to content

Commit 5949a7e

Browse files
committed
Merge remote-tracking branch 'regulator/topic/drivers' into regulator-next
Conflicts: drivers/regulator/88pm8607.c (simple overlap with a bugfix in v3.4)
2 parents 178e43a + 411a2df commit 5949a7e

33 files changed

Lines changed: 559 additions & 304 deletions

‎Documentation/devicetree/bindings/regulator/fixed-regulator.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Optional properties:
88
- startup-delay-us: startup time in microseconds
99
- enable-active-high: Polarity of GPIO is Active high
1010
If this property is missing, the default assumed is Active low.
11+
- gpio-open-drain: GPIO is open drain type.
12+
If this property is missing then default assumption is false.
1113

1214
Any property defined as part of the core regulator
1315
binding, defined in regulator.txt, can also be used.
@@ -25,5 +27,6 @@ Example:
2527
gpio = <&gpio1 16 0>;
2628
startup-delay-us = <70000>;
2729
enable-active-high;
28-
regulator-boot-on
30+
regulator-boot-on;
31+
gpio-open-drain;
2932
};
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
TPS6586x family of regulators
2+
3+
Required properties:
4+
- compatible: "ti,tps6586x"
5+
- reg: I2C slave address
6+
- interrupts: the interrupt outputs of the controller
7+
- #gpio-cells: number of cells to describe a GPIO
8+
- gpio-controller: mark the device as a GPIO controller
9+
- regulators: list of regulators provided by this controller, must be named
10+
after their hardware counterparts: sm[0-2], ldo[0-9] and ldo_rtc
11+
12+
Each regulator is defined using the standard binding for regulators.
13+
14+
Example:
15+
16+
pmu: tps6586x@34 {
17+
compatible = "ti,tps6586x";
18+
reg = <0x34>;
19+
interrupts = <0 88 0x4>;
20+
21+
#gpio-cells = <2>;
22+
gpio-controller;
23+
24+
regulators {
25+
sm0_reg: sm0 {
26+
regulator-min-microvolt = < 725000>;
27+
regulator-max-microvolt = <1500000>;
28+
regulator-boot-on;
29+
regulator-always-on;
30+
};
31+
32+
sm1_reg: sm1 {
33+
regulator-min-microvolt = < 725000>;
34+
regulator-max-microvolt = <1500000>;
35+
regulator-boot-on;
36+
regulator-always-on;
37+
};
38+
39+
sm2_reg: sm2 {
40+
regulator-min-microvolt = <3000000>;
41+
regulator-max-microvolt = <4550000>;
42+
regulator-boot-on;
43+
regulator-always-on;
44+
};
45+
46+
ldo0_reg: ldo0 {
47+
regulator-name = "PCIE CLK";
48+
regulator-min-microvolt = <3300000>;
49+
regulator-max-microvolt = <3300000>;
50+
};
51+
52+
ldo1_reg: ldo1 {
53+
regulator-min-microvolt = < 725000>;
54+
regulator-max-microvolt = <1500000>;
55+
};
56+
57+
ldo2_reg: ldo2 {
58+
regulator-min-microvolt = < 725000>;
59+
regulator-max-microvolt = <1500000>;
60+
};
61+
62+
ldo3_reg: ldo3 {
63+
regulator-min-microvolt = <1250000>;
64+
regulator-max-microvolt = <3300000>;
65+
};
66+
67+
ldo4_reg: ldo4 {
68+
regulator-min-microvolt = <1700000>;
69+
regulator-max-microvolt = <2475000>;
70+
};
71+
72+
ldo5_reg: ldo5 {
73+
regulator-min-microvolt = <1250000>;
74+
regulator-max-microvolt = <3300000>;
75+
};
76+
77+
ldo6_reg: ldo6 {
78+
regulator-min-microvolt = <1250000>;
79+
regulator-max-microvolt = <3300000>;
80+
};
81+
82+
ldo7_reg: ldo7 {
83+
regulator-min-microvolt = <1250000>;
84+
regulator-max-microvolt = <3300000>;
85+
};
86+
87+
ldo8_reg: ldo8 {
88+
regulator-min-microvolt = <1250000>;
89+
regulator-max-microvolt = <3300000>;
90+
};
91+
92+
ldo9_reg: ldo9 {
93+
regulator-min-microvolt = <1250000>;
94+
regulator-max-microvolt = <3300000>;
95+
};
96+
};
97+
};

‎drivers/mfd/tps6586x.c‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/slab.h>
2424
#include <linux/gpio.h>
2525
#include <linux/i2c.h>
26+
#include <linux/regulator/of_regulator.h>
2627

2728
#include <linux/mfd/core.h>
2829
#include <linux/mfd/tps6586x.h>
@@ -460,6 +461,7 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x,
460461

461462
pdev->dev.parent = tps6586x->dev;
462463
pdev->dev.platform_data = subdev->platform_data;
464+
pdev->dev.of_node = subdev->of_node;
463465

464466
ret = platform_device_add(pdev);
465467
if (ret) {
@@ -474,13 +476,96 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x,
474476
return ret;
475477
}
476478

479+
#ifdef CONFIG_OF
480+
static struct of_regulator_match tps6586x_matches[] = {
481+
{ .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 },
482+
{ .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 },
483+
{ .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 },
484+
{ .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 },
485+
{ .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 },
486+
{ .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 },
487+
{ .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 },
488+
{ .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 },
489+
{ .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 },
490+
{ .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 },
491+
{ .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 },
492+
{ .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 },
493+
{ .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 },
494+
{ .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC },
495+
};
496+
497+
static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
498+
{
499+
const unsigned int num = ARRAY_SIZE(tps6586x_matches);
500+
struct device_node *np = client->dev.of_node;
501+
struct tps6586x_platform_data *pdata;
502+
struct tps6586x_subdev_info *devs;
503+
struct device_node *regs;
504+
unsigned int count;
505+
unsigned int i, j;
506+
int err;
507+
508+
regs = of_find_node_by_name(np, "regulators");
509+
if (!regs)
510+
return NULL;
511+
512+
err = of_regulator_match(&client->dev, regs, tps6586x_matches, num);
513+
if (err < 0) {
514+
of_node_put(regs);
515+
return NULL;
516+
}
517+
518+
of_node_put(regs);
519+
count = err;
520+
521+
devs = devm_kzalloc(&client->dev, count * sizeof(*devs), GFP_KERNEL);
522+
if (!devs)
523+
return NULL;
524+
525+
for (i = 0, j = 0; i < num && j < count; i++) {
526+
if (!tps6586x_matches[i].init_data)
527+
continue;
528+
529+
devs[j].name = "tps6586x-regulator";
530+
devs[j].platform_data = tps6586x_matches[i].init_data;
531+
devs[j].id = (int)tps6586x_matches[i].driver_data;
532+
devs[j].of_node = tps6586x_matches[i].of_node;
533+
j++;
534+
}
535+
536+
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
537+
if (!pdata)
538+
return NULL;
539+
540+
pdata->num_subdevs = count;
541+
pdata->subdevs = devs;
542+
pdata->gpio_base = -1;
543+
pdata->irq_base = -1;
544+
545+
return pdata;
546+
}
547+
548+
static struct of_device_id tps6586x_of_match[] = {
549+
{ .compatible = "ti,tps6586x", },
550+
{ },
551+
};
552+
#else
553+
static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
554+
{
555+
return NULL;
556+
}
557+
#endif
558+
477559
static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
478560
const struct i2c_device_id *id)
479561
{
480562
struct tps6586x_platform_data *pdata = client->dev.platform_data;
481563
struct tps6586x *tps6586x;
482564
int ret;
483565

566+
if (!pdata && client->dev.of_node)
567+
pdata = tps6586x_parse_dt(client);
568+
484569
if (!pdata) {
485570
dev_err(&client->dev, "tps6586x requires platform data\n");
486571
return -ENOTSUPP;
@@ -573,6 +658,7 @@ static struct i2c_driver tps6586x_driver = {
573658
.driver = {
574659
.name = "tps6586x",
575660
.owner = THIS_MODULE,
661+
.of_match_table = of_match_ptr(tps6586x_of_match),
576662
},
577663
.probe = tps6586x_i2c_probe,
578664
.remove = __devexit_p(tps6586x_i2c_remove),

‎drivers/mfd/twl-core.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,6 @@
224224
#define HIGH_PERF_SQ (1 << 3)
225225
#define CK32K_LOWPWR_EN (1 << 7)
226226

227-
228-
/* chip-specific feature flags, for i2c_device_id.driver_data */
229-
#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
230-
#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
231-
#define TWL5031 BIT(2) /* twl5031 has different registers */
232-
#define TWL6030_CLASS BIT(3) /* TWL6030 class */
233-
234227
/*----------------------------------------------------------------------*/
235228

236229
/* is driver active, bound to a chip? */

‎drivers/regulator/aat2870-regulator.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <linux/err.h>
2525
#include <linux/module.h>
2626
#include <linux/slab.h>
27-
#include <linux/delay.h>
2827
#include <linux/platform_device.h>
2928
#include <linux/regulator/driver.h>
3029
#include <linux/regulator/machine.h>

‎drivers/regulator/ab3100.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/kernel.h>
1414
#include <linux/init.h>
1515
#include <linux/err.h>
16-
#include <linux/delay.h>
1716
#include <linux/platform_device.h>
1817
#include <linux/regulator/driver.h>
1918
#include <linux/mfd/abx500.h>

‎drivers/regulator/da9052-regulator.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/regulator/driver.h>
2121
#include <linux/regulator/machine.h>
2222
#ifdef CONFIG_OF
23+
#include <linux/of.h>
2324
#include <linux/regulator/of_regulator.h>
2425
#endif
2526

@@ -393,7 +394,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
393394
if (!nproot)
394395
return -ENODEV;
395396

396-
for (np = of_get_next_child(nproot, NULL); !np;
397+
for (np = of_get_next_child(nproot, NULL); np;
397398
np = of_get_next_child(nproot, np)) {
398399
if (!of_node_cmp(np->name,
399400
regulator->info->reg_desc.name)) {

‎drivers/regulator/fixed.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/regulator/driver.h>
2626
#include <linux/regulator/fixed.h>
2727
#include <linux/gpio.h>
28-
#include <linux/delay.h>
2928
#include <linux/slab.h>
3029
#include <linux/of.h>
3130
#include <linux/of_gpio.h>
@@ -91,6 +90,9 @@ of_get_fixed_voltage_config(struct device *dev)
9190
if (of_find_property(np, "enable-active-high", NULL))
9291
config->enable_high = true;
9392

93+
if (of_find_property(np, "gpio-open-drain", NULL))
94+
config->gpio_is_open_drain = true;
95+
9496
return config;
9597
}
9698

‎drivers/regulator/gpio-regulator.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <linux/regulator/machine.h>
3131
#include <linux/regulator/gpio-regulator.h>
3232
#include <linux/gpio.h>
33-
#include <linux/delay.h>
3433
#include <linux/slab.h>
3534

3635
struct gpio_regulator_data {

‎drivers/regulator/isl6271a-regulator.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/platform_device.h>
2323
#include <linux/regulator/driver.h>
2424
#include <linux/i2c.h>
25-
#include <linux/delay.h>
2625
#include <linux/slab.h>
2726

2827
#define ISL6271A_VOLTAGE_MIN 850000

0 commit comments

Comments
 (0)