fsl_mcdmafec.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2007 Freescale Semiconductor, Inc.
  6. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <malloc.h>
  28. #include <command.h>
  29. #include <config.h>
  30. #include <net.h>
  31. #include <miiphy.h>
  32. #ifdef CONFIG_FSLDMAFEC
  33. #undef ET_DEBUG
  34. #undef MII_DEBUG
  35. /* Ethernet Transmit and Receive Buffers */
  36. #define DBUF_LENGTH 1520
  37. #define PKT_MAXBUF_SIZE 1518
  38. #define PKT_MINBUF_SIZE 64
  39. #define PKT_MAXBLR_SIZE 1536
  40. #define LAST_PKTBUFSRX PKTBUFSRX - 1
  41. #define BD_ENET_RX_W_E (BD_ENET_RX_WRAP | BD_ENET_RX_EMPTY)
  42. #define BD_ENET_TX_RDY_LST (BD_ENET_TX_READY | BD_ENET_TX_LAST)
  43. #define FIFO_ERRSTAT (FIFO_STAT_RXW | FIFO_STAT_UF | FIFO_STAT_OF)
  44. /* RxBD bits definitions */
  45. #define BD_ENET_RX_ERR (BD_ENET_RX_LG | BD_ENET_RX_NO | BD_ENET_RX_CR | \
  46. BD_ENET_RX_OV | BD_ENET_RX_TR)
  47. #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI)
  48. #include <asm/immap.h>
  49. #include <asm/fsl_mcdmafec.h>
  50. #include "MCD_dma.h"
  51. DECLARE_GLOBAL_DATA_PTR;
  52. struct fec_info_dma fec_info[] = {
  53. #ifdef CFG_FEC0_IOBASE
  54. {
  55. 0, /* index */
  56. CFG_FEC0_IOBASE, /* io base */
  57. CFG_FEC0_PINMUX, /* gpio pin muxing */
  58. CFG_FEC0_MIIBASE, /* mii base */
  59. -1, /* phy_addr */
  60. 0, /* duplex and speed */
  61. 0, /* phy name */
  62. 0, /* phyname init */
  63. 0, /* RX BD */
  64. 0, /* TX BD */
  65. 0, /* rx Index */
  66. 0, /* tx Index */
  67. 0, /* tx buffer */
  68. 0, /* initialized flag */
  69. (struct fec_info_dma *)-1, /* next */
  70. FEC0_RX_TASK, /* rxTask */
  71. FEC0_TX_TASK, /* txTask */
  72. FEC0_RX_PRIORITY, /* rxPri */
  73. FEC0_TX_PRIORITY, /* txPri */
  74. FEC0_RX_INIT, /* rxInit */
  75. FEC0_TX_INIT, /* txInit */
  76. 0, /* usedTbdIndex */
  77. 0, /* cleanTbdNum */
  78. },
  79. #endif
  80. #ifdef CFG_FEC1_IOBASE
  81. {
  82. 1, /* index */
  83. CFG_FEC1_IOBASE, /* io base */
  84. CFG_FEC1_PINMUX, /* gpio pin muxing */
  85. CFG_FEC1_MIIBASE, /* mii base */
  86. -1, /* phy_addr */
  87. 0, /* duplex and speed */
  88. 0, /* phy name */
  89. 0, /* phy name init */
  90. 0, /* RX BD */
  91. 0, /* TX BD */
  92. 0, /* rx Index */
  93. 0, /* tx Index */
  94. 0, /* tx buffer */
  95. 0, /* initialized flag */
  96. (struct fec_info_dma *)-1, /* next */
  97. FEC1_RX_TASK, /* rxTask */
  98. FEC1_TX_TASK, /* txTask */
  99. FEC1_RX_PRIORITY, /* rxPri */
  100. FEC1_TX_PRIORITY, /* txPri */
  101. FEC1_RX_INIT, /* rxInit */
  102. FEC1_TX_INIT, /* txInit */
  103. 0, /* usedTbdIndex */
  104. 0, /* cleanTbdNum */
  105. }
  106. #endif
  107. };
  108. static int fec_send(struct eth_device *dev, volatile void *packet, int length);
  109. static int fec_recv(struct eth_device *dev);
  110. static int fec_init(struct eth_device *dev, bd_t * bd);
  111. static void fec_halt(struct eth_device *dev);
  112. #ifdef ET_DEBUG
  113. static void dbg_fec_regs(struct eth_device *dev)
  114. {
  115. struct fec_info_dma *info = dev->priv;
  116. volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);
  117. printf("=====\n");
  118. printf("ievent %x - %x\n", (int)&fecp->eir, fecp->eir);
  119. printf("imask %x - %x\n", (int)&fecp->eimr, fecp->eimr);
  120. printf("ecntrl %x - %x\n", (int)&fecp->ecr, fecp->ecr);
  121. printf("mii_mframe %x - %x\n", (int)&fecp->mmfr, fecp->mmfr);
  122. printf("mii_speed %x - %x\n", (int)&fecp->mscr, fecp->mscr);
  123. printf("mii_ctrlstat %x - %x\n", (int)&fecp->mibc, fecp->mibc);
  124. printf("r_cntrl %x - %x\n", (int)&fecp->rcr, fecp->rcr);
  125. printf("r hash %x - %x\n", (int)&fecp->rhr, fecp->rhr);
  126. printf("x_cntrl %x - %x\n", (int)&fecp->tcr, fecp->tcr);
  127. printf("padr_l %x - %x\n", (int)&fecp->palr, fecp->palr);
  128. printf("padr_u %x - %x\n", (int)&fecp->paur, fecp->paur);
  129. printf("op_pause %x - %x\n", (int)&fecp->opd, fecp->opd);
  130. printf("iadr_u %x - %x\n", (int)&fecp->iaur, fecp->iaur);
  131. printf("iadr_l %x - %x\n", (int)&fecp->ialr, fecp->ialr);
  132. printf("gadr_u %x - %x\n", (int)&fecp->gaur, fecp->gaur);
  133. printf("gadr_l %x - %x\n", (int)&fecp->galr, fecp->galr);
  134. printf("x_wmrk %x - %x\n", (int)&fecp->tfwr, fecp->tfwr);
  135. printf("r_fdata %x - %x\n", (int)&fecp->rfdr, fecp->rfdr);
  136. printf("r_fstat %x - %x\n", (int)&fecp->rfsr, fecp->rfsr);
  137. printf("r_fctrl %x - %x\n", (int)&fecp->rfcr, fecp->rfcr);
  138. printf("r_flrfp %x - %x\n", (int)&fecp->rlrfp, fecp->rlrfp);
  139. printf("r_flwfp %x - %x\n", (int)&fecp->rlwfp, fecp->rlwfp);
  140. printf("r_frfar %x - %x\n", (int)&fecp->rfar, fecp->rfar);
  141. printf("r_frfrp %x - %x\n", (int)&fecp->rfrp, fecp->rfrp);
  142. printf("r_frfwp %x - %x\n", (int)&fecp->rfwp, fecp->rfwp);
  143. printf("t_fdata %x - %x\n", (int)&fecp->tfdr, fecp->tfdr);
  144. printf("t_fstat %x - %x\n", (int)&fecp->tfsr, fecp->tfsr);
  145. printf("t_fctrl %x - %x\n", (int)&fecp->tfcr, fecp->tfcr);
  146. printf("t_flrfp %x - %x\n", (int)&fecp->tlrfp, fecp->tlrfp);
  147. printf("t_flwfp %x - %x\n", (int)&fecp->tlwfp, fecp->tlwfp);
  148. printf("t_ftfar %x - %x\n", (int)&fecp->tfar, fecp->tfar);
  149. printf("t_ftfrp %x - %x\n", (int)&fecp->tfrp, fecp->tfrp);
  150. printf("t_ftfwp %x - %x\n", (int)&fecp->tfwp, fecp->tfwp);
  151. printf("frst %x - %x\n", (int)&fecp->frst, fecp->frst);
  152. printf("ctcwr %x - %x\n", (int)&fecp->ctcwr, fecp->ctcwr);
  153. }
  154. #endif
  155. static void set_fec_duplex_speed(volatile fecdma_t * fecp, bd_t * bd, int dup_spd)
  156. {
  157. if ((dup_spd >> 16) == FULL) {
  158. /* Set maximum frame length */
  159. fecp->rcr = FEC_RCR_MAX_FL(PKT_MAXBUF_SIZE) | FEC_RCR_MII_MODE |
  160. FEC_RCR_PROM | 0x100;
  161. fecp->tcr = FEC_TCR_FDEN;
  162. } else {
  163. /* Half duplex mode */
  164. fecp->rcr = FEC_RCR_MAX_FL(PKT_MAXBUF_SIZE) |
  165. FEC_RCR_MII_MODE | FEC_RCR_DRT;
  166. fecp->tcr &= ~FEC_TCR_FDEN;
  167. }
  168. if ((dup_spd & 0xFFFF) == _100BASET) {
  169. #ifdef MII_DEBUG
  170. printf("100Mbps\n");
  171. #endif
  172. bd->bi_ethspeed = 100;
  173. } else {
  174. #ifdef MII_DEBUG
  175. printf("10Mbps\n");
  176. #endif
  177. bd->bi_ethspeed = 10;
  178. }
  179. }
  180. static int fec_send(struct eth_device *dev, volatile void *packet, int length)
  181. {
  182. struct fec_info_dma *info = dev->priv;
  183. cbd_t *pTbd, *pUsedTbd;
  184. u16 phyStatus;
  185. miiphy_read(dev->name, info->phy_addr, PHY_BMSR, &phyStatus);
  186. /* process all the consumed TBDs */
  187. while (info->cleanTbdNum < CFG_TX_ETH_BUFFER) {
  188. pUsedTbd = &info->txbd[info->usedTbdIdx];
  189. if (pUsedTbd->cbd_sc & BD_ENET_TX_READY) {
  190. #ifdef ET_DEBUG
  191. printf("Cannot clean TBD %d, in use\n",
  192. info->cleanTbdNum);
  193. #endif
  194. return 0;
  195. }
  196. /* clean this buffer descriptor */
  197. if (info->usedTbdIdx == (CFG_TX_ETH_BUFFER - 1))
  198. pUsedTbd->cbd_sc = BD_ENET_TX_WRAP;
  199. else
  200. pUsedTbd->cbd_sc = 0;
  201. /* update some indeces for a correct handling of the TBD ring */
  202. info->cleanTbdNum++;
  203. info->usedTbdIdx = (info->usedTbdIdx + 1) % CFG_TX_ETH_BUFFER;
  204. }
  205. /* Check for valid length of data. */
  206. if ((length > 1500) || (length <= 0)) {
  207. return -1;
  208. }
  209. /* Check the number of vacant TxBDs. */
  210. if (info->cleanTbdNum < 1) {
  211. printf("No available TxBDs ...\n");
  212. return -1;
  213. }
  214. /* Get the first TxBD to send the mac header */
  215. pTbd = &info->txbd[info->txIdx];
  216. pTbd->cbd_datlen = length;
  217. pTbd->cbd_bufaddr = (u32) packet;
  218. pTbd->cbd_sc |= BD_ENET_TX_LAST | BD_ENET_TX_TC | BD_ENET_TX_READY;
  219. info->txIdx = (info->txIdx + 1) % CFG_TX_ETH_BUFFER;
  220. /* Enable DMA transmit task */
  221. MCD_continDma(info->txTask);
  222. info->cleanTbdNum -= 1;
  223. /* wait until frame is sent . */
  224. while (pTbd->cbd_sc & BD_ENET_TX_READY) {
  225. udelay(10);
  226. }
  227. return (int)(info->txbd[info->txIdx].cbd_sc & BD_ENET_TX_STATS);
  228. }
  229. static int fec_recv(struct eth_device *dev)
  230. {
  231. struct fec_info_dma *info = dev->priv;
  232. volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);
  233. cbd_t *pRbd = &info->rxbd[info->rxIdx];
  234. u32 ievent;
  235. int frame_length, len = 0;
  236. /* Check if any critical events have happened */
  237. ievent = fecp->eir;
  238. if (ievent != 0) {
  239. fecp->eir = ievent;
  240. if (ievent & (FEC_EIR_BABT | FEC_EIR_TXERR | FEC_EIR_RXERR)) {
  241. printf("fec_recv: error\n");
  242. fec_halt(dev);
  243. fec_init(dev, NULL);
  244. return 0;
  245. }
  246. if (ievent & FEC_EIR_HBERR) {
  247. /* Heartbeat error */
  248. fecp->tcr |= FEC_TCR_GTS;
  249. }
  250. if (ievent & FEC_EIR_GRA) {
  251. /* Graceful stop complete */
  252. if (fecp->tcr & FEC_TCR_GTS) {
  253. printf("fec_recv: tcr_gts\n");
  254. fec_halt(dev);
  255. fecp->tcr &= ~FEC_TCR_GTS;
  256. fec_init(dev, NULL);
  257. }
  258. }
  259. }
  260. if (!(pRbd->cbd_sc & BD_ENET_RX_EMPTY)) {
  261. if ((pRbd->cbd_sc & BD_ENET_RX_LAST)
  262. && !(pRbd->cbd_sc & BD_ENET_RX_ERR)
  263. && ((pRbd->cbd_datlen - 4) > 14)) {
  264. /* Get buffer address and size */
  265. frame_length = pRbd->cbd_datlen - 4;
  266. /* Fill the buffer and pass it to upper layers */
  267. NetReceive((volatile uchar *)pRbd->cbd_bufaddr,
  268. frame_length);
  269. len = frame_length;
  270. }
  271. /* Reset buffer descriptor as empty */
  272. if ((info->rxIdx) == (PKTBUFSRX - 1))
  273. pRbd->cbd_sc = (BD_ENET_RX_WRAP | BD_ENET_RX_EMPTY);
  274. else
  275. pRbd->cbd_sc = BD_ENET_RX_EMPTY;
  276. pRbd->cbd_datlen = PKTSIZE_ALIGN;
  277. /* Now, we have an empty RxBD, restart the DMA receive task */
  278. MCD_continDma(info->rxTask);
  279. /* Increment BD count */
  280. info->rxIdx = (info->rxIdx + 1) % PKTBUFSRX;
  281. }
  282. return len;
  283. }
  284. static void fec_set_hwaddr(volatile fecdma_t * fecp, u8 * mac)
  285. {
  286. u8 currByte; /* byte for which to compute the CRC */
  287. int byte; /* loop - counter */
  288. int bit; /* loop - counter */
  289. u32 crc = 0xffffffff; /* initial value */
  290. for (byte = 0; byte < 6; byte++) {
  291. currByte = mac[byte];
  292. for (bit = 0; bit < 8; bit++) {
  293. if ((currByte & 0x01) ^ (crc & 0x01)) {
  294. crc >>= 1;
  295. crc = crc ^ 0xedb88320;
  296. } else {
  297. crc >>= 1;
  298. }
  299. currByte >>= 1;
  300. }
  301. }
  302. crc = crc >> 26;
  303. /* Set individual hash table register */
  304. if (crc >= 32) {
  305. fecp->ialr = (1 << (crc - 32));
  306. fecp->iaur = 0;
  307. } else {
  308. fecp->ialr = 0;
  309. fecp->iaur = (1 << crc);
  310. }
  311. /* Set physical address */
  312. fecp->palr = (mac[0] << 24) + (mac[1] << 16) + (mac[2] << 8) + mac[3];
  313. fecp->paur = (mac[4] << 24) + (mac[5] << 16) + 0x8808;
  314. /* Clear multicast address hash table */
  315. fecp->gaur = 0;
  316. fecp->galr = 0;
  317. }
  318. static int fec_init(struct eth_device *dev, bd_t * bd)
  319. {
  320. struct fec_info_dma *info = dev->priv;
  321. volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);
  322. int i;
  323. #ifdef ET_DEBUG
  324. printf("fec_init: iobase 0x%08x ...\n", info->iobase);
  325. #endif
  326. fecpin_setclear(dev, 1);
  327. fec_halt(dev);
  328. #if defined(CONFIG_CMD_MII) || defined (CONFIG_MII) || \
  329. defined (CFG_DISCOVER_PHY)
  330. mii_init();
  331. set_fec_duplex_speed(fecp, bd, info->dup_spd);
  332. #else
  333. #ifndef CFG_DISCOVER_PHY
  334. set_fec_duplex_speed(fecp, bd, (FECDUPLEX << 16) | FECSPEED);
  335. #endif /* ifndef CFG_DISCOVER_PHY */
  336. #endif /* CONFIG_CMD_MII || CONFIG_MII */
  337. /* We use strictly polling mode only */
  338. fecp->eimr = 0;
  339. /* Clear any pending interrupt */
  340. fecp->eir = 0xffffffff;
  341. /* Set station address */
  342. if ((u32) fecp == CFG_FEC0_IOBASE) {
  343. fec_set_hwaddr(fecp, bd->bi_enetaddr);
  344. } else {
  345. fec_set_hwaddr(fecp, bd->bi_enet1addr);
  346. }
  347. /* Set Opcode/Pause Duration Register */
  348. fecp->opd = 0x00010020;
  349. /* Setup Buffers and Buffer Desriptors */
  350. info->rxIdx = 0;
  351. info->txIdx = 0;
  352. /* Setup Receiver Buffer Descriptors (13.14.24.18)
  353. * Settings: Empty, Wrap */
  354. for (i = 0; i < PKTBUFSRX; i++) {
  355. info->rxbd[i].cbd_sc = BD_ENET_RX_EMPTY;
  356. info->rxbd[i].cbd_datlen = PKTSIZE_ALIGN;
  357. info->rxbd[i].cbd_bufaddr = (uint) NetRxPackets[i];
  358. }
  359. info->rxbd[PKTBUFSRX - 1].cbd_sc |= BD_ENET_RX_WRAP;
  360. /* Setup Ethernet Transmitter Buffer Descriptors (13.14.24.19)
  361. * Settings: Last, Tx CRC */
  362. for (i = 0; i < CFG_TX_ETH_BUFFER; i++) {
  363. info->txbd[i].cbd_sc = 0;
  364. info->txbd[i].cbd_datlen = 0;
  365. info->txbd[i].cbd_bufaddr = (uint) (&info->txbuf[0]);
  366. }
  367. info->txbd[CFG_TX_ETH_BUFFER - 1].cbd_sc |= BD_ENET_TX_WRAP;
  368. info->usedTbdIdx = 0;
  369. info->cleanTbdNum = CFG_TX_ETH_BUFFER;
  370. /* Set Rx FIFO alarm and granularity value */
  371. fecp->rfcr = 0x0c000000;
  372. fecp->rfar = 0x0000030c;
  373. /* Set Tx FIFO granularity value */
  374. fecp->tfcr = FIFO_CTRL_FRAME | FIFO_CTRL_GR(6) | 0x00040000;
  375. fecp->tfar = 0x00000080;
  376. fecp->tfwr = 0x2;
  377. fecp->ctcwr = 0x03000000;
  378. /* Enable DMA receive task */
  379. MCD_startDma(info->rxTask, /* Dma channel */
  380. (s8 *) info->rxbd, /*Source Address */
  381. 0, /* Source increment */
  382. (s8 *) (&fecp->rfdr), /* dest */
  383. 4, /* dest increment */
  384. 0, /* DMA size */
  385. 4, /* xfer size */
  386. info->rxInit, /* initiator */
  387. info->rxPri, /* priority */
  388. (MCD_FECRX_DMA | MCD_TT_FLAGS_DEF), /* Flags */
  389. (MCD_NO_CSUM | MCD_NO_BYTE_SWAP) /* Function description */
  390. );
  391. /* Enable DMA tx task with no ready buffer descriptors */
  392. MCD_startDma(info->txTask, /* Dma channel */
  393. (s8 *) info->txbd, /*Source Address */
  394. 0, /* Source increment */
  395. (s8 *) (&fecp->tfdr), /* dest */
  396. 4, /* dest incr */
  397. 0, /* DMA size */
  398. 4, /* xfer size */
  399. info->txInit, /* initiator */
  400. info->txPri, /* priority */
  401. (MCD_FECTX_DMA | MCD_TT_FLAGS_DEF), /* Flags */
  402. (MCD_NO_CSUM | MCD_NO_BYTE_SWAP) /* Function description */
  403. );
  404. /* Now enable the transmit and receive processing */
  405. fecp->ecr |= FEC_ECR_ETHER_EN;
  406. return 1;
  407. }
  408. static void fec_halt(struct eth_device *dev)
  409. {
  410. struct fec_info_dma *info = dev->priv;
  411. volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);
  412. int counter = 0xffff;
  413. /* issue graceful stop command to the FEC transmitter if necessary */
  414. fecp->tcr |= FEC_TCR_GTS;
  415. /* wait for graceful stop to register */
  416. while ((counter--) && (!(fecp->eir & FEC_EIR_GRA))) ;
  417. /* Disable DMA tasks */
  418. MCD_killDma(info->txTask);
  419. MCD_killDma(info->rxTask);;
  420. /* Disable the Ethernet Controller */
  421. fecp->ecr &= ~FEC_ECR_ETHER_EN;
  422. /* Clear FIFO status registers */
  423. fecp->rfsr &= FIFO_ERRSTAT;
  424. fecp->tfsr &= FIFO_ERRSTAT;
  425. fecp->frst = 0x01000000;
  426. /* Issue a reset command to the FEC chip */
  427. fecp->ecr |= FEC_ECR_RESET;
  428. /* wait at least 20 clock cycles */
  429. udelay(10000);
  430. #ifdef ET_DEBUG
  431. printf("Ethernet task stopped\n");
  432. #endif
  433. }
  434. int mcdmafec_initialize(bd_t * bis)
  435. {
  436. struct eth_device *dev;
  437. int i;
  438. for (i = 0; i < sizeof(fec_info) / sizeof(fec_info[0]); i++) {
  439. dev =
  440. (struct eth_device *)memalign(CFG_CACHELINE_SIZE,
  441. sizeof *dev);
  442. if (dev == NULL)
  443. hang();
  444. memset(dev, 0, sizeof(*dev));
  445. sprintf(dev->name, "FEC%d", fec_info[i].index);
  446. dev->priv = &fec_info[i];
  447. dev->init = fec_init;
  448. dev->halt = fec_halt;
  449. dev->send = fec_send;
  450. dev->recv = fec_recv;
  451. /* setup Receive and Transmit buffer descriptor */
  452. fec_info[i].rxbd =
  453. (cbd_t *) memalign(CFG_CACHELINE_SIZE,
  454. (PKTBUFSRX * sizeof(cbd_t)));
  455. fec_info[i].txbd =
  456. (cbd_t *) memalign(CFG_CACHELINE_SIZE,
  457. (CFG_TX_ETH_BUFFER * sizeof(cbd_t)));
  458. fec_info[i].txbuf =
  459. (char *)memalign(CFG_CACHELINE_SIZE, DBUF_LENGTH);
  460. #ifdef ET_DEBUG
  461. printf("rxbd %x txbd %x\n",
  462. (int)fec_info[i].rxbd, (int)fec_info[i].txbd);
  463. #endif
  464. fec_info[i].phy_name = (char *)memalign(CFG_CACHELINE_SIZE, 32);
  465. eth_register(dev);
  466. #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
  467. miiphy_register(dev->name,
  468. mcffec_miiphy_read, mcffec_miiphy_write);
  469. #endif
  470. if (i > 0)
  471. fec_info[i - 1].next = &fec_info[i];
  472. }
  473. fec_info[i - 1].next = &fec_info[0];
  474. /* default speed */
  475. bis->bi_ethspeed = 10;
  476. return 1;
  477. }
  478. #endif /* CONFIG_CMD_NET && CONFIG_NET_MULTI */
  479. #endif /* CONFIG_FSLDMAFEC */