592
593 //PHY_REG 27 (1Bh) <- 0037h
594 phy_write(db, 27, 0x0037);
595 //PHY_REG 27 (1Bh) <- AA37h
596 phy_write(db, 27, 0xaa37);
597
598 //PHY_REG 27 (1Bh) <- 0040h
599 phy_write(db, 27, 0x0040);
600 //PHY_REG 27 (1Bh) <- AA40h
601 phy_write(db, 27, 0xaa40);
602
603 //For long code:
604 //PHY_REG 27 (1Bh) <- 0050h
605 phy_write(db, 27, 0x0050);
606 //PHY_REG 27 (1Bh) <- AA50h
607 phy_write(db, 27, 0xaa50);
608
609 //PHY_REG 27 (1Bh) <- 006Bh
610 phy_write(db, 27, 0x006b);
611 //PHY_REG 27 (1Bh) <- AA6Bh
612 phy_write(db, 27, 0xaa6b);
613
614 //PHY_REG 27 (1Bh) <- 007Dh
615 phy_write(db, 27, 0x007d);
616 //PHY_REG 27 (1Bh) <- AA7Dh
617 phy_write(db, 27, 0xaa7d);
618
619 //PHY_REG 27 (1Bh) <- 008Dh
620 phy_write(db, 27, 0x008d);
621 //PHY_REG 27 (1Bh) <- AA8Dh
622 phy_write(db, 27, 0xaa8d);
623
624 //PHY_REG 27 (1Bh) <- 009Ch
625 phy_write(db, 27, 0x009c);
626 //PHY_REG 27 (1Bh) <- AA9Ch
627 phy_write(db, 27, 0xaa9c);
628
629 //PHY_REG 27 (1Bh) <- 00A3h
630 phy_write(db, 27, 0x00a3);
631 //PHY_REG 27 (1Bh) <- AAA3h
632 phy_write(db, 27, 0xaaa3);
633
634 //PHY_REG 27 (1Bh) <- 00B1h
635 phy_write(db, 27, 0x00b1);
636 //PHY_REG 27 (1Bh) <- AAB1h
637 phy_write(db, 27, 0xaab1);
638
639 //PHY_REG 27 (1Bh) <- 00C0h
640 phy_write(db, 27, 0x00c0);
641 //PHY_REG 27 (1Bh) <- AAC0h
642 phy_write(db, 27, 0xaac0);
643
644 //PHY_REG 27 (1Bh) <- 00D2h
645 phy_write(db, 27, 0x00d2);
646 //PHY_REG 27 (1Bh) <- AAD2h
647 phy_write(db, 27, 0xaad2);
648
649 //PHY_REG 27 (1Bh) <- 00E0h
650 phy_write(db, 27, 0x00e0);
651 //PHY_REG 27 (1Bh) <- AAE0h
652 phy_write(db, 27, 0xaae0);
653 //PHY_REG 27 (1Bh) <- 0000h
654 phy_write(db, 27, 0x0000);
655 }
656 }
657
658 /*
659 Initilize dm9000 board
660 */
661 static void dmfe_init_dm9000(struct net_device *dev)
662 {
663 board_info_t *db = (board_info_t *)dev->priv;
664 DMFE_DBUG(0, 'dmfe_init_dm9000()', 0);
665
666 spin_lock_init(&db->lock);
667
668 iow(db, DM9KS_GPR, 0); /* GPR (reg_1Fh)bit GPIO0=0 pre-activate PHY */
669 mdelay(20); /* wait for PHY power-on ready */
670
671 /* do a software reset and wait 20us */
672 iow(db, DM9KS_NCR, 3);
673 udelay(20); /* wait 20us at least for software reset ok */
674 iow(db, DM9KS_NCR, 3); /* NCR (reg_00h) bit[0] RST=1 & Loopback=1, reset on */
675 udelay(20); /* wait 20us at least for software reset ok */
676
677 /* I/O mode */
678 db->io_mode = ior(db, DM9KS_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
679
680 /* Set PHY */
681 db->op_mode = media_mode;
682 set_PHY_mode(db);
683
684 /* Program operating register */
685 iow(db, DM9KS_NCR, 0);
686 iow(db, DM9KS_TCR, 0); /* TX Polling clear */
687 iow(db, DM9KS_BPTR, 0x3f); /* Less 3kb, 600us */
688 iow(db, DM9KS_SMCR, 0); /* Special Mode */
689 iow(db, DM9KS_NSR, 0x2c); /* clear TX status */
690 iow(db, DM9KS_ISR, 0x0f); /* Clear interrupt status */
691 iow(db, DM9KS_TCR2, 0x80); /* Set LED mode 1 */
692 if (db->chip_revision == 0x1A){
693 /* Data bus current driving/sinking capability */
694 iow(db, DM9KS_BUSCR, 0x01); /* default: 2mA */
695 }
696 #ifdef FLOW_CONTROL
697 iow(db, DM9KS_BPTR, 0x37);
698 iow(db, DM9KS_FCTR, 0x38);
699 iow(db, DM9KS_FCR, 0x29);
700 #endif
701
702 #ifdef DM8606
703 iow(db,0x34,1);
704 #endif
705
706 if (dev->features & NETIF_F_HW_CSUM){
707 printk(KERN_INFO 'DM9KS:enable TX checksumn');
708 iow(db, DM9KS_TCCR, 0x07); /* TX UDP/TCP/IP checksum enable */
709 }
710 if (db->rx_csum){
711 printk(KERN_INFO 'DM9KS:enable RX checksumn');
712 iow(db, DM9KS_RCSR, 0x02); /* RX checksum enable */
713 }
714
715 #ifdef ETRANS
716 /*If TX loading is heavy, the driver can try to anbel 'early transmit'.
717 The programmer can tune the 'Early Transmit Threshold' to get
718 the optimization. (DM9KS_ETXCSR.[1-0])
719
720 Side Effect: It will happen 'Transmit under-run'. When TX under-run
721 always happens, the programmer can increase the value of 'Early
722 Transmit Threshold'. */
723 iow(db, DM9KS_ETXCSR, 0x83);
724 #endif
725
726 /* Set address filter table */
727 dm9000_hash_table(dev);
728
729 /* Activate DM9000/DM9010 */
730 iow(db, DM9KS_IMR, DM9KS_REGFF); /* Enable TX/RX interrupt mask */
731 iow(db, DM9KS_RXCR, DM9KS_REG05 | 1); /* RX enable */
732
733 /* Init Driver variable */
734 db->tx_pkt_cnt = 0;
735
736 netif_carrier_on(dev);
737
738 }
739
740 /*
741 Hardware start transmission.
742 Send a packet to media from the upper layer.
743 */
744 static int dmfe_start_xmit(struct sk_buff *skb, struct net_device *dev)
745 {
746 board_info_t *db = (board_info_t *)dev->priv;
747 char * data_ptr;
748 int i, tmplen;
749 u16 MDWAH, MDWAL;
750
751 #ifdef TDBUG /* check TX FIFO pointer */
752 u16 MDWAH1, MDWAL1;
753 u16 tx_ptr;
754 #endif
755
756 DMFE_DBUG(0, 'dmfe_start_xmit', 0);
757 if (db->chip_revision != 0x1A)
758 {
759 if(db->Speed == 10)
760 {if (db->tx_pkt_cnt >= 1) return 1;}
761 else
762 {if (db->tx_pkt_cnt >= 2) return 1;}
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-13 19:27
设计资源 培训 开发板 精华推荐
- LT1086CM 用于改善纹波抑制的低压差正稳压器的典型应用
- 带 L5991A 的 25W 离线自动测距电池充电器
- EVAL-AD7177-2SDZ,评估具有 100 us 稳定和集成模拟输入缓冲器的 AD7177-2、32 位、10 kSPS、Sigma-Delta ADC
- 使用 NXP Semiconductors 的 PCF85263AT 的参考设计
- L7812C 带温度补偿的可调输出电压的典型应用
- 基于IPS160HF的工业数字输出扩展板,适用于STM32 Nucleo
- 使用 Analog Devices 的 REF192 的参考设计
- #第七届立创电赛#实时姿态显示
- EVAL-ADG796AEB,用于高清电视的 ADG796 十六进制 2:1 模拟多路复用器的评估板
- VN7040AJ评估板