mini6410移植全攻略(13)--linux2.6.39 移植之支持dm9000


本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。

     转载请注明出处:http://blog.csdn.net/muge0913/article/details/7242677


、vi include/linux/dm9000.h


28行增加
unsignedchar param_addr[6];

如下:



structdm9000_plat_data {

unsignedint flags;

unsignedchar dev_addr[6];

unsignedchar param_addr[6];

/*allow replacement IO routines */

void (*inblk)(void__iomem *reg, void *data, int len);

void (*outblk)(void__iomem *reg, void *data, int len);

void (*dumpblk)(void__iomem *reg, int len);

};



、viarch/arm/mach-s3c64xx/mach-th6410.c
添加头文件:

/*更改网卡头文件*/

//#include<linux/smsc911x.h>

#include<linux/dm9000.h>


增加

#defineS3C64XX_PA_DM9000 (0x18000000)
#define S3C64XX_SZ_DM9000SZ_1M
#define S3C64XX_VA_DM9000 S3C_ADDR(0x03b00300)

staticstruct resource dm9000_resources[] = {
[0] = {
.start =S3C64XX_PA_DM9000,
.end = S3C64XX_PA_DM9000 + 3,
.flags =IORESOURCE_MEM,
},
[1] = {
.start = S3C64XX_PA_DM9000 +4,
.end = S3C64XX_PA_DM9000 + S3C64XX_SZ_DM9000 - 1,
.flags =IORESOURCE_MEM,
},
[2] = {
.start = IRQ_EINT(7),
.end =IRQ_EINT(7),
.flags = IORESOURCE_IRQ |IRQF_TRIGGER_HIGH,
},
};

static struct dm9000_plat_datadm9000_setup = {
.flags = DM9000_PLATF_16BITONLY,
.dev_addr = {0x08, 0x90, 0x00, 0xa0, 0x90, 0x90 },
};

static structplatform_device s3c_device_dm9000 = {
.name = "dm9000",
.id= 0,
.num_resources = ARRAY_SIZE(dm9000_resources),
.resource =dm9000_resources,
.dev = {
.platform_data =&dm9000_setup,
}
};




增加mac 地址设置函数
staticint __init dm9000_set_mac(char *str) {
unsigned charaddr[6];
unsigned int val;
int idx = 0;
char *p = str,*end;
while (*p && idx < 6) {
val =simple_strtoul(p, &end, 16);
if (end <= p) {
/* convertfailed */
break;
} else {
addr[idx++] = val;
p = end;
if(*p == ':'|| *p == '-') {
p++;
} else {
break;
}
}
}
if(idx == 6) {
printk("Setup ethernet address to %pM\n",addr);
memcpy(dm9000_setup.param_addr, addr, 6);
}

return1;
}

__setup("ethmac=",dm9000_set_mac);



增加IO 映射
增加映射结构体
static struct map_desc th6410_iodesc[] = {
#ifdefCONFIG_DM9000
{
.virtual = (u32)S3C64XX_VA_DM9000,
.pfn =__phys_to_pfn(S3C64XX_PA_DM9000),
.length =S3C64XX_SZ_DM9000,
.type = MT_DEVICE,
},
#endif
};

 
 然后在staticvoid __init th6410_map_io(void) 
 函数中 
 将s3c64xx_init_io(NULL,0); 
 改成 
 
s3c64xx_init_io(th6410_iodesc,ARRAY_SIZE(th6410_iodesc));



最后在staticstruct platform_device *th6410_devices[] __initdata 的初始化设备中
&th6410_smsc911x,
改成

&s3c_device_dm9000,



、vidrivers/net/dm9000.c
大概1586
mac_src= "platform data";
memcpy(ndev->dev_addr,pdata->dev_addr, 6);

改成

mac_src= "param data";
memcpy(ndev->dev_addr,pdata->param_addr, 6);



大概1598
增加
if(!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL){
mac_src = "platform data";
memcpy(ndev->dev_addr,pdata->dev_addr, 6);
}




、makemenuconfig
[*] Networking support --->
Networking options--->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: DHCP support
[*] IP: BOOTP support
[*] IP: RARPsupport
Device Drivers --->
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
<*> DM9000 support
[ ] Ethernet (1000 Mbit) --->
去掉
其他的默认

编译出来,在引导信息中就能看到dm9000网卡信息了。

dm9000Ethernet Driver, V1.31
eth0: dm9000a at d0930000,d0e00004 IRQ 108MAC: 08:90:90:90:


本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。

     转载请注明出处:http://blog.csdn.net/muge0913/article/details/7242677






你可能感兴趣的:(c,IO,struct,resources,networking,Sockets)