###dm9000的移植(注意中文括号)
plat_dev平台代码修改:
vim arch/arm/mach-s5pc100/mach-smdkv210.c
1. 修改网卡的mac地址:
static struct dm9000_plat_data smdkv210_dm9000_platdata = {
.flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
.dev_addr = { 0x00, 0x09, 0xc0, 0xff, 0xec, 0xee }, // 设置为座位号码
};
//2. 修改结构体数组smdkv210_dm9000_resources为:
static struct resource smdkv210_dm9000_resources[] = {
[0] = {
.start = 0x88000000,
.end = 0x88000000 + 0x3,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = 0x88000000 + 0x4,
.end = 0x88000000 + 0x4 + 0x3,
.flags = IORESOURCE_MEM,
},
[2] = {
.start = IRQ_EINT(10),
.end = IRQ_EINT(10),
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
},
};
//3. 修改函数smdkv210_dm9000_init为:
static void __init smdkv210_dm9000_init(void)
{
unsigned int tmp;
gpio_request(S5PV210_MP01(1), "nCS1");
s3c_gpio_cfgpin(S5PV210_MP01(1), S3C_GPIO_SFN(2));
gpio_free(S5PV210_MP01(1));
tmp = (5 << S5P_SROM_BCX__TACC__SHIFT);
__raw_writel(tmp, S5P_SROM_BC1);
tmp = __raw_readl(S5P_SROM_BW);
tmp&= (S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS1__SHIFT);
tmp |= (1 << S5P_SROM_BW__NCS1__SHIFT);
__raw_writel(tmp, S5P_SROM_BW);
}
-------------------------------------------------------------------------------------------------------------------------
plat_drv移植方法:
//1.修改驱动:driver/net/dm9000.c, 在文件的偏向开始的位置添加
static unsigned char boot_dev_addr[6];
static unsigned char boot_mac_flag = 0;
static int __init netmac_boot_setup(char *str)
{
int i = 0;
char *buf, *tok;
char *whitespace = ":";
buf = str;
do {
buf = buf + strspn(buf, whitespace); // find :
tok = strsep(&buf, whitespace); // seperate string
if (*tok == '\0') {
break;
}
if(i >= 6)
break;
boot_dev_addr[i++] = (unsigned char )simple_strtoul(tok, NULL, 16);
}while(buf);
if (i != 6)
return 0;
boot_mac_flag = 1;
return 1;
}
__setup("ethaddr=", netmac_boot_setup); // 有了这个__setup,我们bootargs中传递的ethaddr=00:12:34:aa:ac:ef 才有效
//2. 修改dm9000_probe()
if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
mac_src = "platform data";
///jihq add
if(boot_mac_flag)
memcpy(ndev->dev_addr, boot_dev_addr, 6); //使用uboot传递过来的mac地址
else
memcpy(ndev->dev_addr, pdata->dev_addr, 6);
}
-------------------------------------------------------------------------------------------------------------------------
dm9000的内核配置
配置内核
$ make menuconfig
[*] Networking support (NEW) --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: multicasting
[*] IP: kernel level autoconfiguration
[*] IP: BOOTP support
Device Drivers --->
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
<*> DM9000 support
File systems --->
[*] Network File Systems --->
<*> NFS client suppor
[*] NFS client support for NFS version 3
[*] NFS client support for the NFSv3 ACL protocol extension
[*] Root file system on NFS
编译内核,并拷贝到tftpboot目录下
$ make zImage
$ cp arch/arm/boot/zImage /tftpboot
dm9000的移植
最新推荐文章于 2017-08-11 23:50:00 发布