Skip to content

Commit 76b9840

Browse files
chanwoochoiLee Jones
authored and
Lee Jones
committed
regulator: s2mps11: Add support S2MPS13 regulator device
This patch adds S2MPS13 regulator device to existing S2MPS11 device driver. The S2MPS13 has just different number of regulators from S2MPS14. The S2MPS13 regulator device includes LDO[1-40] and BUCK[1-10]. Signed-off-by: Chanwoo Choi <[email protected]> Acked-by: Sangbeom Kim <[email protected]> Acked-by: Mark Brown <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 3bc2ee9 commit 76b9840

File tree

5 files changed

+304
-8
lines changed

5 files changed

+304
-8
lines changed

drivers/mfd/sec-core.c

+13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/mfd/samsung/irq.h>
2828
#include <linux/mfd/samsung/s2mpa01.h>
2929
#include <linux/mfd/samsung/s2mps11.h>
30+
#include <linux/mfd/samsung/s2mps13.h>
3031
#include <linux/mfd/samsung/s2mps14.h>
3132
#include <linux/mfd/samsung/s2mpu02.h>
3233
#include <linux/mfd/samsung/s5m8763.h>
@@ -206,6 +207,15 @@ static const struct regmap_config s2mps11_regmap_config = {
206207
.cache_type = REGCACHE_FLAT,
207208
};
208209

210+
static const struct regmap_config s2mps13_regmap_config = {
211+
.reg_bits = 8,
212+
.val_bits = 8,
213+
214+
.max_register = S2MPS13_REG_LDODSCH5,
215+
.volatile_reg = s2mps11_volatile,
216+
.cache_type = REGCACHE_FLAT,
217+
};
218+
209219
static const struct regmap_config s2mps14_regmap_config = {
210220
.reg_bits = 8,
211221
.val_bits = 8,
@@ -337,6 +347,9 @@ static int sec_pmic_probe(struct i2c_client *i2c,
337347
case S2MPS11X:
338348
regmap = &s2mps11_regmap_config;
339349
break;
350+
case S2MPS13X:
351+
regmap = &s2mps13_regmap_config;
352+
break;
340353
case S2MPS14X:
341354
regmap = &s2mps14_regmap_config;
342355
break;

drivers/regulator/Kconfig

+5-5
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,13 @@ config REGULATOR_S2MPA01
529529
via I2C bus. S2MPA01 has 10 Bucks and 26 LDO outputs.
530530

531531
config REGULATOR_S2MPS11
532-
tristate "Samsung S2MPS11/S2MPS14/S2MPU02 voltage regulator"
532+
tristate "Samsung S2MPS11/S2MPS13/S2MPS14/S2MPU02 voltage regulator"
533533
depends on MFD_SEC_CORE
534534
help
535-
This driver supports a Samsung S2MPS11/S2MPS14/S2MPU02 voltage output
536-
regulator via I2C bus. The chip is comprised of high efficient Buck
537-
converters including Dual-Phase Buck converter, Buck-Boost converter,
538-
various LDOs.
535+
This driver supports a Samsung S2MPS11/S2MPS13/S2MPS14/S2MPU02 voltage
536+
output regulator via I2C bus. The chip is comprised of high efficient
537+
Buck converters including Dual-Phase Buck converter, Buck-Boost
538+
converter, various LDOs.
539539

540540
config REGULATOR_S5M8767
541541
tristate "Samsung S5M8767A voltage regulator"

drivers/regulator/s2mps11.c

+99-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/of_gpio.h>
3131
#include <linux/mfd/samsung/core.h>
3232
#include <linux/mfd/samsung/s2mps11.h>
33+
#include <linux/mfd/samsung/s2mps13.h>
3334
#include <linux/mfd/samsung/s2mps14.h>
3435
#include <linux/mfd/samsung/s2mpu02.h>
3536

@@ -45,10 +46,10 @@ struct s2mps11_info {
4546
enum sec_device_type dev_type;
4647

4748
/*
48-
* One bit for each S2MPS14/S2MPU02 regulator whether the suspend mode
49-
* was enabled.
49+
* One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether
50+
* the suspend mode was enabled.
5051
*/
51-
unsigned long long s2mps14_suspend_state:35;
52+
unsigned long long s2mps14_suspend_state:50;
5253

5354
/* Array of size rdev_num with GPIO-s for external sleep control */
5455
int *ext_control_gpio;
@@ -369,12 +370,101 @@ static const struct regulator_desc s2mps11_regulators[] = {
369370
regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV),
370371
};
371372

373+
static struct regulator_ops s2mps14_reg_ops;
374+
375+
#define regulator_desc_s2mps13_ldo(num, min, step, min_sel) { \
376+
.name = "LDO"#num, \
377+
.id = S2MPS13_LDO##num, \
378+
.ops = &s2mps14_reg_ops, \
379+
.type = REGULATOR_VOLTAGE, \
380+
.owner = THIS_MODULE, \
381+
.min_uV = min, \
382+
.uV_step = step, \
383+
.linear_min_sel = min_sel, \
384+
.n_voltages = S2MPS14_LDO_N_VOLTAGES, \
385+
.vsel_reg = S2MPS13_REG_L1CTRL + num - 1, \
386+
.vsel_mask = S2MPS14_LDO_VSEL_MASK, \
387+
.enable_reg = S2MPS13_REG_L1CTRL + num - 1, \
388+
.enable_mask = S2MPS14_ENABLE_MASK \
389+
}
390+
391+
#define regulator_desc_s2mps13_buck(num, min, step, min_sel) { \
392+
.name = "BUCK"#num, \
393+
.id = S2MPS13_BUCK##num, \
394+
.ops = &s2mps14_reg_ops, \
395+
.type = REGULATOR_VOLTAGE, \
396+
.owner = THIS_MODULE, \
397+
.min_uV = min, \
398+
.uV_step = step, \
399+
.linear_min_sel = min_sel, \
400+
.n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
401+
.ramp_delay = S2MPS13_BUCK_RAMP_DELAY, \
402+
.vsel_reg = S2MPS13_REG_B1OUT + (num - 1) * 2, \
403+
.vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
404+
.enable_reg = S2MPS13_REG_B1CTRL + (num - 1) * 2, \
405+
.enable_mask = S2MPS14_ENABLE_MASK \
406+
}
407+
408+
static const struct regulator_desc s2mps13_regulators[] = {
409+
regulator_desc_s2mps13_ldo(1, MIN_800_MV, STEP_12_5_MV, 0x00),
410+
regulator_desc_s2mps13_ldo(2, MIN_1400_MV, STEP_50_MV, 0x0C),
411+
regulator_desc_s2mps13_ldo(3, MIN_1000_MV, STEP_25_MV, 0x08),
412+
regulator_desc_s2mps13_ldo(4, MIN_800_MV, STEP_12_5_MV, 0x00),
413+
regulator_desc_s2mps13_ldo(5, MIN_800_MV, STEP_12_5_MV, 0x00),
414+
regulator_desc_s2mps13_ldo(6, MIN_800_MV, STEP_12_5_MV, 0x00),
415+
regulator_desc_s2mps13_ldo(7, MIN_1000_MV, STEP_25_MV, 0x08),
416+
regulator_desc_s2mps13_ldo(8, MIN_1000_MV, STEP_25_MV, 0x08),
417+
regulator_desc_s2mps13_ldo(9, MIN_1000_MV, STEP_25_MV, 0x08),
418+
regulator_desc_s2mps13_ldo(10, MIN_1400_MV, STEP_50_MV, 0x0C),
419+
regulator_desc_s2mps13_ldo(11, MIN_800_MV, STEP_25_MV, 0x10),
420+
regulator_desc_s2mps13_ldo(12, MIN_800_MV, STEP_25_MV, 0x10),
421+
regulator_desc_s2mps13_ldo(13, MIN_800_MV, STEP_25_MV, 0x10),
422+
regulator_desc_s2mps13_ldo(14, MIN_800_MV, STEP_12_5_MV, 0x00),
423+
regulator_desc_s2mps13_ldo(15, MIN_800_MV, STEP_12_5_MV, 0x00),
424+
regulator_desc_s2mps13_ldo(16, MIN_1400_MV, STEP_50_MV, 0x0C),
425+
regulator_desc_s2mps13_ldo(17, MIN_1400_MV, STEP_50_MV, 0x0C),
426+
regulator_desc_s2mps13_ldo(18, MIN_1000_MV, STEP_25_MV, 0x08),
427+
regulator_desc_s2mps13_ldo(19, MIN_1000_MV, STEP_25_MV, 0x08),
428+
regulator_desc_s2mps13_ldo(20, MIN_1400_MV, STEP_50_MV, 0x0C),
429+
regulator_desc_s2mps13_ldo(21, MIN_1000_MV, STEP_25_MV, 0x08),
430+
regulator_desc_s2mps13_ldo(22, MIN_1000_MV, STEP_25_MV, 0x08),
431+
regulator_desc_s2mps13_ldo(23, MIN_800_MV, STEP_12_5_MV, 0x00),
432+
regulator_desc_s2mps13_ldo(24, MIN_800_MV, STEP_12_5_MV, 0x00),
433+
regulator_desc_s2mps13_ldo(25, MIN_1400_MV, STEP_50_MV, 0x0C),
434+
regulator_desc_s2mps13_ldo(26, MIN_1400_MV, STEP_50_MV, 0x0C),
435+
regulator_desc_s2mps13_ldo(27, MIN_1400_MV, STEP_50_MV, 0x0C),
436+
regulator_desc_s2mps13_ldo(28, MIN_1000_MV, STEP_25_MV, 0x08),
437+
regulator_desc_s2mps13_ldo(29, MIN_1400_MV, STEP_50_MV, 0x0C),
438+
regulator_desc_s2mps13_ldo(30, MIN_1400_MV, STEP_50_MV, 0x0C),
439+
regulator_desc_s2mps13_ldo(31, MIN_1000_MV, STEP_25_MV, 0x08),
440+
regulator_desc_s2mps13_ldo(32, MIN_1000_MV, STEP_25_MV, 0x08),
441+
regulator_desc_s2mps13_ldo(33, MIN_1400_MV, STEP_50_MV, 0x0C),
442+
regulator_desc_s2mps13_ldo(34, MIN_1000_MV, STEP_25_MV, 0x08),
443+
regulator_desc_s2mps13_ldo(35, MIN_1400_MV, STEP_50_MV, 0x0C),
444+
regulator_desc_s2mps13_ldo(36, MIN_800_MV, STEP_12_5_MV, 0x00),
445+
regulator_desc_s2mps13_ldo(37, MIN_1000_MV, STEP_25_MV, 0x08),
446+
regulator_desc_s2mps13_ldo(38, MIN_1400_MV, STEP_50_MV, 0x0C),
447+
regulator_desc_s2mps13_ldo(39, MIN_1000_MV, STEP_25_MV, 0x08),
448+
regulator_desc_s2mps13_ldo(40, MIN_1400_MV, STEP_50_MV, 0x0C),
449+
regulator_desc_s2mps13_buck(1, MIN_500_MV, STEP_6_25_MV, 0x10),
450+
regulator_desc_s2mps13_buck(2, MIN_500_MV, STEP_6_25_MV, 0x10),
451+
regulator_desc_s2mps13_buck(3, MIN_500_MV, STEP_6_25_MV, 0x10),
452+
regulator_desc_s2mps13_buck(4, MIN_500_MV, STEP_6_25_MV, 0x10),
453+
regulator_desc_s2mps13_buck(5, MIN_500_MV, STEP_6_25_MV, 0x10),
454+
regulator_desc_s2mps13_buck(6, MIN_500_MV, STEP_6_25_MV, 0x10),
455+
regulator_desc_s2mps13_buck(7, MIN_500_MV, STEP_6_25_MV, 0x10),
456+
regulator_desc_s2mps13_buck(8, MIN_1000_MV, STEP_12_5_MV, 0x20),
457+
regulator_desc_s2mps13_buck(9, MIN_1000_MV, STEP_12_5_MV, 0x20),
458+
regulator_desc_s2mps13_buck(10, MIN_500_MV, STEP_6_25_MV, 0x10),
459+
};
460+
372461
static int s2mps14_regulator_enable(struct regulator_dev *rdev)
373462
{
374463
struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
375464
unsigned int val;
376465

377466
switch (s2mps11->dev_type) {
467+
case S2MPS13X:
378468
case S2MPS14X:
379469
if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
380470
val = S2MPS14_ENABLE_SUSPEND;
@@ -406,6 +496,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
406496

407497
/* Below LDO should be always on or does not support suspend mode. */
408498
switch (s2mps11->dev_type) {
499+
case S2MPS13X:
409500
case S2MPS14X:
410501
switch (rdev_id) {
411502
case S2MPS14_LDO3:
@@ -831,6 +922,10 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
831922
s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
832923
regulators = s2mps11_regulators;
833924
break;
925+
case S2MPS13X:
926+
s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
927+
regulators = s2mps13_regulators;
928+
break;
834929
case S2MPS14X:
835930
s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
836931
regulators = s2mps14_regulators;
@@ -927,6 +1022,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
9271022

9281023
static const struct platform_device_id s2mps11_pmic_id[] = {
9291024
{ "s2mps11-pmic", S2MPS11X},
1025+
{ "s2mps13-pmic", S2MPS13X},
9301026
{ "s2mps14-pmic", S2MPS14X},
9311027
{ "s2mpu02-pmic", S2MPU02},
9321028
{ },

include/linux/mfd/samsung/core.h

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define MIN_800_MV 800000
2929
#define MIN_750_MV 750000
3030
#define MIN_600_MV 600000
31+
#define MIN_500_MV 500000
3132

3233
/* Macros to represent steps for LDO/BUCK */
3334
#define STEP_50_MV 50000

include/linux/mfd/samsung/s2mps13.h

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/*
2+
* s2mps13.h
3+
*
4+
* Copyright (c) 2014 Samsung Electronics Co., Ltd
5+
* http://www.samsung.com
6+
*
7+
* This program is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU General Public License as published by the
9+
* Free Software Foundation; either version 2 of the License, or (at your
10+
* option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
*/
18+
19+
#ifndef __LINUX_MFD_S2MPS13_H
20+
#define __LINUX_MFD_S2MPS13_H
21+
22+
/* S2MPS13 registers */
23+
enum s2mps13_reg {
24+
S2MPS13_REG_ID,
25+
S2MPS13_REG_INT1,
26+
S2MPS13_REG_INT2,
27+
S2MPS13_REG_INT3,
28+
S2MPS13_REG_INT1M,
29+
S2MPS13_REG_INT2M,
30+
S2MPS13_REG_INT3M,
31+
S2MPS13_REG_ST1,
32+
S2MPS13_REG_ST2,
33+
S2MPS13_REG_PWRONSRC,
34+
S2MPS13_REG_OFFSRC,
35+
S2MPS13_REG_BU_CHG,
36+
S2MPS13_REG_RTCCTRL,
37+
S2MPS13_REG_CTRL1,
38+
S2MPS13_REG_CTRL2,
39+
S2MPS13_REG_RSVD1,
40+
S2MPS13_REG_RSVD2,
41+
S2MPS13_REG_RSVD3,
42+
S2MPS13_REG_RSVD4,
43+
S2MPS13_REG_RSVD5,
44+
S2MPS13_REG_RSVD6,
45+
S2MPS13_REG_CTRL3,
46+
S2MPS13_REG_RSVD7,
47+
S2MPS13_REG_RSVD8,
48+
S2MPS13_REG_WRSTBI,
49+
S2MPS13_REG_B1CTRL,
50+
S2MPS13_REG_B1OUT,
51+
S2MPS13_REG_B2CTRL,
52+
S2MPS13_REG_B2OUT,
53+
S2MPS13_REG_B3CTRL,
54+
S2MPS13_REG_B3OUT,
55+
S2MPS13_REG_B4CTRL,
56+
S2MPS13_REG_B4OUT,
57+
S2MPS13_REG_B5CTRL,
58+
S2MPS13_REG_B5OUT,
59+
S2MPS13_REG_B6CTRL,
60+
S2MPS13_REG_B6OUT,
61+
S2MPS13_REG_B7CTRL,
62+
S2MPS13_REG_B7OUT,
63+
S2MPS13_REG_B8CTRL,
64+
S2MPS13_REG_B8OUT,
65+
S2MPS13_REG_B9CTRL,
66+
S2MPS13_REG_B9OUT,
67+
S2MPS13_REG_B10CTRL,
68+
S2MPS13_REG_B10OUT,
69+
S2MPS13_REG_BB1CTRL,
70+
S2MPS13_REG_BB1OUT,
71+
S2MPS13_REG_BUCK_RAMP1,
72+
S2MPS13_REG_BUCK_RAMP2,
73+
S2MPS13_REG_LDO_DVS1,
74+
S2MPS13_REG_LDO_DVS2,
75+
S2MPS13_REG_LDO_DVS3,
76+
S2MPS13_REG_B6OUT2,
77+
S2MPS13_REG_L1CTRL,
78+
S2MPS13_REG_L2CTRL,
79+
S2MPS13_REG_L3CTRL,
80+
S2MPS13_REG_L4CTRL,
81+
S2MPS13_REG_L5CTRL,
82+
S2MPS13_REG_L6CTRL,
83+
S2MPS13_REG_L7CTRL,
84+
S2MPS13_REG_L8CTRL,
85+
S2MPS13_REG_L9CTRL,
86+
S2MPS13_REG_L10CTRL,
87+
S2MPS13_REG_L11CTRL,
88+
S2MPS13_REG_L12CTRL,
89+
S2MPS13_REG_L13CTRL,
90+
S2MPS13_REG_L14CTRL,
91+
S2MPS13_REG_L15CTRL,
92+
S2MPS13_REG_L16CTRL,
93+
S2MPS13_REG_L17CTRL,
94+
S2MPS13_REG_L18CTRL,
95+
S2MPS13_REG_L19CTRL,
96+
S2MPS13_REG_L20CTRL,
97+
S2MPS13_REG_L21CTRL,
98+
S2MPS13_REG_L22CTRL,
99+
S2MPS13_REG_L23CTRL,
100+
S2MPS13_REG_L24CTRL,
101+
S2MPS13_REG_L25CTRL,
102+
S2MPS13_REG_L26CTRL,
103+
S2MPS13_REG_L27CTRL,
104+
S2MPS13_REG_L28CTRL,
105+
S2MPS13_REG_L30CTRL,
106+
S2MPS13_REG_L31CTRL,
107+
S2MPS13_REG_L32CTRL,
108+
S2MPS13_REG_L33CTRL,
109+
S2MPS13_REG_L34CTRL,
110+
S2MPS13_REG_L35CTRL,
111+
S2MPS13_REG_L36CTRL,
112+
S2MPS13_REG_L37CTRL,
113+
S2MPS13_REG_L38CTRL,
114+
S2MPS13_REG_L39CTRL,
115+
S2MPS13_REG_L40CTRL,
116+
S2MPS13_REG_LDODSCH1,
117+
S2MPS13_REG_LDODSCH2,
118+
S2MPS13_REG_LDODSCH3,
119+
S2MPS13_REG_LDODSCH4,
120+
S2MPS13_REG_LDODSCH5,
121+
};
122+
123+
/* regulator ids */
124+
enum s2mps13_regulators {
125+
S2MPS13_LDO1,
126+
S2MPS13_LDO2,
127+
S2MPS13_LDO3,
128+
S2MPS13_LDO4,
129+
S2MPS13_LDO5,
130+
S2MPS13_LDO6,
131+
S2MPS13_LDO7,
132+
S2MPS13_LDO8,
133+
S2MPS13_LDO9,
134+
S2MPS13_LDO10,
135+
S2MPS13_LDO11,
136+
S2MPS13_LDO12,
137+
S2MPS13_LDO13,
138+
S2MPS13_LDO14,
139+
S2MPS13_LDO15,
140+
S2MPS13_LDO16,
141+
S2MPS13_LDO17,
142+
S2MPS13_LDO18,
143+
S2MPS13_LDO19,
144+
S2MPS13_LDO20,
145+
S2MPS13_LDO21,
146+
S2MPS13_LDO22,
147+
S2MPS13_LDO23,
148+
S2MPS13_LDO24,
149+
S2MPS13_LDO25,
150+
S2MPS13_LDO26,
151+
S2MPS13_LDO27,
152+
S2MPS13_LDO28,
153+
S2MPS13_LDO29,
154+
S2MPS13_LDO30,
155+
S2MPS13_LDO31,
156+
S2MPS13_LDO32,
157+
S2MPS13_LDO33,
158+
S2MPS13_LDO34,
159+
S2MPS13_LDO35,
160+
S2MPS13_LDO36,
161+
S2MPS13_LDO37,
162+
S2MPS13_LDO38,
163+
S2MPS13_LDO39,
164+
S2MPS13_LDO40,
165+
S2MPS13_BUCK1,
166+
S2MPS13_BUCK2,
167+
S2MPS13_BUCK3,
168+
S2MPS13_BUCK4,
169+
S2MPS13_BUCK5,
170+
S2MPS13_BUCK6,
171+
S2MPS13_BUCK7,
172+
S2MPS13_BUCK8,
173+
S2MPS13_BUCK9,
174+
S2MPS13_BUCK10,
175+
176+
S2MPS13_REGULATOR_MAX,
177+
};
178+
179+
/*
180+
* Default ramp delay in uv/us. Datasheet says that ramp delay can be
181+
* controlled however it does not specify which register is used for that.
182+
* Let's assume that default value will be set.
183+
*/
184+
#define S2MPS13_BUCK_RAMP_DELAY 12500
185+
186+
#endif /* __LINUX_MFD_S2MPS13_H */

0 commit comments

Comments
 (0)