在厂家提供的dm9dev9000c.c上修改,
1、注释掉#ifdef MODULE #endif
2、用模块化函数修饰入口出口函数
3、在dm9000c_init入口函数,增加iobase = (int)ioremap(0x20000000,1024);irq = IRQ_EINT7;
4、一路进入,在dmfe_probe1中注释掉if((db->chip_revision!=0x1A) || ((chip_info&(1<<5))!=0) || ((chip_info&(1<<2))!=1)) return -ENODEV;
5、dmfe_open中if (request_irq(dev->irq,&dmfe_interrupt,0,dev->name,dev))修改为if (request_irq(dev->irq,&dmfe_interrupt,IRQF_TRIGGER_RISING,dev->name,dev))
6、在出口函数dm9000c_exit中增加iounmap((void *)iobase);
7、增加头文件#include <asm/irq.h>
#include <asm/delay.h>
#include <asm/io.h>
#include <asm/arch-s3c2410/regs-mem.h>
编译通过。
8、在dm9000c_init入口函数里添加时序:volatile unsigned long bwscon;
volatile unsigned long bankcon4;
unsigned long val;
bwscon = ioremap(0x48000000,4);
bankcon4 = ioremap(0x48000014,4);
val = *bwscon;
val &= ~(0xf<<16);
val |= (1<<16);
*bwscon = val;
*bankcon4 = (1<<6);
iounmap(bwscon);
iounmap(bankcon4);
编译通过。
9、测试驱动:在内核/drivers/net中替换.c文档,修改makefile,编译新的uImage。烧写后,启动
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:60:6E:33:44:55
inet addr:192.168.42.222 Bcast:192.168.42.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:317012 errors:0 dropped:0 overruns:0 frame:0
TX packets:1239 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32863664 (31.3 MiB) TX bytes:191590 (187.0 KiB)
Interrupt:51 Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
# ping 192.168.42.144
PING 192.168.42.144 (192.168.42.144): 56 data bytes
64 bytes from 192.168.42.144: seq=0 ttl=64 time=0.865 ms
64 bytes from 192.168.42.144: seq=1 ttl=64 time=1.077 ms
64 bytes from 192.168.42.144: seq=2 ttl=64 time=1.047 ms
--- 192.168.42.144 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.865/0.996/1.077 ms