391 id_val |= inb(iobase + 4) << 24;
392
393 if (id_val == DM9KS_ID || id_val == DM9010_ID) {
394
395 /* Request IO from system */
396 if(!request_region(iobase, 2, dev->name))
397 return -ENODEV;
398
399 printk(KERN_ERR' 400 dm9000_found = TRUE; 401 402 /* Allocated board information structure */ 403 memset(dev->priv, 0, sizeof(struct board_info)); 404 db = (board_info_t *)dev->priv; 405 dmfe_dev = dev; 406 db->io_addr = iobase; 407 db->io_data = iobase + 4; 408 db->chip_revision = ior(db, DM9KS_CHIPR); 409 410 chip_info = ior(db,0x43); 411 if((db->chip_revision!=0x1A) || ((chip_info&(1<<5))!=0) || ((chip_info&(1<<2))!=1)) return -ENODEV; 412 413 /* driver system function */ 414 dev->base_addr = iobase; 415 dev->irq = irq; 416 dev->open = &dmfe_open; 417 dev->hard_start_xmit = &dmfe_start_xmit; 418 dev->watchdog_timeo = 5*HZ; 419 dev->tx_timeout = dmfe_timeout; 420 dev->stop = &dmfe_stop; 421 dev->get_stats = &dmfe_get_stats; 422 dev->set_multicast_list = &dm9000_hash_table; 423 dev->do_ioctl = &dmfe_do_ioctl; 424 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,28) 425 dev->ethtool_ops = &dmfe_ethtool_ops; 426 #endif 427 #ifdef CHECKSUM 428 //dev->features |= NETIF_F_IP_CSUM; 429 dev->features |= NETIF_F_IP_CSUM|NETIF_F_SG; 430 #endif 431 db->mii.dev = dev; 432 db->mii.mdio_read = mdio_read; 433 db->mii.mdio_write = mdio_write; 434 db->mii.phy_id = 1; 435 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) 436 db->mii.phy_id_mask = 0x1F; 437 db->mii.reg_num_mask = 0x1F; 438 #endif 439 //db->msg_enable =(debug == 0 ? DMFE_DEF_MSG_ENABLE : ((1 << debug) - 1)); 440 441 /* Read SROM content */ 442 for (i=0; i<64; i++) 443 ((u16 *)db->srom)[i] = read_srom_word(db, i); 444 445 /* Get the PID and VID from EEPROM to check */ 446 id_val = (((u16 *)db->srom)[4])|(((u16 *)db->srom)[5]<<16); 447 printk('id_val=%xn', id_val); 448 if (id_val == DM9KS_ID || id_val == DM9010_ID) 449 HasEEPROM =1; 450 451 /* Set Node Address */ 452 for (i=0; i<6; i++) 453 { 454 if (HasEEPROM) /* use EEPROM */ 455 dev->dev_addr[i] = db->srom[i]; 456 else /* No EEPROM */ 457 dev->dev_addr[i] = MAC_addr[i]; 458 } 459 }//end of if() 460 iobase += 0x10; 461 }while(!dm9000_found && iobase <= DM9KS_MAX_IO); 462 463 return dm9000_found ? 0:-ENODEV; 464 } 465 466 467 /* 468 Open the interface. 469 The interface is opened whenever 'ifconfig' actives it. 470 */ 471 static int dmfe_open(struct net_device *dev) 472 { 473 board_info_t *db = (board_info_t *)dev->priv; 474 u8 reg_nsr; 475 int i; 476 DMFE_DBUG(0, 'dmfe_open', 0); 477 478 if (request_irq(dev->irq,&dmfe_interrupt,0,dev->name,dev)) 479 return -EAGAIN; 480 481 /* Initilize DM910X board */ 482 dmfe_init_dm9000(dev); 483 #ifdef DM8606 484 // control DM8606 485 printk('[8606]reg0=0x%04xn',dm8606_read(db,0)); 486 printk('[8606]reg1=0x%04xn',dm8606_read(db,0x1)); 487 #endif 488 /* Init driver variable */ 489 db->reset_counter = 0; 490 db->reset_tx_timeout = 0; 491 db->cont_rx_pkt_cnt = 0; 492 493 /* check link state and media speed */ 494 db->Speed =10; 495 i=0; 496 do { 497 reg_nsr = ior(db,DM9KS_NSR); 498 if(reg_nsr & 0x40) /* link OK!! */ 499 { 500 /* wait for detected Speed */ 501 mdelay(200); 502 reg_nsr = ior(db,DM9KS_NSR); 503 if(reg_nsr & 0x80) 504 db->Speed =10; 505 else 506 db->Speed =100; 507 break; 508 } 509 i++; 510 mdelay(1); 511 }while(i<3000); /* wait 3 second */ 512 //printk('i=%d Speed=%dn',i,db->Speed); 513 /* set and active a timer process */ 514 init_timer(&db->timer); 515 db->timer.expires = DMFE_TIMER_WUT; 516 db->timer.data = (unsigned long)dev; 517 db->timer.function = &dmfe_timer; 518 add_timer(&db->timer); //Move to DM9000 initiallization was finished. 519 520 netif_start_queue(dev); 521 522 return 0; 523 } 524 525 /* Set PHY operationg mode 526 */ 527 static void set_PHY_mode(board_info_t *db) 528 { 529 #ifndef DM8606 530 u16 phy_reg0 = 0x1000;/* Auto-negotiation*/ 531 u16 phy_reg4 = 0x01e1; 532 533 if ( !(db->op_mode & DM9KS_AUTO) ) // op_mode didn't auto sense */ 534 { 535 switch(db->op_mode) {
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-05 22:18
设计资源 培训 开发板 精华推荐
- LTC2945IMS 在 -48V 系统中使用外部线性稳压器为光耦合器和 SCL/SDA 电阻上拉供电的电源监控的典型应用
- ADR364A、4.096V 低功耗、低噪声负基准电压源的典型应用
- ADP5134 降压稳压器的典型应用电路,具有可调输出电压和精密使能引脚
- MIC2012PZM USB 电源控制器的典型应用
- 使用 Microchip Technology 的 LM385COA-1.2 的参考设计
- LT3990HMSE-5 1.8V 降压转换器的典型应用
- ADP3330 高输出电流线性稳压器的典型应用
- LTC1514-5,低功率双输出电源(最大组合 IOUT = 50mA)
- 使用 Analog Devices 的 LTC1159CG-5 的参考设计
- 使用 Analog Devices 的 LTC7851IUHH-1 的参考设计