Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
5ff26a14
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5ff26a14
编写于
7月 02, 2013
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
regulator: wm831x-ldo: Convert to use linear ranges
Signed-off-by:
N
Mark Brown
<
broonie@linaro.org
>
上级
6692e432
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
80 deletion
+24
-80
drivers/regulator/wm831x-ldo.c
drivers/regulator/wm831x-ldo.c
+24
-80
未找到文件。
drivers/regulator/wm831x-ldo.c
浏览文件 @
5ff26a14
...
...
@@ -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
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录