Skip to content

Commit 178a097

Browse files
committed
Merge remote-tracking branch 'regulator/topic/s5m8767' into regulator-next
2 parents 7280888 + e81d7bc commit 178a097

4 files changed

Lines changed: 438 additions & 68 deletions

File tree

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
* Samsung S5M8767 Voltage and Current Regulator
2+
3+
The Samsung S5M8767 is a multi-function device which includes volatage and
4+
current regulators, rtc, charger controller and other sub-blocks. It is
5+
interfaced to the host controller using a i2c interface. Each sub-block is
6+
addressed by the host system using different i2c slave address. This document
7+
describes the bindings for 'pmic' sub-block of s5m8767.
8+
9+
Required properties:
10+
- compatible: Should be "samsung,s5m8767-pmic".
11+
- reg: Specifies the i2c slave address of the pmic block. It should be 0x66.
12+
13+
- s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
14+
units for buck2 when changing voltage using gpio dvs. Refer to [1] below
15+
for additional information.
16+
17+
- s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
18+
units for buck3 when changing voltage using gpio dvs. Refer to [1] below
19+
for additional information.
20+
21+
- s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
22+
units for buck4 when changing voltage using gpio dvs. Refer to [1] below
23+
for additional information.
24+
25+
- s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used
26+
for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines.
27+
28+
[1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional
29+
property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage'
30+
property should specify atleast one voltage level (which would be a
31+
safe operating voltage).
32+
33+
If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional
34+
property is specified, then all the eight voltage values for the
35+
's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified.
36+
37+
Optional properties:
38+
- interrupt-parent: Specifies the phandle of the interrupt controller to which
39+
the interrupts from s5m8767 are delivered to.
40+
- interrupts: Interrupt specifiers for two interrupt sources.
41+
- First interrupt specifier is for 'irq1' interrupt.
42+
- Second interrupt specifier is for 'alert' interrupt.
43+
- s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs.
44+
- s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs.
45+
- s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs.
46+
47+
Additional properties required if either of the optional properties are used:
48+
49+
- s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from
50+
the possible 8 options selectable by the dvs gpios. The value of this
51+
property should be between 0 and 7. If not specified or if out of range, the
52+
default value of this property is set to 0.
53+
54+
- s5m8767,pmic-buck-dvs-gpios: GPIO specifiers for three host gpio's used
55+
for dvs. The format of the gpio specifier depends in the gpio controller.
56+
57+
Regulators: The regulators of s5m8767 that have to be instantiated should be
58+
included in a sub-node named 'regulators'. Regulator nodes included in this
59+
sub-node should be of the format as listed below.
60+
61+
regulator_name {
62+
ldo1_reg: LDO1 {
63+
regulator-name = "VDD_ALIVE_1.0V";
64+
regulator-min-microvolt = <1100000>;
65+
regulator-max-microvolt = <1100000>;
66+
regulator-always-on;
67+
regulator-boot-on;
68+
op_mode = <1>; /* Normal Mode */
69+
};
70+
};
71+
The above regulator entries are defined in regulator bindings documentation
72+
except op_mode description.
73+
- op_mode: describes the different operating modes of the LDO's with
74+
power mode change in SOC. The different possible values are,
75+
0 - always off mode
76+
1 - on in normal mode
77+
2 - low power mode
78+
3 - suspend mode
79+
80+
The following are the names of the regulators that the s5m8767 pmic block
81+
supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number
82+
as per the datasheet of s5m8767.
83+
84+
- LDOn
85+
- valid values for n are 1 to 28
86+
- Example: LDO0, LD01, LDO28
87+
- BUCKn
88+
- valid values for n are 1 to 9.
89+
- Example: BUCK1, BUCK2, BUCK9
90+
91+
The bindings inside the regulator nodes use the standard regulator bindings
92+
which are documented elsewhere.
93+
94+
Example:
95+
96+
s5m8767_pmic@66 {
97+
compatible = "samsung,s5m8767-pmic";
98+
reg = <0x66>;
99+
100+
s5m8767,pmic-buck2-uses-gpio-dvs;
101+
s5m8767,pmic-buck3-uses-gpio-dvs;
102+
s5m8767,pmic-buck4-uses-gpio-dvs;
103+
104+
s5m8767,pmic-buck-default-dvs-idx = <0>;
105+
106+
s5m8767,pmic-buck-dvs-gpios = <&gpx0 0 1 0 0>, /* DVS1 */
107+
<&gpx0 1 1 0 0>, /* DVS2 */
108+
<&gpx0 2 1 0 0>; /* DVS3 */
109+
110+
s5m8767,pmic-buck-ds-gpios = <&gpx2 3 1 0 0>, /* SET1 */
111+
<&gpx2 4 1 0 0>, /* SET2 */
112+
<&gpx2 5 1 0 0>; /* SET3 */
113+
114+
s5m8767,pmic-buck2-dvs-voltage = <1350000>, <1300000>,
115+
<1250000>, <1200000>,
116+
<1150000>, <1100000>,
117+
<1000000>, <950000>;
118+
119+
s5m8767,pmic-buck3-dvs-voltage = <1100000>, <1100000>,
120+
<1100000>, <1100000>,
121+
<1000000>, <1000000>,
122+
<1000000>, <1000000>;
123+
124+
s5m8767,pmic-buck4-dvs-voltage = <1200000>, <1200000>,
125+
<1200000>, <1200000>,
126+
<1200000>, <1200000>,
127+
<1200000>, <1200000>;
128+
129+
regulators {
130+
ldo1_reg: LDO1 {
131+
regulator-name = "VDD_ABB_3.3V";
132+
regulator-min-microvolt = <3300000>;
133+
regulator-max-microvolt = <3300000>;
134+
op_mode = <1>; /* Normal Mode */
135+
};
136+
137+
ldo2_reg: LDO2 {
138+
regulator-name = "VDD_ALIVE_1.1V";
139+
regulator-min-microvolt = <1100000>;
140+
regulator-max-microvolt = <1100000>;
141+
regulator-always-on;
142+
};
143+
144+
buck1_reg: BUCK1 {
145+
regulator-name = "VDD_MIF_1.2V";
146+
regulator-min-microvolt = <950000>;
147+
regulator-max-microvolt = <1350000>;
148+
regulator-always-on;
149+
regulator-boot-on;
150+
};
151+
};
152+
};

‎drivers/mfd/sec-core.c‎

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/err.h>
1818
#include <linux/slab.h>
1919
#include <linux/i2c.h>
20+
#include <linux/of_irq.h>
2021
#include <linux/interrupt.h>
2122
#include <linux/pm_runtime.h>
2223
#include <linux/mutex.h>
@@ -60,6 +61,15 @@ static struct mfd_cell s2mps11_devs[] = {
6061
},
6162
};
6263

64+
#ifdef CONFIG_OF
65+
static struct of_device_id sec_dt_match[] = {
66+
{ .compatible = "samsung,s5m8767-pmic",
67+
.data = (void *)S5M8767X,
68+
},
69+
{},
70+
};
71+
#endif
72+
6373
int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest)
6474
{
6575
return regmap_read(sec_pmic->regmap, reg, dest);
@@ -95,6 +105,57 @@ static struct regmap_config sec_regmap_config = {
95105
.val_bits = 8,
96106
};
97107

108+
109+
#ifdef CONFIG_OF
110+
/*
111+
* Only the common platform data elements for s5m8767 are parsed here from the
112+
* device tree. Other sub-modules of s5m8767 such as pmic, rtc , charger and
113+
* others have to parse their own platform data elements from device tree.
114+
*
115+
* The s5m8767 platform data structure is instantiated here and the drivers for
116+
* the sub-modules need not instantiate another instance while parsing their
117+
* platform data.
118+
*/
119+
static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata(
120+
struct device *dev)
121+
{
122+
struct sec_platform_data *pd;
123+
124+
pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
125+
if (!pd) {
126+
dev_err(dev, "could not allocate memory for pdata\n");
127+
return ERR_PTR(-ENOMEM);
128+
}
129+
130+
/*
131+
* ToDo: the 'wakeup' member in the platform data is more of a linux
132+
* specfic information. Hence, there is no binding for that yet and
133+
* not parsed here.
134+
*/
135+
136+
return pd;
137+
}
138+
#else
139+
static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata(
140+
struct device *dev)
141+
{
142+
return 0;
143+
}
144+
#endif
145+
146+
static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
147+
const struct i2c_device_id *id)
148+
{
149+
#ifdef CONFIG_OF
150+
if (i2c->dev.of_node) {
151+
const struct of_device_id *match;
152+
match = of_match_node(sec_dt_match, i2c->dev.of_node);
153+
return (int)match->data;
154+
}
155+
#endif
156+
return (int)id->driver_data;
157+
}
158+
98159
static int sec_pmic_probe(struct i2c_client *i2c,
99160
const struct i2c_device_id *id)
100161
{
@@ -111,13 +172,22 @@ static int sec_pmic_probe(struct i2c_client *i2c,
111172
sec_pmic->dev = &i2c->dev;
112173
sec_pmic->i2c = i2c;
113174
sec_pmic->irq = i2c->irq;
114-
sec_pmic->type = id->driver_data;
115-
175+
sec_pmic->type = sec_i2c_get_driver_data(i2c, id);
176+
177+
if (sec_pmic->dev->of_node) {
178+
pdata = sec_pmic_i2c_parse_dt_pdata(sec_pmic->dev);
179+
if (IS_ERR(pdata)) {
180+
ret = PTR_ERR(pdata);
181+
return ret;
182+
}
183+
pdata->device_type = sec_pmic->type;
184+
}
116185
if (pdata) {
117186
sec_pmic->device_type = pdata->device_type;
118187
sec_pmic->ono = pdata->ono;
119188
sec_pmic->irq_base = pdata->irq_base;
120189
sec_pmic->wakeup = pdata->wakeup;
190+
sec_pmic->pdata = pdata;
121191
}
122192

123193
sec_pmic->regmap = devm_regmap_init_i2c(i2c, &sec_regmap_config);
@@ -192,6 +262,7 @@ static struct i2c_driver sec_pmic_driver = {
192262
.driver = {
193263
.name = "sec_pmic",
194264
.owner = THIS_MODULE,
265+
.of_match_table = of_match_ptr(sec_dt_match),
195266
},
196267
.probe = sec_pmic_probe,
197268
.remove = sec_pmic_remove,

0 commit comments

Comments
 (0)