Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
29f7ac7e
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看板
提交
29f7ac7e
编写于
6月 24, 2006
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MTD] sun_uflash: Port to new EBUS device layer.
Signed-off-by:
N
David S. Miller
<
davem@davemloft.net
>
上级
fcc18e83
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
95 addition
and
100 deletion
+95
-100
drivers/mtd/maps/sun_uflash.c
drivers/mtd/maps/sun_uflash.c
+95
-100
未找到文件。
drivers/mtd/maps/sun_uflash.c
浏览文件 @
29f7ac7e
...
...
@@ -18,6 +18,7 @@
#include <linux/ioport.h>
#include <asm/ebus.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/uaccess.h>
#include <asm/io.h>
...
...
@@ -30,146 +31,140 @@
#define UFLASH_WINDOW_SIZE 0x200000
#define UFLASH_BUSWIDTH 1
/* EBus is 8-bit */
MODULE_AUTHOR
(
"Eric Brower <ebrower@usa.net>"
);
MODULE_DESCRIPTION
(
"User-programmable flash device on Sun Microsystems boardsets"
);
MODULE_SUPPORTED_DEVICE
(
"userflash"
);
MODULE_LICENSE
(
"GPL"
);
MODULE_AUTHOR
(
"Eric Brower <ebrower@usa.net>"
);
MODULE_DESCRIPTION
(
"User-programmable flash device on Sun Microsystems boardsets"
);
MODULE_SUPPORTED_DEVICE
(
"userflash"
);
MODULE_LICENSE
(
"GPL"
);
MODULE_VERSION
(
"2.0"
);
static
LIST_HEAD
(
device_list
);
struct
uflash_dev
{
char
*
name
;
/* device name */
char
*
name
;
/* device name */
struct
map_info
map
;
/* mtd map info */
struct
mtd_info
*
mtd
;
/* mtd info */
struct
list_head
list
;
struct
mtd_info
*
mtd
;
/* mtd info */
};
struct
map_info
uflash_map_templ
=
{
.
name
=
"SUNW,???-????"
,
.
size
=
UFLASH_WINDOW_SIZE
,
.
bankwidth
=
UFLASH_BUSWIDTH
,
.
name
=
"SUNW,???-????"
,
.
size
=
UFLASH_WINDOW_SIZE
,
.
bankwidth
=
UFLASH_BUSWIDTH
,
};
int
uflash_devinit
(
struct
linux_ebus_device
*
edev
)
int
uflash_devinit
(
struct
linux_ebus_device
*
edev
,
struct
device_node
*
dp
)
{
int
iTmp
,
nregs
;
struct
linux_prom_registers
regs
[
2
];
struct
uflash_dev
*
pdev
;
iTmp
=
prom_getproperty
(
edev
->
prom_node
,
"reg"
,
(
void
*
)
regs
,
sizeof
(
regs
));
if
((
iTmp
%
sizeof
(
regs
[
0
]))
!=
0
)
{
printk
(
"%s: Strange reg property size %d
\n
"
,
UFLASH_DEVNAME
,
iTmp
);
return
-
ENODEV
;
}
struct
uflash_dev
*
up
;
struct
resource
*
res
;
nregs
=
iTmp
/
sizeof
(
regs
[
0
])
;
res
=
&
edev
->
resource
[
0
]
;
if
(
nreg
s
!=
1
)
{
if
(
edev
->
num_addr
s
!=
1
)
{
/* Non-CFI userflash device-- once I find one we
* can work on supporting it.
*/
printk
(
"%s: unsupported device at 0x%lx (%d regs): "
\
"email ebrower@usa.net
\n
"
,
UFLASH_DEVNAME
,
edev
->
resource
[
0
].
start
,
nregs
);
dp
->
full_name
,
res
->
start
,
edev
->
num_addrs
);
return
-
ENODEV
;
}
if
(
0
==
(
pdev
=
kmalloc
(
sizeof
(
struct
uflash_dev
),
GFP_KERNEL
)))
{
printk
(
"%s: unable to kmalloc new device
\n
"
,
UFLASH_DEVNAME
);
return
(
-
ENOMEM
);
}
up
=
kzalloc
(
sizeof
(
struct
uflash_dev
),
GFP_KERNEL
);
if
(
!
up
)
return
-
ENOMEM
;
/* copy defaults and tweak parameters */
memcpy
(
&
pdev
->
map
,
&
uflash_map_templ
,
sizeof
(
uflash_map_templ
));
pdev
->
map
.
size
=
regs
[
0
].
reg_size
;
iTmp
=
prom_getproplen
(
edev
->
prom_node
,
"model"
);
pdev
->
name
=
kmalloc
(
iTmp
,
GFP_KERNEL
);
prom_getstring
(
edev
->
prom_node
,
"model"
,
pdev
->
name
,
iTmp
);
if
(
0
!=
pdev
->
name
&&
0
<
strlen
(
pdev
->
name
))
{
pdev
->
map
.
name
=
pdev
->
name
;
}
pdev
->
map
.
phys
=
edev
->
resource
[
0
].
start
;
pdev
->
map
.
virt
=
ioremap_nocache
(
edev
->
resource
[
0
].
start
,
pdev
->
map
.
size
);
if
(
0
==
pdev
->
map
.
virt
)
{
printk
(
"%s: failed to map device
\n
"
,
__FUNCTION__
);
kfree
(
pdev
->
name
);
kfree
(
pdev
);
return
(
-
1
);
memcpy
(
&
up
->
map
,
&
uflash_map_templ
,
sizeof
(
uflash_map_templ
));
up
->
map
.
size
=
(
res
->
end
-
res
->
start
)
+
1UL
;
up
->
name
=
of_get_property
(
dp
,
"model"
,
NULL
);
if
(
up
->
name
&&
0
<
strlen
(
up
->
name
))
up
->
map
.
name
=
up
->
name
;
up
->
map
.
phys
=
res
->
start
;
up
->
map
.
virt
=
ioremap_nocache
(
res
->
start
,
up
->
map
.
size
);
if
(
!
up
->
map
.
virt
)
{
printk
(
"%s: Failed to map device.
\n
"
,
dp
->
full_name
);
kfree
(
up
);
return
-
EINVAL
;
}
simple_map_init
(
&
pdev
->
map
);
simple_map_init
(
&
up
->
map
);
/* MTD registration */
pdev
->
mtd
=
do_map_probe
(
"cfi_probe"
,
&
pdev
->
map
);
if
(
0
==
pdev
->
mtd
)
{
iounmap
(
pdev
->
map
.
virt
);
kfree
(
pdev
->
name
);
kfree
(
pdev
);
return
(
-
ENXIO
)
;
up
->
mtd
=
do_map_probe
(
"cfi_probe"
,
&
up
->
map
);
if
(
!
up
->
mtd
)
{
iounmap
(
up
->
map
.
virt
);
kfree
(
up
);
return
-
ENXIO
;
}
list_add
(
&
pdev
->
list
,
&
device_list
)
;
up
->
mtd
->
owner
=
THIS_MODULE
;
pdev
->
mtd
->
owner
=
THIS_MODULE
;
add_mtd_device
(
up
->
mtd
)
;
add_mtd_device
(
pdev
->
mtd
);
return
(
0
);
dev_set_drvdata
(
&
edev
->
ofdev
.
dev
,
up
);
return
0
;
}
static
int
__
init
uflash_init
(
void
)
static
int
__
devinit
uflash_probe
(
struct
of_device
*
dev
,
const
struct
of_device_id
*
match
)
{
struct
linux_ebus
*
ebus
=
NULL
;
struct
linux_ebus_device
*
edev
=
NULL
;
for_each_ebus
(
ebus
)
{
for_each_ebusdev
(
edev
,
ebus
)
{
if
(
!
strcmp
(
edev
->
prom_name
,
UFLASH_OBPNAME
))
{
if
(
0
>
prom_getproplen
(
edev
->
prom_node
,
"user"
))
{
DEBUG
(
2
,
"%s: ignoring device at 0x%lx
\n
"
,
UFLASH_DEVNAME
,
edev
->
resource
[
0
].
start
);
}
else
{
uflash_devinit
(
edev
);
}
}
}
}
struct
linux_ebus_device
*
edev
=
to_ebus_device
(
&
dev
->
dev
);
struct
device_node
*
dp
=
dev
->
node
;
if
(
list_empty
(
&
device_list
))
{
printk
(
"%s: unable to locate device
\n
"
,
UFLASH_DEVNAME
);
if
(
of_find_property
(
dp
,
"user"
,
NULL
))
return
-
ENODEV
;
}
return
(
0
);
return
uflash_devinit
(
edev
,
dp
);
}
static
void
__exit
uflash_cleanup
(
void
)
static
int
__devexit
uflash_remove
(
struct
of_device
*
dev
)
{
struct
list_head
*
udevlist
;
struct
uflash_dev
*
udev
;
list_for_each
(
udevlist
,
&
device_list
)
{
udev
=
list_entry
(
udevlist
,
struct
uflash_dev
,
list
);
DEBUG
(
2
,
"%s: removing device %s
\n
"
,
UFLASH_DEVNAME
,
udev
->
name
);
if
(
0
!=
udev
->
mtd
)
{
del_mtd_device
(
udev
->
mtd
);
map_destroy
(
udev
->
mtd
);
}
if
(
0
!=
udev
->
map
.
virt
)
{
iounmap
(
udev
->
map
.
virt
);
udev
->
map
.
virt
=
NULL
;
}
kfree
(
udev
->
name
);
kfree
(
udev
);
struct
uflash_dev
*
up
=
dev_get_drvdata
(
&
dev
->
dev
);
if
(
up
->
mtd
)
{
del_mtd_device
(
up
->
mtd
);
map_destroy
(
up
->
mtd
);
}
if
(
up
->
map
.
virt
)
{
iounmap
(
up
->
map
.
virt
);
up
->
map
.
virt
=
NULL
;
}
kfree
(
up
);
return
0
;
}
static
struct
of_device_id
uflash_match
[]
=
{
{
.
name
=
UFLASH_OBPNAME
,
},
{},
};
MODULE_DEVICE_TABLE
(
of
,
uflash_match
);
static
struct
of_platform_driver
uflash_driver
=
{
.
name
=
UFLASH_DEVNAME
,
.
match_table
=
uflash_match
,
.
probe
=
uflash_probe
,
.
remove
=
__devexit_p
(
uflash_remove
),
};
static
int
__init
uflash_init
(
void
)
{
return
of_register_driver
(
&
uflash_driver
,
&
ebus_bus_type
);
}
static
void
__exit
uflash_exit
(
void
)
{
of_unregister_driver
(
&
uflash_driver
);
}
module_init
(
uflash_init
);
module_exit
(
uflash_
cleanup
);
module_exit
(
uflash_
exit
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录