ARM9开发板FL2440移植Linux-3.0内核————dm9000网卡的移植

时间:2021-06-08 16:31:50

第一步、修改内核代码

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

#include <linux/dm9000.h>  //添加DM9000网卡的头文件

并添加如下代码

/* add DM9000 ethernet drivers ,whitch is bodify by liuchengdeng */
#define DM9000_BASE    (S3C2410_CS4 + 0x300)
static struct resource s3c_dm9000_resource[] = {
     [0] = {
        .start = DM9000_BASE,
        .end   = DM9000_BASE + 3,
        .flags = IORESOURCE_MEM
    },
    [1] = {
        .start = DM9000_BASE + 4,
        .end   = DM9000_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 s3c_dm9000_pdata = {
    .flags      = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};

static struct platform_device s3c_device_dm9000 = {
    .name       = "dm9000",
    .id     = -1,
    .num_resources  = ARRAY_SIZE(s3c_dm9000_resource),
    .resource   = s3c_dm9000_resource,
    .dev        = {
        .platform_data  = &s3c_dm9000_pdata,
    },
};

2.修改platform_device *smdk2440_devices[] __initdata结构体为如下,在其中添加启动DM9000

static struct platform_device *smdk2440_devices[] __initdata = {
    &s3c_device_ohci,
    &s3c_device_lcd,
    &s3c_device_wdt,
    &s3c_device_i2c0,
    &s3c_device_iis,
   
&s3c_device_dm9000,
};

3.vim include/linux/dm9000.h  添加如下头文件

#include <linux/io.h>

重新make之后,我们的内核文件就支持dm9000网卡了,在开发板上跑起来后,就能够ping 192.168.1.168(电脑有线IP)