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
nexedi
linux
Commits
28c37c9c
Commit
28c37c9c
authored
Sep 01, 2013
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regulator/topic/88pm800' into regulator-next
parents
d8dfad38
720c0273
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
732 additions
and
275 deletions
+732
-275
Documentation/devicetree/bindings/regulator/88pm800.txt
Documentation/devicetree/bindings/regulator/88pm800.txt
+38
-0
drivers/regulator/88pm800.c
drivers/regulator/88pm800.c
+383
-0
drivers/regulator/Kconfig
drivers/regulator/Kconfig
+132
-122
drivers/regulator/Makefile
drivers/regulator/Makefile
+2
-1
drivers/regulator/core.c
drivers/regulator/core.c
+95
-0
drivers/regulator/wm831x-ldo.c
drivers/regulator/wm831x-ldo.c
+24
-80
drivers/regulator/wm8350-regulator.c
drivers/regulator/wm8350-regulator.c
+17
-38
drivers/regulator/wm8400-regulator.c
drivers/regulator/wm8400-regulator.c
+16
-34
include/linux/regulator/driver.h
include/linux/regulator/driver.h
+25
-0
No files found.
Documentation/devicetree/bindings/regulator/88pm800.txt
0 → 100644
View file @
28c37c9c
Marvell 88PM800 regulator
Required properties:
- compatible: "marvell,88pm800"
- reg: I2C slave address
- regulators: A node that houses a sub-node for each regulator within the
device. Each sub-node is identified using the node's name (or the deprecated
regulator-compatible property if present), with valid values listed below.
The content of each sub-node is defined by the standard binding for
regulators; see regulator.txt.
The valid names for regulators are:
buck1, buck2, buck3, buck4, buck5, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7,
ldo8, ldo9, ldo10, ldo11, ldo12, ldo13, ldo14, ldo15, ldo16, ldo17, ldo18, ldo19
Example:
pmic: 88pm800@31 {
compatible = "marvell,88pm800";
reg = <0x31>;
regulators {
buck1 {
regulator-min-microvolt = <600000>;
regulator-max-microvolt = <3950000>;
regulator-boot-on;
regulator-always-on;
};
ldo1 {
regulator-min-microvolt = <600000>;
regulator-max-microvolt = <15000000>;
regulator-boot-on;
regulator-always-on;
};
...
};
};
drivers/regulator/88pm800.c
0 → 100644
View file @
28c37c9c
This diff is collapsed.
Click to expand it.
drivers/regulator/Kconfig
View file @
28c37c9c
This diff is collapsed.
Click to expand it.
drivers/regulator/Makefile
View file @
28c37c9c
...
...
@@ -9,6 +9,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER)
+=
virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER)
+=
userspace-consumer.o
obj-$(CONFIG_REGULATOR_88PM800)
+=
88pm800.o
obj-$(CONFIG_REGULATOR_88PM8607)
+=
88pm8607.o
obj-$(CONFIG_REGULATOR_AAT2870)
+=
aat2870-regulator.o
obj-$(CONFIG_REGULATOR_AB3100)
+=
ab3100.o
...
...
@@ -52,6 +53,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583)
+=
rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_S2MPS11)
+=
s2mps11.o
obj-$(CONFIG_REGULATOR_S5M8767)
+=
s5m8767.o
obj-$(CONFIG_REGULATOR_TI_ABB)
+=
ti-abb-regulator.o
obj-$(CONFIG_REGULATOR_TPS6105X)
+=
tps6105x-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360)
+=
tps62360-regulator.o
obj-$(CONFIG_REGULATOR_TPS65023)
+=
tps65023-regulator.o
...
...
@@ -64,7 +66,6 @@ obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
obj-$(CONFIG_REGULATOR_TPS65912)
+=
tps65912-regulator.o
obj-$(CONFIG_REGULATOR_TPS80031)
+=
tps80031-regulator.o
obj-$(CONFIG_REGULATOR_TWL4030)
+=
twl-regulator.o
obj-$(CONFIG_REGULATOR_TI_ABB)
+=
ti-abb-regulator.o
obj-$(CONFIG_REGULATOR_VEXPRESS)
+=
vexpress.o
obj-$(CONFIG_REGULATOR_WM831X)
+=
wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X)
+=
wm831x-isink.o
...
...
drivers/regulator/core.c
View file @
28c37c9c
...
...
@@ -2078,6 +2078,43 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
}
EXPORT_SYMBOL_GPL
(
regulator_list_voltage_linear
);
/**
* regulator_list_voltage_linear_range - List voltages for linear ranges
*
* @rdev: Regulator device
* @selector: Selector to convert into a voltage
*
* Regulators with a series of simple linear mappings between voltages
* and selectors can set linear_ranges in the regulator descriptor and
* then use this function as their list_voltage() operation,
*/
int
regulator_list_voltage_linear_range
(
struct
regulator_dev
*
rdev
,
unsigned
int
selector
)
{
const
struct
regulator_linear_range
*
range
;
int
i
;
if
(
!
rdev
->
desc
->
n_linear_ranges
)
{
BUG_ON
(
!
rdev
->
desc
->
n_linear_ranges
);
return
-
EINVAL
;
}
for
(
i
=
0
;
i
<
rdev
->
desc
->
n_linear_ranges
;
i
++
)
{
range
=
&
rdev
->
desc
->
linear_ranges
[
i
];
if
(
!
(
selector
>=
range
->
min_sel
&&
selector
<=
range
->
max_sel
))
continue
;
selector
-=
range
->
min_sel
;
return
range
->
min_uV
+
(
range
->
uV_step
*
selector
);
}
return
-
EINVAL
;
}
EXPORT_SYMBOL_GPL
(
regulator_list_voltage_linear_range
);
/**
* regulator_list_voltage_table - List voltages with table based mapping
*
...
...
@@ -2368,6 +2405,64 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
}
EXPORT_SYMBOL_GPL
(
regulator_map_voltage_linear
);
/**
* regulator_map_voltage_linear - map_voltage() for multiple linear ranges
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers providing linear_ranges in their descriptor can use this as
* their map_voltage() callback.
*/
int
regulator_map_voltage_linear_range
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
)
{
const
struct
regulator_linear_range
*
range
;
int
ret
=
-
EINVAL
;
int
voltage
,
i
;
if
(
!
rdev
->
desc
->
n_linear_ranges
)
{
BUG_ON
(
!
rdev
->
desc
->
n_linear_ranges
);
return
-
EINVAL
;
}
for
(
i
=
0
;
i
<
rdev
->
desc
->
n_linear_ranges
;
i
++
)
{
range
=
&
rdev
->
desc
->
linear_ranges
[
i
];
if
(
!
(
min_uV
<=
range
->
max_uV
&&
max_uV
>=
range
->
min_uV
))
continue
;
if
(
min_uV
<=
range
->
min_uV
)
min_uV
=
range
->
min_uV
;
/* range->uV_step == 0 means fixed voltage range */
if
(
range
->
uV_step
==
0
)
{
ret
=
0
;
}
else
{
ret
=
DIV_ROUND_UP
(
min_uV
-
range
->
min_uV
,
range
->
uV_step
);
if
(
ret
<
0
)
return
ret
;
}
ret
+=
range
->
min_sel
;
break
;
}
if
(
i
==
rdev
->
desc
->
n_linear_ranges
)
return
-
EINVAL
;
/* Map back into a voltage to verify we're still in bounds */
voltage
=
rdev
->
desc
->
ops
->
list_voltage
(
rdev
,
ret
);
if
(
voltage
<
min_uV
||
voltage
>
max_uV
)
return
-
EINVAL
;
return
ret
;
}
EXPORT_SYMBOL_GPL
(
regulator_map_voltage_linear_range
);
static
int
_regulator_do_set_voltage
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
)
{
...
...
drivers/regulator/wm831x-ldo.c
View file @
28c37c9c
...
...
@@ -62,41 +62,12 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data)
* General purpose LDOs
*/
#define WM831X_GP_LDO_SELECTOR_LOW 0xe
#define WM831X_GP_LDO_MAX_SELECTOR 0x1f
static
int
wm831x_gp_ldo_list_voltage
(
struct
regulator_dev
*
rdev
,
unsigned
int
selector
)
{
/* 0.9-1.6V in 50mV steps */
if
(
selector
<=
WM831X_GP_LDO_SELECTOR_LOW
)
return
900000
+
(
selector
*
50000
);
/* 1.7-3.3V in 100mV steps */
if
(
selector
<=
WM831X_GP_LDO_MAX_SELECTOR
)
return
1600000
+
((
selector
-
WM831X_GP_LDO_SELECTOR_LOW
)
*
100000
);
return
-
EINVAL
;
}
static
int
wm831x_gp_ldo_map_voltage
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
)
{
int
volt
,
vsel
;
if
(
min_uV
<
900000
)
vsel
=
0
;
else
if
(
min_uV
<
1700000
)
vsel
=
((
min_uV
-
900000
)
/
50000
);
else
vsel
=
((
min_uV
-
1700000
)
/
100000
)
+
WM831X_GP_LDO_SELECTOR_LOW
+
1
;
volt
=
wm831x_gp_ldo_list_voltage
(
rdev
,
vsel
);
if
(
volt
<
min_uV
||
volt
>
max_uV
)
return
-
EINVAL
;
return
vsel
;
}
static
const
struct
regulator_linear_range
wm831x_gp_ldo_ranges
[]
=
{
{
.
min_uV
=
900000
,
.
max_uV
=
1650000
,
.
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
int
wm831x_gp_ldo_set_suspend_voltage
(
struct
regulator_dev
*
rdev
,
int
uV
)
...
...
@@ -105,7 +76,7 @@ static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
struct
wm831x
*
wm831x
=
ldo
->
wm831x
;
int
sel
,
reg
=
ldo
->
base
+
WM831X_LDO_SLEEP_CONTROL
;
sel
=
wm831x_gp_ldo_map_volta
ge
(
rdev
,
uV
,
uV
);
sel
=
regulator_map_voltage_linear_ran
ge
(
rdev
,
uV
,
uV
);
if
(
sel
<
0
)
return
sel
;
...
...
@@ -230,8 +201,8 @@ static unsigned int wm831x_gp_ldo_get_optimum_mode(struct regulator_dev *rdev,
static
struct
regulator_ops
wm831x_gp_ldo_ops
=
{
.
list_voltage
=
wm831x_gp_ldo_list_volta
ge
,
.
map_voltage
=
wm831x_gp_ldo_map_volta
ge
,
.
list_voltage
=
regulator_list_voltage_linear_ran
ge
,
.
map_voltage
=
regulator_map_voltage_linear_ran
ge
,
.
get_voltage_sel
=
regulator_get_voltage_sel_regmap
,
.
set_voltage_sel
=
regulator_set_voltage_sel_regmap
,
.
set_suspend_voltage
=
wm831x_gp_ldo_set_suspend_voltage
,
...
...
@@ -290,7 +261,7 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
ldo
->
desc
.
id
=
id
;
ldo
->
desc
.
type
=
REGULATOR_VOLTAGE
;
ldo
->
desc
.
n_voltages
=
WM831X_GP_LDO_MAX_SELECTOR
+
1
;
ldo
->
desc
.
n_voltages
=
32
;
ldo
->
desc
.
ops
=
&
wm831x_gp_ldo_ops
;
ldo
->
desc
.
owner
=
THIS_MODULE
;
ldo
->
desc
.
vsel_reg
=
ldo
->
base
+
WM831X_LDO_ON_CONTROL
;
...
...
@@ -299,6 +270,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev)
ldo
->
desc
.
enable_mask
=
1
<<
id
;
ldo
->
desc
.
bypass_reg
=
ldo
->
base
;
ldo
->
desc
.
bypass_mask
=
WM831X_LDO1_SWI
;
ldo
->
desc
.
linear_ranges
=
wm831x_gp_ldo_ranges
;
ldo
->
desc
.
n_linear_ranges
=
ARRAY_SIZE
(
wm831x_gp_ldo_ranges
);
config
.
dev
=
pdev
->
dev
.
parent
;
if
(
pdata
)
...
...
@@ -358,43 +331,12 @@ static struct platform_driver wm831x_gp_ldo_driver = {
* Analogue LDOs
*/
#define WM831X_ALDO_SELECTOR_LOW 0xc
#define WM831X_ALDO_MAX_SELECTOR 0x1f
static
int
wm831x_aldo_list_voltage
(
struct
regulator_dev
*
rdev
,
unsigned
int
selector
)
{
/* 1-1.6V in 50mV steps */
if
(
selector
<=
WM831X_ALDO_SELECTOR_LOW
)
return
1000000
+
(
selector
*
50000
);
/* 1.7-3.5V in 100mV steps */
if
(
selector
<=
WM831X_ALDO_MAX_SELECTOR
)
return
1600000
+
((
selector
-
WM831X_ALDO_SELECTOR_LOW
)
*
100000
);
return
-
EINVAL
;
}
static
int
wm831x_aldo_map_voltage
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
)
{
int
volt
,
vsel
;
if
(
min_uV
<
1000000
)
vsel
=
0
;
else
if
(
min_uV
<
1700000
)
vsel
=
((
min_uV
-
1000000
)
/
50000
);
else
vsel
=
((
min_uV
-
1700000
)
/
100000
)
+
WM831X_ALDO_SELECTOR_LOW
+
1
;
volt
=
wm831x_aldo_list_voltage
(
rdev
,
vsel
);
if
(
volt
<
min_uV
||
volt
>
max_uV
)
return
-
EINVAL
;
return
vsel
;
}
static
const
struct
regulator_linear_range
wm831x_aldo_ranges
[]
=
{
{
.
min_uV
=
1000000
,
.
max_uV
=
1650000
,
.
min_sel
=
0
,
.
max_sel
=
12
,
.
uV_step
=
50000
},
{
.
min_uV
=
1700000
,
.
max_uV
=
3500000
,
.
min_sel
=
13
,
.
max_sel
=
31
,
.
uV_step
=
100000
},
};
static
int
wm831x_aldo_set_suspend_voltage
(
struct
regulator_dev
*
rdev
,
int
uV
)
...
...
@@ -403,7 +345,7 @@ static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
struct
wm831x
*
wm831x
=
ldo
->
wm831x
;
int
sel
,
reg
=
ldo
->
base
+
WM831X_LDO_SLEEP_CONTROL
;
sel
=
wm831x_aldo_map_volta
ge
(
rdev
,
uV
,
uV
);
sel
=
regulator_map_voltage_linear_ran
ge
(
rdev
,
uV
,
uV
);
if
(
sel
<
0
)
return
sel
;
...
...
@@ -486,8 +428,8 @@ static int wm831x_aldo_get_status(struct regulator_dev *rdev)
}
static
struct
regulator_ops
wm831x_aldo_ops
=
{
.
list_voltage
=
wm831x_aldo_list_volta
ge
,
.
map_voltage
=
wm831x_aldo_map_volta
ge
,
.
list_voltage
=
regulator_list_voltage_linear_ran
ge
,
.
map_voltage
=
regulator_map_voltage_linear_ran
ge
,
.
get_voltage_sel
=
regulator_get_voltage_sel_regmap
,
.
set_voltage_sel
=
regulator_set_voltage_sel_regmap
,
.
set_suspend_voltage
=
wm831x_aldo_set_suspend_voltage
,
...
...
@@ -545,7 +487,9 @@ static int wm831x_aldo_probe(struct platform_device *pdev)
ldo
->
desc
.
id
=
id
;
ldo
->
desc
.
type
=
REGULATOR_VOLTAGE
;
ldo
->
desc
.
n_voltages
=
WM831X_ALDO_MAX_SELECTOR
+
1
;
ldo
->
desc
.
n_voltages
=
32
;
ldo
->
desc
.
linear_ranges
=
wm831x_aldo_ranges
;
ldo
->
desc
.
n_linear_ranges
=
ARRAY_SIZE
(
wm831x_aldo_ranges
);
ldo
->
desc
.
ops
=
&
wm831x_aldo_ops
;
ldo
->
desc
.
owner
=
THIS_MODULE
;
ldo
->
desc
.
vsel_reg
=
ldo
->
base
+
WM831X_LDO_ON_CONTROL
;
...
...
drivers/regulator/wm8350-regulator.c
View file @
28c37c9c
...
...
@@ -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
,
...
...
drivers/regulator/wm8400-regulator.c
View file @
28c37c9c
...
...
@@ -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
,
...
...
include/linux/regulator/driver.h
View file @
28c37c9c
...
...
@@ -39,6 +39,24 @@ enum regulator_status {
REGULATOR_STATUS_UNDEFINED
,
};
/**
* Specify a range of voltages for regulator_map_linar_range() and
* regulator_list_linear_range().
*
* @min_uV: Lowest voltage in range
* @max_uV: Highest voltage in range
* @min_sel: Lowest selector for range
* @max_sel: Highest selector for range
* @uV_step: Step size
*/
struct
regulator_linear_range
{
unsigned
int
min_uV
;
unsigned
int
max_uV
;
unsigned
int
min_sel
;
unsigned
int
max_sel
;
unsigned
int
uV_step
;
};
/**
* struct regulator_ops - regulator operations.
*
...
...
@@ -223,6 +241,9 @@ struct regulator_desc {
unsigned
int
linear_min_sel
;
unsigned
int
ramp_delay
;
const
struct
regulator_linear_range
*
linear_ranges
;
int
n_linear_ranges
;
const
unsigned
int
*
volt_table
;
unsigned
int
vsel_reg
;
...
...
@@ -326,10 +347,14 @@ int regulator_mode_to_status(unsigned int);
int
regulator_list_voltage_linear
(
struct
regulator_dev
*
rdev
,
unsigned
int
selector
);
int
regulator_list_voltage_linear_range
(
struct
regulator_dev
*
rdev
,
unsigned
int
selector
);
int
regulator_list_voltage_table
(
struct
regulator_dev
*
rdev
,
unsigned
int
selector
);
int
regulator_map_voltage_linear
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
);
int
regulator_map_voltage_linear_range
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
);
int
regulator_map_voltage_iterate
(
struct
regulator_dev
*
rdev
,
int
min_uV
,
int
max_uV
);
int
regulator_map_voltage_ascend
(
struct
regulator_dev
*
rdev
,
...
...
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