Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93029
  • 博文数量: 21
  • 博客积分: 548
  • 博客等级: 中士
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-01 12:11
文章分类

全部博文(21)

文章存档

2012年(12)

2011年(9)

我的朋友

分类: 嵌入式

2012-04-24 16:49:53

嵌入式Linux2.6.32系统移植–DM9000

主机:RHEL6.0(2.6.32-220.2.1.el6.i686)

开发板:FL2440

编译器:arm-unknown-linux-gnueabi-gcc-4.4.6

@@arch/arm/plat-s3c24xx/common-smdk.c

##添加头文件

#include

##添加函数

点击(此处)折叠或打开

  1. /* DM9000 */
  2. static struct resource s3c_dm9k_resource[] = {
  3.         [0] = {
  4.                 .start = S3C2410_CS4, /* ADDR2=0 ,发送地址时使用这个地址 */
  5.                 .end = S3C2410_CS4 + 3,
  6.                 .flags = IORESOURCE_MEM,
  7.         },

  8.         [1] = {
  9.                 .start = S3C2410_CS4 + 4, /* ADDR2=1 ,传输数据时使用这个地址 */
  10.                 .end = S3C2410_CS4 + 4 + 3,
  11.                 .flags = IORESOURCE_MEM,
  12.         },

  13.         [2] = {
  14.                 .start = IRQ_EINT7, /* 中断号 */
  15.                 .end = IRQ_EINT7,
  16.                 .flags = IORESOURCE_IRQ|IRQF_TRIGGER_RISING,
  17.         }

  18. };


  19. /* for the moment we limit ourselves to 16bit IO until some
  20.  *
  21.  * * better IO routines can be written and tested
  22.  *
  23.  * */

  24. static struct dm9000_plat_data s3c_dm9k_platdata = {
  25.         .flags = DM9000_PLATF_16BITONLY,
  26. };

  27. static struct platform_device s3c_device_dm9k = {
  28.         .name = "dm9000",
  29.         .id = 0,
  30.         .num_resources = ARRAY_SIZE(s3c_dm9k_resource),
  31.         .resource = s3c_dm9k_resource,
  32.         .dev = {
  33.                 .platform_data = &s3c_dm9k_platdata,
  34.         }
  35. };

##注册设备

  1. &s3c_device_nand,
  2. + &s3c_device_dm9k,

修改dm9000.c源码

##添加头文件

  1. #ifdef CONFIG_ARCH_S3C2440
  2. #include <mach/regs-mem.h>
  3. #endif

##添加初始化部分

点击(此处)折叠或打开

  1. dm9000_init(void)
  2. {
  3. +#ifdef CONFIG_ARCH_S3C2440
  4. + unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
  5. + unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
  6. + *((volatile unsigned int *)S3C2410_BWSCON) =
  7. + (oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 |
  8. + S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
  9. + *((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
  10. +#endif
  11.         printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
  12.         return platform_driver_register(&dm9000_driver);
  13. }

##添加软MAC地址

点击(此处)折叠或打开

  1. + //使用软MAC地址,10:23:45:67:89:ab
  2. + memcpy(ndev->dev_addr, "\x10\x23\x45\x67\x89\xab", 6);
  3.         if (!is_valid_ether_addr(ndev->dev_addr))
  4.                 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
  5.                          "set using ifconfig\n", ndev->name);

##指定中断方式

##不然会出现:dm9000 dm9000.0: WARNING: no IRQ resource flags set.

##dm9000_open函数中

点击(此处)折叠或打开

  1. +#ifdef CONFIG_ARCH_S3C2440
  2. + if (request_irq(dev->irq, &dm9000_interrupt, IRQF_SHARED|IRQF_TRIGGER_RISING, dev->name, dev))
  3. +#else
  4.         if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
  5. +#endif
  6.                 return -EAGAIN;

 至此,DM9000的移植完成。

##附RTC的实现

@@arch/arm/mach-s3c2440/mach-smdk2440.c

smdk2440_devices[] __initdata添加一行:

&s3c_device_rtc,





阅读(790) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~