全部博文(489)
分类:
2011-12-22 20:48:35
原文地址:DM9000 驱动的移植 作者:luozhiyong131
修改arch/arm/mach-s3c2440/mach-smdk2440.c 160 行 Platform_device 结构体中,加入:
&s
修改arch/arm/plat-s3c24xx/devs.c 在最前面38 行加入:
#include
/*DM9000*/
static struct resource s
[0] = {
.start = S
.end = S
.flags = IORESOURCE_MEM,
},
[1] = {
.start = S
.end = S
.flags = IORESOURCE_MEM,
},
[2] = {
.start = IRQ_EINT18, /*use eint18 GPG10*/
.end = IRQ_EINT18,
.flags = IORESOURCE_IRQ,
}
};
static struct dm9000_plat_data s
.flags = DM9000_PLATF_16BITONLY,
};
static struct platform_device s
.name = "dm9000",
.id = 0,
.num_resources = ARRAY_SIZE(s
.resource = s
.dev = {
.platform_data = &s
}
};
EXPORT_SYMBOL(s
在arch/arm/plat-s3c/include/plat/devs.h 中加入一行:
extern struct platform_device s
编译时出现一个奇怪的错误:
arch/arm/plat-s
s
static struct platform_device s
的static 改成extern,就可以了
下面修改dm9000.c 源码,在drivers/net/dm9000.c 中
1. 添加头文件,在第43 行加入:
#if defined(CONFIG_ARCH_S
#include
#endif
2. 指定注册时的中断触发方式,在第1019 行加入:
static int dm9000_open(struct net_device *dev)
{
…………
irqflags |= IRQF_SHARED;
#if defined (CONFIG_ARCH_S
if(request_irq(dev->irq,&dm9000_interrupt,IRQF_SHARED|IRQF_TRIGGER_RSING,dev->name,dev))
#else
if(request_irq(dev->irq,&dm9000_interrupt,IRQF_SHARED,dev->name,dev))
#endif
//if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name,dev))
return -EAGAIN;
…………
}
3. 设置BANK4, 设置MAC 地址,在1215 行,dm9000_probe 函数中加入:
int ret = 0;
int iosize;
int i;
u32 id_val;
#if defined(CONFIG_ARCH_S
unsigned int oldval_bwscon = *(volatile unsigned int *)S
unsigned int oldval_bankcon4 = *(volatile unsigned int *)S
#endif
/* Init network device */
ndev = alloc_etherdev(sizeof(struct board_info));
if (!ndev) {
dev_err(&pdev->dev, "could not allocate device.\n");
return -ENOMEM;
}
在1231 行加入:
SET_NETDEV_DEV(ndev, &pdev->dev);
dev_dbg(&pdev->dev, "dm9000_probe()\n");
#if defined(CONFIG_ARCH_S
*((volatile unsigned int *)S
*((volatile unsigned int *)S
#endif
在1390 行加入:
db->mii.mdio_read = dm9000_phy_read;
db->mii.mdio_write = dm9000_phy_write;
#if defined(CONFIG_ARCH_S
printk("Now use the default MAC address: 08:90:90:90:90:90 ");
mac_src = "http://luozhiyong131.cublog.cn/";
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;
#else
mac_src = "eeprom";
/* try reading the node address from the attached EEPROM */
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
mac_src = "platform data";
memcpy(ndev->dev_addr, pdata->dev_addr, 6);
}
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
if (!is_valid_ether_addr(ndev->dev_addr))
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please " "set using ifconfig\n", ndev->name);
#endif
platform_set_drvdata(pdev, ndev);
ret = register_netdev(ndev);
if (ret == 0)
printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %pM (%s)\n",
ndev->name, dm9000_type_to_char(db->type),
db->io_addr, db->io_data, ndev->irq,
ndev->dev_addr, mac_src);
return 0;
out:
#if defined(CONFIG_ARCH_S
*(volatile unsigned int *)S
*(volatile unsigned int *)S
#endif
配置内核,支持网卡:
Device Drivers --->
[*] Network device support --->
[*] Ethernet(10 or 100 Mbit) --->
<*> DM9000 support
(4) DM9000 maximum debug level
补丁文件
文件:
linux-2.6.31.DM9000.rar
大小:
166KB
下载:
下载
启动时输出:
dm9000 Ethernet Driver, V1.31
Now use the default MAC address: 08:90:90:90:90:90
eth0: dm9000e at c
系统启动后,可能会出现这个错误:
ifconfig: SIOCSIFFLAGS: Cannot assign requested address
原因是MAC 地址没有设置或没有设置对,在启动脚本中加上:
ifconfig eth0 down
ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX MAC 地址,随便设
ifconfig eth0 up
一般问题可以解决,如果还提示有错,再改一下MAC 地址测试网卡的方法:连接好计算机和开发板之间的网线,如果网开发板网卡的灯亮起,说明已经连接到计算机;
可以在计算机的命令行窗口下(开始->运行->cmd)使用PING 命令测试网络:ping 192.168.1.10 开发板的IP 地址也可以在开发板的串口终端下PING 计算机的网卡