本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。
转载请注明出处:http://blog.csdn.net/muge0913/article/details/7242677
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); };
/*更改网卡头文件*/ //#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, } };
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);
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 };
s3c64xx_init_io(th6410_iodesc,ARRAY_SIZE(th6410_iodesc));
&s3c_device_dm9000,
mac_src= "param data"; memcpy(ndev->dev_addr,pdata->param_addr, 6);
if(!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL){ mac_src = "platform data"; memcpy(ndev->dev_addr,pdata->dev_addr, 6); }
本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。
转载请注明出处:http://blog.csdn.net/muge0913/article/details/7242677