只用到一条地址线,ADDR2,这是由 DM9000 的特性决定的:DM9000的地址信号和数据信号复用,使用 CMD引脚来区分它们(CMD为低时数据总线上传输的是地址信号,反之,数据信号)。访问DM9000内部寄存器时,需要先将 CMD 置为低电平,发出地址信号,然后将CMD置为高电平,读写数据。
3.
4.
- # vim arch/arm/mach-s3c2440/mach-smdk2440.c
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&dm9000_device,
};
5.
- static int __devinit
-
dm9000_probe(struct platform_device *pdev)
-
{
- ...。。。。。。。。
-
int i;
-
u32 id_val;
###############
用来保存 BWSCON S3C2410_BANKCON4 寄存器的值 ,
-
#if defined(CONFIG_ARCH_S3C2410)
-
unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
-
unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
-
#endif
-
-
/* Init network device */
-
ndev = alloc_etherdev(sizeof(struct board_info));
- .......。。。。。。。。
-
dev_dbg(&pdev->dev, "dm9000_probe()\n");
############
设置 bank4,总线宽度为16,时能nWAIT、
设置BANK4的时间参数
-
#if defined(CONFIG_ARCH_S3C2410)
-
*((volatile unsigned int *)S3C2410_BWSCON) = (oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
-
*((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
-
#endif
-
/* setup board info structure */
-
db = netdev_priv(ndev);
- 。。。。。。。。
-
db->flags = pdata->flags;
-
}
-
-
#ifdef CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL
-
db->flags |= DM9000_PLATF_SIMPLE_PHY;
-
#endif
-
-
dm9000_reset(db);
-
。。。。。。。。。。。
-
-
db->mii.mdio_write = dm9000_phy_write;
##################
设置 MAC 地址
-
#if defined(CONFIG_ARCH_S3C2410)
-
printk("Now use the default MAC address: 10:23:45:67:89:ab\n");
-
mac_src = "ywx";
-
ndev->dev_addr[0] = 0x10;
-
ndev->dev_addr[1] = 0x23;
-
ndev->dev_addr[2] = 0x45;
-
ndev->dev_addr[3] = 0x67;
-
ndev->dev_addr[4] = 0x89;
-
ndev->dev_addr[5] = 0xab;
-
#else
-
-
mac_src = "eeprom";
-
-
/* try reading the node address from the attached EEPROM */
-
for (i = 0; i < 6; i += 2)
-
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
-
-
if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
-
mac_src = "platform data";
-
memcpy(ndev->dev_addr, pdata->dev_addr, 6);
-
}
-
-
if (!is_valid_ether_addr(ndev->dev_addr)) {
-
/* try reading from mac */
-
-
mac_src = "chip";
-
for (i = 0; i < 6; i++)
-
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
-
}
-
-
if (!is_valid_ether_addr(ndev->dev_addr))
-
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
-
"set using ifconfig\n", ndev->name);
-
#endif
-
-
platform_set_drvdata(pdev, ndev);
- 。。。。。
-
return 0;
-
-
out:
-
#if defined(CONFIG_ARCH_S3C2410)
-
*(volatile unsigned int *)S3C2410_BWSCON = oldval_bwscon;
-
*(volatile unsigned int *)S3C2410_BANKCON4 = oldval_bankcon4;
-
#endif
-
dev_err(db->dev, "not found (%d).\n", ret);
-
-
dm9000_release_board(pdev, db);
-
free_netdev(ndev);
-
-
return ret;
-
}