我在FS44B0 II上移植u-boot的过程中在写网卡的驱动的时候遇到问题。因为uboot里边的RTL8019的驱动只支持8bit模式,所以需要做一些修改才能支持16bit,现在按照手册上的过程修改之后,编译并且用FS44B0II_BIOS下载到SDRAM中运行,ping或者tftp都不能运行,提示"packet too big!", 在PC上用ethereal抓包,发现根本没有数据从8019发出。我的程序是完全找DP8390的手册来修改的,贴出源程序和设置如下,请大家帮忙看看问题究竟出在哪里,谢谢!!!
我的设置如下:
#define RTL8019_BASE 0x06000000
#ifdef CONFIG_RTL8019_USE_16_BIT #define ADDR_SFT 1 #else #define ADDR_SFT 0 #endif
#ifdef CONFIG_DRIVER_RTL8019
#define RTL8019_REG_00 (RTL8019_BASE + (0x00<<ADDR_SFT)) #define RTL8019_REG_01 (RTL8019_BASE + (0x01<<ADDR_SFT)) #define RTL8019_REG_02 (RTL8019_BASE + (0x02<<ADDR_SFT)) #define RTL8019_REG_03 (RTL8019_BASE + (0x03<<ADDR_SFT)) #define RTL8019_REG_04 (RTL8019_BASE + (0x04<<ADDR_SFT)) #define RTL8019_REG_05 (RTL8019_BASE + (0x05<<ADDR_SFT)) #define RTL8019_REG_06 (RTL8019_BASE + (0x06<<ADDR_SFT)) #define RTL8019_REG_07 (RTL8019_BASE + (0x07<<ADDR_SFT)) #define RTL8019_REG_08 (RTL8019_BASE + (0x08<<ADDR_SFT)) #define RTL8019_REG_09 (RTL8019_BASE + (0x09<<ADDR_SFT)) #define RTL8019_REG_0a (RTL8019_BASE + (0x0a<<ADDR_SFT)) #define RTL8019_REG_0b (RTL8019_BASE + (0x0b<<ADDR_SFT)) #define RTL8019_REG_0c (RTL8019_BASE + (0x0c<<ADDR_SFT)) #define RTL8019_REG_0d (RTL8019_BASE + (0x0d<<ADDR_SFT)) #define RTL8019_REG_0e (RTL8019_BASE + (0x0e<<ADDR_SFT)) #define RTL8019_REG_0f (RTL8019_BASE + (0x0f<<ADDR_SFT)) #define RTL8019_REG_10 (RTL8019_BASE + (0x10<<ADDR_SFT)) #define RTL8019_REG_18 (RTL8019_BASE + (0x18<<ADDR_SFT))
#define RTL8019_COMMAND RTL8019_REG_00 #define RTL8019_PAGESTART RTL8019_REG_01 #define RTL8019_PAGESTOP RTL8019_REG_02 #define RTL8019_BOUNDARY RTL8019_REG_03 #define RTL8019_TRANSMITSTATUS RTL8019_REG_04 #define RTL8019_TRANSMITPAGE RTL8019_REG_04 #define RTL8019_TRANSMITBYTECOUNT0 RTL8019_REG_05 #define RTL8019_NCR RTL8019_REG_05 #define RTL8019_TRANSMITBYTECOUNT1 RTL8019_REG_06 #define RTL8019_INTERRUPTSTATUS RTL8019_REG_07 #define RTL8019_CURRENT RTL8019_REG_07 #define RTL8019_REMOTESTARTADDRESS0 RTL8019_REG_08 #define RTL8019_CRDMA0 RTL8019_REG_08 #define RTL8019_REMOTESTARTADDRESS1 RTL8019_REG_09 #define RTL8019_CRDMA1 RTL8019_REG_09 #define RTL8019_REMOTEBYTECOUNT0 RTL8019_REG_0a #define RTL8019_REMOTEBYTECOUNT1 RTL8019_REG_0b #define RTL8019_RECEIVESTATUS RTL8019_REG_0c #define RTL8019_RECEIVECONFIGURATION RTL8019_REG_0c #define RTL8019_TRANSMITCONFIGURATION RTL8019_REG_0d #define RTL8019_FAE_TALLY RTL8019_REG_0d #define RTL8019_DATACONFIGURATION RTL8019_REG_0e #define RTL8019_CRC_TALLY RTL8019_REG_0e #define RTL8019_INTERRUPTMASK RTL8019_REG_0f #define RTL8019_MISS_PKT_TALLY RTL8019_REG_0f #define RTL8019_PHYSICALADDRESS0 RTL8019_REG_01 #define RTL8019_PHYSICALADDRESS1 RTL8019_REG_02 #define RTL8019_PHYSICALADDRESS2 RTL8019_REG_03 #define RTL8019_PHYSICALADDRESS3 RTL8019_REG_04 #define RTL8019_PHYSICALADDRESS4 RTL8019_REG_05 #define RTL8019_PHYSICALADDRESS5 RTL8019_REG_06 #define RTL8019_MULTIADDRESS0 RTL8019_REG_08 #define RTL8019_MULTIADDRESS1 RTL8019_REG_09 #define RTL8019_MULTIADDRESS2 RTL8019_REG_0a #define RTL8019_MULTIADDRESS3 RTL8019_REG_0b #define RTL8019_MULTIADDRESS4 RTL8019_REG_0c #define RTL8019_MULTIADDRESS5 RTL8019_REG_0d #define RTL8019_MULTIADDRESS6 RTL8019_REG_0e #define RTL8019_MULTIADDRESS7 RTL8019_REG_0f #define RTL8019_DMA_DATA RTL8019_REG_10 #define RTL8019_RESET RTL8019_REG_18
#define RTL8019_PAGE0 0x22 #define RTL8019_PAGE1 0x62 #define RTL8019_PAGE0DMAWRITE 0x12 #define RTL8019_PAGE2DMAWRITE 0x92 #define RTL8019_REMOTEDMAWR 0x12 #define RTL8019_REMOTEDMARD 0x0A #define RTL8019_ABORTDMAWR 0x32 #define RTL8019_ABORTDMARD 0x2A #define RTL8019_PAGE0STOP 0x21 #define RTL8019_PAGE1STOP 0x61 #define RTL8019_TRANSMIT 0x26 #define RTL8019_TXINPROGRESS 0x04 #define RTL8019_SEND 0x1A
#define RTL8019_PSTART 0x4c #define RTL8019_PSTOP 0x80 #define RTL8019_TPSTART 0x40
复位函数: static void eth_reset (void) { unsigned char ucTemp;
/* reset NIC */ ucTemp = get_reg (RTL8019_RESET); put_reg (RTL8019_RESET, ucTemp); udelay (2000); /* wait for 2ms */ } 初始化:
int eth_init (bd_t * bd) { eth_reset (); put_reg (RTL8019_COMMAND, RTL8019_PAGE0STOP); //CMD page0, stop put_reg (RTL8019_DATACONFIGURATION, 0xc9); //DCR put_reg (RTL8019_REMOTEBYTECOUNT0, 0x00); //RBCR0 put_reg (RTL8019_REMOTEBYTECOUNT1, 0x00); //RBCR1 put_reg (RTL8019_RECEIVECONFIGURATION, 0xcc); //RCR put_reg (RTL8019_TRANSMITCONFIGURATION, 0x02); //TCR in mode 1 put_reg (RTL8019_BOUNDARY, RTL8019_PSTART); //BNDRY put_reg (RTL8019_PAGESTART, RTL8019_PSTART); //PSTART put_reg (RTL8019_PAGESTOP, RTL8019_PSTOP); //PSTOP put_reg (RTL8019_TRANSMITPAGE, RTL8019_TPSTART); //TPSR put_reg (RTL8019_INTERRUPTSTATUS, 0xff); //ISR cleared put_reg (RTL8019_INTERRUPTMASK, 0x1b); //IMR "OVWE, TXEE, PTXE, PRXE" put_reg (RTL8019_COMMAND, RTL8019_PAGE1STOP); //CMD page1, stop put_reg (RTL8019_PHYSICALADDRESS0, bd->bi_enetaddr[0]); //physical address put_reg (RTL8019_PHYSICALADDRESS1, bd->bi_enetaddr[1]); put_reg (RTL8019_PHYSICALADDRESS2, bd->bi_enetaddr[2]); put_reg (RTL8019_PHYSICALADDRESS3, bd->bi_enetaddr[3]); put_reg (RTL8019_PHYSICALADDRESS4, bd->bi_enetaddr[4]); put_reg (RTL8019_PHYSICALADDRESS5, bd->bi_enetaddr[5]); put_reg (RTL8019_MULTIADDRESS0, 0x00); //multi address put_reg (RTL8019_MULTIADDRESS1, 0x41); put_reg (RTL8019_MULTIADDRESS2, 0x00); put_reg (RTL8019_MULTIADDRESS3, 0x80); put_reg (RTL8019_MULTIADDRESS4, 0x00); put_reg (RTL8019_MULTIADDRESS5, 0x00); put_reg (RTL8019_MULTIADDRESS6, 0x00); put_reg (RTL8019_MULTIADDRESS7, 0x00); put_reg (RTL8019_CURRENT, RTL8019_PSTART+1); //CURR = PSTART+1 put_reg (RTL8019_COMMAND, RTL8019_PAGE0); //CMD page0 start put_reg (RTL8019_TRANSMITCONFIGURATION, 0xe0); //TCR mode 0
return 0; } 发送函数:
/* Send a data block via Ethernet. */ extern int eth_send (volatile void *packet, int length) { volatile unsigned char *p; volatile unsigned short *ps; unsigned int pn;
pn = length; p = (volatile unsigned char *) packet;
if (pn < 60) { for (; pn<60; pn++) *(p+pn) = 0x20; //0x20 is the pad } while (get_reg (RTL8019_COMMAND) == RTL8019_TRANSMIT);
put_reg (RTL8019_REMOTESTARTADDRESS0, 0); //RSAR0 = TPSR_LSB put_reg (RTL8019_REMOTESTARTADDRESS1, RTL8019_TPSTART); //RSAR1 = TRSR_MSB put_reg (RTL8019_REMOTEBYTECOUNT0, (pn & 0xff)); //RBCR0 = length_LSB put_reg (RTL8019_REMOTEBYTECOUNT1, ((pn >> 8) & 0xff)); //RBCR1 = length_MSB
put_reg (RTL8019_COMMAND, RTL8019_REMOTEDMAWR); //CMD RD1|STA
printf ("send data in words="); ps = (unsigned short *)p; while ((pn+1)/2) //16bit { printf ("<%04X>", *ps); put_regw (RTL8019_DMA_DATA, *ps++); pn -= 2; } printf ("
"); pn = length; if (pn < 60) pn = 60; while (!(get_reg (RTL8019_INTERRUPTSTATUS)) & 0x40); //check ISR_RDC
put_reg (RTL8019_INTERRUPTSTATUS, 0x40); //rest ISR put_reg (RTL8019_TRANSMITPAGE, RTL8019_TPSTART); //TPSR put_reg (RTL8019_TRANSMITBYTECOUNT0, (pn & 0xff)); //TBCR0 ? put_reg (RTL8019_TRANSMITBYTECOUNT1, ((pn >> 8 & 0xff))); //TBCR1 ?
put_reg (RTL8019_COMMAND, RTL8019_TRANSMIT); //CMD RD2|STA|TXP return 0; } |
|