XC2440开发板上使用的以太网卡芯片是DM9000A,内核中的驱动文件为:drivers/net/dm9000.c,我们需要在mach-xc2440.c文件中加入对dm9000网卡的驱动支持,并创建平台数据:
加入dm9000头文件:
#include
在xc2440_devices[ ]平台设备结构体数组中加入ethernet设备:
&xc2440_ethernet_device,
创建platform_device和platform_data:
- /* DM9000A Net */
-
static struct resource xc2440_dm9k_resource[] = {
-
[0] = {
-
.start = S3C2410_CS4,
-
.end = S3C2410_CS4 + 3,
-
.flags = IORESOURCE_MEM
-
},
-
[1] = {
-
.start = S3C2410_CS4 + 4,
-
.end = S3C2410_CS4 + 7,
-
.flags = IORESOURCE_MEM
-
},
-
[2] = {
-
.start = IRQ_EINT(18),
-
.end = IRQ_EINT(18),
-
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
-
}
-
};
说明:DM9000A使用nGCS4片选,也就是使用了存储控制器的BANK4,起始地址是0x20000000, 中断管脚接在了EINT18上,使用上升沿触发中断。在dm9000.c驱动中获得这个resource
- /*platform_data*/
-
static struct dm9000_plat_data xc2440_dm9k_pdata = {
-
.flags =(DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
-
.dev_addr = { 0x08, 0x09, 0x0a, 0xa0, 0x90, 0x80 };
-
};
-
-
static struct platform_device xc2440_ethernet_device = {
-
.name = "dm9000",
-
.id = -1,
-
.num_resources = ARRAY_SIZE(xc2440_dm9k_resource),
-
.resource = xc2440_dm9k_resource,
-
.dev = {
-
.platform_data = &xc2440_dm9k_pdata,
-
},
-
};
说明:向驱动传入flags参数(使用16位数据线,没有EEPROM)和dev_addr(MAC地址)
配置内核,支持网卡:
- Device Drivers --->
- [*] Network device support --->
- [*] Ethernet(10 or 100 Mbit) --->
- <*> DM9000 support
- (4) DM9000 maximum debug level
启动时输出:
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c480c000,c4810004 IRQ 62 MAC: 08:09:0a:a0:90:80 (platform data)
测试网络连接可以用ping命令,测试网速可以用iperf工具
阅读(553) | 评论(0) | 转发(0) |