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
38cdaddf
Commit
38cdaddf
authored
Jul 20, 2016
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regulator/topic/axp20x' into regulator-next
parents
02214f10
636e2a39
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
28 deletions
+125
-28
Documentation/devicetree/bindings/mfd/axp20x.txt
Documentation/devicetree/bindings/mfd/axp20x.txt
+6
-0
drivers/regulator/axp20x-regulator.c
drivers/regulator/axp20x-regulator.c
+119
-28
No files found.
Documentation/devicetree/bindings/mfd/axp20x.txt
View file @
38cdaddf
...
...
@@ -22,6 +22,11 @@ Optional properties:
AXP152/20X: range: 750-1875, Default: 1.5 MHz
AXP22X/80X: range: 1800-4050, Default: 3 MHz
- x-powers,drive-vbus-en: axp221 / axp223 only boolean, set this when the
N_VBUSEN pin is used as an output pin to control an external
regulator to drive the OTG VBus, rather then as an input pin
which signals whether the board is driving OTG VBus or not.
- <input>-supply: a phandle to the regulator supply node. May be omitted if
inputs are unregulated, such as using the IPSOUT output
from the PMIC.
...
...
@@ -79,6 +84,7 @@ ELDO3 : LDO : eldoin-supply : shared supply
LDO_IO0 : LDO : ips-supply : GPIO 0
LDO_IO1 : LDO : ips-supply : GPIO 1
RTC_LDO : LDO : ips-supply : always on
DRIVEVBUS : Enable output : drivevbus-supply : external regulator
AXP809 regulators, type, and corresponding input supply names:
...
...
drivers/regulator/axp20x-regulator.c
View file @
38cdaddf
...
...
@@ -36,6 +36,8 @@
#define AXP20X_FREQ_DCDC_MASK 0x0f
#define AXP22X_MISC_N_VBUSEN_FUNC BIT(4)
#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _enable_val, _disable_val) \
[_family##_##_id] = { \
...
...
@@ -230,6 +232,73 @@ static const struct regulator_desc axp22x_regulators[] = {
AXP_DESC_FIXED
(
AXP22X
,
RTC_LDO
,
"rtc_ldo"
,
"ips"
,
3000
),
};
static
const
struct
regulator_desc
axp22x_drivevbus_regulator
=
{
.
name
=
"drivevbus"
,
.
supply_name
=
"drivevbus"
,
.
of_match
=
of_match_ptr
(
"drivevbus"
),
.
regulators_node
=
of_match_ptr
(
"regulators"
),
.
type
=
REGULATOR_VOLTAGE
,
.
owner
=
THIS_MODULE
,
.
enable_reg
=
AXP20X_VBUS_IPSOUT_MGMT
,
.
enable_mask
=
BIT
(
2
),
.
ops
=
&
axp20x_ops_sw
,
};
static
const
struct
regulator_linear_range
axp809_dcdc4_ranges
[]
=
{
REGULATOR_LINEAR_RANGE
(
600000
,
0x0
,
0x2f
,
20000
),
REGULATOR_LINEAR_RANGE
(
1800000
,
0x30
,
0x38
,
100000
),
};
static
const
struct
regulator_linear_range
axp809_dldo1_ranges
[]
=
{
REGULATOR_LINEAR_RANGE
(
700000
,
0x0
,
0x1a
,
100000
),
REGULATOR_LINEAR_RANGE
(
3400000
,
0x1b
,
0x1f
,
200000
),
};
static
const
struct
regulator_desc
axp809_regulators
[]
=
{
AXP_DESC
(
AXP809
,
DCDC1
,
"dcdc1"
,
"vin1"
,
1600
,
3400
,
100
,
AXP22X_DCDC1_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
1
)),
AXP_DESC
(
AXP809
,
DCDC2
,
"dcdc2"
,
"vin2"
,
600
,
1540
,
20
,
AXP22X_DCDC2_V_OUT
,
0x3f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
2
)),
AXP_DESC
(
AXP809
,
DCDC3
,
"dcdc3"
,
"vin3"
,
600
,
1860
,
20
,
AXP22X_DCDC3_V_OUT
,
0x3f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
3
)),
AXP_DESC_RANGES
(
AXP809
,
DCDC4
,
"dcdc4"
,
"vin4"
,
axp809_dcdc4_ranges
,
57
,
AXP22X_DCDC4_V_OUT
,
0x3f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
4
)),
AXP_DESC
(
AXP809
,
DCDC5
,
"dcdc5"
,
"vin5"
,
1000
,
2550
,
50
,
AXP22X_DCDC5_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
5
)),
/* secondary switchable output of DCDC1 */
AXP_DESC_SW
(
AXP809
,
DC1SW
,
"dc1sw"
,
NULL
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
7
)),
/* LDO regulator internally chained to DCDC5 */
AXP_DESC
(
AXP809
,
DC5LDO
,
"dc5ldo"
,
NULL
,
700
,
1400
,
100
,
AXP22X_DC5LDO_V_OUT
,
0x7
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
0
)),
AXP_DESC
(
AXP809
,
ALDO1
,
"aldo1"
,
"aldoin"
,
700
,
3300
,
100
,
AXP22X_ALDO1_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
6
)),
AXP_DESC
(
AXP809
,
ALDO2
,
"aldo2"
,
"aldoin"
,
700
,
3300
,
100
,
AXP22X_ALDO2_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL1
,
BIT
(
7
)),
AXP_DESC
(
AXP809
,
ALDO3
,
"aldo3"
,
"aldoin"
,
700
,
3300
,
100
,
AXP22X_ALDO3_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
5
)),
AXP_DESC_RANGES
(
AXP809
,
DLDO1
,
"dldo1"
,
"dldoin"
,
axp809_dldo1_ranges
,
32
,
AXP22X_DLDO1_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
3
)),
AXP_DESC
(
AXP809
,
DLDO2
,
"dldo2"
,
"dldoin"
,
700
,
3300
,
100
,
AXP22X_DLDO2_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
4
)),
AXP_DESC
(
AXP809
,
ELDO1
,
"eldo1"
,
"eldoin"
,
700
,
3300
,
100
,
AXP22X_ELDO1_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
0
)),
AXP_DESC
(
AXP809
,
ELDO2
,
"eldo2"
,
"eldoin"
,
700
,
3300
,
100
,
AXP22X_ELDO2_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
1
)),
AXP_DESC
(
AXP809
,
ELDO3
,
"eldo3"
,
"eldoin"
,
700
,
3300
,
100
,
AXP22X_ELDO3_V_OUT
,
0x1f
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
2
)),
AXP_DESC_IO
(
AXP809
,
LDO_IO0
,
"ldo_io0"
,
"ips"
,
700
,
3300
,
100
,
AXP22X_LDO_IO0_V_OUT
,
0x1f
,
AXP20X_GPIO0_CTRL
,
0x07
,
AXP22X_IO_ENABLED
,
AXP22X_IO_DISABLED
),
AXP_DESC_IO
(
AXP809
,
LDO_IO1
,
"ldo_io1"
,
"ips"
,
700
,
3300
,
100
,
AXP22X_LDO_IO1_V_OUT
,
0x1f
,
AXP20X_GPIO1_CTRL
,
0x07
,
AXP22X_IO_ENABLED
,
AXP22X_IO_DISABLED
),
AXP_DESC_FIXED
(
AXP809
,
RTC_LDO
,
"rtc_ldo"
,
"ips"
,
1800
),
AXP_DESC_SW
(
AXP809
,
SW
,
"sw"
,
"swin"
,
AXP22X_PWR_OUT_CTRL2
,
BIT
(
6
)),
};
static
int
axp20x_set_dcdc_freq
(
struct
platform_device
*
pdev
,
u32
dcdcfreq
)
{
struct
axp20x_dev
*
axp20x
=
dev_get_drvdata
(
pdev
->
dev
.
parent
);
...
...
@@ -245,6 +314,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
break
;
case
AXP221_ID
:
case
AXP223_ID
:
case
AXP809_ID
:
min
=
1800
;
max
=
4050
;
def
=
3000
;
...
...
@@ -324,6 +394,7 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
case
AXP221_ID
:
case
AXP223_ID
:
case
AXP809_ID
:
if
(
id
<
AXP22X_DCDC1
||
id
>
AXP22X_DCDC5
)
return
-
EINVAL
;
...
...
@@ -352,8 +423,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
};
int
ret
,
i
,
nregulators
;
u32
workmode
;
const
char
*
axp22x_dc1_name
=
axp22x_regulators
[
AXP22X_DCDC1
].
name
;
const
char
*
axp22x_dc5_name
=
axp22x_regulators
[
AXP22X_DCDC5
].
name
;
const
char
*
dcdc1_name
=
axp22x_regulators
[
AXP22X_DCDC1
].
name
;
const
char
*
dcdc5_name
=
axp22x_regulators
[
AXP22X_DCDC5
].
name
;
bool
drivevbus
=
false
;
switch
(
axp20x
->
variant
)
{
case
AXP202_ID
:
...
...
@@ -365,6 +437,12 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
case
AXP223_ID
:
regulators
=
axp22x_regulators
;
nregulators
=
AXP22X_REG_ID_MAX
;
drivevbus
=
of_property_read_bool
(
pdev
->
dev
.
parent
->
of_node
,
"x-powers,drive-vbus-en"
);
break
;
case
AXP809_ID
:
regulators
=
axp809_regulators
;
nregulators
=
AXP809_REG_ID_MAX
;
break
;
default:
dev_err
(
&
pdev
->
dev
,
"Unsupported AXP variant: %ld
\n
"
,
...
...
@@ -388,23 +466,23 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
* part of this loop to see where we save the DT defined
* name.
*/
if
(
regulators
==
axp22x_regulators
)
{
if
(
i
==
AXP22X_DC1SW
)
{
new_desc
=
devm_kzalloc
(
&
pdev
->
dev
,
sizeof
(
*
desc
),
if
((
regulators
==
axp22x_regulators
&&
i
==
AXP22X_DC1SW
)
||
(
regulators
==
axp809_regulators
&&
i
==
AXP809_DC1SW
))
{
new_desc
=
devm_kzalloc
(
&
pdev
->
dev
,
sizeof
(
*
desc
),
GFP_KERNEL
);
*
new_desc
=
regulators
[
i
];
new_desc
->
supply_name
=
axp22x_
dc1_name
;
new_desc
->
supply_name
=
dc
dc1_name
;
desc
=
new_desc
;
}
else
if
(
i
==
AXP22X_DC5LDO
)
{
new_desc
=
devm_kzalloc
(
&
pdev
->
dev
,
sizeof
(
*
desc
),
}
if
((
regulators
==
axp22x_regulators
&&
i
==
AXP22X_DC5LDO
)
||
(
regulators
==
axp809_regulators
&&
i
==
AXP809_DC5LDO
))
{
new_desc
=
devm_kzalloc
(
&
pdev
->
dev
,
sizeof
(
*
desc
),
GFP_KERNEL
);
*
new_desc
=
regulators
[
i
];
new_desc
->
supply_name
=
axp22x_
dc5_name
;
new_desc
->
supply_name
=
dc
dc5_name
;
desc
=
new_desc
;
}
}
rdev
=
devm_regulator_register
(
&
pdev
->
dev
,
desc
,
&
config
);
if
(
IS_ERR
(
rdev
))
{
...
...
@@ -426,16 +504,29 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
/*
* Save AXP22X DCDC1 / DCDC5 regulator names for later.
*/
if
(
regulators
==
axp22x_regulators
)
{
/* Can we use rdev->constraints->name instead? */
if
(
i
==
AXP22X_DCDC1
)
if
((
regulators
==
axp22x_regulators
&&
i
==
AXP22X_DCDC1
)
||
(
regulators
==
axp809_regulators
&&
i
==
AXP809_DCDC1
))
of_property_read_string
(
rdev
->
dev
.
of_node
,
"regulator-name"
,
&
axp22x_dc1_name
);
else
if
(
i
==
AXP22X_DCDC5
)
&
dcdc1_name
);
if
((
regulators
==
axp22x_regulators
&&
i
==
AXP22X_DCDC5
)
||
(
regulators
==
axp809_regulators
&&
i
==
AXP809_DCDC5
))
of_property_read_string
(
rdev
->
dev
.
of_node
,
"regulator-name"
,
&
axp22x_dc5_name
);
&
dcdc5_name
);
}
if
(
drivevbus
)
{
/* Change N_VBUSEN sense pin to DRIVEVBUS output pin */
regmap_update_bits
(
axp20x
->
regmap
,
AXP20X_OVER_TMP
,
AXP22X_MISC_N_VBUSEN_FUNC
,
0
);
rdev
=
devm_regulator_register
(
&
pdev
->
dev
,
&
axp22x_drivevbus_regulator
,
&
config
);
if
(
IS_ERR
(
rdev
))
{
dev_err
(
&
pdev
->
dev
,
"Failed to register drivevbus
\n
"
);
return
PTR_ERR
(
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