763 }else
764 if (db->tx_pkt_cnt >= 2) return 1;
765
766 /* packet counting */
767 db->tx_pkt_cnt++;
768
769 db->stats.tx_packets++;
770 db->stats.tx_bytes+=skb->len;
771 if (db->chip_revision != 0x1A)
772 {
773 if (db->Speed == 10)
774 {if (db->tx_pkt_cnt >= 1) netif_stop_queue(dev);}
775 else
776 {if (db->tx_pkt_cnt >= 2) netif_stop_queue(dev);}
777 }else
778 if (db->tx_pkt_cnt >= 2) netif_stop_queue(dev);
779
780 /* Disable all interrupt */
781 iow(db, DM9KS_IMR, DM9KS_DISINTR);
782
783 MDWAH = ior(db,DM9KS_MDWAH);
784 MDWAL = ior(db,DM9KS_MDWAL);
785
786 /* Set TX length to reg. 0xfc & 0xfd */
787 iow(db, DM9KS_TXPLL, (skb->len & 0xff));
788 iow(db, DM9KS_TXPLH, (skb->len >> 8) & 0xff);
789
790 /* Move data to TX SRAM */
791 data_ptr = (char *)skb->data;
792
793 outb(DM9KS_MWCMD, db->io_addr); // Write data into SRAM trigger
794 switch(db->io_mode)
795 {
796 case DM9KS_BYTE_MODE:
797 for (i = 0; i < skb->len; i++)
798 outb((data_ptr[i] & 0xff), db->io_data);
799 break;
800 case DM9KS_WORD_MODE:
801 tmplen = (skb->len + 1) / 2;
802 for (i = 0; i < tmplen; i++)
803 outw(((u16 *)data_ptr)[i], db->io_data);
804 break;
805 case DM9KS_DWORD_MODE:
806 tmplen = (skb->len + 3) / 4;
807 for (i = 0; i< tmplen; i++)
808 outl(((u32 *)data_ptr)[i], db->io_data);
809 break;
810 }
811
812 #ifndef ETRANS
813 /* Issue TX polling command */
814 iow(db, DM9KS_TCR, 0x1); /* Cleared after TX complete*/
815 #endif
816
817 #ifdef TDBUG /* check TX FIFO pointer */
818 MDWAH1 = ior(db,DM9KS_MDWAH);
819 MDWAL1 = ior(db,DM9KS_MDWAL);
820 tx_ptr = (MDWAH<<8)|MDWAL;
821 switch (db->io_mode)
822 {
823 case DM9KS_BYTE_MODE:
824 tx_ptr += skb->len;
825 break;
826 case DM9KS_WORD_MODE:
827 tx_ptr += ((skb->len + 1) / 2)*2;
828 break;
829 case DM9KS_DWORD_MODE:
830 tx_ptr += ((skb->len+3)/4)*4;
831 break;
832 }
833 if (tx_ptr > 0x0bff)
834 tx_ptr -= 0x0c00;
835 if (tx_ptr != ((MDWAH1<<8)|MDWAL1))
836 printk('[dm9ks:TX FIFO ERRORn');
837 #endif
838 /* Saved the time stamp */
839 dev->trans_start = jiffies;
840 db->cont_rx_pkt_cnt =0;
841
842 /* Free this SKB */
843 dev_kfree_skb(skb);
844
845 /* Re-enable interrupt */
846 iow(db, DM9KS_IMR, DM9KS_REGFF);
847
848 return 0;
849 }
850
851 /*
852 Stop the interface.
853 The interface is stopped when it is brought.
854 */
855 static int dmfe_stop(struct net_device *dev)
856 {
857 board_info_t *db = (board_info_t *)dev->priv;
858 DMFE_DBUG(0, 'dmfe_stop', 0);
859
860 /* deleted timer */
861 del_timer(&db->timer);
862
863 netif_stop_queue(dev);
864
865 /* free interrupt */
866 free_irq(dev->irq, dev);
867
868 /* RESET devie */
869 phy_write(db, 0x00, 0x8000); /* PHY RESET */
870 //iow(db, DM9KS_GPR, 0x01); /* Power-Down PHY */
871 iow(db, DM9KS_IMR, DM9KS_DISINTR); /* Disable all interrupt */
872 iow(db, DM9KS_RXCR, 0x00); /* Disable RX */
873
874 /* Dump Statistic counter */
875 #if FALSE
876 printk('nRX FIFO OVERFLOW %lxn', db->stats.rx_fifo_errors);
877 printk('RX CRC %lxn', db->stats.rx_crc_errors);
878 printk('RX LEN Err %lxn', db->stats.rx_length_errors);
879 printk('RESET %xn', db->reset_counter);
880 printk('RESET: TX Timeout %xn', db->reset_tx_timeout);
881 printk('g_TX_nsr %xn', g_TX_nsr);
882 #endif
883
884 return 0;
885 }
886
887 static void dmfe_tx_done(unsigned long unused)
888 {
889 struct net_device *dev = dmfe_dev;
890 board_info_t *db = (board_info_t *)dev->priv;
891 int nsr;
892
893 DMFE_DBUG(0, 'dmfe_tx_done()', 0);
894
895 nsr = ior(db, DM9KS_NSR);
896 if (nsr & 0x0c)
897 {
898 if(nsr & 0x04) db->tx_pkt_cnt--;
899 if(nsr & 0x08) db->tx_pkt_cnt--;
900 if(db->tx_pkt_cnt < 0)
901 {
902 printk(KERN_DEBUG 'DM9KS:tx_pkt_cnt ERROR!!n');
903 while(ior(db,DM9KS_TCR) & 0x1){}
904 db->tx_pkt_cnt = 0;
905 }
906
907 }else{
908 while(ior(db,DM9KS_TCR) & 0x1){}
909 db->tx_pkt_cnt = 0;
910 }
911
912 netif_wake_queue(dev);
913
914 return;
915 }
916
917 /*
918 DM9000 insterrupt handler
919 receive the packet to upper layer, free the transmitted packet
920 */
921 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
922 static void dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs)
923 #else
924 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
925 static irqreturn_t dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs)
926 #else
927 static irqreturn_t dmfe_interrupt(int irq, void *dev_id) /* for kernel 2.6.20*/
928 #endif
929 #endif
930 {
931 struct net_device *dev = dev_id;
932 board_info_t *db;
933 int int_status,i;
934 u8 reg_save;
935
936 DMFE_DBUG(0, 'dmfe_interrupt()', 0);
937
938 /* A real interrupt coming */
939 db = (board_info_t *)dev->priv;
940 spin_lock(&db->lock);
941
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-13 19:29
设计资源 培训 开发板 精华推荐
- 使用 Analog Devices 的 LTC1538CG-AUX 的参考设计
- 用于射频电路的TCR5BM/8BM系列LDO稳压器的应用电路
- esp32-solo开发板
- ATtiny88-On-Arduino
- NCP51200 3 Amp VTT 终端稳压器 DDR1、DDR2、DDR3、LPDDR3、DDR4 的典型应用
- LT1307BIS8 单节电池供电恒流 LED 驱动器的典型应用电路
- LTM8054EY 2 同步和开关降压-升压转换器 LTM8054 的典型应用电路由具有不同电流能力的输入源供电,共享输出电流以运行单个负载
- EVAL-AD7902SDZ,用于评估 AD7902 双路伪差分、16 位、1 MSPS PulSAR ADC 的评估板
- AM2G-2418DH30Z ±18V 2 瓦 DC-DC 转换器的典型应用,用于开/关控制应用
- 用于射频和模拟电路的 NCP160 250 mA、超低噪声和高 PSRR LDO 稳压器的典型应用