好了,不罗嗦了,先把工作做完。
移植步骤
1. 修改arch/arm/plat-s3c24xx/devs.c,加入dm9000的信息,并使用EXPORT_SYMBOL 宏将platform_device s3c_device_dm9000导出,在smdk2410.c中会用到
//===========================================================================
// dm9000 ------yangdk
#define DM9000_BASE 0x28000300
//#define DM9000_IRQ IRQ_EINT3
static struct resource s3c_dm9000_resource[] = {
[0] = {
.start = DM9000_BASE,
.end = DM9000_BASE+ 0x3,
.flags = IORESOURCE_MEM
},
[1]={
.start = DM9000_BASE + 0x4,
.end = DM9000_BASE + 0x4 + 0x7c,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT3,
.end = IRQ_EINT3,
.flags = IORESOURCE_IRQ
}
};
static struct dm9000_plat_data s3c_device_dm9000_platdata = {
.flags= DM9000_PLATF_16BITONLY,
};
struct platform_device s3c_device_dm9000 = {
.name= "dm9000",
.id= 0,
.num_resources= ARRAY_SIZE(s3c_dm9000_resource),
.resource= s3c_dm9000_resource,
.dev= {
.platform_data = &s3c_device_dm9000_platdata,
}
};
EXPORT_SYMBOL(s3c_device_dm9000);
//end of DM9000
//===========================================================================
2.在include/asm-arm/plat-s3c24xx/devs.h 文件中 添加一行
extern struct platform_device s3c_device_dm9000;
3.在arch/arm/mach-s3c2410/mach-smdk2410.c中将dm9000加入到要初始化的设备链表里去,内核启动时将会检测设备并加载驱动
static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
&s3c_device_dm9000,
};
4.在arch/arm/mach-s3c2440/mach-smdk2440.c中加入对DM9000的地址映射
static struct map_desc smdk2440_iodesc[] __initdata = {
/* ISA IO Space map (memory space selected by A24) */
{
.virtual = (u32)S3C24XX_VA_ISA_WORD,
.pfn = __phys_to_pfn(S3C2410_CS2),
.length = 0x10000,
.type = MT_DEVICE,
}, {
.virtual = (u32)S3C24XX_VA_ISA_WORD + 0x10000,
.pfn = __phys_to_pfn(S3C2410_CS2 + (1<<24)),
.length = SZ_4M,
.type = MT_DEVICE,
}, {
.virtual = (u32)S3C24XX_VA_ISA_BYTE,
.pfn = __phys_to_pfn(S3C2410_CS2),
.length = 0x10000,
.type = MT_DEVICE,
}, {
.virtual = (u32)S3C24XX_VA_ISA_BYTE + 0x10000,
.pfn = __phys_to_pfn(S3C2410_CS2 + (1<<24)),
.length = SZ_4M,
.type = MT_DEVICE,
},{
.virtual = S3C2410_ADDR(0x02100300),
.pfn = __phys_to_pfn(0x28000300), //DM9000 -----yangdk
.length = SZ_1M,
.type = MT_DEVICE,
}
};
5. 修改driver/net/dm9000.c
加入几个头文件,后面有用
#include
#include
#include
在probe函数中加入
unsigned char ne_def_eth_mac_addr[]={0x00,0x12,0x34,0x56,0x80,0x49};//yangdk
for (i = 0; i < 6; i++)
//ndev->dev_addr[i] = ior(db, i+DM9000_PAR); //yangdk
ndev->dev_addr[i] = ne_def_eth_mac_addr[i];
//-----------yangdk------------------------------------------------->
static void *bwscon,*bankcon4,*bankcon5;
static void *gpfcon,*gpfcon1;
static void *extint0,*extint01;
static void *intmsk;
static void *dsc0,*dsc1;
#define BWSCON (0x48000000)
#define BANKCON4 (0x48000014)
#define BANKCON5 (0x48000018)
#define GPFCON (0x56000060) //infact: GPGCON=0X56000060
#define GPFCON1 (0x56000050)
#define EXTINT0 (0x5600008C)
#define EXTINT01 (0x56000088)
#define INTMSK (0x4A000008)
#define DSC0 0x560000c4)
#define DSC1 (0x560000c8)
bwscon=ioremap_nocache(BWSCON,0x0000004);
extint01=ioremap_nocache(EXTINT01,0x0000004);//
intmsk=ioremap_nocache(INTMSK,0x0000004);
dsc1=ioremap_nocache(DSC1,0x0000004);
writel(readl(bwscon)|0xc0000,bwscon);
writel(readl(dsc1)|(0xf<<8),dsc1);
s3c2410_gpio_cfgpin(S3C2410_GPF3, S3C2410_GPF3_EINT3);
writel((readl(extint01)&(~(3<<13)))|(1<<12),extint01); //eint3 high level
writel(readl(intmsk)&(~(1<<3)),intmsk); //
//<-----------yangdk------------------------------------------------