Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
c36a1cdf
Commit
c36a1cdf
authored
Jul 02, 2013
by
Mark Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regulator: wm8350: Convert to use linear ranges
Signed-off-by:
Mark Brown
<
broonie@linaro.org
>
parent
5ff26a14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
38 deletions
+17
-38
drivers/regulator/wm8350-regulator.c
drivers/regulator/wm8350-regulator.c
+17
-38
No files found.
drivers/regulator/wm8350-regulator.c
View file @
c36a1cdf
...
...
@@ -542,41 +542,12 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev,
return
0
;
}
static
int
wm8350_ldo_list_voltage
(
struct
regulator_dev
*
rdev
,
unsigned
selector
)
{
if
(
selector
>
WM8350_LDO1_VSEL_MASK
)
return
-
EINVAL
;
if
(
selector
<
16
)
return
(
selector
*
50000
)
+
900000
;
else
return
((
selector
-
16
)
*
100000
)
+
1800000
;
}
static
int
wm8350_ldo_map_voltage
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
)
{
int
volt
,
sel
;
int
min_mV
=
min_uV
/
1000
;
int
max_mV
=
max_uV
/
1000
;
if
(
min_mV
<
900
||
min_mV
>
3300
)
return
-
EINVAL
;
if
(
max_mV
<
900
||
max_mV
>
3300
)
return
-
EINVAL
;
if
(
min_mV
<
1800
)
/* step size is 50mV < 1800mV */
sel
=
DIV_ROUND_UP
(
min_uV
-
900
,
50
);
else
/* step size is 100mV > 1800mV */
sel
=
DIV_ROUND_UP
(
min_uV
-
1800
,
100
)
+
16
;
volt
=
wm8350_ldo_list_voltage
(
rdev
,
sel
);
if
(
volt
<
min_uV
||
volt
>
max_uV
)
return
-
EINVAL
;
return
sel
;
}
static
const
struct
regulator_linear_range
wm8350_ldo_ranges
[]
=
{
{
.
min_uV
=
900000
,
.
max_uV
=
1750000
,
.
min_sel
=
0
,
.
max_sel
=
15
,
.
uV_step
=
50000
},
{
.
min_uV
=
1800000
,
.
max_uV
=
3300000
,
.
min_sel
=
16
,
.
max_sel
=
31
,
.
uV_step
=
100000
},
};
static
int
wm8350_ldo_set_suspend_voltage
(
struct
regulator_dev
*
rdev
,
int
uV
)
{
...
...
@@ -603,7 +574,7 @@ static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV)
return
-
EINVAL
;
}
sel
=
wm8350_ldo_map_volta
ge
(
rdev
,
uV
,
uV
);
sel
=
regulator_map_voltage_linear_ran
ge
(
rdev
,
uV
,
uV
);
if
(
sel
<
0
)
return
-
EINVAL
;
...
...
@@ -998,10 +969,10 @@ static struct regulator_ops wm8350_dcdc2_5_ops = {
};
static
struct
regulator_ops
wm8350_ldo_ops
=
{
.
map_voltage
=
wm8350_ldo_map_volta
ge
,
.
map_voltage
=
regulator_map_voltage_linear_ran
ge
,
.
set_voltage_sel
=
regulator_set_voltage_sel_regmap
,
.
get_voltage_sel
=
regulator_get_voltage_sel_regmap
,
.
list_voltage
=
wm8350_ldo_list_volta
ge
,
.
list_voltage
=
regulator_list_voltage_linear_ran
ge
,
.
enable
=
regulator_enable_regmap
,
.
disable
=
regulator_disable_regmap
,
.
is_enabled
=
regulator_is_enabled_regmap
,
...
...
@@ -1108,6 +1079,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
.
irq
=
WM8350_IRQ_UV_LDO1
,
.
type
=
REGULATOR_VOLTAGE
,
.
n_voltages
=
WM8350_LDO1_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8350_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8350_ldo_ranges
),
.
vsel_reg
=
WM8350_LDO1_CONTROL
,
.
vsel_mask
=
WM8350_LDO1_VSEL_MASK
,
.
enable_reg
=
WM8350_DCDC_LDO_REQUESTED
,
...
...
@@ -1121,6 +1094,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
.
irq
=
WM8350_IRQ_UV_LDO2
,
.
type
=
REGULATOR_VOLTAGE
,
.
n_voltages
=
WM8350_LDO2_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8350_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8350_ldo_ranges
),
.
vsel_reg
=
WM8350_LDO2_CONTROL
,
.
vsel_mask
=
WM8350_LDO2_VSEL_MASK
,
.
enable_reg
=
WM8350_DCDC_LDO_REQUESTED
,
...
...
@@ -1134,6 +1109,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
.
irq
=
WM8350_IRQ_UV_LDO3
,
.
type
=
REGULATOR_VOLTAGE
,
.
n_voltages
=
WM8350_LDO3_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8350_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8350_ldo_ranges
),
.
vsel_reg
=
WM8350_LDO3_CONTROL
,
.
vsel_mask
=
WM8350_LDO3_VSEL_MASK
,
.
enable_reg
=
WM8350_DCDC_LDO_REQUESTED
,
...
...
@@ -1147,6 +1124,8 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
.
irq
=
WM8350_IRQ_UV_LDO4
,
.
type
=
REGULATOR_VOLTAGE
,
.
n_voltages
=
WM8350_LDO4_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8350_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8350_ldo_ranges
),
.
vsel_reg
=
WM8350_LDO4_CONTROL
,
.
vsel_mask
=
WM8350_LDO4_VSEL_MASK
,
.
enable_reg
=
WM8350_DCDC_LDO_REQUESTED
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment