bfin_mac.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /*
  2. * Driver for Blackfin On-Chip MAC device
  3. *
  4. * Copyright (c) 2005-2008 Analog Device, Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <common.h>
  9. #include <config.h>
  10. #include <net.h>
  11. #include <netdev.h>
  12. #include <command.h>
  13. #include <malloc.h>
  14. #include <miiphy.h>
  15. #include <linux/mii.h>
  16. #include <asm/blackfin.h>
  17. #include <asm/mach-common/bits/dma.h>
  18. #include <asm/mach-common/bits/emac.h>
  19. #include <asm/mach-common/bits/pll.h>
  20. #include "bfin_mac.h"
  21. #ifndef CONFIG_PHY_ADDR
  22. # define CONFIG_PHY_ADDR 1
  23. #endif
  24. #ifndef CONFIG_PHY_CLOCK_FREQ
  25. # define CONFIG_PHY_CLOCK_FREQ 2500000
  26. #endif
  27. #ifdef CONFIG_POST
  28. #include <post.h>
  29. #endif
  30. #define RXBUF_BASE_ADDR 0xFF900000
  31. #define TXBUF_BASE_ADDR 0xFF800000
  32. #define TX_BUF_CNT 1
  33. #define TOUT_LOOP 1000000
  34. static ADI_ETHER_BUFFER *txbuf[TX_BUF_CNT];
  35. static ADI_ETHER_BUFFER *rxbuf[PKTBUFSRX];
  36. static u16 txIdx; /* index of the current RX buffer */
  37. static u16 rxIdx; /* index of the current TX buffer */
  38. /* DMAx_CONFIG values at DMA Restart */
  39. static const union {
  40. u16 data;
  41. ADI_DMA_CONFIG_REG reg;
  42. } txdmacfg = {
  43. .reg = {
  44. .b_DMA_EN = 1, /* enabled */
  45. .b_WNR = 0, /* read from memory */
  46. .b_WDSIZE = 2, /* wordsize is 32 bits */
  47. .b_DMA2D = 0,
  48. .b_RESTART = 0,
  49. .b_DI_SEL = 0,
  50. .b_DI_EN = 0, /* no interrupt */
  51. .b_NDSIZE = 5, /* 5 half words is desc size */
  52. .b_FLOW = 7 /* large desc flow */
  53. },
  54. };
  55. static int bfin_miiphy_wait(void)
  56. {
  57. /* poll the STABUSY bit */
  58. while (bfin_read_EMAC_STAADD() & STABUSY)
  59. continue;
  60. return 0;
  61. }
  62. static int bfin_miiphy_read(char *devname, uchar addr, uchar reg, ushort *val)
  63. {
  64. if (bfin_miiphy_wait())
  65. return 1;
  66. bfin_write_EMAC_STAADD(SET_PHYAD(addr) | SET_REGAD(reg) | STABUSY);
  67. if (bfin_miiphy_wait())
  68. return 1;
  69. *val = bfin_read_EMAC_STADAT();
  70. return 0;
  71. }
  72. static int bfin_miiphy_write(char *devname, uchar addr, uchar reg, ushort val)
  73. {
  74. if (bfin_miiphy_wait())
  75. return 1;
  76. bfin_write_EMAC_STADAT(val);
  77. bfin_write_EMAC_STAADD(SET_PHYAD(addr) | SET_REGAD(reg) | STAOP | STABUSY);
  78. return 0;
  79. }
  80. int bfin_EMAC_initialize(bd_t *bis)
  81. {
  82. struct eth_device *dev;
  83. dev = malloc(sizeof(*dev));
  84. if (dev == NULL)
  85. hang();
  86. memset(dev, 0, sizeof(*dev));
  87. sprintf(dev->name, "Blackfin EMAC");
  88. dev->iobase = 0;
  89. dev->priv = 0;
  90. dev->init = bfin_EMAC_init;
  91. dev->halt = bfin_EMAC_halt;
  92. dev->send = bfin_EMAC_send;
  93. dev->recv = bfin_EMAC_recv;
  94. eth_register(dev);
  95. #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
  96. miiphy_register(dev->name, bfin_miiphy_read, bfin_miiphy_write);
  97. #endif
  98. return 0;
  99. }
  100. static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet,
  101. int length)
  102. {
  103. int i;
  104. int result = 0;
  105. unsigned int *buf;
  106. buf = (unsigned int *)packet;
  107. if (length <= 0) {
  108. printf("Ethernet: bad packet size: %d\n", length);
  109. goto out;
  110. }
  111. if ((*pDMA2_IRQ_STATUS & DMA_ERR) != 0) {
  112. printf("Ethernet: tx DMA error\n");
  113. goto out;
  114. }
  115. for (i = 0; (*pDMA2_IRQ_STATUS & DMA_RUN) != 0; i++) {
  116. if (i > TOUT_LOOP) {
  117. puts("Ethernet: tx time out\n");
  118. goto out;
  119. }
  120. }
  121. txbuf[txIdx]->FrmData->NoBytes = length;
  122. memcpy(txbuf[txIdx]->FrmData->Dest, (void *)packet, length);
  123. txbuf[txIdx]->Dma[0].START_ADDR = (u32) txbuf[txIdx]->FrmData;
  124. *pDMA2_NEXT_DESC_PTR = txbuf[txIdx]->Dma;
  125. *pDMA2_CONFIG = txdmacfg.data;
  126. *pEMAC_OPMODE |= TE;
  127. for (i = 0; (txbuf[txIdx]->StatusWord & TX_COMP) == 0; i++) {
  128. if (i > TOUT_LOOP) {
  129. puts("Ethernet: tx error\n");
  130. goto out;
  131. }
  132. }
  133. result = txbuf[txIdx]->StatusWord;
  134. txbuf[txIdx]->StatusWord = 0;
  135. if ((txIdx + 1) >= TX_BUF_CNT)
  136. txIdx = 0;
  137. else
  138. txIdx++;
  139. out:
  140. debug("BFIN EMAC send: length = %d\n", length);
  141. return result;
  142. }
  143. static int bfin_EMAC_recv(struct eth_device *dev)
  144. {
  145. int length = 0;
  146. for (;;) {
  147. if ((rxbuf[rxIdx]->StatusWord & RX_COMP) == 0) {
  148. length = -1;
  149. break;
  150. }
  151. if ((rxbuf[rxIdx]->StatusWord & RX_DMAO) != 0) {
  152. printf("Ethernet: rx dma overrun\n");
  153. break;
  154. }
  155. if ((rxbuf[rxIdx]->StatusWord & RX_OK) == 0) {
  156. printf("Ethernet: rx error\n");
  157. break;
  158. }
  159. length = rxbuf[rxIdx]->StatusWord & 0x000007FF;
  160. if (length <= 4) {
  161. printf("Ethernet: bad frame\n");
  162. break;
  163. }
  164. debug("%s: len = %d\n", __func__, length - 4);
  165. NetRxPackets[rxIdx] =
  166. (volatile uchar *)(rxbuf[rxIdx]->FrmData->Dest);
  167. NetReceive(NetRxPackets[rxIdx], length - 4);
  168. *pDMA1_IRQ_STATUS |= DMA_DONE | DMA_ERR;
  169. rxbuf[rxIdx]->StatusWord = 0x00000000;
  170. if ((rxIdx + 1) >= PKTBUFSRX)
  171. rxIdx = 0;
  172. else
  173. rxIdx++;
  174. }
  175. return length;
  176. }
  177. /**************************************************************
  178. *
  179. * Ethernet Initialization Routine
  180. *
  181. *************************************************************/
  182. /* MDC = SCLK / MDC_freq / 2 - 1 */
  183. #define MDC_FREQ_TO_DIV(mdc_freq) (get_sclk() / (mdc_freq) / 2 - 1)
  184. static int bfin_miiphy_init(struct eth_device *dev, int *opmode)
  185. {
  186. u16 phydat;
  187. size_t count;
  188. /* Enable PHY output */
  189. *pVR_CTL |= CLKBUFOE;
  190. /* Set all the pins to peripheral mode */
  191. #ifdef CONFIG_RMII
  192. /* grab RMII pins */
  193. # if defined(__ADSPBF51x__)
  194. *pPORTF_MUX = (*pPORTF_MUX & \
  195. ~(PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \
  196. PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1;
  197. *pPORTF_FER |= PF8 | PF9 | PF10 | PF11 | PF12 | PF13 | PF14 | PF15;
  198. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1;
  199. *pPORTG_FER |= PG0 | PG1 | PG2;
  200. # elif defined(__ADSPBF52x__)
  201. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2;
  202. *pPORTG_FER |= PG14 | PG15;
  203. *pPORTH_MUX = (*pPORTH_MUX & ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK)) | \
  204. PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2;
  205. *pPORTH_FER |= PH0 | PH1 | PH2 | PH3 | PH4 | PH5 | PH6 | PH7 | PH8;
  206. # else
  207. *pPORTH_FER |= PH0 | PH1 | PH4 | PH5 | PH6 | PH8 | PH9 | PH14 | PH15;
  208. # endif
  209. #else
  210. /* grab MII & RMII pins */
  211. # if defined(__ADSPBF51x__)
  212. *pPORTF_MUX = (*pPORTF_MUX & \
  213. ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK | PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \
  214. PORT_x_MUX_0_FUNC_1 | PORT_x_MUX_1_FUNC_1 | PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1;
  215. *pPORTF_FER |= PF0 | PF1 | PF2 | PF3 | PF4 | PF5 | PF6 | PF8 | PF9 | PF10 | PF11 | PF12 | PF13 | PF14 | PF15;
  216. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1;
  217. *pPORTG_FER |= PG0 | PG1 | PG2;
  218. # elif defined(__ADSPBF52x__)
  219. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2;
  220. *pPORTG_FER |= PG14 | PG15;
  221. *pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2 | PORT_x_MUX_2_FUNC_2;
  222. *pPORTH_FER = -1; /* all pins */
  223. # else
  224. *pPORTH_FER = -1; /* all pins */
  225. # endif
  226. #endif
  227. /* Odd word alignment for Receive Frame DMA word */
  228. /* Configure checksum support and rcve frame word alignment */
  229. bfin_write_EMAC_SYSCTL(RXDWA | RXCKS | SET_MDCDIV(MDC_FREQ_TO_DIV(CONFIG_PHY_CLOCK_FREQ)));
  230. /* turn on auto-negotiation and wait for link to come up */
  231. bfin_miiphy_write(dev->name, CONFIG_PHY_ADDR, MII_BMCR, BMCR_ANENABLE);
  232. count = 0;
  233. while (1) {
  234. ++count;
  235. if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_BMSR, &phydat))
  236. return -1;
  237. if (phydat & BMSR_LSTATUS)
  238. break;
  239. if (count > 30000) {
  240. printf("%s: link down, check cable\n", dev->name);
  241. return -1;
  242. }
  243. udelay(100);
  244. }
  245. /* see what kind of link we have */
  246. if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_LPA, &phydat))
  247. return -1;
  248. if (phydat & LPA_DUPLEX)
  249. *opmode = FDMODE;
  250. else
  251. *opmode = 0;
  252. bfin_write_EMAC_MMC_CTL(RSTC | CROLL);
  253. /* Initialize the TX DMA channel registers */
  254. *pDMA2_X_COUNT = 0;
  255. *pDMA2_X_MODIFY = 4;
  256. *pDMA2_Y_COUNT = 0;
  257. *pDMA2_Y_MODIFY = 0;
  258. /* Initialize the RX DMA channel registers */
  259. *pDMA1_X_COUNT = 0;
  260. *pDMA1_X_MODIFY = 4;
  261. *pDMA1_Y_COUNT = 0;
  262. *pDMA1_Y_MODIFY = 0;
  263. return 0;
  264. }
  265. static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)
  266. {
  267. u32 opmode;
  268. int dat;
  269. int i;
  270. debug("Eth_init: ......\n");
  271. txIdx = 0;
  272. rxIdx = 0;
  273. /* Initialize System Register */
  274. if (bfin_miiphy_init(dev, &dat) < 0)
  275. return -1;
  276. /* Initialize EMAC address */
  277. bfin_EMAC_setup_addr(dev->enetaddr);
  278. /* Initialize TX and RX buffer */
  279. for (i = 0; i < PKTBUFSRX; i++) {
  280. rxbuf[i] = SetupRxBuffer(i);
  281. if (i > 0) {
  282. rxbuf[i - 1]->Dma[1].NEXT_DESC_PTR = rxbuf[i]->Dma;
  283. if (i == (PKTBUFSRX - 1))
  284. rxbuf[i]->Dma[1].NEXT_DESC_PTR = rxbuf[0]->Dma;
  285. }
  286. }
  287. for (i = 0; i < TX_BUF_CNT; i++) {
  288. txbuf[i] = SetupTxBuffer(i);
  289. if (i > 0) {
  290. txbuf[i - 1]->Dma[1].NEXT_DESC_PTR = txbuf[i]->Dma;
  291. if (i == (TX_BUF_CNT - 1))
  292. txbuf[i]->Dma[1].NEXT_DESC_PTR = txbuf[0]->Dma;
  293. }
  294. }
  295. /* Set RX DMA */
  296. *pDMA1_NEXT_DESC_PTR = rxbuf[0]->Dma;
  297. *pDMA1_CONFIG = rxbuf[0]->Dma[0].CONFIG_DATA;
  298. /* Wait MII done */
  299. bfin_miiphy_wait();
  300. /* We enable only RX here */
  301. /* ASTP : Enable Automatic Pad Stripping
  302. PR : Promiscuous Mode for test
  303. PSF : Receive frames with total length less than 64 bytes.
  304. FDMODE : Full Duplex Mode
  305. LB : Internal Loopback for test
  306. RE : Receiver Enable */
  307. if (dat == FDMODE)
  308. opmode = ASTP | FDMODE | PSF;
  309. else
  310. opmode = ASTP | PSF;
  311. opmode |= RE;
  312. #ifdef CONFIG_RMII
  313. opmode |= TE | RMII;
  314. #endif
  315. /* Turn on the EMAC */
  316. *pEMAC_OPMODE = opmode;
  317. return 0;
  318. }
  319. static void bfin_EMAC_halt(struct eth_device *dev)
  320. {
  321. debug("Eth_halt: ......\n");
  322. /* Turn off the EMAC */
  323. *pEMAC_OPMODE = 0x00000000;
  324. /* Turn off the EMAC RX DMA */
  325. *pDMA1_CONFIG = 0x0000;
  326. *pDMA2_CONFIG = 0x0000;
  327. }
  328. void bfin_EMAC_setup_addr(uchar *enetaddr)
  329. {
  330. *pEMAC_ADDRLO =
  331. enetaddr[0] |
  332. enetaddr[1] << 8 |
  333. enetaddr[2] << 16 |
  334. enetaddr[3] << 24;
  335. *pEMAC_ADDRHI =
  336. enetaddr[4] |
  337. enetaddr[5] << 8;
  338. }
  339. ADI_ETHER_BUFFER *SetupRxBuffer(int no)
  340. {
  341. ADI_ETHER_FRAME_BUFFER *frmbuf;
  342. ADI_ETHER_BUFFER *buf;
  343. int nobytes_buffer = sizeof(ADI_ETHER_BUFFER[2]) / 2; /* ensure a multi. of 4 */
  344. int total_size = nobytes_buffer + RECV_BUFSIZE;
  345. buf = (void *) (RXBUF_BASE_ADDR + no * total_size);
  346. frmbuf = (void *) (RXBUF_BASE_ADDR + no * total_size + nobytes_buffer);
  347. memset(buf, 0x00, nobytes_buffer);
  348. buf->FrmData = frmbuf;
  349. memset(frmbuf, 0xfe, RECV_BUFSIZE);
  350. /* set up first desc to point to receive frame buffer */
  351. buf->Dma[0].NEXT_DESC_PTR = &(buf->Dma[1]);
  352. buf->Dma[0].START_ADDR = (u32) buf->FrmData;
  353. buf->Dma[0].CONFIG.b_DMA_EN = 1; /* enabled */
  354. buf->Dma[0].CONFIG.b_WNR = 1; /* Write to memory */
  355. buf->Dma[0].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  356. buf->Dma[0].CONFIG.b_NDSIZE = 5; /* 5 half words is desc size. */
  357. buf->Dma[0].CONFIG.b_FLOW = 7; /* large desc flow */
  358. /* set up second desc to point to status word */
  359. buf->Dma[1].NEXT_DESC_PTR = buf->Dma;
  360. buf->Dma[1].START_ADDR = (u32) & buf->IPHdrChksum;
  361. buf->Dma[1].CONFIG.b_DMA_EN = 1; /* enabled */
  362. buf->Dma[1].CONFIG.b_WNR = 1; /* Write to memory */
  363. buf->Dma[1].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  364. buf->Dma[1].CONFIG.b_DI_EN = 1; /* enable interrupt */
  365. buf->Dma[1].CONFIG.b_NDSIZE = 5; /* must be 0 when FLOW is 0 */
  366. buf->Dma[1].CONFIG.b_FLOW = 7; /* stop */
  367. return buf;
  368. }
  369. ADI_ETHER_BUFFER *SetupTxBuffer(int no)
  370. {
  371. ADI_ETHER_FRAME_BUFFER *frmbuf;
  372. ADI_ETHER_BUFFER *buf;
  373. int nobytes_buffer = sizeof(ADI_ETHER_BUFFER[2]) / 2; /* ensure a multi. of 4 */
  374. int total_size = nobytes_buffer + RECV_BUFSIZE;
  375. buf = (void *) (TXBUF_BASE_ADDR + no * total_size);
  376. frmbuf = (void *) (TXBUF_BASE_ADDR + no * total_size + nobytes_buffer);
  377. memset(buf, 0x00, nobytes_buffer);
  378. buf->FrmData = frmbuf;
  379. memset(frmbuf, 0x00, RECV_BUFSIZE);
  380. /* set up first desc to point to receive frame buffer */
  381. buf->Dma[0].NEXT_DESC_PTR = &(buf->Dma[1]);
  382. buf->Dma[0].START_ADDR = (u32) buf->FrmData;
  383. buf->Dma[0].CONFIG.b_DMA_EN = 1; /* enabled */
  384. buf->Dma[0].CONFIG.b_WNR = 0; /* Read to memory */
  385. buf->Dma[0].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  386. buf->Dma[0].CONFIG.b_NDSIZE = 5; /* 5 half words is desc size. */
  387. buf->Dma[0].CONFIG.b_FLOW = 7; /* large desc flow */
  388. /* set up second desc to point to status word */
  389. buf->Dma[1].NEXT_DESC_PTR = &(buf->Dma[0]);
  390. buf->Dma[1].START_ADDR = (u32) & buf->StatusWord;
  391. buf->Dma[1].CONFIG.b_DMA_EN = 1; /* enabled */
  392. buf->Dma[1].CONFIG.b_WNR = 1; /* Write to memory */
  393. buf->Dma[1].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  394. buf->Dma[1].CONFIG.b_DI_EN = 1; /* enable interrupt */
  395. buf->Dma[1].CONFIG.b_NDSIZE = 0; /* must be 0 when FLOW is 0 */
  396. buf->Dma[1].CONFIG.b_FLOW = 0; /* stop */
  397. return buf;
  398. }
  399. #if defined(CONFIG_POST) && defined(CONFIG_SYS_POST_ETHER)
  400. int ether_post_test(int flags)
  401. {
  402. uchar buf[64];
  403. int i, value = 0;
  404. int length;
  405. printf("\n--------");
  406. bfin_EMAC_init(NULL, NULL);
  407. /* construct the package */
  408. buf[0] = buf[6] = (unsigned char)(*pEMAC_ADDRLO & 0xFF);
  409. buf[1] = buf[7] = (unsigned char)((*pEMAC_ADDRLO & 0xFF00) >> 8);
  410. buf[2] = buf[8] = (unsigned char)((*pEMAC_ADDRLO & 0xFF0000) >> 16);
  411. buf[3] = buf[9] = (unsigned char)((*pEMAC_ADDRLO & 0xFF000000) >> 24);
  412. buf[4] = buf[10] = (unsigned char)(*pEMAC_ADDRHI & 0xFF);
  413. buf[5] = buf[11] = (unsigned char)((*pEMAC_ADDRHI & 0xFF00) >> 8);
  414. buf[12] = 0x08; /* Type: ARP */
  415. buf[13] = 0x06;
  416. buf[14] = 0x00; /* Hardware type: Ethernet */
  417. buf[15] = 0x01;
  418. buf[16] = 0x08; /* Protocal type: IP */
  419. buf[17] = 0x00;
  420. buf[18] = 0x06; /* Hardware size */
  421. buf[19] = 0x04; /* Protocol size */
  422. buf[20] = 0x00; /* Opcode: request */
  423. buf[21] = 0x01;
  424. for (i = 0; i < 42; i++)
  425. buf[i + 22] = i;
  426. printf("--------Send 64 bytes......\n");
  427. bfin_EMAC_send(NULL, (volatile void *)buf, 64);
  428. for (i = 0; i < 100; i++) {
  429. udelay(10000);
  430. if ((rxbuf[rxIdx]->StatusWord & RX_COMP) != 0) {
  431. value = 1;
  432. break;
  433. }
  434. }
  435. if (value == 0) {
  436. printf("--------EMAC can't receive any data\n");
  437. eth_halt();
  438. return -1;
  439. }
  440. length = rxbuf[rxIdx]->StatusWord & 0x000007FF - 4;
  441. for (i = 0; i < length; i++) {
  442. if (rxbuf[rxIdx]->FrmData->Dest[i] != buf[i]) {
  443. printf("--------EMAC receive error data!\n");
  444. eth_halt();
  445. return -1;
  446. }
  447. }
  448. printf("--------receive %d bytes, matched\n", length);
  449. bfin_EMAC_halt(NULL);
  450. return 0;
  451. }
  452. #endif