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
6692e432
Commit
6692e432
authored
Jul 02, 2013
by
Mark Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regulator: wm8400: Use linear ranges
Signed-off-by:
Mark Brown
<
broonie@linaro.org
>
parent
94d33c02
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
34 deletions
+16
-34
drivers/regulator/wm8400-regulator.c
drivers/regulator/wm8400-regulator.c
+16
-34
No files found.
drivers/regulator/wm8400-regulator.c
View file @
6692e432
...
...
@@ -19,47 +19,21 @@
#include <linux/regulator/driver.h>
#include <linux/mfd/wm8400-private.h>
static
int
wm8400_ldo_list_voltage
(
struct
regulator_dev
*
dev
,
unsigned
selector
)
{
if
(
selector
>
WM8400_LDO1_VSEL_MASK
)
return
-
EINVAL
;
if
(
selector
<
15
)
return
900000
+
(
selector
*
50000
);
else
return
1700000
+
((
selector
-
15
)
*
100000
);
}
static
int
wm8400_ldo_map_voltage
(
struct
regulator_dev
*
dev
,
int
min_uV
,
int
max_uV
)
{
u16
val
;
int
volt
;
if
(
min_uV
<
900000
||
min_uV
>
3300000
)
return
-
EINVAL
;
if
(
min_uV
<
1700000
)
/* Steps of 50mV from 900mV; */
val
=
DIV_ROUND_UP
(
min_uV
-
900000
,
50000
);
else
/* Steps of 100mV from 1700mV */
val
=
DIV_ROUND_UP
(
min_uV
-
1700000
,
100000
)
+
15
;
volt
=
wm8400_ldo_list_voltage
(
dev
,
val
);
if
(
volt
<
min_uV
||
volt
>
max_uV
)
return
-
EINVAL
;
return
val
;
}
static
const
struct
regulator_linear_range
wm8400_ldo_ranges
[]
=
{
{
.
min_uV
=
900000
,
.
max_uV
=
1600000
,
.
min_sel
=
0
,
.
max_sel
=
14
,
.
uV_step
=
50000
},
{
.
min_uV
=
1700000
,
.
max_uV
=
3300000
,
.
min_sel
=
15
,
.
max_sel
=
31
,
.
uV_step
=
100000
},
};
static
struct
regulator_ops
wm8400_ldo_ops
=
{
.
is_enabled
=
regulator_is_enabled_regmap
,
.
enable
=
regulator_enable_regmap
,
.
disable
=
regulator_disable_regmap
,
.
list_voltage
=
wm8400_ldo_list_volta
ge
,
.
list_voltage
=
regulator_list_voltage_linear_ran
ge
,
.
get_voltage_sel
=
regulator_get_voltage_sel_regmap
,
.
set_voltage_sel
=
regulator_set_voltage_sel_regmap
,
.
map_voltage
=
wm8400_ldo_map_volta
ge
,
.
map_voltage
=
regulator_map_voltage_linear_ran
ge
,
};
static
unsigned
int
wm8400_dcdc_get_mode
(
struct
regulator_dev
*
dev
)
...
...
@@ -155,6 +129,8 @@ static struct regulator_desc regulators[] = {
.
enable_reg
=
WM8400_LDO1_CONTROL
,
.
enable_mask
=
WM8400_LDO1_ENA
,
.
n_voltages
=
WM8400_LDO1_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8400_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8400_ldo_ranges
),
.
vsel_reg
=
WM8400_LDO1_CONTROL
,
.
vsel_mask
=
WM8400_LDO1_VSEL_MASK
,
.
type
=
REGULATOR_VOLTAGE
,
...
...
@@ -167,6 +143,8 @@ static struct regulator_desc regulators[] = {
.
enable_reg
=
WM8400_LDO2_CONTROL
,
.
enable_mask
=
WM8400_LDO2_ENA
,
.
n_voltages
=
WM8400_LDO2_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8400_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8400_ldo_ranges
),
.
type
=
REGULATOR_VOLTAGE
,
.
vsel_reg
=
WM8400_LDO2_CONTROL
,
.
vsel_mask
=
WM8400_LDO2_VSEL_MASK
,
...
...
@@ -179,6 +157,8 @@ static struct regulator_desc regulators[] = {
.
enable_reg
=
WM8400_LDO3_CONTROL
,
.
enable_mask
=
WM8400_LDO3_ENA
,
.
n_voltages
=
WM8400_LDO3_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8400_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8400_ldo_ranges
),
.
vsel_reg
=
WM8400_LDO3_CONTROL
,
.
vsel_mask
=
WM8400_LDO3_VSEL_MASK
,
.
type
=
REGULATOR_VOLTAGE
,
...
...
@@ -191,6 +171,8 @@ static struct regulator_desc regulators[] = {
.
enable_reg
=
WM8400_LDO4_CONTROL
,
.
enable_mask
=
WM8400_LDO4_ENA
,
.
n_voltages
=
WM8400_LDO4_VSEL_MASK
+
1
,
.
linear_ranges
=
wm8400_ldo_ranges
,
.
n_linear_ranges
=
ARRAY_SIZE
(
wm8400_ldo_ranges
),
.
vsel_reg
=
WM8400_LDO4_CONTROL
,
.
vsel_mask
=
WM8400_LDO4_VSEL_MASK
,
.
type
=
REGULATOR_VOLTAGE
,
...
...
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