免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2042 | 回复: 0

DM9000A驱动在FL2440的移植(2.6.33.7内核) [复制链接]

论坛徽章:
0
发表于 2011-12-20 09:44 |显示全部楼层
一、移植环境
    主  机:Fedora 14 (kernel-2.6.33.7)
    开发板:FL2440(nandflash:K9F1G08 128MB)
    编译器:arm-linux-gcc-4.3.2
 
二、移植步骤
    1. 在没有移植驱动之前,从系统的启动信息我们可以看到,开发板无法检测到网卡的存在。
  1. init started: BusyBox v1.6.0 (2008-01-09 17:10:28 CST) multi-call binary
  2. starting pid 940, tty '': '/etc/init.d/rcS'
  3. mount: mounting none on /dev/pts failed
  4. mount: mounting tmpfs on /dev/shm failed
  5. ifconfig: SIOCSIFADDR: No such device
  6. ifconfig: SIOCSIFADDR: No such device
  2. FL2440开发板采用的是DM9000网络适配卡,linux-2.6.33.7内核中已经同样对D9000网卡有了很好的支持,我所要做的就是对驱动进行必要的修改和配置。首先增加DM9000的基地址和虚拟地址的定义。
  1. #vim arch/arm/mach-s3c2410/include/mach/map.h
  2. #define S3C24XX_PA_DM9000 (0x20000300)
  3. #define S3C24XX_VA_DM9000 (0xE0000000)
  3. 创建DM9000设备IO资源到内核虚拟地址的映射,如下。
  1. #vim arch/arm/mach/s3c2410/mach-smdk2410.c
  2. (这次我直接修改mach-smdk2410.c而不是mach-smdk2440.c了,mach-smdk2440.c的修改总是不起作用,
  3. 而要去修改mach-smdk2410.c,原因还没找到。)

  4. static struct map_desc smdk2410_iodesc[] __initdata = {
  5.   /* nothing here yet */
  6.         [0] = {
  7.                 .virtual = (unsigned long)S3C24XX_VA_DM9000,
  8.                 .pfn = __phys_to_pfn(S3C24XX_PA_DM9000),
  9.                 .length = SZ_1M,
  10.                 .type = MT_DEVICE,
  11.         },
  12. };
  4. 在设备初始化中添加对DM9000设备的支持。
  1. #vim arch/arm/mach/s3c2410/mach-smdk2410.c
  2. static struct platform_device *smdk2410_devices[] __initdata = {
  3.         &s3c_device_usb,
  4.         &s3c_device_lcd,
  5.         &s3c_device_wdt,
  6.         &s3c_device_i2c0,
  7.         &s3c_device_iis,
  8.         &s3c_device_rtc,
  9.         &s3c24xx_uda134x, //uda
  10.         &s3c_device_dm9000,
  11. };
  5. 在内核中注册DM9000设备,添加如下内容。
  1. //添加头文件:
  2. #vim arch/arm/plat-s3c24xx/devs.c
  3. #include <linux/dm9000.h>
  4. //注册DM9000:
  5. static struct resource s3c_dm9000_resource[] = {
  6.         [0] = {
  7.                 .start = S3C24XX_PA_DM9000,
  8.                 .end = S3C24XX_PA_DM9000+ 0x3,
  9.                 .flags = IORESOURCE_MEM
  10.         },
  11.         [1] = {
  12.                 .start = S3C24XX_PA_DM9000 + 0x4, //CMD pin is A2
  13.                 .end = S3C24XX_PA_DM9000 + 0x4 + 0x7c,
  14.                 .flags = IORESOURCE_MEM
  15.         },
  16.         [2] = {
  17.                 .start = IRQ_EINT7,
  18.                 .end = IRQ_EINT7,
  19.                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL//IRQF_TRIGGER_RISING
  20.         },
  21. };

  22. static struct dm9000_plat_data s3c_device_dm9000_platdata = {
  23.         .flags= DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
  24. };

  25. struct platform_device s3c_device_dm9000 = {
  26.         .name= "dm9000",
  27.         .id= 0,
  28.         .num_resources= ARRAY_SIZE(s3c_dm9000_resource),
  29.         .resource= s3c_dm9000_resource,
  30.         .dev= {
  31.                .platform_data = &s3c_device_dm9000_platdata,
  32.         }

  33. };
  34. EXPORT_SYMBOL(s3c_device_dm9000);
  6. 在头文件中声明第三步中定义的s3c_device_dm9000
  1. # vi arch/arm/plat-s3c/include/plat/devs.h
  2. extern struct platform_device s3c_device_rtc;
  3. extern struct platform_device s3c_device_adc;
  4. extern struct platform_device s3c_device_sdi;
  5. extern struct platform_device s3c_device_iis;
  6. extern struct platform_device s3c_device_dm9000;
  7. 修改DM9000驱动源码,主要是dm9000_probe函数。
  1. //增加头文件:
  2. #include <mach/regs-gpio.h>
  3. #include <mach/irqs.h>
  4. #include <mach/hardware.h>
  5. //在dm9000_probe 函数开始:
  6. static int __devinit
  7. dm9000_probe(struct platform_device *pdev)
  8. {
  9.         unsigned char ne_def_eth_mac_addr[] = {
  10.                 0x00,0x12,0x34,0x56,0x80,0x49
  11.         };
  12.         static void *bwscon;
  13.         static void *gpfcon;
  14.         static void *extint0;
  15.         static void *intmsk;

  16.         #define BWSCON 0x48000000
  17.         #define GPFCON 0x56000050
  18.         #define EXTINT0 0x56000088
  19.         #define INTMSK 0x4A000008

  20.         bwscon = ioremap_nocache(BWSCON,0x00000004);
  21.         gpfcon = ioremap_nocache(GPFCON,0x00000004);
  22.         extint0 = ioremap_nocache(EXTINT0,0x00000004);
  23.         intmsk = ioremap_nocache(INTMSK,0x00000004);

  24.         writel(readl(bwscon)|0xc0000,bwscon);
  25.         writel((readl(gpfcon)&~(0x3<<4))|(0x2<<4),gpfcon);
  26.         writel(readl(gpfcon)|(0x1<<7),gpfcon); //disable pull-up
  27.         writel((readl(extint0)&~(0xf<<28))|(0x4<<28),extint0);//rising edge
  28.         writel((readl(intmsk)) & ~0x80,intmsk);
  29. //在这个函数最后修改以下位置
  30.     if (!is_valid_ether_addr(ndev->dev_addr)) {
  31.                 /* try reading from mac */
  32.                 
  33.                 mac_src = "chip";
  34.                 for (i = 0; i < 6; i++)
  35.                         //ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
  36.                         ndev->dev_addr[i] = ne_def_eth_mac_addr[i];//修改这里
  37.         }

  8. 编译生成zImage文件,下载到开发板,从启动信息中可以看到,开发板已经可以检测到DM9000网卡驱动:至于“ifconfig: SIOCSIFADDR: No such device”这个信息,我还没有找到原因和解决办法。
  1. starting pid 942, tty '': '/etc/init.d/rcS'
  2. mount: mounting none on /dev/pts failed
  3. mount: mounting tmpfs on /dev/shm failed
  4. dm9000 dm9000.0: WARNING: no IRQ resource flags set.
  5. eth0: link down
  6. ifconfig: SIOCSIFADDR: No such device
  然后就是我们平时熟悉的操作了:
  1. #ifconfig lo 127.0.0.1
  2. #ifconfig eth0 169.254.244.205
  3. # ping 169.254.244.206(我主机的IP)

  4. PING 169.254.244.206 (169.254.244.206): 56 data bytes
  5. 64 bytes from 169.254.244.206: seq=0 ttl=40 time=5.9 ms
  6. 64 bytes from 169.254.244.206: seq=1 ttl=40 time=1.2 ms
  7. 64 bytes from 169.254.244.206: seq=2 ttl=40 time=1.3 ms
  8. 64 bytes from 169.254.244.206: seq=3 ttl=40 time=1.2 ms
  9. 64 bytes from 169.254.244.206: seq=4 ttl=40 time=1.2 ms
  10. 64 bytes from 169.254.244.206: seq=5 ttl=40 time=1.3 ms
  11. 64 bytes from 169.254.244.206: seq=6 ttl=40 time=1.3 ms
  12. 64 bytes from 169.254.244.206: seq=7 ttl=40 time=1.3 ms
  13. 64 bytes from 169.254.244.206: seq=8 ttl=40 time=1.3 ms
  14. 64 bytes from 169.254.244.206: seq=9 ttl=40 time=1.2 ms
  15. 64 bytes from 169.254.244.206: seq=10 ttl=40 time=1.3 ms
  16. ^C
  17. --- 169.254.244.206 ping statistics ---
  18. 11 packets transmitted, 11 packets received, 000000000acket loss
  19. round-trip min/avg/max = 1.2/1.6/5.9 ms
OK,网卡驱动也终于搞掂了。。


2011-01-27
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP