Skip to content

Commit 9b08f76

Browse files
committed
Merge remote-tracking branches 'regulator/topic/hi6421v530', 'regulator/topic/lp8755', 'regulator/topic/lp87565', 'regulator/topic/max8997' and 'regulator/topic/palmas' into regulator-next
6 parents 8f5bb9c + ded7b2a + 80aec6f + 42f1ea4 + f74521c + 96e4f52 commit 9b08f76

File tree

7 files changed

+481
-14
lines changed

7 files changed

+481
-14
lines changed

drivers/regulator/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ config REGULATOR_HI6421
296296
21 general purpose LDOs, 3 dedicated LDOs, and 5 BUCKs. All
297297
of them come with support to either ECO (idle) or sleep mode.
298298

299+
config REGULATOR_HI6421V530
300+
tristate "HiSilicon Hi6421v530 PMIC voltage regulator support"
301+
depends on MFD_HI6421_PMIC && OF
302+
help
303+
This driver provides support for the voltage regulators on
304+
HiSilicon Hi6421v530 PMU / Codec IC.
305+
Hi6421v530 is a multi-function device which, on regulator part,
306+
provides 5 general purpose LDOs, and all of them come with support
307+
to either ECO (idle) or sleep mode.
308+
299309
config REGULATOR_HI655X
300310
tristate "Hisilicon HI655X PMIC regulators support"
301311
depends on ARCH_HISI || COMPILE_TEST
@@ -365,6 +375,14 @@ config REGULATOR_LP8755
365375
chip contains six step-down DC/DC converters which can support
366376
9 mode multiphase configuration.
367377

378+
config REGULATOR_LP87565
379+
tristate "TI LP87565 Power regulators"
380+
depends on MFD_TI_LP87565 && OF
381+
help
382+
This driver supports LP87565 voltage regulator chips. LP87565
383+
provides four step-down converters. It supports software based
384+
voltage control for different voltage domains
385+
368386
config REGULATOR_LP8788
369387
tristate "TI LP8788 Power Regulators"
370388
depends on MFD_LP8788

drivers/regulator/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
3838
obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
3939
obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
4040
obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o
41+
obj-$(CONFIG_REGULATOR_HI6421V530) += hi6421v530-regulator.o
4142
obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o
4243
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
4344
obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o
@@ -46,6 +47,7 @@ obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
4647
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
4748
obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o
4849
obj-$(CONFIG_REGULATOR_LP873X) += lp873x-regulator.o
50+
obj-$(CONFIG_REGULATOR_LP87565) += lp87565-regulator.o
4951
obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o
5052
obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o
5153
obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
/*
2+
* Device driver for regulators in Hi6421V530 IC
3+
*
4+
* Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
5+
* http://www.hisilicon.com
6+
* Copyright (c) <2017> Linaro Ltd.
7+
* http://www.linaro.org
8+
*
9+
* Author: Wang Xiaoyin <[email protected]>
10+
* Guodong Xu <[email protected]>
11+
*
12+
* This program is free software; you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License version 2 as
14+
* published by the Free Software Foundation.
15+
*/
16+
17+
#include <linux/mfd/hi6421-pmic.h>
18+
#include <linux/module.h>
19+
#include <linux/of.h>
20+
#include <linux/platform_device.h>
21+
#include <linux/regmap.h>
22+
#include <linux/regulator/driver.h>
23+
24+
/*
25+
* struct hi6421v530_regulator_info - hi6421v530 regulator information
26+
* @desc: regulator description
27+
* @mode_mask: ECO mode bitmask of LDOs; for BUCKs, this masks sleep
28+
* @eco_microamp: eco mode load upper limit (in uA), valid for LDOs only
29+
*/
30+
struct hi6421v530_regulator_info {
31+
struct regulator_desc rdesc;
32+
u8 mode_mask;
33+
u32 eco_microamp;
34+
};
35+
36+
/* HI6421v530 regulators */
37+
enum hi6421v530_regulator_id {
38+
HI6421V530_LDO3,
39+
HI6421V530_LDO9,
40+
HI6421V530_LDO11,
41+
HI6421V530_LDO15,
42+
HI6421V530_LDO16,
43+
};
44+
45+
static const unsigned int ldo_3_voltages[] = {
46+
1800000, 1825000, 1850000, 1875000,
47+
1900000, 1925000, 1950000, 1975000,
48+
2000000, 2025000, 2050000, 2075000,
49+
2100000, 2125000, 2150000, 2200000,
50+
};
51+
52+
static const unsigned int ldo_9_11_voltages[] = {
53+
1750000, 1800000, 1825000, 2800000,
54+
2850000, 2950000, 3000000, 3300000,
55+
};
56+
57+
static const unsigned int ldo_15_16_voltages[] = {
58+
1750000, 1800000, 2400000, 2600000,
59+
2700000, 2850000, 2950000, 3000000,
60+
};
61+
62+
static const struct regulator_ops hi6421v530_ldo_ops;
63+
64+
#define HI6421V530_LDO_ENABLE_TIME (350)
65+
66+
/*
67+
* _id - LDO id name string
68+
* v_table - voltage table
69+
* vreg - voltage select register
70+
* vmask - voltage select mask
71+
* ereg - enable register
72+
* emask - enable mask
73+
* odelay - off/on delay time in uS
74+
* ecomask - eco mode mask
75+
* ecoamp - eco mode load uppler limit in uA
76+
*/
77+
#define HI6421V530_LDO(_ID, v_table, vreg, vmask, ereg, emask, \
78+
odelay, ecomask, ecoamp) { \
79+
.rdesc = { \
80+
.name = #_ID, \
81+
.of_match = of_match_ptr(#_ID), \
82+
.regulators_node = of_match_ptr("regulators"), \
83+
.ops = &hi6421v530_ldo_ops, \
84+
.type = REGULATOR_VOLTAGE, \
85+
.id = HI6421V530_##_ID, \
86+
.owner = THIS_MODULE, \
87+
.n_voltages = ARRAY_SIZE(v_table), \
88+
.volt_table = v_table, \
89+
.vsel_reg = HI6421_REG_TO_BUS_ADDR(vreg), \
90+
.vsel_mask = vmask, \
91+
.enable_reg = HI6421_REG_TO_BUS_ADDR(ereg), \
92+
.enable_mask = emask, \
93+
.enable_time = HI6421V530_LDO_ENABLE_TIME, \
94+
.off_on_delay = odelay, \
95+
}, \
96+
.mode_mask = ecomask, \
97+
.eco_microamp = ecoamp, \
98+
}
99+
100+
/* HI6421V530 regulator information */
101+
102+
static struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
103+
HI6421V530_LDO(LDO3, ldo_3_voltages, 0x061, 0xf, 0x060, 0x2,
104+
20000, 0x6, 8000),
105+
HI6421V530_LDO(LDO9, ldo_9_11_voltages, 0x06b, 0x7, 0x06a, 0x2,
106+
40000, 0x6, 8000),
107+
HI6421V530_LDO(LDO11, ldo_9_11_voltages, 0x06f, 0x7, 0x06e, 0x2,
108+
40000, 0x6, 8000),
109+
HI6421V530_LDO(LDO15, ldo_15_16_voltages, 0x077, 0x7, 0x076, 0x2,
110+
40000, 0x6, 8000),
111+
HI6421V530_LDO(LDO16, ldo_15_16_voltages, 0x079, 0x7, 0x078, 0x2,
112+
40000, 0x6, 8000),
113+
};
114+
115+
static unsigned int hi6421v530_regulator_ldo_get_mode(
116+
struct regulator_dev *rdev)
117+
{
118+
struct hi6421v530_regulator_info *info;
119+
unsigned int reg_val;
120+
121+
info = rdev_get_drvdata(rdev);
122+
regmap_read(rdev->regmap, rdev->desc->enable_reg, &reg_val);
123+
124+
if (reg_val & (info->mode_mask))
125+
return REGULATOR_MODE_IDLE;
126+
127+
return REGULATOR_MODE_NORMAL;
128+
}
129+
130+
static int hi6421v530_regulator_ldo_set_mode(struct regulator_dev *rdev,
131+
unsigned int mode)
132+
{
133+
struct hi6421v530_regulator_info *info;
134+
unsigned int new_mode;
135+
136+
info = rdev_get_drvdata(rdev);
137+
switch (mode) {
138+
case REGULATOR_MODE_NORMAL:
139+
new_mode = 0;
140+
break;
141+
case REGULATOR_MODE_IDLE:
142+
new_mode = info->mode_mask;
143+
break;
144+
default:
145+
return -EINVAL;
146+
}
147+
148+
regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
149+
info->mode_mask, new_mode);
150+
151+
return 0;
152+
}
153+
154+
155+
static const struct regulator_ops hi6421v530_ldo_ops = {
156+
.is_enabled = regulator_is_enabled_regmap,
157+
.enable = regulator_enable_regmap,
158+
.disable = regulator_disable_regmap,
159+
.list_voltage = regulator_list_voltage_table,
160+
.map_voltage = regulator_map_voltage_ascend,
161+
.get_voltage_sel = regulator_get_voltage_sel_regmap,
162+
.set_voltage_sel = regulator_set_voltage_sel_regmap,
163+
.get_mode = hi6421v530_regulator_ldo_get_mode,
164+
.set_mode = hi6421v530_regulator_ldo_set_mode,
165+
};
166+
167+
static int hi6421v530_regulator_probe(struct platform_device *pdev)
168+
{
169+
struct hi6421_pmic *pmic;
170+
struct regulator_dev *rdev;
171+
struct regulator_config config = { };
172+
unsigned int i;
173+
174+
pmic = dev_get_drvdata(pdev->dev.parent);
175+
if (!pmic) {
176+
dev_err(&pdev->dev, "no pmic in the regulator parent node\n");
177+
return -ENODEV;
178+
}
179+
180+
for (i = 0; i < ARRAY_SIZE(hi6421v530_regulator_info); i++) {
181+
config.dev = pdev->dev.parent;
182+
config.regmap = pmic->regmap;
183+
config.driver_data = &hi6421v530_regulator_info[i];
184+
185+
rdev = devm_regulator_register(&pdev->dev,
186+
&hi6421v530_regulator_info[i].rdesc,
187+
&config);
188+
if (IS_ERR(rdev)) {
189+
dev_err(&pdev->dev, "failed to register regulator %s\n",
190+
hi6421v530_regulator_info[i].rdesc.name);
191+
return PTR_ERR(rdev);
192+
}
193+
}
194+
return 0;
195+
}
196+
197+
static const struct platform_device_id hi6421v530_regulator_table[] = {
198+
{ .name = "hi6421v530-regulator" },
199+
{},
200+
};
201+
MODULE_DEVICE_TABLE(platform, hi6421v530_regulator_table);
202+
203+
static struct platform_driver hi6421v530_regulator_driver = {
204+
.id_table = hi6421v530_regulator_table,
205+
.driver = {
206+
.name = "hi6421v530-regulator",
207+
},
208+
.probe = hi6421v530_regulator_probe,
209+
};
210+
module_platform_driver(hi6421v530_regulator_driver);
211+
212+
MODULE_AUTHOR("Wang Xiaoyin <[email protected]>");
213+
MODULE_DESCRIPTION("Hi6421v530 regulator driver");
214+
MODULE_LICENSE("GPL v2");

drivers/regulator/lp8755.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int lp8755_buck_enable_time(struct regulator_dev *rdev)
9999

100100
ret = lp8755_read(pchip, 0x12 + id, &regval);
101101
if (ret < 0) {
102-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
102+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
103103
return ret;
104104
}
105105
return (regval & 0xff) * 100;
@@ -144,7 +144,7 @@ static int lp8755_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
144144
goto err_i2c;
145145
return ret;
146146
err_i2c:
147-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
147+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
148148
return ret;
149149
}
150150

@@ -175,7 +175,7 @@ static unsigned int lp8755_buck_get_mode(struct regulator_dev *rdev)
175175
return REGULATOR_MODE_NORMAL;
176176

177177
err_i2c:
178-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
178+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
179179
return 0;
180180
}
181181

@@ -223,7 +223,7 @@ static int lp8755_buck_set_ramp(struct regulator_dev *rdev, int ramp)
223223
goto err_i2c;
224224
return ret;
225225
err_i2c:
226-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
226+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
227227
return ret;
228228
}
229229

@@ -295,7 +295,7 @@ static int lp8755_init_data(struct lp8755_chip *pchip)
295295
return ret;
296296

297297
out_i2c_error:
298-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
298+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
299299
return ret;
300300
}
301301

@@ -404,7 +404,7 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
404404
return IRQ_HANDLED;
405405

406406
err_i2c:
407-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
407+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
408408
return IRQ_NONE;
409409
}
410410

@@ -420,7 +420,7 @@ static int lp8755_int_config(struct lp8755_chip *pchip)
420420

421421
ret = lp8755_read(pchip, 0x0F, &regval);
422422
if (ret < 0) {
423-
dev_err(pchip->dev, "i2c acceess error %s\n", __func__);
423+
dev_err(pchip->dev, "i2c access error %s\n", __func__);
424424
return ret;
425425
}
426426

0 commit comments

Comments
 (0)