Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
50eeef5d
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
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看板
提交
50eeef5d
编写于
8月 09, 2011
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mfd: Convert WM8400 to regmap API
Signed-off-by:
N
Mark Brown
<
broonie@opensource.wolfsonmicro.com
>
上级
d6c645fc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
81 deletion
+32
-81
drivers/mfd/wm8400-core.c
drivers/mfd/wm8400-core.c
+29
-77
include/linux/mfd/wm8400-private.h
include/linux/mfd/wm8400-private.h
+3
-4
未找到文件。
drivers/mfd/wm8400-core.c
浏览文件 @
50eeef5d
...
...
@@ -13,11 +13,13 @@
*/
#include <linux/bug.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/mfd/core.h>
#include <linux/mfd/wm8400-private.h>
#include <linux/mfd/wm8400-audio.h>
#include <linux/regmap.h>
#include <linux/slab.h>
static
struct
{
...
...
@@ -123,14 +125,9 @@ static int wm8400_read(struct wm8400 *wm8400, u8 reg, int num_regs, u16 *dest)
/* If there are any volatile reads then read back the entire block */
for
(
i
=
reg
;
i
<
reg
+
num_regs
;
i
++
)
if
(
reg_data
[
i
].
vol
)
{
ret
=
wm8400
->
read_dev
(
wm8400
->
io_data
,
reg
,
num_regs
,
dest
);
if
(
ret
!=
0
)
return
ret
;
for
(
i
=
0
;
i
<
num_regs
;
i
++
)
dest
[
i
]
=
be16_to_cpu
(
dest
[
i
]);
return
0
;
ret
=
regmap_bulk_read
(
wm8400
->
regmap
,
reg
,
dest
,
num_regs
);
return
ret
;
}
/* Otherwise use the cache */
...
...
@@ -149,14 +146,11 @@ static int wm8400_write(struct wm8400 *wm8400, u8 reg, int num_regs,
for
(
i
=
0
;
i
<
num_regs
;
i
++
)
{
BUG_ON
(
!
reg_data
[
reg
+
i
].
writable
);
wm8400
->
reg_cache
[
reg
+
i
]
=
src
[
i
];
src
[
i
]
=
cpu_to_be16
(
src
[
i
]);
ret
=
regmap_write
(
wm8400
->
regmap
,
reg
,
src
[
i
]);
if
(
ret
!=
0
)
return
ret
;
}
/* Do the actual I/O */
ret
=
wm8400
->
write_dev
(
wm8400
->
io_data
,
reg
,
num_regs
,
src
);
if
(
ret
!=
0
)
return
-
EIO
;
return
0
;
}
...
...
@@ -270,14 +264,14 @@ static int wm8400_init(struct wm8400 *wm8400,
dev_set_drvdata
(
wm8400
->
dev
,
wm8400
);
/* Check that this is actually a WM8400 */
ret
=
wm8400
->
read_dev
(
wm8400
->
io_data
,
WM8400_RESET_ID
,
1
,
&
reg
);
ret
=
regmap_read
(
wm8400
->
regmap
,
WM8400_RESET_ID
,
&
i
);
if
(
ret
!=
0
)
{
dev_err
(
wm8400
->
dev
,
"Chip ID register read failed
\n
"
);
return
-
EIO
;
}
if
(
be16_to_cpu
(
reg
)
!=
reg_data
[
WM8400_RESET_ID
].
default_val
)
{
if
(
i
!=
reg_data
[
WM8400_RESET_ID
].
default_val
)
{
dev_err
(
wm8400
->
dev
,
"Device is not a WM8400, ID is %x
\n
"
,
be16_to_cpu
(
reg
)
);
reg
);
return
-
ENODEV
;
}
...
...
@@ -285,9 +279,8 @@ static int wm8400_init(struct wm8400 *wm8400,
* is a PMIC we can't reset it safely so initialise the register
* cache from the hardware.
*/
ret
=
wm8400
->
read_dev
(
wm8400
->
io_data
,
0
,
ARRAY_SIZE
(
wm8400
->
reg_cache
),
wm8400
->
reg_cache
);
ret
=
regmap_raw_read
(
wm8400
->
regmap
,
0
,
wm8400
->
reg_cache
,
ARRAY_SIZE
(
wm8400
->
reg_cache
));
if
(
ret
!=
0
)
{
dev_err
(
wm8400
->
dev
,
"Register cache read failed
\n
"
);
return
-
EIO
;
...
...
@@ -337,60 +330,13 @@ static void wm8400_release(struct wm8400 *wm8400)
mfd_remove_devices
(
wm8400
->
dev
);
}
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
static
int
wm8400_i2c_read
(
void
*
io_data
,
char
reg
,
int
count
,
u16
*
dest
)
{
struct
i2c_client
*
i2c
=
io_data
;
struct
i2c_msg
xfer
[
2
];
int
ret
;
/* Write register */
xfer
[
0
].
addr
=
i2c
->
addr
;
xfer
[
0
].
flags
=
0
;
xfer
[
0
].
len
=
1
;
xfer
[
0
].
buf
=
&
reg
;
/* Read data */
xfer
[
1
].
addr
=
i2c
->
addr
;
xfer
[
1
].
flags
=
I2C_M_RD
;
xfer
[
1
].
len
=
count
*
sizeof
(
u16
);
xfer
[
1
].
buf
=
(
u8
*
)
dest
;
ret
=
i2c_transfer
(
i2c
->
adapter
,
xfer
,
2
);
if
(
ret
==
2
)
ret
=
0
;
else
if
(
ret
>=
0
)
ret
=
-
EIO
;
return
ret
;
}
static
int
wm8400_i2c_write
(
void
*
io_data
,
char
reg
,
int
count
,
const
u16
*
src
)
{
struct
i2c_client
*
i2c
=
io_data
;
u8
*
msg
;
int
ret
;
/* We add 1 byte for device register - ideally I2C would gather. */
msg
=
kmalloc
((
count
*
sizeof
(
u16
))
+
1
,
GFP_KERNEL
);
if
(
msg
==
NULL
)
return
-
ENOMEM
;
msg
[
0
]
=
reg
;
memcpy
(
&
msg
[
1
],
src
,
count
*
sizeof
(
u16
));
ret
=
i2c_master_send
(
i2c
,
msg
,
(
count
*
sizeof
(
u16
))
+
1
);
if
(
ret
==
(
count
*
2
)
+
1
)
ret
=
0
;
else
if
(
ret
>=
0
)
ret
=
-
EIO
;
kfree
(
msg
);
return
ret
;
}
static
const
struct
regmap_config
wm8400_regmap_config
=
{
.
reg_bits
=
8
,
.
val_bits
=
16
,
.
max_register
=
WM8400_REGISTER_COUNT
-
1
,
};
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
static
int
wm8400_i2c_probe
(
struct
i2c_client
*
i2c
,
const
struct
i2c_device_id
*
id
)
{
...
...
@@ -403,18 +349,23 @@ static int wm8400_i2c_probe(struct i2c_client *i2c,
goto
err
;
}
wm8400
->
io_data
=
i2c
;
wm8400
->
read_dev
=
wm8400_i2c_read
;
wm8400
->
write_dev
=
wm8400_i2c_write
;
wm8400
->
regmap
=
regmap_init_i2c
(
i2c
,
&
wm8400_regmap_config
);
if
(
IS_ERR
(
wm8400
->
regmap
))
{
ret
=
PTR_ERR
(
wm8400
->
regmap
);
goto
struct_err
;
}
wm8400
->
dev
=
&
i2c
->
dev
;
i2c_set_clientdata
(
i2c
,
wm8400
);
ret
=
wm8400_init
(
wm8400
,
i2c
->
dev
.
platform_data
);
if
(
ret
!=
0
)
goto
struct
_err
;
goto
map
_err
;
return
0
;
map_err:
regmap_exit
(
wm8400
->
regmap
);
struct_err:
kfree
(
wm8400
);
err:
...
...
@@ -426,6 +377,7 @@ static int wm8400_i2c_remove(struct i2c_client *i2c)
struct
wm8400
*
wm8400
=
i2c_get_clientdata
(
i2c
);
wm8400_release
(
wm8400
);
regmap_exit
(
wm8400
->
regmap
);
kfree
(
wm8400
);
return
0
;
...
...
include/linux/mfd/wm8400-private.h
浏览文件 @
50eeef5d
...
...
@@ -25,16 +25,15 @@
#include <linux/mutex.h>
#include <linux/platform_device.h>
struct
regmap
;
#define WM8400_REGISTER_COUNT 0x55
struct
wm8400
{
struct
device
*
dev
;
int
(
*
read_dev
)(
void
*
data
,
char
reg
,
int
count
,
u16
*
dst
);
int
(
*
write_dev
)(
void
*
data
,
char
reg
,
int
count
,
const
u16
*
src
);
struct
mutex
io_lock
;
void
*
io_data
;
struct
regmap
*
regmap
;
u16
reg_cache
[
WM8400_REGISTER_COUNT
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录