Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
b28422e3
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看板
提交
b28422e3
编写于
8月 24, 2008
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sparc64: Convert UltraSPARC-III memory controller driver to OF driver probing.
Signed-off-by:
N
David S. Miller
<
davem@davemloft.net
>
上级
e0418088
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
41 deletion
+78
-41
arch/sparc64/kernel/chmc.c
arch/sparc64/kernel/chmc.c
+78
-41
未找到文件。
arch/sparc64/kernel/chmc.c
浏览文件 @
b28422e3
/*
memctrlr
.c: Driver for UltraSPARC-III memory controller.
/*
chmc
.c: Driver for UltraSPARC-III memory controller.
*
* Copyright (C) 2001, 2007 David S. Miller (davem@davemloft.net)
* Copyright (C) 2001, 2007
, 2008
David S. Miller (davem@davemloft.net)
*/
#include <linux/module.h>
...
...
@@ -13,13 +13,25 @@
#include <linux/smp.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <asm/spitfire.h>
#include <asm/chmctrl.h>
#include <asm/cpudata.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/head.h>
#include <asm/io.h>
#define DRV_MODULE_NAME "chmc"
#define PFX DRV_MODULE_NAME ": "
#define DRV_MODULE_VERSION "0.2"
MODULE_AUTHOR
(
"David S. Miller (davem@davemloft.net)"
);
MODULE_DESCRIPTION
(
"UltraSPARC-III memory controller driver"
);
MODULE_LICENSE
(
"GPL"
);
MODULE_VERSION
(
DRV_MODULE_VERSION
);
#define CHMCTRL_NDGRPS 2
#define CHMCTRL_NDIMMS 4
...
...
@@ -343,16 +355,25 @@ static void fetch_decode_regs(struct mctrl_info *mp)
read_mcreg
(
mp
,
CHMCTRL_DECODE4
));
}
static
int
init_one_mctrl
(
struct
device_node
*
dp
)
static
int
__devinit
chmc_probe
(
struct
of_device
*
op
,
const
struct
of_device_id
*
match
)
{
struct
mctrl_info
*
mp
=
kzalloc
(
sizeof
(
*
mp
),
GFP_KERNEL
)
;
int
portid
=
of_getintprop_default
(
dp
,
"portid"
,
-
1
)
;
const
struct
linux_prom64_registers
*
regs
;
struct
device_node
*
dp
=
op
->
node
;
struct
mctrl_info
*
mp
;
unsigned
long
ver
;
const
void
*
pval
;
int
len
;
int
len
,
portid
;
__asm__
(
"rdpr %%ver, %0"
:
"=r"
(
ver
));
if
((
ver
>>
32UL
)
==
__JALAPENO_ID
||
(
ver
>>
32UL
)
==
__SERRANO_ID
)
return
-
ENODEV
;
mp
=
kzalloc
(
sizeof
(
*
mp
),
GFP_KERNEL
);
if
(
!
mp
)
return
-
1
;
return
-
ENOMEM
;
portid
=
of_getintprop_default
(
dp
,
"portid"
,
-
1
);
if
(
portid
==
-
1
)
goto
fail
;
...
...
@@ -362,18 +383,19 @@ static int init_one_mctrl(struct device_node *dp)
if
(
!
pval
)
mp
->
layout_size
=
0
;
else
{
if
(
mp
->
layout_size
>
sizeof
(
mp
->
layout_prop
))
if
(
mp
->
layout_size
>
sizeof
(
mp
->
layout_prop
))
{
printk
(
KERN_ERR
PFX
"Unexpected memory-layout property "
"size %d.
\n
"
,
mp
->
layout_size
);
goto
fail
;
}
memcpy
(
&
mp
->
layout_prop
,
pval
,
len
);
}
regs
=
of_get_property
(
dp
,
"reg"
,
NULL
);
if
(
!
regs
||
regs
->
reg_size
!=
0x48
)
goto
fail
;
mp
->
regs
=
ioremap
(
regs
->
phys_addr
,
regs
->
reg_size
);
if
(
mp
->
regs
==
NULL
)
mp
->
regs
=
of_ioremap
(
&
op
->
resource
[
0
],
0
,
0x48
,
"chmc"
);
if
(
!
mp
->
regs
)
{
printk
(
KERN_ERR
PFX
"Could not map registers.
\n
"
);
goto
fail
;
}
if
(
mp
->
layout_size
!=
0UL
)
{
mp
->
timing_control1
=
read_mcreg
(
mp
,
CHMCTRL_TCTRL1
);
...
...
@@ -388,54 +410,69 @@ static int init_one_mctrl(struct device_node *dp)
list_add
(
&
mp
->
list
,
&
mctrl_list
);
/* Report the device. */
printk
(
KERN_INFO
"%s: US3 memory controller at %p
[%s]
\n
"
,
printk
(
KERN_INFO
PFX
"UltraSPARC-III memory controller at %s
[%s]
\n
"
,
dp
->
full_name
,
mp
->
regs
,
(
mp
->
layout_size
?
"ACTIVE"
:
"INACTIVE"
));
(
mp
->
layout_size
?
"ACTIVE"
:
"INACTIVE"
));
dev_set_drvdata
(
&
op
->
dev
,
mp
);
return
0
;
fail:
if
(
mp
)
{
if
(
mp
->
regs
!=
NULL
)
iounmap
(
mp
->
regs
);
of_iounmap
(
&
op
->
resource
[
0
],
mp
->
regs
,
0x48
);
kfree
(
mp
);
}
return
-
1
;
}
static
int
__
init
chmc_init
(
void
)
static
int
__
devexit
chmc_remove
(
struct
of_device
*
op
)
{
struct
device_node
*
dp
;
struct
mctrl_info
*
mp
=
dev_get_drvdata
(
&
op
->
dev
)
;
/* This driver is only for cheetah platforms. */
if
(
tlb_type
!=
cheetah
&&
tlb_type
!=
cheetah_plus
)
return
-
ENODEV
;
if
(
mp
)
{
list_del
(
&
mp
->
list
);
of_iounmap
(
&
op
->
resource
[
0
],
mp
->
regs
,
0x48
);
kfree
(
mp
);
}
return
0
;
}
for_each_node_by_name
(
dp
,
"memory-controller"
)
init_one_mctrl
(
dp
);
static
struct
of_device_id
chmc_match
[]
=
{
{
.
name
=
"memory-controller"
,
},
{},
};
MODULE_DEVICE_TABLE
(
of
,
chmc_match
);
for_each_node_by_name
(
dp
,
"mc-us3"
)
init_one_mctrl
(
dp
);
static
struct
of_platform_driver
chmc_driver
=
{
.
name
=
"chmc"
,
.
match_table
=
chmc_match
,
.
probe
=
chmc_probe
,
.
remove
=
__devexit_p
(
chmc_remove
),
};
return
0
;
static
inline
bool
chmc_platform
(
void
)
{
if
(
tlb_type
==
cheetah
||
tlb_type
==
cheetah_plus
)
return
true
;
return
false
;
}
static
void
__exit
chmc_cleanup
(
void
)
static
int
__init
chmc_init
(
void
)
{
struct
list_head
*
head
=
&
mctrl_list
;
struct
list_head
*
tmp
=
head
->
next
;
if
(
!
chmc_platform
())
return
-
ENODEV
;
for
(;;)
{
struct
mctrl_info
*
p
=
list_entry
(
tmp
,
struct
mctrl_info
,
list
);
if
(
tmp
==
head
)
break
;
tmp
=
tmp
->
next
;
return
of_register_driver
(
&
chmc_driver
,
&
of_bus_type
);
}
list_del
(
&
p
->
list
);
iounmap
(
p
->
regs
);
kfree
(
p
);
}
static
void
__exit
chmc_cleanup
(
void
)
{
if
(
chmc_platform
())
of_unregister_driver
(
&
chmc_driver
);
}
module_init
(
chmc_init
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录