日期:2014-05-16  浏览次数:20712 次

linux-2.6.32在mini2440开发板上移植之DM9000网卡移植(3)

                                                                  移植DM9000 网卡驱动
1 设备资源初始化
      Linux-2..6.32.2 已经自带了完善的DM9000 网卡驱动驱动(源代码位置:linux-2.6.32.2/
drivers/net/dm9000.c),它也是一个平台设备,因此在目标平台初始化代码中,只要填写好相
应的结构表即可,具体步骤如下:

首先添加驱动所需的头文件dm9000.h:
#include <linux/dm9000.h>

再定义DM9000 网卡设备的物理基地址,以便后面用到:
/* DM9000AEP 10/100 ethernet controller */
#define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
再填充该平台设备的资源设置,以便和DM9000 网卡驱动接口配合起来,如下
static struct resource mini2440_dm9k_resource[] = {
        [0] = {
                .start = MACH_MINI2440_DM9K_BASE,
                .end = MACH_MINI2440_DM9K_BASE + 3,
                .flags = IORESOURCE_MEM
               },
        [1] = {
               .start = MACH_MINI2440_DM9K_BASE + 4,
               .end = MACH_MINI2440_DM9K_BASE + 7,
               .flags = IORESOURCE_MEM
               },
        [2] = {
              .start = IRQ_EINT7,
              .end = IRQ_EINT7,
              .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
               }
};
/*
* * * The DM9000 has no eeprom, and it's MAC address is set by
* * * the bootloader before starting the kernel.
* * */
static struct dm9000_plat_data mini2440_dm9k_pdata = {
                  .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
static struct platform_device mini2440_device_eth = {
                 .name = "dm9000",
                 .id = -1,
                 .num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
                 .resource = mini2440_dm9k_resource,
                .dev = {
                .platform_data = &mini2440_dm9k_pdata,
       &