分类: LINUX
2010-05-25 16:26:30
DM9000网卡驱动的移植:参考《DM9000网卡驱动移植——海边淘沙BLOG》
a) #make menuconfig进入配置菜单选中driver——net——10/
b) 在arch/arm/plat-s
static struct resource s
[0] = {
.start = 0x18000000,
//dm
.end = 0x18000003,
//这里搞不懂为什么是加3[可能因为是块设备吧]
.flags = IORESOURCE_MEM,
},
[1] = {
.start = 0x18000004,
//因为CMD接的是A2,其为1时就是数据端口
.end = 0x18000007,
//0X
.flags = IORESOURCE_MEM,
},
[2] = {
.start = IRQ_EINT9, //根据电路图接的是EINT9管脚
.end = IRQ_EINT9,
.flags = IORESOURCE_IRQ,
// .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, //at2440evb中的设置
}
};
static struct dm9000_plat_data s
// .flags = (DM9000_PLATF_16BITONLY|DM9000_PLATF_NO_EEPROM), //at2440evb中的设置
.flags = DM9000_PLATF_16BITONLY
};
static struct platform_device s
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(s
.resource = s
.dev = {
.platform_data = &s
},
};
EXPORT_SYMBOL(s
c) arch/arm/plat-s
extern struct platform_device s
d) arch/arm/mach-s
static struct platform_device *smdk2440_devices[] __initdata = {
&s
&s
&s
&s
&s
&s
};至此,向内核注册DM
e) 在drivers/net/dm9000.c开头中添加
#include
#define EINTMASK (0x
#define EXTINT1 (0x
#define INTMSK (0x
在dm9000_probe()中ret = register_netdev(ndev); 1392行,之前添加
memcpy(ndev->dev_addr,"\oandy1",6);
extint1 =ioremap_nocache(EXTINT1,0x00000004);
intmsk =ioremp_nocache(INTMSK,4);
s
writel(readl(extint1)|0x40,extint1); //中断为上升沿
writel(readl(intmsk)&0xfff1,intmsk);
iounmap(intmsk);
iounmap(extint1);
f) 第二种方案是直接参考/arch/arm/mach-s
i. 修改/arch/arm/mach-s
#include
static struct resource s
[0] = {
.start = S
.end = S
.flags = IORESOURCE_MEM
},
[1] = {
.start = S
.end = S
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT9,
.end = IRQ_EINT9,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
}
};
static struct dm9000_plat_data s
.flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
static struct platform_device s
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(s
.resource = s
.dev = {
.platform_data = & s
},
};
这段代码加在static struct platform_device *smdk2440_devices[] __initdata之前,修改设备初始化
static struct platform_device *smdk2440_devices[] __initdata = {
&s
&s
&s
&s
&s
&s
};
g) 修改根文件系统/etc/init.d/rcS配置网卡,增加下面的代码
ifconfig lo 127.0.0.1
ifconfig eth0 hw ether 08:00:3e:26:
ifconfig eth0 192.168.1.70
route add default gw 192.168.1.1
h) 配置内核:
#make menuconfig
Device Drivers—Network device support—Ethernet(10 or 10Mbit)—DM9000 support