bfin_mac.c 14 KB

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