分类: 嵌入式
2010-09-27 01:44:10
DM9000移植的好文章:
1.http://blog.chinaunix.net/u1/57901/showart_2023852.html
2.http://blog.csdn.net/baozhongchao/archive/2009/09/10/4538182.aspx
1.修改arch/arm/plat-s3c24xx/common-smdk.c文件
在包含头文件的区域增加以下代码:
#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
#include
#endif
在smdk_devs结构体之前添加以下代码:
#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
//DM9000网卡使用的资源列表。使用0x20000000、0x20000004这两个地址就可以操作DM9000网卡。
static struct resource s3c_dm9k_resource[] = {
[0] = {
.start = S3C2410_CS4, //S3C2410_CS4被定义为0x20000000(BANK4基地址)
.end = S3C2410_CS4+3,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = S3C2410_CS4 + 4, //0x20000004
.end = S3C2410_CS4 + 4 + 3,
.flags = IORESOURCE_MEM,
},
[2] = {
.start = IRQ_EINT7, //连接S3C2440的EINT7引脚
.end = IRQ_EINT7,
.flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, //上升沿触发
}
};
//DM9000与开发板相关的数据,指定访问DM9000时,数据位宽为16
static struct dm9000_plat_data s3c_dm9k_platdata = {
.flags = DM9000_PLATF_16BITONLY,
};
static struct platform_device s3c_device_dm9k = {
.name = "dm9000",
.id = 0,
.num_resources = ARRAY_SIZE(s3c_dm9k_resource),
.resource = s3c_dm9k_resource,
.dev = {
.platform_data = &s3c_dm9k_platdata,
}
};
#endif
在smdk_devs结构体中添加以下代码:
#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
&s3c_device_dm9k,
#endif
2.修改drivers/net/dm9000.c文件
在包含头文件区域添加以下代码
#if defined(CONFIG_ARCH_S3C2410)
#include
#endif
在dm9000_probe函数中的变量声明之后添加以下代码:
#if defined(CONFIG_ARCH_S3C2410)
unsigned int oldval_bwscon;
unsigned int oldval_bankcon4;
#endif
在dev_dbg(&pdev->dev, "dm9000_probe()\n");语句之后添加以下代码:
#if defined(CONFIG_ARCH_S3C2410)
oldval_bwscon=*((volatile unsigned int *)S3C2410_BWSCON);
*((volatile
unsigned int *)S3C2410_BWSCON)=(oldval_bwscon & ~(3<<16))|
S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
oldval_bankcon4=*((volatile unsigned int *)S3C2410_BANKCON4);
*((volatile unsigned int *)S3C2410_BANKCON4)=0x1f7c;
#endif
将platform_set_drvdata(pdev, ndev);之前的if判断语句改为:
if (!is_valid_ether_addr(ndev->dev_addr))
{
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
"set using ifconfig\n", ndev->name);
#if defined(CONFIG_ARCH_S3C2410)
printk("Now use the default MAC address: 08:90:90:90:90:90\n");
ndev->dev_addr[0]=0x08;
ndev->dev_addr[1]=0x90;
ndev->dev_addr[2]=0x90;
ndev->dev_addr[3]=0x90;
ndev->dev_addr[4]=0x90;
ndev->dev_addr[5]=0x90;
#endif
}
在dev_err(db->dev, "not found (%d).\n", ret);之后添加以下代码:
#if defined(CONFIG_ARCH_S3C2410)
*((volatile unsigned int *)S3C2410_BWSCON)=oldval_bwscon;
*((volatile unsigned int *)S3C2410_BWSCON)=oldval_bankcon4;
#endif
3.配置内核
Device Drivers --->
Network device support --->
[*] Network device support --->
Ethernet (10 or 100Mbit) --->
<*> DM9000 support
4.测试一下能否ping通主机: