bfin_mac.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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. NetRxPackets[rxIdx] =
  165. (volatile uchar *)(rxbuf[rxIdx]->FrmData->Dest);
  166. NetReceive(NetRxPackets[rxIdx], length - 4);
  167. *pDMA1_IRQ_STATUS |= DMA_DONE | DMA_ERR;
  168. rxbuf[rxIdx]->StatusWord = 0x00000000;
  169. if ((rxIdx + 1) >= PKTBUFSRX)
  170. rxIdx = 0;
  171. else
  172. rxIdx++;
  173. }
  174. return length;
  175. }
  176. /**************************************************************
  177. *
  178. * Ethernet Initialization Routine
  179. *
  180. *************************************************************/
  181. /* MDC = SCLK / MDC_freq / 2 - 1 */
  182. #define MDC_FREQ_TO_DIV(mdc_freq) (get_sclk() / (mdc_freq) / 2 - 1)
  183. static int bfin_miiphy_init(struct eth_device *dev, int *opmode)
  184. {
  185. u16 phydat;
  186. size_t count;
  187. /* Enable PHY output */
  188. *pVR_CTL |= CLKBUFOE;
  189. /* Set all the pins to peripheral mode */
  190. #ifdef CONFIG_RMII
  191. /* grab RMII pins */
  192. # if defined(__ADSPBF51x__)
  193. *pPORTF_MUX = (*pPORTF_MUX & \
  194. ~(PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \
  195. PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1;
  196. *pPORTF_FER |= PF8 | PF9 | PF10 | PF11 | PF12 | PF13 | PF14 | PF15;
  197. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1;
  198. *pPORTG_FER |= PG0 | PG1 | PG2;
  199. # elif defined(__ADSPBF52x__)
  200. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2;
  201. *pPORTG_FER |= PG14 | PG15;
  202. *pPORTH_MUX = (*pPORTH_MUX & ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK)) | \
  203. PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2;
  204. *pPORTH_FER |= PH0 | PH1 | PH2 | PH3 | PH4 | PH5 | PH6 | PH7 | PH8;
  205. # else
  206. *pPORTH_FER |= PH0 | PH1 | PH4 | PH5 | PH6 | PH8 | PH9 | PH14 | PH15;
  207. # endif
  208. #else
  209. /* grab MII & RMII pins */
  210. # if defined(__ADSPBF51x__)
  211. *pPORTF_MUX = (*pPORTF_MUX & \
  212. ~(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)) | \
  213. 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;
  214. *pPORTF_FER |= PF0 | PF1 | PF2 | PF3 | PF4 | PF5 | PF6 | PF8 | PF9 | PF10 | PF11 | PF12 | PF13 | PF14 | PF15;
  215. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1;
  216. *pPORTG_FER |= PG0 | PG1 | PG2;
  217. # elif defined(__ADSPBF52x__)
  218. *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2;
  219. *pPORTG_FER |= PG14 | PG15;
  220. *pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2 | PORT_x_MUX_2_FUNC_2;
  221. *pPORTH_FER = -1; /* all pins */
  222. # else
  223. *pPORTH_FER = -1; /* all pins */
  224. # endif
  225. #endif
  226. /* Odd word alignment for Receive Frame DMA word */
  227. /* Configure checksum support and rcve frame word alignment */
  228. bfin_write_EMAC_SYSCTL(RXDWA | RXCKS | SET_MDCDIV(MDC_FREQ_TO_DIV(CONFIG_PHY_CLOCK_FREQ)));
  229. /* turn on auto-negotiation and wait for link to come up */
  230. bfin_miiphy_write(dev->name, CONFIG_PHY_ADDR, MII_BMCR, BMCR_ANENABLE);
  231. count = 0;
  232. while (1) {
  233. ++count;
  234. if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_BMSR, &phydat))
  235. return -1;
  236. if (phydat & BMSR_LSTATUS)
  237. break;
  238. if (count > 30000) {
  239. printf("%s: link down, check cable\n", dev->name);
  240. return -1;
  241. }
  242. udelay(100);
  243. }
  244. /* see what kind of link we have */
  245. if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_LPA, &phydat))
  246. return -1;
  247. if (phydat & LPA_DUPLEX)
  248. *opmode = FDMODE;
  249. else
  250. *opmode = 0;
  251. bfin_write_EMAC_MMC_CTL(RSTC | CROLL);
  252. /* Initialize the TX DMA channel registers */
  253. *pDMA2_X_COUNT = 0;
  254. *pDMA2_X_MODIFY = 4;
  255. *pDMA2_Y_COUNT = 0;
  256. *pDMA2_Y_MODIFY = 0;
  257. /* Initialize the RX DMA channel registers */
  258. *pDMA1_X_COUNT = 0;
  259. *pDMA1_X_MODIFY = 4;
  260. *pDMA1_Y_COUNT = 0;
  261. *pDMA1_Y_MODIFY = 0;
  262. return 0;
  263. }
  264. static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)
  265. {
  266. u32 opmode;
  267. int dat;
  268. int i;
  269. debug("Eth_init: ......\n");
  270. txIdx = 0;
  271. rxIdx = 0;
  272. /* Initialize System Register */
  273. if (bfin_miiphy_init(dev, &dat) < 0)
  274. return -1;
  275. /* Initialize EMAC address */
  276. bfin_EMAC_setup_addr(dev->enetaddr);
  277. /* Initialize TX and RX buffer */
  278. for (i = 0; i < PKTBUFSRX; i++) {
  279. rxbuf[i] = SetupRxBuffer(i);
  280. if (i > 0) {
  281. rxbuf[i - 1]->Dma[1].NEXT_DESC_PTR = rxbuf[i]->Dma;
  282. if (i == (PKTBUFSRX - 1))
  283. rxbuf[i]->Dma[1].NEXT_DESC_PTR = rxbuf[0]->Dma;
  284. }
  285. }
  286. for (i = 0; i < TX_BUF_CNT; i++) {
  287. txbuf[i] = SetupTxBuffer(i);
  288. if (i > 0) {
  289. txbuf[i - 1]->Dma[1].NEXT_DESC_PTR = txbuf[i]->Dma;
  290. if (i == (TX_BUF_CNT - 1))
  291. txbuf[i]->Dma[1].NEXT_DESC_PTR = txbuf[0]->Dma;
  292. }
  293. }
  294. /* Set RX DMA */
  295. *pDMA1_NEXT_DESC_PTR = rxbuf[0]->Dma;
  296. *pDMA1_CONFIG = rxbuf[0]->Dma[0].CONFIG_DATA;
  297. /* Wait MII done */
  298. bfin_miiphy_wait();
  299. /* We enable only RX here */
  300. /* ASTP : Enable Automatic Pad Stripping
  301. PR : Promiscuous Mode for test
  302. PSF : Receive frames with total length less than 64 bytes.
  303. FDMODE : Full Duplex Mode
  304. LB : Internal Loopback for test
  305. RE : Receiver Enable */
  306. if (dat == FDMODE)
  307. opmode = ASTP | FDMODE | PSF;
  308. else
  309. opmode = ASTP | PSF;
  310. opmode |= RE;
  311. #ifdef CONFIG_RMII
  312. opmode |= TE | RMII;
  313. #endif
  314. /* Turn on the EMAC */
  315. *pEMAC_OPMODE = opmode;
  316. return 0;
  317. }
  318. static void bfin_EMAC_halt(struct eth_device *dev)
  319. {
  320. debug("Eth_halt: ......\n");
  321. /* Turn off the EMAC */
  322. *pEMAC_OPMODE = 0x00000000;
  323. /* Turn off the EMAC RX DMA */
  324. *pDMA1_CONFIG = 0x0000;
  325. *pDMA2_CONFIG = 0x0000;
  326. }
  327. void bfin_EMAC_setup_addr(uchar *enetaddr)
  328. {
  329. *pEMAC_ADDRLO =
  330. enetaddr[0] |
  331. enetaddr[1] << 8 |
  332. enetaddr[2] << 16 |
  333. enetaddr[3] << 24;
  334. *pEMAC_ADDRHI =
  335. enetaddr[4] |
  336. enetaddr[5] << 8;
  337. }
  338. ADI_ETHER_BUFFER *SetupRxBuffer(int no)
  339. {
  340. ADI_ETHER_FRAME_BUFFER *frmbuf;
  341. ADI_ETHER_BUFFER *buf;
  342. int nobytes_buffer = sizeof(ADI_ETHER_BUFFER[2]) / 2; /* ensure a multi. of 4 */
  343. int total_size = nobytes_buffer + RECV_BUFSIZE;
  344. buf = (void *) (RXBUF_BASE_ADDR + no * total_size);
  345. frmbuf = (void *) (RXBUF_BASE_ADDR + no * total_size + nobytes_buffer);
  346. memset(buf, 0x00, nobytes_buffer);
  347. buf->FrmData = frmbuf;
  348. memset(frmbuf, 0xfe, RECV_BUFSIZE);
  349. /* set up first desc to point to receive frame buffer */
  350. buf->Dma[0].NEXT_DESC_PTR = &(buf->Dma[1]);
  351. buf->Dma[0].START_ADDR = (u32) buf->FrmData;
  352. buf->Dma[0].CONFIG.b_DMA_EN = 1; /* enabled */
  353. buf->Dma[0].CONFIG.b_WNR = 1; /* Write to memory */
  354. buf->Dma[0].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  355. buf->Dma[0].CONFIG.b_NDSIZE = 5; /* 5 half words is desc size. */
  356. buf->Dma[0].CONFIG.b_FLOW = 7; /* large desc flow */
  357. /* set up second desc to point to status word */
  358. buf->Dma[1].NEXT_DESC_PTR = buf->Dma;
  359. buf->Dma[1].START_ADDR = (u32) & buf->IPHdrChksum;
  360. buf->Dma[1].CONFIG.b_DMA_EN = 1; /* enabled */
  361. buf->Dma[1].CONFIG.b_WNR = 1; /* Write to memory */
  362. buf->Dma[1].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  363. buf->Dma[1].CONFIG.b_DI_EN = 1; /* enable interrupt */
  364. buf->Dma[1].CONFIG.b_NDSIZE = 5; /* must be 0 when FLOW is 0 */
  365. buf->Dma[1].CONFIG.b_FLOW = 7; /* stop */
  366. return buf;
  367. }
  368. ADI_ETHER_BUFFER *SetupTxBuffer(int no)
  369. {
  370. ADI_ETHER_FRAME_BUFFER *frmbuf;
  371. ADI_ETHER_BUFFER *buf;
  372. int nobytes_buffer = sizeof(ADI_ETHER_BUFFER[2]) / 2; /* ensure a multi. of 4 */
  373. int total_size = nobytes_buffer + RECV_BUFSIZE;
  374. buf = (void *) (TXBUF_BASE_ADDR + no * total_size);
  375. frmbuf = (void *) (TXBUF_BASE_ADDR + no * total_size + nobytes_buffer);
  376. memset(buf, 0x00, nobytes_buffer);
  377. buf->FrmData = frmbuf;
  378. memset(frmbuf, 0x00, RECV_BUFSIZE);
  379. /* set up first desc to point to receive frame buffer */
  380. buf->Dma[0].NEXT_DESC_PTR = &(buf->Dma[1]);
  381. buf->Dma[0].START_ADDR = (u32) buf->FrmData;
  382. buf->Dma[0].CONFIG.b_DMA_EN = 1; /* enabled */
  383. buf->Dma[0].CONFIG.b_WNR = 0; /* Read to memory */
  384. buf->Dma[0].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  385. buf->Dma[0].CONFIG.b_NDSIZE = 5; /* 5 half words is desc size. */
  386. buf->Dma[0].CONFIG.b_FLOW = 7; /* large desc flow */
  387. /* set up second desc to point to status word */
  388. buf->Dma[1].NEXT_DESC_PTR = &(buf->Dma[0]);
  389. buf->Dma[1].START_ADDR = (u32) & buf->StatusWord;
  390. buf->Dma[1].CONFIG.b_DMA_EN = 1; /* enabled */
  391. buf->Dma[1].CONFIG.b_WNR = 1; /* Write to memory */
  392. buf->Dma[1].CONFIG.b_WDSIZE = 2; /* wordsize is 32 bits */
  393. buf->Dma[1].CONFIG.b_DI_EN = 1; /* enable interrupt */
  394. buf->Dma[1].CONFIG.b_NDSIZE = 0; /* must be 0 when FLOW is 0 */
  395. buf->Dma[1].CONFIG.b_FLOW = 0; /* stop */
  396. return buf;
  397. }
  398. #if defined(CONFIG_POST) && defined(CONFIG_SYS_POST_ETHER)
  399. int ether_post_test(int flags)
  400. {
  401. uchar buf[64];
  402. int i, value = 0;
  403. int length;
  404. printf("\n--------");
  405. bfin_EMAC_init(NULL, NULL);
  406. /* construct the package */
  407. buf[0] = buf[6] = (unsigned char)(*pEMAC_ADDRLO & 0xFF);
  408. buf[1] = buf[7] = (unsigned char)((*pEMAC_ADDRLO & 0xFF00) >> 8);
  409. buf[2] = buf[8] = (unsigned char)((*pEMAC_ADDRLO & 0xFF0000) >> 16);
  410. buf[3] = buf[9] = (unsigned char)((*pEMAC_ADDRLO & 0xFF000000) >> 24);
  411. buf[4] = buf[10] = (unsigned char)(*pEMAC_ADDRHI & 0xFF);
  412. buf[5] = buf[11] = (unsigned char)((*pEMAC_ADDRHI & 0xFF00) >> 8);
  413. buf[12] = 0x08; /* Type: ARP */
  414. buf[13] = 0x06;
  415. buf[14] = 0x00; /* Hardware type: Ethernet */
  416. buf[15] = 0x01;
  417. buf[16] = 0x08; /* Protocal type: IP */
  418. buf[17] = 0x00;
  419. buf[18] = 0x06; /* Hardware size */
  420. buf[19] = 0x04; /* Protocol size */
  421. buf[20] = 0x00; /* Opcode: request */
  422. buf[21] = 0x01;
  423. for (i = 0; i < 42; i++)
  424. buf[i + 22] = i;
  425. printf("--------Send 64 bytes......\n");
  426. bfin_EMAC_send(NULL, (volatile void *)buf, 64);
  427. for (i = 0; i < 100; i++) {
  428. udelay(10000);
  429. if ((rxbuf[rxIdx]->StatusWord & RX_COMP) != 0) {
  430. value = 1;
  431. break;
  432. }
  433. }
  434. if (value == 0) {
  435. printf("--------EMAC can't receive any data\n");
  436. eth_halt();
  437. return -1;
  438. }
  439. length = rxbuf[rxIdx]->StatusWord & 0x000007FF - 4;
  440. for (i = 0; i < length; i++) {
  441. if (rxbuf[rxIdx]->FrmData->Dest[i] != buf[i]) {
  442. printf("--------EMAC receive error data!\n");
  443. eth_halt();
  444. return -1;
  445. }
  446. }
  447. printf("--------receive %d bytes, matched\n", length);
  448. bfin_EMAC_halt(NULL);
  449. return 0;
  450. }
  451. #endif