DM9000网卡驱动的移植

a)      #make menuconfig

进入配置菜单选中

driver——

net——

10/100M net——

DM9000 support

b)     

 在arch/arm/plat-s3c24xx/devs.c也可做在arch/arm/mach-s3c2440/mach-smdk2440.c中的

 中加入DM9000A的端口及设备说明仿照前面的设备添加就是了结构都一样就是值不同。

static struct resource s3c_dm9k_resource[] = {

         [0] = {

                   .start = 0x18000000,                  

//dm9000a的片选我的板子接的是nGCS3,这里没有加300的基址

                   .end   = 0x18000003,               

//这里搞不懂为什么是加3[可能因为是块设备吧]

                   .flags = IORESOURCE_MEM,

         },

         [1] = {

                   .start = 0x18000004,                  

//因为CMD接的是A2,其为1时就是数据端口

                   .end   = 0x18000007,               

//0X3F,0X7F为什么是这个地址

                   .flags = IORESOURCE_MEM,

         },

         [2] = {

                   .start = IRQ_EINT9,                            //根据电路图接的是EINT9管脚

                   .end   = IRQ_EINT9,

                   .flags = IORESOURCE_IRQ,

//               .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, //at2440evb中的设置

         }

};

 

static struct dm9000_plat_data s3c_device_dm9k_pdata = {

//      .flags         = (DM9000_PLATF_16BITONLY|DM9000_PLATF_NO_EEPROM), //at2440evb中的设置

         .flags         = DM9000_PLATF_16BITONLY

};

 

static struct platform_device s3c_device_dm9k = {

         .name                 = "dm9000",

         .id              = -1,

         .num_resources        = ARRAY_SIZE(s3c_dm9k_resource),

         .resource  = s3c_dm9k_resource,

         .dev           = {

                                     .platform_data          = &s3c_device_dm9k_pdata,

         },

};

 

EXPORT_SYMBOL(s3c_device_dm9k);

c)      arch/arm/plat-s3c24xx/include/plat/devs.h中添加网卡声明

extern struct platform_device s3c_device_dm9k;

d)      arch/arm/mach-s3c2440/ mach-s3c2440.c中将dm9000a加到平台设备初始化列表中

static struct platform_device *smdk2440_devices[] __initdata = {

         &s3c_device_usb,

         &s3c_device_lcd,

         &s3c_device_wdt,

         &s3c_device_i2c,

         &s3c_device_iis,

         &s3c_device_dm9k,

};至此向内核注册DM9000A已经完成。

e)      drivers/net/dm9000.c开头中添加

#include <mach/regs-gpio.h>

#define     EINTMASK      (0x560000a4)            //外部中断屏蔽

#define     EXTINT1  (0x5600008c)                     //外部中断方式

#define     INTMSK  (0x4a000008)                     //中断屏蔽

dm9000_probe()ret = register_netdev(ndev); 1392之前添加

memcpy(ndev->dev_addr,"/oandy1",6);

extint1      =ioremap_nocache(EXTINT1,0x00000004);

intmsk     =ioremp_nocache(INTMSK,4);

 

s3c2410_gpio_cfgpin(s3c2410_GPG1,s3c2410_GPG1_EINT9); //设置GPG1为中断功能

writel(readl(extint1)|0x40,extint1);                   //中断为上升沿

writel(readl(intmsk)&0xfff1,intmsk);

 

iounmap(intmsk);

iounmap(extint1);

f)      第二种方案是直接参考/arch/arm/mach-s3c2440/mach-at2440evb.c进行修改我按照此方案更改完全有效。

i.       修改/arch/arm/mach-s3c2440/mach-smdk2440.c拷贝/arch/arm/mach-s3c2440/mach-at2440evb.c中关于DM9000AEP的代码进行修改

         #include <linux/dm9000.h>

static struct resource s3c_dm9k_resource[] = {

         [0] = {

                   .start = S3C2410_CS3,

                   .end   = S3C2410_CS3 + 3,

                   .flags = IORESOURCE_MEM

         },

         [1] = {

                   .start = S3C2410_CS3 + 4,

                   .end   = S3C2410_CS3 + 7,

                   .flags = IORESOURCE_MEM

         },

         [2] = {

                   .start = IRQ_EINT9,

                   .end   = IRQ_EINT9,

                   .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,

         }

};

 

static struct dm9000_plat_data s3c_dm9k_pdata = {

         .flags                  = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),

};

 

static struct platform_device s3c_device_dm9k = {

         .name                 = "dm9000",

         .id              = -1,

         .num_resources         = ARRAY_SIZE(s3c_dm9k_resource),

         .resource   = s3c_dm9k_resource,

         .dev           = {

                   .platform_data          = & s3c_dm9k_pdata,

         },

};

这段代码加在static struct platform_device *smdk2440_devices[] __initdata之前修改设备初始化

static struct platform_device *smdk2440_devices[] __initdata = {

         &s3c_device_usb,

         &s3c_device_lcd,

         &s3c_device_wdt,

         &s3c_device_i2c,

         &s3c_device_iis,

         &s3c_device_dm9k,

};

g)      修改根文件系统/etc/init.d/rcS配置网卡,增加下面的代码

ifconfig lo 127.0.0.1

ifconfig eth0 hw ether 08:00:3e:26:0a:5b

ifconfig eth0 192.168.1.70

route add default gw 192.168.1.1

h)      配置内核:

                   #make menuconfig

                            Device Drivers—

                      Network device support—

                      Ethernet(10 or 10Mbit)—

                      DM9000 support

你可能感兴趣的:(c,struct,cmd,NetWork,IIS,resources)