Skip to content

Commit 4c35c86

Browse files
committed
Merge remote-tracking branch 'regulator/topic/linear' into regulator-next
2 parents a611761 + 8828bae commit 4c35c86

11 files changed

Lines changed: 51 additions & 81 deletions

File tree

‎drivers/regulator/88pm800.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,14 @@ struct pm800_regulators {
141141

142142
/* Ranges are sorted in ascending order. */
143143
static const struct regulator_linear_range buck1_volt_range[] = {
144-
{ .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f,
145-
.uV_step = 12500 },
146-
{ .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50,
147-
.max_sel = 0x54, .uV_step = 50000 },
144+
REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500),
145+
REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x54, 50000),
148146
};
149147

150148
/* BUCK 2~5 have same ranges. */
151149
static const struct regulator_linear_range buck2_5_volt_range[] = {
152-
{ .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f,
153-
.uV_step = 12500 },
154-
{ .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50,
155-
.max_sel = 0x72, .uV_step = 50000 },
150+
REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500),
151+
REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x72, 50000),
156152
};
157153

158154
static const unsigned int ldo1_volt_table[] = {

‎drivers/regulator/as3711-regulator.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,19 @@ static struct regulator_ops as3711_dldo_ops = {
117117
};
118118

119119
static const struct regulator_linear_range as3711_sd_ranges[] = {
120-
{ .min_uV = 612500, .max_uV = 1400000,
121-
.min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 },
122-
{ .min_uV = 1425000, .max_uV = 2600000,
123-
.min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 },
124-
{ .min_uV = 2650000, .max_uV = 3350000,
125-
.min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 },
120+
REGULATOR_LINEAR_RANGE(612500, 0x1, 0x40, 12500),
121+
REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
122+
REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7f, 50000),
126123
};
127124

128125
static const struct regulator_linear_range as3711_aldo_ranges[] = {
129-
{ .min_uV = 1200000, .max_uV = 1950000,
130-
.min_sel = 0, .max_sel = 0xf, .uV_step = 50000 },
131-
{ .min_uV = 1800000, .max_uV = 3300000,
132-
.min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 },
126+
REGULATOR_LINEAR_RANGE(1200000, 0, 0xf, 50000),
127+
REGULATOR_LINEAR_RANGE(1800000, 0x10, 0x1f, 100000),
133128
};
134129

135130
static const struct regulator_linear_range as3711_dldo_ranges[] = {
136-
{ .min_uV = 900000, .max_uV = 1700000,
137-
.min_sel = 0, .max_sel = 0x10, .uV_step = 50000 },
138-
{ .min_uV = 1750000, .max_uV = 3300000,
139-
.min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 },
131+
REGULATOR_LINEAR_RANGE(900000, 0, 0x10, 50000),
132+
REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000),
140133
};
141134

142135
#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \

‎drivers/regulator/as3722-regulator.c‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,9 @@ static struct regulator_ops as3722_ldo3_extcntrl_ops = {
435435
.get_current_limit = as3722_ldo3_get_current_limit,
436436
};
437437

438-
#define regulator_lin_range(_min_sel, _max_sel, _min_uV, _step_uV) \
439-
{ \
440-
.min_sel = _min_sel, \
441-
.max_sel = _max_sel, \
442-
.uV_step = _step_uV, \
443-
.min_uV = _min_uV, \
444-
.max_uV = _min_uV + (_max_sel - _min_sel) * _step_uV, \
445-
}
446-
447438
static const struct regulator_linear_range as3722_ldo_ranges[] = {
448-
regulator_lin_range(0x01, 0x24, 825000, 25000),
449-
regulator_lin_range(0x40, 0x7F, 1725000, 25000),
439+
REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000),
440+
REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000),
450441
};
451442

452443
static struct regulator_ops as3722_ldo_ops = {
@@ -605,9 +596,9 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev,
605596
}
606597

607598
static const struct regulator_linear_range as3722_sd2345_ranges[] = {
608-
regulator_lin_range(0x01, 0x40, 612500, 12500),
609-
regulator_lin_range(0x41, 0x70, 1425000, 25000),
610-
regulator_lin_range(0x71, 0x7F, 2650000, 50000),
599+
REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500),
600+
REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
601+
REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000),
611602
};
612603

613604
static struct regulator_ops as3722_sd016_ops = {

‎drivers/regulator/da903x.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,8 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev,
253253
}
254254

255255
static const struct regulator_linear_range da9034_ldo12_ranges[] = {
256-
{ .min_uV = 1700000, .max_uV = 2050000, .min_sel = 0, .max_sel = 7,
257-
.uV_step = 50000 },
258-
{ .min_uV = 2700000, .max_uV = 3050000, .min_sel = 8, .max_sel = 15,
259-
.uV_step = 50000 },
256+
REGULATOR_LINEAR_RANGE(1700000, 0, 7, 50000),
257+
REGULATOR_LINEAR_RANGE(2700000, 8, 15, 50000),
260258
};
261259

262260
static struct regulator_ops da903x_regulator_ldo_ops = {

‎drivers/regulator/helpers.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,13 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
284284
}
285285

286286
for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
287+
int linear_max_uV;
288+
287289
range = &rdev->desc->linear_ranges[i];
290+
linear_max_uV = range->min_uV +
291+
(range->max_sel - range->min_sel) * range->uV_step;
288292

289-
if (!(min_uV <= range->max_uV && max_uV >= range->min_uV))
293+
if (!(min_uV <= linear_max_uV && max_uV >= range->min_uV))
290294
continue;
291295

292296
if (min_uV <= range->min_uV)

‎drivers/regulator/tps65217-regulator.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,17 @@ static const unsigned int LDO1_VSEL_table[] = {
5252
};
5353

5454
static const struct regulator_linear_range tps65217_uv1_ranges[] = {
55-
{ .min_uV = 900000, .max_uV = 1500000, .min_sel = 0, .max_sel = 24,
56-
.uV_step = 25000 },
57-
{ .min_uV = 1550000, .max_uV = 1800000, .min_sel = 25, .max_sel = 30,
58-
.uV_step = 50000 },
59-
{ .min_uV = 1850000, .max_uV = 2900000, .min_sel = 31, .max_sel = 52,
60-
.uV_step = 50000 },
61-
{ .min_uV = 3000000, .max_uV = 3200000, .min_sel = 53, .max_sel = 55,
62-
.uV_step = 100000 },
63-
{ .min_uV = 3300000, .max_uV = 3300000, .min_sel = 56, .max_sel = 62,
64-
.uV_step = 0 },
55+
REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000),
56+
REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000),
57+
REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000),
58+
REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000),
59+
REGULATOR_LINEAR_RANGE(3300000, 56, 62, 0),
6560
};
6661

6762
static const struct regulator_linear_range tps65217_uv2_ranges[] = {
68-
{ .min_uV = 1500000, .max_uV = 1900000, .min_sel = 0, .max_sel = 8,
69-
.uV_step = 50000 },
70-
{ .min_uV = 2000000, .max_uV = 2400000, .min_sel = 9, .max_sel = 13,
71-
.uV_step = 100000 },
72-
{ .min_uV = 2450000, .max_uV = 3300000, .min_sel = 14, .max_sel = 31,
73-
.uV_step = 50000 },
63+
REGULATOR_LINEAR_RANGE(1500000, 0, 8, 50000),
64+
REGULATOR_LINEAR_RANGE(2000000, 9, 13, 100000),
65+
REGULATOR_LINEAR_RANGE(2450000, 14, 31, 50000),
7466
};
7567

7668
static int tps65217_pmic_enable(struct regulator_dev *dev)

‎drivers/regulator/tps65912-regulator.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,9 @@ struct tps65912_reg {
119119
};
120120

121121
static const struct regulator_linear_range tps65912_ldo_ranges[] = {
122-
{ .min_uV = 800000, .max_uV = 1600000, .min_sel = 0, .max_sel = 32,
123-
.uV_step = 25000 },
124-
{ .min_uV = 1650000, .max_uV = 3000000, .min_sel = 33, .max_sel = 60,
125-
.uV_step = 50000 },
126-
{ .min_uV = 3100000, .max_uV = 3300000, .min_sel = 61, .max_sel = 63,
127-
.uV_step = 100000 },
122+
REGULATOR_LINEAR_RANGE(800000, 0, 32, 25000),
123+
REGULATOR_LINEAR_RANGE(1650000, 33, 60, 50000),
124+
REGULATOR_LINEAR_RANGE(3100000, 61, 63, 100000),
128125
};
129126

130127
static int tps65912_get_range(struct tps65912_reg *pmic, int id)

‎drivers/regulator/wm831x-ldo.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data)
6363
*/
6464

6565
static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = {
66-
{ .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14,
67-
.uV_step = 50000 },
68-
{ .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
69-
.uV_step = 100000 },
66+
REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000),
67+
REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000),
7068
};
7169

7270
static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
@@ -320,10 +318,8 @@ static struct platform_driver wm831x_gp_ldo_driver = {
320318
*/
321319

322320
static const struct regulator_linear_range wm831x_aldo_ranges[] = {
323-
{ .min_uV = 1000000, .max_uV = 1600000, .min_sel = 0, .max_sel = 12,
324-
.uV_step = 50000 },
325-
{ .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31,
326-
.uV_step = 100000 },
321+
REGULATOR_LINEAR_RANGE(1000000, 0, 12, 50000),
322+
REGULATOR_LINEAR_RANGE(1700000, 13, 31, 100000),
327323
};
328324

329325
static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,

‎drivers/regulator/wm8350-regulator.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,8 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev,
543543
}
544544

545545
static const struct regulator_linear_range wm8350_ldo_ranges[] = {
546-
{ .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 15,
547-
.uV_step = 50000 },
548-
{ .min_uV = 1800000, .max_uV = 3300000, .min_sel = 16, .max_sel = 31,
549-
.uV_step = 100000 },
546+
REGULATOR_LINEAR_RANGE(900000, 0, 15, 50000),
547+
REGULATOR_LINEAR_RANGE(1800000, 16, 31, 100000),
550548
};
551549

552550
static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV)

‎drivers/regulator/wm8400-regulator.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
#include <linux/mfd/wm8400-private.h>
2121

2222
static const struct regulator_linear_range wm8400_ldo_ranges[] = {
23-
{ .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14,
24-
.uV_step = 50000 },
25-
{ .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
26-
.uV_step = 100000 },
23+
REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000),
24+
REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000),
2725
};
2826

2927
static struct regulator_ops wm8400_ldo_ops = {

0 commit comments

Comments
 (0)