Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
6b8c90f2
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看板
提交
6b8c90f2
编写于
8月 29, 2008
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
envctrl: Convert to pure OF driver.
Signed-off-by:
N
David S. Miller
<
davem@davemloft.net
>
上级
95d43905
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
68 deletion
+79
-68
drivers/sbus/char/envctrl.c
drivers/sbus/char/envctrl.c
+79
-68
未找到文件。
drivers/sbus/char/envctrl.c
浏览文件 @
6b8c90f2
/* $Id: envctrl.c,v 1.25 2002/01/15 09:01:26 davem Exp $
* envctrl.c: Temperature and Fan monitoring on Machines providing it.
/* envctrl.c: Temperature and Fan monitoring on Machines providing it.
*
* Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
* Copyright (C) 2000 Vinh Truong (vinh.truong@eng.sun.com)
...
...
@@ -28,12 +27,16 @@
#include <linux/kmod.h>
#include <linux/reboot.h>
#include <linux/smp_lock.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <asm/ebus.h>
#include <asm/uaccess.h>
#include <asm/envctrl.h>
#include <asm/io.h>
#define DRIVER_NAME "envctrl"
#define PFX DRIVER_NAME ": "
#define ENVCTRL_MINOR 162
#define PCF8584_ADDRESS 0x55
...
...
@@ -193,7 +196,7 @@ static void envtrl_i2c_test_pin(void)
}
if
(
limit
<=
0
)
printk
(
KERN_INFO
"envctrl:
Pin status will not clear.
\n
"
);
printk
(
KERN_INFO
PFX
"
Pin status will not clear.
\n
"
);
}
/* Function Description: Test busy bit.
...
...
@@ -211,7 +214,7 @@ static void envctrl_i2c_test_bb(void)
}
if
(
limit
<=
0
)
printk
(
KERN_INFO
"envctrl:
Busy bit will not clear.
\n
"
);
printk
(
KERN_INFO
PFX
"
Busy bit will not clear.
\n
"
);
}
/* Function Description: Send the address for a read access.
...
...
@@ -858,11 +861,10 @@ static void envctrl_init_voltage_status(struct i2c_child_t *pchild)
/* Function Description: Initialize i2c child device.
* Return: None.
*/
static
void
envctrl_init_i2c_child
(
struct
linux_ebus_child
*
edev_child
,
static
void
envctrl_init_i2c_child
(
struct
device_node
*
dp
,
struct
i2c_child_t
*
pchild
)
{
int
len
,
i
,
tbls_size
=
0
;
struct
device_node
*
dp
=
edev_child
->
prom_node
;
const
void
*
pval
;
/* Get device address. */
...
...
@@ -882,12 +884,12 @@ static void envctrl_init_i2c_child(struct linux_ebus_child *edev_child,
pchild
->
tables
=
kmalloc
(
tbls_size
,
GFP_KERNEL
);
if
(
pchild
->
tables
==
NULL
){
printk
(
"envctrl:
Failed to allocate table.
\n
"
);
printk
(
KERN_ERR
PFX
"
Failed to allocate table.
\n
"
);
return
;
}
pval
=
of_get_property
(
dp
,
"tables"
,
&
len
);
if
(
!
pval
||
len
<=
0
)
{
printk
(
"envctrl:
Failed to get table.
\n
"
);
printk
(
KERN_ERR
PFX
"
Failed to get table.
\n
"
);
return
;
}
memcpy
(
pchild
->
tables
,
pval
,
len
);
...
...
@@ -993,14 +995,14 @@ static int kenvctrld(void *__unused)
struct
i2c_child_t
*
cputemp
;
if
(
NULL
==
(
cputemp
=
envctrl_get_i2c_child
(
ENVCTRL_CPUTEMP_MON
)))
{
printk
(
KERN_ERR
"
envctrl:
kenvctrld unable to monitor CPU temp-- exiting
\n
"
);
printk
(
KERN_ERR
PFX
"kenvctrld unable to monitor CPU temp-- exiting
\n
"
);
return
-
ENODEV
;
}
poll_interval
=
5000
;
/* TODO env_mon_interval */
printk
(
KERN_INFO
"envctrl:
%s starting...
\n
"
,
current
->
comm
);
printk
(
KERN_INFO
PFX
"
%s starting...
\n
"
,
current
->
comm
);
for
(;;)
{
msleep_interruptible
(
poll_interval
);
...
...
@@ -1022,54 +1024,35 @@ static int kenvctrld(void *__unused)
}
}
}
printk
(
KERN_INFO
"envctrl:
%s exiting...
\n
"
,
current
->
comm
);
printk
(
KERN_INFO
PFX
"
%s exiting...
\n
"
,
current
->
comm
);
return
0
;
}
static
int
__init
envctrl_init
(
void
)
static
int
__devinit
envctrl_probe
(
struct
of_device
*
op
,
const
struct
of_device_id
*
match
)
{
struct
linux_ebus
*
ebus
=
NULL
;
struct
linux_ebus_device
*
edev
=
NULL
;
struct
linux_ebus_child
*
edev_child
=
NULL
;
int
err
,
i
=
0
;
for_each_ebus
(
ebus
)
{
for_each_ebusdev
(
edev
,
ebus
)
{
if
(
!
strcmp
(
edev
->
prom_node
->
name
,
"bbc"
))
{
/* If we find a boot-bus controller node,
* then this envctrl driver is not for us.
*/
return
-
ENODEV
;
}
}
}
struct
device_node
*
dp
;
int
index
,
err
;
/* Traverse through ebus and ebus device list for i2c device and
* adc and gpio nodes.
*/
for_each_ebus
(
ebus
)
{
for_each_ebusdev
(
edev
,
ebus
)
{
if
(
!
strcmp
(
edev
->
prom_node
->
name
,
"i2c"
))
{
i2c
=
ioremap
(
edev
->
resource
[
0
].
start
,
0x2
);
for_each_edevchild
(
edev
,
edev_child
)
{
if
(
!
strcmp
(
"gpio"
,
edev_child
->
prom_node
->
name
))
{
i2c_childlist
[
i
].
i2ctype
=
I2C_GPIO
;
envctrl_init_i2c_child
(
edev_child
,
&
(
i2c_childlist
[
i
++
]));
}
if
(
!
strcmp
(
"adc"
,
edev_child
->
prom_node
->
name
))
{
i2c_childlist
[
i
].
i2ctype
=
I2C_ADC
;
envctrl_init_i2c_child
(
edev_child
,
&
(
i2c_childlist
[
i
++
]));
}
}
goto
done
;
}
if
(
i2c
)
return
-
EINVAL
;
i2c
=
of_ioremap
(
&
op
->
resource
[
0
],
0
,
0x2
,
DRIVER_NAME
);
if
(
!
i2c
)
return
-
ENOMEM
;
index
=
0
;
dp
=
op
->
node
->
child
;
while
(
dp
)
{
if
(
!
strcmp
(
dp
->
name
,
"gpio"
))
{
i2c_childlist
[
index
].
i2ctype
=
I2C_GPIO
;
envctrl_init_i2c_child
(
dp
,
&
(
i2c_childlist
[
index
++
]));
}
else
if
(
!
strcmp
(
dp
->
name
,
"adc"
))
{
i2c_childlist
[
index
].
i2ctype
=
I2C_ADC
;
envctrl_init_i2c_child
(
dp
,
&
(
i2c_childlist
[
index
++
]));
}
}
done:
if
(
!
edev
)
{
printk
(
"envctrl: I2C device not found.
\n
"
);
return
-
ENODEV
;
dp
=
dp
->
sibling
;
}
/* Set device address. */
...
...
@@ -1087,7 +1070,7 @@ static int __init envctrl_init(void)
/* Register the device as a minor miscellaneous device. */
err
=
misc_register
(
&
envctrl_dev
);
if
(
err
)
{
printk
(
"envctrl:
Unable to get misc minor %d
\n
"
,
printk
(
KERN_ERR
PFX
"
Unable to get misc minor %d
\n
"
,
envctrl_dev
.
minor
);
goto
out_iounmap
;
}
...
...
@@ -1096,12 +1079,12 @@ static int __init envctrl_init(void)
* a next child device, so we decrement before reverse-traversal of
* child devices.
*/
printk
(
"envctrl: i
nitialized "
);
for
(
--
i
;
i
>=
0
;
--
i
)
{
printk
(
KERN_INFO
PFX
"I
nitialized "
);
for
(
--
i
ndex
;
index
>=
0
;
--
index
)
{
printk
(
"[%s 0x%lx]%s"
,
(
I2C_ADC
==
i2c_childlist
[
i
].
i2ctype
)
?
(
"adc"
)
:
((
I2C_GPIO
==
i2c_childlist
[
i
].
i2ctype
)
?
(
"gpio"
)
:
(
"unknown"
)
),
i2c_childlist
[
i
].
addr
,
(
0
==
i
)
?
(
"
\n
"
)
:
(
" "
)
);
(
I2C_ADC
==
i2c_childlist
[
i
ndex
].
i2ctype
)
?
"adc"
:
((
I2C_GPIO
==
i2c_childlist
[
i
ndex
].
i2ctype
)
?
"gpio"
:
"unknown"
),
i2c_childlist
[
i
ndex
].
addr
,
(
0
==
index
)
?
"
\n
"
:
" "
);
}
kenvctrld_task
=
kthread_run
(
kenvctrld
,
NULL
,
"kenvctrld"
);
...
...
@@ -1115,26 +1098,54 @@ static int __init envctrl_init(void)
out_deregister:
misc_deregister
(
&
envctrl_dev
);
out_iounmap:
iounmap
(
i2c
);
for
(
i
=
0
;
i
<
ENVCTRL_MAX_CPU
*
2
;
i
++
)
kfree
(
i2c_childlist
[
i
].
tables
);
of_iounmap
(
&
op
->
resource
[
0
],
i2c
,
0x2
);
for
(
i
ndex
=
0
;
index
<
ENVCTRL_MAX_CPU
*
2
;
index
++
)
kfree
(
i2c_childlist
[
i
ndex
].
tables
);
return
err
;
}
static
void
__exit
envctrl_cleanup
(
void
)
static
int
__devexit
envctrl_remove
(
struct
of_device
*
op
)
{
int
i
;
int
i
ndex
;
kthread_stop
(
kenvctrld_task
);
iounmap
(
i2c
);
of_iounmap
(
&
op
->
resource
[
0
],
i2c
,
0x2
);
misc_deregister
(
&
envctrl_dev
);
for
(
i
=
0
;
i
<
ENVCTRL_MAX_CPU
*
2
;
i
++
)
kfree
(
i2c_childlist
[
i
].
tables
);
for
(
index
=
0
;
index
<
ENVCTRL_MAX_CPU
*
2
;
index
++
)
kfree
(
i2c_childlist
[
index
].
tables
);
return
0
;
}
static
struct
of_device_id
envctrl_match
[]
=
{
{
.
name
=
"i2c"
,
.
compatible
=
"i2cpcf,8584"
,
},
{},
};
MODULE_DEVICE_TABLE
(
of
,
envctrl_match
);
static
struct
of_platform_driver
envctrl_driver
=
{
.
name
=
DRIVER_NAME
,
.
match_table
=
envctrl_match
,
.
probe
=
envctrl_probe
,
.
remove
=
__devexit_p
(
envctrl_remove
),
};
static
int
__init
envctrl_init
(
void
)
{
return
of_register_driver
(
&
envctrl_driver
,
&
of_bus_type
);
}
static
void
__exit
envctrl_exit
(
void
)
{
of_unregister_driver
(
&
envctrl_driver
);
}
module_init
(
envctrl_init
);
module_exit
(
envctrl_
cleanup
);
module_exit
(
envctrl_
exit
);
MODULE_LICENSE
(
"GPL"
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录