Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
05d448e2
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
161
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
05d448e2
编写于
11月 21, 2011
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ASoC: Convert WM8731 to direct regmap API usage
Signed-off-by:
N
Mark Brown
<
broonie@opensource.wolfsonmicro.com
>
上级
5091f5b7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
23 deletion
+86
-23
sound/soc/codecs/wm8731.c
sound/soc/codecs/wm8731.c
+86
-23
未找到文件。
sound/soc/codecs/wm8731.c
浏览文件 @
05d448e2
...
...
@@ -19,6 +19,7 @@
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/of_device.h>
...
...
@@ -41,7 +42,7 @@ static const char *wm8731_supply_names[WM8731_NUM_SUPPLIES] = {
/* codec private data */
struct
wm8731_priv
{
enum
snd_soc_control_type
control_type
;
struct
regmap
*
regmap
;
struct
regulator_bulk_data
supplies
[
WM8731_NUM_SUPPLIES
];
unsigned
int
sysclk
;
int
sysclk_type
;
...
...
@@ -52,16 +53,30 @@ struct wm8731_priv {
/*
* wm8731 register cache
* We can't read the WM8731 register space when we are
* using 2 wire for device control, so we cache them instead.
* There is no point in caching the reset register
*/
static
const
u16
wm8731_reg
[
WM8731_CACHEREGNUM
]
=
{
0x0097
,
0x0097
,
0x0079
,
0x0079
,
0x000a
,
0x0008
,
0x009f
,
0x000a
,
0x0000
,
0x0000
static
const
struct
reg_default
wm8731_reg_defaults
[]
=
{
{
0
,
0x0097
},
{
1
,
0x0097
},
{
2
,
0x0079
},
{
3
,
0x0079
},
{
4
,
0x000a
},
{
5
,
0x0008
},
{
6
,
0x009f
},
{
7
,
0x000a
},
{
8
,
0x0000
},
{
9
,
0x0000
},
};
static
bool
wm8731_volatile
(
struct
device
*
dev
,
unsigned
int
reg
)
{
return
reg
==
WM8731_RESET
;
}
static
bool
wm8731_writeable
(
struct
device
*
dev
,
unsigned
int
reg
)
{
return
reg
<=
WM8731_RESET
;
}
#define wm8731_reset(c) snd_soc_write(c, WM8731_RESET, 0)
static
const
char
*
wm8731_input_select
[]
=
{
"Line In"
,
"Mic"
};
...
...
@@ -441,7 +456,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec,
if
(
ret
!=
0
)
return
ret
;
snd_soc_cache_sync
(
codec
);
regcache_sync
(
wm8731
->
regmap
);
}
/* Clear PWROFF, gate CLKOUT, everything else as-is */
...
...
@@ -452,7 +467,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec,
snd_soc_write
(
codec
,
WM8731_PWR
,
0xffff
);
regulator_bulk_disable
(
ARRAY_SIZE
(
wm8731
->
supplies
),
wm8731
->
supplies
);
codec
->
cache_sync
=
1
;
regcache_mark_dirty
(
wm8731
->
regmap
)
;
break
;
}
codec
->
dapm
.
bias_level
=
level
;
...
...
@@ -513,7 +528,8 @@ static int wm8731_probe(struct snd_soc_codec *codec)
struct
wm8731_priv
*
wm8731
=
snd_soc_codec_get_drvdata
(
codec
);
int
ret
=
0
,
i
;
ret
=
snd_soc_codec_set_cache_io
(
codec
,
7
,
9
,
wm8731
->
control_type
);
codec
->
control_data
=
wm8731
->
regmap
;
ret
=
snd_soc_codec_set_cache_io
(
codec
,
7
,
9
,
SND_SOC_REGMAP
);
if
(
ret
<
0
)
{
dev_err
(
codec
->
dev
,
"Failed to set cache I/O: %d
\n
"
,
ret
);
return
ret
;
...
...
@@ -585,9 +601,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8731 = {
.
suspend
=
wm8731_suspend
,
.
resume
=
wm8731_resume
,
.
set_bias_level
=
wm8731_set_bias_level
,
.
reg_cache_size
=
ARRAY_SIZE
(
wm8731_reg
),
.
reg_word_size
=
sizeof
(
u16
),
.
reg_cache_default
=
wm8731_reg
,
.
dapm_widgets
=
wm8731_dapm_widgets
,
.
num_dapm_widgets
=
ARRAY_SIZE
(
wm8731_dapm_widgets
),
.
dapm_routes
=
wm8731_intercon
,
...
...
@@ -603,6 +616,19 @@ static const struct of_device_id wm8731_of_match[] = {
MODULE_DEVICE_TABLE
(
of
,
wm8731_of_match
);
static
const
struct
regmap_config
wm8731_regmap
=
{
.
reg_bits
=
7
,
.
val_bits
=
9
,
.
max_register
=
WM8731_RESET
,
.
volatile_reg
=
wm8731_volatile
,
.
writeable_reg
=
wm8731_writeable
,
.
cache_type
=
REGCACHE_RBTREE
,
.
reg_defaults
=
wm8731_reg_defaults
,
.
num_reg_defaults
=
ARRAY_SIZE
(
wm8731_reg_defaults
),
};
#if defined(CONFIG_SPI_MASTER)
static
int
__devinit
wm8731_spi_probe
(
struct
spi_device
*
spi
)
{
...
...
@@ -613,20 +639,39 @@ static int __devinit wm8731_spi_probe(struct spi_device *spi)
if
(
wm8731
==
NULL
)
return
-
ENOMEM
;
wm8731
->
control_type
=
SND_SOC_SPI
;
wm8731
->
regmap
=
regmap_init_spi
(
spi
,
&
wm8731_regmap
);
if
(
IS_ERR
(
wm8731
->
regmap
))
{
ret
=
PTR_ERR
(
wm8731
->
regmap
);
dev_err
(
&
spi
->
dev
,
"Failed to allocate register map: %d
\n
"
,
ret
);
goto
err
;
}
spi_set_drvdata
(
spi
,
wm8731
);
ret
=
snd_soc_register_codec
(
&
spi
->
dev
,
&
soc_codec_dev_wm8731
,
&
wm8731_dai
,
1
);
if
(
ret
<
0
)
kfree
(
wm8731
);
if
(
ret
!=
0
)
{
dev_err
(
&
spi
->
dev
,
"Failed to register CODEC: %d
\n
"
,
ret
);
goto
err_regmap
;
}
return
0
;
err_regmap:
regmap_exit
(
wm8731
->
regmap
);
err:
kfree
(
wm8731
);
return
ret
;
}
static
int
__devexit
wm8731_spi_remove
(
struct
spi_device
*
spi
)
{
struct
wm8731_priv
*
wm8731
=
spi_get_drvdata
(
spi
);
snd_soc_unregister_codec
(
&
spi
->
dev
);
kfree
(
spi_get_drvdata
(
spi
));
regmap_exit
(
wm8731
->
regmap
);
kfree
(
wm8731
);
return
0
;
}
...
...
@@ -652,20 +697,38 @@ static __devinit int wm8731_i2c_probe(struct i2c_client *i2c,
if
(
wm8731
==
NULL
)
return
-
ENOMEM
;
wm8731
->
regmap
=
regmap_init_i2c
(
i2c
,
&
wm8731_regmap
);
if
(
IS_ERR
(
wm8731
->
regmap
))
{
ret
=
PTR_ERR
(
wm8731
->
regmap
);
dev_err
(
&
i2c
->
dev
,
"Failed to allocate register map: %d
\n
"
,
ret
);
goto
err
;
}
i2c_set_clientdata
(
i2c
,
wm8731
);
wm8731
->
control_type
=
SND_SOC_I2C
;
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
ret
=
snd_soc_register_codec
(
&
i2c
->
dev
,
&
soc_codec_dev_wm8731
,
&
wm8731_dai
,
1
);
if
(
ret
<
0
)
kfree
(
wm8731
);
if
(
ret
!=
0
)
{
dev_err
(
&
i2c
->
dev
,
"Failed to register CODEC: %d
\n
"
,
ret
);
goto
err_regmap
;
}
return
0
;
err_regmap:
regmap_exit
(
wm8731
->
regmap
);
err:
kfree
(
wm8731
);
return
ret
;
}
static
__devexit
int
wm8731_i2c_remove
(
struct
i2c_client
*
client
)
{
struct
wm8731_priv
*
wm8731
=
i2c_get_clientdata
(
client
);
snd_soc_unregister_codec
(
&
client
->
dev
);
kfree
(
i2c_get_clientdata
(
client
));
regmap_exit
(
wm8731
->
regmap
);
kfree
(
wm8731
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录