分类: LINUX
2010-09-05 22:35:02
static struct resource s3c_dm9k_resource0[] = {
[0] = {
.start = S3C2410_CS4,
.end = S3C2410_CS4 + 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = S3C2410_CS4 + 4,
.end = S3C2410_CS4 + 7,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT7,
.end = IRQ_EINT7,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
}
};static struct dm9000_plat_data s3c_device_dm9k_pdata0 = {
.flags = DM9000_PLATF_16BITONLY
};
static struct platform_device s3c_device_eth0 = {
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_dm9k_resource0),
.resource = s3c_dm9k_resource0,
.dev = {
.platform_data = &s3c_device_dm9k_pdata0,
},
};static struct resource s3c_dm9k_resource1[] = {
[0] = {
.start = S3C2410_CS3,
.end = S3C2410_CS3+ 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = S3C2410_CS3+ 4,
.end = S3C2410_CS3+ 7,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT8,
.end = IRQ_EINT8,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
}
};static struct dm9000_plat_data s3c_device_dm9k_pdata1 = {
.flags = DM9000_PLATF_16BITONLY
};
static struct platform_device s3c_device_eth1 = {
.name = "dm9000",
.id = 1,
.num_resources = ARRAY_SIZE(s3c_dm9k_resource1),
.resource = s3c_dm9k_resource1,
.dev = {
.platform_data = &s3c_device_dm9k_pdata1,
},
};
static void s3c_dm9k_bus_init(void)
{
unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
*((volatile unsigned int *)S3C2410_BWSCON) =
(oldval_bwscon & ~(0x33<<12)) | S3C2410_BWSCON_DW3_16|S3C2410_BWSCON_DW4_16;
}
void __init sbc2440_init(void)
{
......s3c_dm9k_bus_init();//koujinqiao......}
if (request_irq(dev->irq, &dm9000_interrupt, SA_INTERRUPT, dev->name, dev))
return -EAGAIN;set_irq_type(dev->irq, IRQT_FALLING);//if (request_irq(dev->irq, &dm9000_interrupt, SA_SHIRQ, dev->name, dev))
// return -EAGAIN;设置中断为单独中断编译通过后,启动系统。
eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
eth1: link up, 100Mbps, full-duplex, lpa 0xCDE1则需要重新启动系统。启动信息显示为Try to bring eth0 interface up......eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Done
Try to bring eth1 interface up......eth1: link up, 100Mbps, full-duplex, lpa 0xCDE1
Done才能可以正常ping通。ping通后若使用ifconfig ethX down 则ethX不能再ping 通。问题怀疑为启动初始化不对
添加函数
static void
dm9000_reinit_dm9000(board_info_t * db)
{
PRINTK1("entering %s\n",__FUNCTION__);/* I/O mode */
db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode *//* GPIO0 on pre-activate PHY */
iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */
iow(db, DM9000_GPR, 0); /* Enable PHY *//* Program operating register */
iow(db, DM9000_TCR, 0); /* TX Polling clear */
iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
iow(db, DM9000_FCR, 0xff); /* Flow Control */
iow(db, DM9000_SMCR, 0); /* Special Mode */
/* clear TX status */
iow(db, DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END);
iow(db, DM9000_ISR, ISR_CLR_STATUS); /* Clear interrupt status *//* Activate DM9000 */
iow(db, DM9000_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN);
/* Enable TX/RX interrupt mask */
iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);/* Init Driver variable */
db->tx_pkt_cnt = 0;
db->queue_pkt_len = 0;
}
在
static void
dm9000_reset(board_info_t * db)
{
PRINTK1("dm9000: resetting\n");
/* RESET device */
writeb(DM9000_NCR, db->io_addr);
udelay(200);
writeb(NCR_RST, db->io_data);
udelay(200);dm9000_reinit_dm9000(db);
}添加了dm9000_reinit_dm9000(db);
解决了重新启动系统才能ping通网络的问题。
chinaunix网友2010-12-28 18:15:28
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com