Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
401e9093
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看板
提交
401e9093
编写于
2月 13, 2007
作者:
P
Paul Mundt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sh: Compile fix for heartbeat consolidation.
Signed-off-by:
N
Paul Mundt
<
lethal@linux-sh.org
>
上级
3b4d9539
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
132 addition
and
0 deletion
+132
-0
arch/sh/drivers/heartbeat.c
arch/sh/drivers/heartbeat.c
+132
-0
未找到文件。
arch/sh/drivers/heartbeat.c
0 → 100644
浏览文件 @
401e9093
/*
* Generic heartbeat driver for regular LED banks
*
* Copyright (C) 2007 Paul Mundt
*
* Most SH reference boards include a number of individual LEDs that can
* be independently controlled (either via a pre-defined hardware
* function or via the LED class, if desired -- the hardware tends to
* encapsulate some of the same "triggers" that the LED class supports,
* so there's not too much value in it).
*
* Additionally, most of these boards also have a LED bank that we've
* traditionally used for strobing the load average. This use case is
* handled by this driver, rather than giving each LED bit position its
* own struct device.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/io.h>
#define DRV_NAME "heartbeat"
#define DRV_VERSION "0.1.0"
struct
heartbeat_data
{
void
__iomem
*
base
;
unsigned
char
bit_pos
[
8
];
struct
timer_list
timer
;
};
static
void
heartbeat_timer
(
unsigned
long
data
)
{
struct
heartbeat_data
*
hd
=
(
struct
heartbeat_data
*
)
data
;
static
unsigned
bit
=
0
,
up
=
1
;
ctrl_outw
(
1
<<
hd
->
bit_pos
[
bit
],
(
unsigned
long
)
hd
->
base
);
if
(
up
)
if
(
bit
==
(
ARRAY_SIZE
(
hd
->
bit_pos
)
-
1
))
{
bit
--
;
up
=
0
;
}
else
bit
++
;
else
if
(
bit
==
0
)
up
=
1
;
else
bit
--
;
mod_timer
(
&
hd
->
timer
,
jiffies
+
(
110
-
((
300
<<
FSHIFT
)
/
((
avenrun
[
0
]
/
5
)
+
(
3
<<
FSHIFT
)))));
}
static
int
heartbeat_drv_probe
(
struct
platform_device
*
pdev
)
{
struct
resource
*
res
;
struct
heartbeat_data
*
hd
;
if
(
unlikely
(
pdev
->
num_resources
!=
1
))
{
dev_err
(
&
pdev
->
dev
,
"invalid number of resources
\n
"
);
return
-
EINVAL
;
}
res
=
platform_get_resource
(
pdev
,
IORESOURCE_MEM
,
0
);
if
(
unlikely
(
res
==
NULL
))
{
dev_err
(
&
pdev
->
dev
,
"invalid resource
\n
"
);
return
-
EINVAL
;
}
hd
=
kmalloc
(
sizeof
(
struct
heartbeat_data
),
GFP_KERNEL
);
if
(
unlikely
(
!
hd
))
return
-
ENOMEM
;
if
(
pdev
->
dev
.
platform_data
)
{
memcpy
(
hd
->
bit_pos
,
pdev
->
dev
.
platform_data
,
ARRAY_SIZE
(
hd
->
bit_pos
));
}
else
{
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
hd
->
bit_pos
);
i
++
)
hd
->
bit_pos
[
i
]
=
i
;
}
hd
->
base
=
(
void
__iomem
*
)
res
->
start
;
setup_timer
(
&
hd
->
timer
,
heartbeat_timer
,
(
unsigned
long
)
hd
);
platform_set_drvdata
(
pdev
,
hd
);
return
mod_timer
(
&
hd
->
timer
,
jiffies
+
1
);
}
static
int
heartbeat_drv_remove
(
struct
platform_device
*
pdev
)
{
struct
heartbeat_data
*
hd
=
platform_get_drvdata
(
pdev
);
del_timer_sync
(
&
hd
->
timer
);
platform_set_drvdata
(
pdev
,
NULL
);
kfree
(
hd
);
return
0
;
}
static
struct
platform_driver
heartbeat_driver
=
{
.
probe
=
heartbeat_drv_probe
,
.
remove
=
heartbeat_drv_remove
,
.
driver
=
{
.
name
=
DRV_NAME
,
},
};
static
int
__init
heartbeat_init
(
void
)
{
printk
(
KERN_NOTICE
DRV_NAME
": version %s loaded
\n
"
,
DRV_VERSION
);
return
platform_driver_register
(
&
heartbeat_driver
);
}
static
void
__exit
heartbeat_exit
(
void
)
{
platform_driver_unregister
(
&
heartbeat_driver
);
}
module_init
(
heartbeat_init
);
module_exit
(
heartbeat_exit
);
MODULE_VERSION
(
DRV_VERSION
);
MODULE_AUTHOR
(
"Paul Mundt"
);
MODULE_LICENSE
(
"GPLv2"
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录