688 }
689 #ifdef FLOW_CONTROL
690 iow(db, DM9KS_BPTR, 0x37);
691 iow(db, DM9KS_FCTR, 0x38);
692 iow(db, DM9KS_FCR, 0x29);
693 #endif
694
695 #ifdef DM8606
696 iow(db,0x34,1);
697 #endif
698
699 if (dev->features & NETIF_F_HW_CSUM){
700 printk(KERN_INFO 'DM9KS:enable TX checksumn');
701 iow(db, DM9KS_TCCR, 0x07); /* TX UDP/TCP/IP checksum enable */
702 }
703 if (db->rx_csum){
704 printk(KERN_INFO 'DM9KS:enable RX checksumn');
705 iow(db, DM9KS_RCSR, 0x02); /* RX checksum enable */
706 }
707
708 #ifdef ETRANS
709 /*If TX loading is heavy, the driver can try to anbel 'early transmit'.
710 The programmer can tune the 'Early Transmit Threshold' to get
711 the optimization. (DM9KS_ETXCSR.[1-0])
712
713 Side Effect: It will happen 'Transmit under-run'. When TX under-run
714 always happens, the programmer can increase the value of 'Early
715 Transmit Threshold'. */
716 iow(db, DM9KS_ETXCSR, 0x83);
717 #endif
718
719 /* Set address filter table */
720 dm9000_hash_table(dev);
721
722 /* Activate DM9000/DM9010 */
723 iow(db, DM9KS_IMR, DM9KS_REGFF); /* Enable TX/RX interrupt mask */
724 iow(db, DM9KS_RXCR, DM9KS_REG05 | 1); /* RX enable */
725
726 /* Init Driver variable */
727 db->tx_pkt_cnt = 0;
728
729 netif_carrier_on(dev);
730
731 }
732
733 /*
734 Hardware start transmission.
735 Send a packet to media from the upper layer.
736 */
737 static int dmfe_start_xmit(struct sk_buff *skb, struct net_device *dev)
738 {
739 board_info_t *db = (board_info_t *)dev->priv;
740 char * data_ptr;
741 int i, tmplen;
742 u16 MDWAH, MDWAL;
743
744 #ifdef TDBUG /* check TX FIFO pointer */
745 u16 MDWAH1, MDWAL1;
746 u16 tx_ptr;
747 #endif
748
749 DMFE_DBUG(0, 'dmfe_start_xmit', 0);
750 if (db->chip_revision != 0x1A)
751 {
752 if(db->Speed == 10)
753 {if (db->tx_pkt_cnt >= 1) return 1;}
754 else
755 {if (db->tx_pkt_cnt >= 2) return 1;}
756 }else
757 if (db->tx_pkt_cnt >= 2) return 1;
758
759 /* packet counting */
760 db->tx_pkt_cnt++;
761
762 db->stats.tx_packets++;
763 db->stats.tx_bytes+=skb->len;
764 if (db->chip_revision != 0x1A)
765 {
766 if (db->Speed == 10)
767 {if (db->tx_pkt_cnt >= 1) netif_stop_queue(dev);}
768 else
769 {if (db->tx_pkt_cnt >= 2) netif_stop_queue(dev);}
770 }else
771 if (db->tx_pkt_cnt >= 2) netif_stop_queue(dev);
772
773 /* Disable all interrupt */
774 iow(db, DM9KS_IMR, DM9KS_DISINTR);
775
776 MDWAH = ior(db,DM9KS_MDWAH);
777 MDWAL = ior(db,DM9KS_MDWAL);
778
779 /* Set TX length to reg. 0xfc & 0xfd */
780 iow(db, DM9KS_TXPLL, (skb->len & 0xff));
781 iow(db, DM9KS_TXPLH, (skb->len >> 8) & 0xff);
782
783 /* Move data to TX SRAM */
784 data_ptr = (char *)skb->data;
785
786 outb(DM9KS_MWCMD, db->io_addr); // Write data into SRAM trigger
787 switch(db->io_mode)
788 {
789 case DM9KS_BYTE_MODE:
790 for (i = 0; i < skb->len; i++)
791 outb((data_ptr[i] & 0xff), db->io_data);
792 break;
793 case DM9KS_WORD_MODE:
794 tmplen = (skb->len + 1) / 2;
795 for (i = 0; i < tmplen; i++)
796 outw(((u16 *)data_ptr)[i], db->io_data);
797 break;
798 case DM9KS_DWORD_MODE:
799 tmplen = (skb->len + 3) / 4;
800 for (i = 0; i< tmplen; i++)
801 outl(((u32 *)data_ptr)[i], db->io_data);
802 break;
803 }
804
805 #ifndef ETRANS
806 /* Issue TX polling command */
807 iow(db, DM9KS_TCR, 0x1); /* Cleared after TX complete*/
808 #endif
809
810 #ifdef TDBUG /* check TX FIFO pointer */
811 MDWAH1 = ior(db,DM9KS_MDWAH);
812 MDWAL1 = ior(db,DM9KS_MDWAL);
813 tx_ptr = (MDWAH<<8)|MDWAL;
814 switch (db->io_mode)
815 {
816 case DM9KS_BYTE_MODE:
817 tx_ptr += skb->len;
818 break;
819 case DM9KS_WORD_MODE:
820 tx_ptr += ((skb->len + 1) / 2)*2;
821 break;
822 case DM9KS_DWORD_MODE:
823 tx_ptr += ((skb->len+3)/4)*4;
824 break;
825 }
826 if (tx_ptr > 0x0bff)
827 tx_ptr -= 0x0c00;
828 if (tx_ptr != ((MDWAH1<<8)|MDWAL1))
829 printk('[dm9ks:TX FIFO ERRORn');
830 #endif
831 /* Saved the time stamp */
832 dev->trans_start = jiffies;
833 db->cont_rx_pkt_cnt =0;
834
835 /* Free this SKB */
836 dev_kfree_skb(skb);
837
838 /* Re-enable interrupt */
839 iow(db, DM9KS_IMR, DM9KS_REGFF);
840
841 return 0;
842 }
843
844 /*
845 Stop the interface.
846 The interface is stopped when it is brought.
847 */
848 static int dmfe_stop(struct net_device *dev)
849 {
850 board_info_t *db = (board_info_t *)dev->priv;
851 DMFE_DBUG(0, 'dmfe_stop', 0);
852
853 /* deleted timer */
854 del_timer(&db->timer);
855
856 netif_stop_queue(dev);
857
858 /* free interrupt */
859 free_irq(dev->irq, dev);
860
861 /* RESET devie */
862 phy_write(db, 0x00, 0x8000); /* PHY RESET */
863 //iow(db, DM9KS_GPR, 0x01); /* Power-Down PHY */
864 iow(db, DM9KS_IMR, DM9KS_DISINTR); /* Disable all interrupt */
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-03 00:27
设计资源 培训 开发板 精华推荐
- STM32F030/051开发板
- 丐17PRO调音师
- AP1509EV,基于 AP1509 降压 DC/DC 转换器的评估板
- FRDM33772CSPEVB: 具有SPI通信功能的MC33772C评估板
- AD8616ARMZ-REEL单电源降噪运算放大器典型应用电路
- LT6656AIDC-3、3V 电压基准作为微功率稳压器的典型应用
- A000062,基于 SAM3X8E ARM Cortex-M3 CPU 的 Arduino Due 微控制器板
- WQFN-16L 3x3 for RT8251, 5A, 24V, 570kHz 降压转换器的典型应用
- 使用 ON Semiconductor 的 STK350-030 的参考设计
- L78L12AB 输出升压电路正电压稳压器的典型应用