Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
49992624
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
49992624
编写于
9月 11, 2012
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ASoC: wm8900: Convert to direct regmap API usage
Signed-off-by:
N
Mark Brown
<
broonie@opensource.wolfsonmicro.com
>
上级
6a58870d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
58 deletion
+90
-58
sound/soc/codecs/wm8900.c
sound/soc/codecs/wm8900.c
+90
-58
未找到文件。
sound/soc/codecs/wm8900.c
浏览文件 @
49992624
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/core.h>
...
@@ -137,7 +138,7 @@
...
@@ -137,7 +138,7 @@
#define WM8900_LRC_MASK 0x03ff
#define WM8900_LRC_MASK 0x03ff
struct
wm8900_priv
{
struct
wm8900_priv
{
enum
snd_soc_control_type
control_type
;
struct
regmap
*
regmap
;
u32
fll_in
;
/* FLL input frequency */
u32
fll_in
;
/* FLL input frequency */
u32
fll_out
;
/* FLL output frequency */
u32
fll_out
;
/* FLL output frequency */
...
@@ -147,54 +148,77 @@ struct wm8900_priv {
...
@@ -147,54 +148,77 @@ struct wm8900_priv {
* wm8900 register cache. We can't read the entire register space and we
* wm8900 register cache. We can't read the entire register space and we
* have slow control buses so we cache the registers.
* have slow control buses so we cache the registers.
*/
*/
static
const
u16
wm8900_reg_defaults
[
WM8900_MAXREG
]
=
{
static
const
struct
reg_default
wm8900_reg_defaults
[]
=
{
0x8900
,
0x0000
,
{
1
,
0x0000
},
0xc000
,
0x0000
,
{
2
,
0xc000
},
0x4050
,
0x4000
,
{
3
,
0x0000
},
0x0008
,
0x0000
,
{
4
,
0x4050
},
0x0040
,
0x0040
,
{
5
,
0x4000
},
0x1004
,
0x00c0
,
{
6
,
0x0008
},
0x00c0
,
0x0000
,
{
7
,
0x0000
},
0x0100
,
0x00c0
,
{
8
,
0x0040
},
0x00c0
,
0x0000
,
{
9
,
0x0040
},
0xb001
,
0x0000
,
{
10
,
0x1004
},
0x0000
,
0x0044
,
{
11
,
0x00c0
},
0x004c
,
0x004c
,
{
12
,
0x00c0
},
0x0044
,
0x0044
,
{
13
,
0x0000
},
0x0000
,
0x0044
,
{
14
,
0x0100
},
0x0000
,
0x0000
,
{
15
,
0x00c0
},
0x0002
,
0x0000
,
{
16
,
0x00c0
},
0x0000
,
0x0000
,
{
17
,
0x0000
},
0x0000
,
0x0000
,
{
18
,
0xb001
},
0x0008
,
0x0000
,
{
19
,
0x0000
},
0x0000
,
0x0008
,
{
20
,
0x0000
},
0x0097
,
0x0100
,
{
21
,
0x0044
},
0x0000
,
0x0000
,
{
22
,
0x004c
},
0x0050
,
0x0050
,
{
23
,
0x004c
},
0x0055
,
0x0055
,
{
24
,
0x0044
},
0x0055
,
0x0000
,
{
25
,
0x0044
},
0x0000
,
0x0079
,
{
26
,
0x0000
},
0x0079
,
0x0079
,
{
27
,
0x0044
},
0x0079
,
0x0000
,
{
28
,
0x0000
},
/* Remaining registers all zero */
{
29
,
0x0000
},
{
30
,
0x0002
},
{
31
,
0x0000
},
{
32
,
0x0000
},
{
33
,
0x0000
},
{
34
,
0x0000
},
{
35
,
0x0000
},
{
36
,
0x0008
},
{
37
,
0x0000
},
{
38
,
0x0000
},
{
39
,
0x0008
},
{
40
,
0x0097
},
{
41
,
0x0100
},
{
42
,
0x0000
},
{
43
,
0x0000
},
{
44
,
0x0050
},
{
45
,
0x0050
},
{
46
,
0x0055
},
{
47
,
0x0055
},
{
48
,
0x0055
},
{
49
,
0x0000
},
{
50
,
0x0000
},
{
51
,
0x0079
},
{
52
,
0x0079
},
{
53
,
0x0079
},
{
54
,
0x0079
},
{
55
,
0x0000
},
};
};
static
int
wm8900_volatile_register
(
struct
snd_soc_codec
*
codec
,
unsigned
int
reg
)
static
bool
wm8900_volatile_register
(
struct
device
*
dev
,
unsigned
int
reg
)
{
{
switch
(
reg
)
{
switch
(
reg
)
{
case
WM8900_REG_ID
:
case
WM8900_REG_ID
:
return
1
;
return
true
;
default:
default:
return
0
;
return
false
;
}
}
}
}
static
void
wm8900_reset
(
struct
snd_soc_codec
*
codec
)
static
void
wm8900_reset
(
struct
snd_soc_codec
*
codec
)
{
{
snd_soc_write
(
codec
,
WM8900_REG_RESET
,
0
);
snd_soc_write
(
codec
,
WM8900_REG_RESET
,
0
);
memcpy
(
codec
->
reg_cache
,
wm8900_reg_defaults
,
sizeof
(
wm8900_reg_defaults
));
}
}
static
int
wm8900_hp_event
(
struct
snd_soc_dapm_widget
*
w
,
static
int
wm8900_hp_event
(
struct
snd_soc_dapm_widget
*
w
,
...
@@ -1119,13 +1143,16 @@ static int wm8900_suspend(struct snd_soc_codec *codec)
...
@@ -1119,13 +1143,16 @@ static int wm8900_suspend(struct snd_soc_codec *codec)
static
int
wm8900_resume
(
struct
snd_soc_codec
*
codec
)
static
int
wm8900_resume
(
struct
snd_soc_codec
*
codec
)
{
{
struct
wm8900_priv
*
wm8900
=
snd_soc_codec_get_drvdata
(
codec
);
struct
wm8900_priv
*
wm8900
=
snd_soc_codec_get_drvdata
(
codec
);
u16
*
cache
;
int
ret
;
int
i
,
ret
;
cache
=
kmemdup
(
codec
->
reg_cache
,
sizeof
(
wm8900_reg_defaults
),
GFP_KERNEL
);
wm8900_reset
(
codec
);
wm8900_reset
(
codec
);
ret
=
regcache_sync
(
wm8900
->
regmap
);
if
(
ret
!=
0
)
{
dev_err
(
codec
->
dev
,
"Failed to restore cache: %d
\n
"
,
ret
);
return
ret
;
}
wm8900_set_bias_level
(
codec
,
SND_SOC_BIAS_STANDBY
);
wm8900_set_bias_level
(
codec
,
SND_SOC_BIAS_STANDBY
);
/* Restart the FLL? */
/* Restart the FLL? */
...
@@ -1139,27 +1166,18 @@ static int wm8900_resume(struct snd_soc_codec *codec)
...
@@ -1139,27 +1166,18 @@ static int wm8900_resume(struct snd_soc_codec *codec)
ret
=
wm8900_set_fll
(
codec
,
0
,
fll_in
,
fll_out
);
ret
=
wm8900_set_fll
(
codec
,
0
,
fll_in
,
fll_out
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
dev_err
(
codec
->
dev
,
"Failed to restart FLL
\n
"
);
dev_err
(
codec
->
dev
,
"Failed to restart FLL
\n
"
);
kfree
(
cache
);
return
ret
;
return
ret
;
}
}
}
}
if
(
cache
)
{
for
(
i
=
0
;
i
<
WM8900_MAXREG
;
i
++
)
snd_soc_write
(
codec
,
i
,
cache
[
i
]);
kfree
(
cache
);
}
else
dev_err
(
codec
->
dev
,
"Unable to allocate register cache
\n
"
);
return
0
;
return
0
;
}
}
static
int
wm8900_probe
(
struct
snd_soc_codec
*
codec
)
static
int
wm8900_probe
(
struct
snd_soc_codec
*
codec
)
{
{
struct
wm8900_priv
*
wm8900
=
snd_soc_codec_get_drvdata
(
codec
);
int
ret
=
0
,
reg
;
int
ret
=
0
,
reg
;
ret
=
snd_soc_codec_set_cache_io
(
codec
,
8
,
16
,
wm8900
->
control_type
);
ret
=
snd_soc_codec_set_cache_io
(
codec
,
8
,
16
,
SND_SOC_REGMAP
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
dev_err
(
codec
->
dev
,
"Failed to set cache I/O: %d
\n
"
,
ret
);
dev_err
(
codec
->
dev
,
"Failed to set cache I/O: %d
\n
"
,
ret
);
return
ret
;
return
ret
;
...
@@ -1207,10 +1225,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8900 = {
...
@@ -1207,10 +1225,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8900 = {
.
suspend
=
wm8900_suspend
,
.
suspend
=
wm8900_suspend
,
.
resume
=
wm8900_resume
,
.
resume
=
wm8900_resume
,
.
set_bias_level
=
wm8900_set_bias_level
,
.
set_bias_level
=
wm8900_set_bias_level
,
.
volatile_register
=
wm8900_volatile_register
,
.
reg_cache_size
=
ARRAY_SIZE
(
wm8900_reg_defaults
),
.
reg_word_size
=
sizeof
(
u16
),
.
reg_cache_default
=
wm8900_reg_defaults
,
.
controls
=
wm8900_snd_controls
,
.
controls
=
wm8900_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
wm8900_snd_controls
),
.
num_controls
=
ARRAY_SIZE
(
wm8900_snd_controls
),
...
@@ -1220,6 +1234,18 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8900 = {
...
@@ -1220,6 +1234,18 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8900 = {
.
num_dapm_routes
=
ARRAY_SIZE
(
wm8900_dapm_routes
),
.
num_dapm_routes
=
ARRAY_SIZE
(
wm8900_dapm_routes
),
};
};
static
const
struct
regmap_config
wm8900_regmap
=
{
.
reg_bits
=
8
,
.
val_bits
=
16
,
.
max_register
=
WM8900_MAXREG
,
.
reg_defaults
=
wm8900_reg_defaults
,
.
num_reg_defaults
=
ARRAY_SIZE
(
wm8900_reg_defaults
),
.
cache_type
=
REGCACHE_RBTREE
,
.
volatile_reg
=
wm8900_volatile_register
,
};
#if defined(CONFIG_SPI_MASTER)
#if defined(CONFIG_SPI_MASTER)
static
int
__devinit
wm8900_spi_probe
(
struct
spi_device
*
spi
)
static
int
__devinit
wm8900_spi_probe
(
struct
spi_device
*
spi
)
{
{
...
@@ -1231,7 +1257,10 @@ static int __devinit wm8900_spi_probe(struct spi_device *spi)
...
@@ -1231,7 +1257,10 @@ static int __devinit wm8900_spi_probe(struct spi_device *spi)
if
(
wm8900
==
NULL
)
if
(
wm8900
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
wm8900
->
control_type
=
SND_SOC_SPI
;
wm8900
->
regmap
=
devm_regmap_init_spi
(
spi
,
&
wm8900_regmap
);
if
(
IS_ERR
(
wm8900
->
regmap
))
return
PTR_ERR
(
wm8900
->
regmap
);
spi_set_drvdata
(
spi
,
wm8900
);
spi_set_drvdata
(
spi
,
wm8900
);
ret
=
snd_soc_register_codec
(
&
spi
->
dev
,
ret
=
snd_soc_register_codec
(
&
spi
->
dev
,
...
@@ -1268,8 +1297,11 @@ static __devinit int wm8900_i2c_probe(struct i2c_client *i2c,
...
@@ -1268,8 +1297,11 @@ static __devinit int wm8900_i2c_probe(struct i2c_client *i2c,
if
(
wm8900
==
NULL
)
if
(
wm8900
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
wm8900
->
regmap
=
devm_regmap_init_i2c
(
i2c
,
&
wm8900_regmap
);
if
(
IS_ERR
(
wm8900
->
regmap
))
return
PTR_ERR
(
wm8900
->
regmap
);
i2c_set_clientdata
(
i2c
,
wm8900
);
i2c_set_clientdata
(
i2c
,
wm8900
);
wm8900
->
control_type
=
SND_SOC_I2C
;
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
&
soc_codec_dev_wm8900
,
&
wm8900_dai
,
1
);
&
soc_codec_dev_wm8900
,
&
wm8900_dai
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录