Skip to content

Commit c1516f8

Browse files
Yadwinder Singh BrarSamuel Ortiz
authored andcommitted
mfd: Add device tree support for max77686
This patch adds device tree support for mfd driver and adds Documentation/devicetree/bindings/mfd/max77686.txt. This patch also intialize max77686 pointer to NULL in max77686_i2c_probe to silent a compile time warning. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 2b40459 commit c1516f8

2 files changed

Lines changed: 98 additions & 6 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Maxim MAX77686 multi-function device
2+
3+
MAX77686 is a Mulitifunction device with PMIC, RTC and Charger on chip. It is
4+
interfaced to host controller using i2c interface. PMIC and Charger submodules
5+
are addressed using same i2c slave address whereas RTC submodule uses
6+
different i2c slave address,presently for which we are statically creating i2c
7+
client while probing.This document describes the binding for mfd device and
8+
PMIC submodule.
9+
10+
Required properties:
11+
- compatible : Must be "maxim,max77686";
12+
- reg : Specifies the i2c slave address of PMIC block.
13+
- interrupts : This i2c device has an IRQ line connected to the main SoC.
14+
- interrupt-parent : The parent interrupt controller.
15+
16+
Optional node:
17+
- voltage-regulators : The regulators of max77686 have to be instantiated
18+
under subnode named "voltage-regulators" using the following format.
19+
20+
regulator_name {
21+
regulator-compatible = LDOn/BUCKn
22+
standard regulator constraints....
23+
};
24+
refer Documentation/devicetree/bindings/regulator/regulator.txt
25+
26+
The regulator-compatible property of regulator should initialized with string
27+
to get matched with their hardware counterparts as follow:
28+
29+
-LDOn : for LDOs, where n can lie in range 1 to 26.
30+
example: LDO1, LDO2, LDO26.
31+
-BUCKn : for BUCKs, where n can lie in range 1 to 9.
32+
example: BUCK1, BUCK5, BUCK9.
33+
34+
Example:
35+
36+
max77686@09 {
37+
compatible = "maxim,max77686";
38+
interrupt-parent = <&wakeup_eint>;
39+
interrupts = <26 0>;
40+
reg = <0x09>;
41+
42+
voltage-regulators {
43+
ldo11_reg {
44+
regulator-compatible = "LDO11";
45+
regulator-name = "vdd_ldo11";
46+
regulator-min-microvolt = <1900000>;
47+
regulator-max-microvolt = <1900000>;
48+
regulator-always-on;
49+
};
50+
51+
buck1_reg {
52+
regulator-compatible = "BUCK1";
53+
regulator-name = "vdd_mif";
54+
regulator-min-microvolt = <950000>;
55+
regulator-max-microvolt = <1300000>;
56+
regulator-always-on;
57+
regulator-boot-on;
58+
};
59+
}

‎drivers/mfd/max77686.c‎

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#define I2C_ADDR_RTC (0x0C >> 1)
3636

37+
static struct of_device_id __devinitdata max77686_pmic_dt_match[] = {
38+
{.compatible = "maxim,max77686", .data = 0},
39+
{},
40+
};
41+
3742
static struct mfd_cell max77686_devs[] = {
3843
{ .name = "max77686-pmic", },
3944
{ .name = "max77686-rtc", },
@@ -44,14 +49,46 @@ static struct regmap_config max77686_regmap_config = {
4449
.val_bits = 8,
4550
};
4651

52+
#ifdef CONFIG_OF
53+
static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
54+
*dev)
55+
{
56+
struct max77686_platform_data *pd;
57+
58+
pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
59+
if (!pd) {
60+
dev_err(dev, "could not allocate memory for pdata\n");
61+
return NULL;
62+
}
63+
64+
dev->platform_data = pd;
65+
return pd;
66+
}
67+
#else
68+
static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
69+
*dev)
70+
{
71+
return 0;
72+
}
73+
#endif
74+
4775
static int max77686_i2c_probe(struct i2c_client *i2c,
4876
const struct i2c_device_id *id)
4977
{
50-
struct max77686_dev *max77686;
78+
struct max77686_dev *max77686 = NULL;
5179
struct max77686_platform_data *pdata = i2c->dev.platform_data;
5280
unsigned int data;
5381
int ret = 0;
5482

83+
if (i2c->dev.of_node)
84+
pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
85+
86+
if (!pdata) {
87+
ret = -EIO;
88+
dev_err(&i2c->dev, "No platform data found.\n");
89+
goto err;
90+
}
91+
5592
max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL);
5693
if (max77686 == NULL)
5794
return -ENOMEM;
@@ -70,11 +107,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
70107
max77686->i2c = i2c;
71108
max77686->type = id->driver_data;
72109

73-
if (!pdata) {
74-
ret = -EIO;
75-
goto err;
76-
}
77-
78110
max77686->wakeup = pdata->wakeup;
79111
max77686->irq_gpio = pdata->irq_gpio;
80112
max77686->irq = i2c->irq;
@@ -130,6 +162,7 @@ static struct i2c_driver max77686_i2c_driver = {
130162
.driver = {
131163
.name = "max77686",
132164
.owner = THIS_MODULE,
165+
.of_match_table = of_match_ptr(max77686_pmic_dt_match),
133166
},
134167
.probe = max77686_i2c_probe,
135168
.remove = max77686_i2c_remove,

0 commit comments

Comments
 (0)