scc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. /*
  2. * File: scc.c
  3. * Description:
  4. * Basic ET HW initialization and packet RX/TX routines
  5. *
  6. * NOTE <<<IMPORTANT: PLEASE READ>>>:
  7. * Do not cache Rx/Tx buffers!
  8. */
  9. /*
  10. * MPC823 <-> MC68160 Connections:
  11. *
  12. * Setup MPC823 to work with MC68160 Enhanced Ethernet
  13. * Serial Tranceiver as follows:
  14. *
  15. * MPC823 Signal MC68160 Comments
  16. * ------ ------ ------- --------
  17. * PA-12 ETHTX --------> TX Eth. Port Transmit Data
  18. * PB-18 E_TENA --------> TENA Eth. Transmit Port Enable
  19. * PA-5 ETHTCK <-------- TCLK Eth. Port Transmit Clock
  20. * PA-13 ETHRX <-------- RX Eth. Port Receive Data
  21. * PC-8 E_RENA <-------- RENA Eth. Receive Enable
  22. * PA-6 ETHRCK <-------- RCLK Eth. Port Receive Clock
  23. * PC-9 E_CLSN <-------- CLSN Eth. Port Collision Indication
  24. *
  25. * FADS Board Signal MC68160 Comments
  26. * ----------------- ------- --------
  27. * (BCSR1) ETHEN* --------> CS2 Eth. Port Enable
  28. * (BSCR4) TPSQEL* --------> TPSQEL Twisted Pair Signal Quality Error Test Enable
  29. * (BCSR4) TPFLDL* --------> TPFLDL Twisted Pair Full-Duplex
  30. * (BCSR4) ETHLOOP --------> LOOP Eth. Port Diagnostic Loop-Back
  31. *
  32. */
  33. #include <common.h>
  34. #include <malloc.h>
  35. #include <commproc.h>
  36. #include <net.h>
  37. #include <command.h>
  38. #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(SCC_ENET)
  39. /* Ethernet Transmit and Receive Buffers */
  40. #define DBUF_LENGTH 1520
  41. #define TX_BUF_CNT 2
  42. #define TOUT_LOOP 100
  43. static char txbuf[DBUF_LENGTH];
  44. static uint rxIdx; /* index of the current RX buffer */
  45. static uint txIdx; /* index of the current TX buffer */
  46. /*
  47. * SCC Ethernet Tx and Rx buffer descriptors allocated at the
  48. * immr->udata_bd address on Dual-Port RAM
  49. * Provide for Double Buffering
  50. */
  51. typedef volatile struct CommonBufferDescriptor {
  52. cbd_t rxbd[PKTBUFSRX]; /* Rx BD */
  53. cbd_t txbd[TX_BUF_CNT]; /* Tx BD */
  54. } RTXBD;
  55. static RTXBD *rtx;
  56. static int scc_send(struct eth_device* dev, volatile void *packet, int length);
  57. static int scc_recv(struct eth_device* dev);
  58. static int scc_init (struct eth_device* dev, bd_t * bd);
  59. static void scc_halt(struct eth_device* dev);
  60. int scc_initialize(bd_t *bis)
  61. {
  62. struct eth_device* dev;
  63. dev = (struct eth_device*) malloc(sizeof *dev);
  64. memset(dev, 0, sizeof *dev);
  65. sprintf(dev->name, "SCC ETHERNET");
  66. dev->iobase = 0;
  67. dev->priv = 0;
  68. dev->init = scc_init;
  69. dev->halt = scc_halt;
  70. dev->send = scc_send;
  71. dev->recv = scc_recv;
  72. eth_register(dev);
  73. return 1;
  74. }
  75. static int scc_send(struct eth_device* dev, volatile void *packet, int length)
  76. {
  77. int i, j=0;
  78. #if 0
  79. volatile char *in, *out;
  80. #endif
  81. /* section 16.9.23.3
  82. * Wait for ready
  83. */
  84. #if 0
  85. while (rtx->txbd[txIdx].cbd_sc & BD_ENET_TX_READY);
  86. out = (char *)(rtx->txbd[txIdx].cbd_bufaddr);
  87. in = packet;
  88. for(i = 0; i < length; i++) {
  89. *out++ = *in++;
  90. }
  91. rtx->txbd[txIdx].cbd_datlen = length;
  92. rtx->txbd[txIdx].cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_LAST);
  93. while (rtx->txbd[txIdx].cbd_sc & BD_ENET_TX_READY) j++;
  94. #ifdef ET_DEBUG
  95. printf("cycles: %d status: %x\n", j, rtx->txbd[txIdx].cbd_sc);
  96. #endif
  97. i = (rtx->txbd[txIdx++].cbd_sc & BD_ENET_TX_STATS) /* return only status bits */;
  98. /* wrap around buffer index when necessary */
  99. if (txIdx >= TX_BUF_CNT) txIdx = 0;
  100. #endif
  101. while ((rtx->txbd[txIdx].cbd_sc & BD_ENET_TX_READY) && (j<TOUT_LOOP)) {
  102. udelay (1); /* will also trigger Wd if needed */
  103. j++;
  104. }
  105. if (j>=TOUT_LOOP) printf("TX not ready\n");
  106. rtx->txbd[txIdx].cbd_bufaddr = (uint)packet;
  107. rtx->txbd[txIdx].cbd_datlen = length;
  108. rtx->txbd[txIdx].cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_LAST |BD_ENET_TX_WRAP);
  109. while ((rtx->txbd[txIdx].cbd_sc & BD_ENET_TX_READY) && (j<TOUT_LOOP)) {
  110. udelay (1); /* will also trigger Wd if needed */
  111. j++;
  112. }
  113. if (j>=TOUT_LOOP) printf("TX timeout\n");
  114. #ifdef ET_DEBUG
  115. printf("cycles: %d status: %x\n", j, rtx->txbd[txIdx].cbd_sc);
  116. #endif
  117. i = (rtx->txbd[txIdx].cbd_sc & BD_ENET_TX_STATS) /* return only status bits */;
  118. return i;
  119. }
  120. static int scc_recv(struct eth_device* dev)
  121. {
  122. int length;
  123. for (;;) {
  124. /* section 16.9.23.2 */
  125. if (rtx->rxbd[rxIdx].cbd_sc & BD_ENET_RX_EMPTY) {
  126. length = -1;
  127. break; /* nothing received - leave for() loop */
  128. }
  129. length = rtx->rxbd[rxIdx].cbd_datlen;
  130. if (rtx->rxbd[rxIdx].cbd_sc & 0x003f) {
  131. #ifdef ET_DEBUG
  132. printf("err: %x\n", rtx->rxbd[rxIdx].cbd_sc);
  133. #endif
  134. } else {
  135. /* Pass the packet up to the protocol layers. */
  136. NetReceive(NetRxPackets[rxIdx], length - 4);
  137. }
  138. /* Give the buffer back to the SCC. */
  139. rtx->rxbd[rxIdx].cbd_datlen = 0;
  140. /* wrap around buffer index when necessary */
  141. if ((rxIdx + 1) >= PKTBUFSRX) {
  142. rtx->rxbd[PKTBUFSRX - 1].cbd_sc = (BD_ENET_RX_WRAP | BD_ENET_RX_EMPTY);
  143. rxIdx = 0;
  144. } else {
  145. rtx->rxbd[rxIdx].cbd_sc = BD_ENET_RX_EMPTY;
  146. rxIdx++;
  147. }
  148. }
  149. return length;
  150. }
  151. /**************************************************************
  152. *
  153. * SCC Ethernet Initialization Routine
  154. *
  155. *************************************************************/
  156. static int scc_init(struct eth_device* dev, bd_t *bis)
  157. {
  158. int i;
  159. scc_enet_t *pram_ptr;
  160. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  161. #if defined(CONFIG_FADS)
  162. #if defined(CONFIG_MPC860T)
  163. /* The FADS860T doesn't use the MODEM_EN or DATA_VOICE signals. */
  164. *((uint *) BCSR4) &= ~BCSR4_ETHLOOP;
  165. *((uint *) BCSR4) |= BCSR4_TFPLDL|BCSR4_TPSQEL;
  166. *((uint *) BCSR1) &= ~BCSR1_ETHEN;
  167. #else
  168. *((uint *) BCSR4) &= ~(BCSR4_ETHLOOP|BCSR4_MODEM_EN);
  169. *((uint *) BCSR4) |= BCSR4_TFPLDL|BCSR4_TPSQEL|BCSR4_DATA_VOICE;
  170. *((uint *) BCSR1) &= ~BCSR1_ETHEN;
  171. #endif
  172. #endif
  173. pram_ptr = (scc_enet_t *)&(immr->im_cpm.cp_dparam[PROFF_ENET]);
  174. rxIdx = 0;
  175. txIdx = 0;
  176. #ifdef CFG_ALLOC_DPRAM
  177. rtx = (RTXBD *) (immr->im_cpm.cp_dpmem +
  178. dpram_alloc_align(sizeof(RTXBD), 8));
  179. #else
  180. rtx = (RTXBD *) (immr->im_cpm.cp_dpmem + CPM_SCC_BASE);
  181. #endif /* 0 */
  182. #if (defined(PA_ENET_RXD) && defined(PA_ENET_TXD))
  183. /* Configure port A pins for Txd and Rxd.
  184. */
  185. immr->im_ioport.iop_papar |= (PA_ENET_RXD | PA_ENET_TXD);
  186. immr->im_ioport.iop_padir &= ~(PA_ENET_RXD | PA_ENET_TXD);
  187. immr->im_ioport.iop_paodr &= ~PA_ENET_TXD;
  188. #elif (defined(PB_ENET_RXD) && defined(PB_ENET_TXD))
  189. /* Configure port B pins for Txd and Rxd.
  190. */
  191. immr->im_cpm.cp_pbpar |= (PB_ENET_RXD | PB_ENET_TXD);
  192. immr->im_cpm.cp_pbdir &= ~(PB_ENET_RXD | PB_ENET_TXD);
  193. immr->im_cpm.cp_pbodr &= ~PB_ENET_TXD;
  194. #else
  195. #error Configuration Error: exactly ONE of PA_ENET_[RT]XD, PB_ENET_[RT]XD must be defined
  196. #endif
  197. #if defined(PC_ENET_LBK)
  198. /* Configure port C pins to disable External Loopback
  199. */
  200. immr->im_ioport.iop_pcpar &= ~PC_ENET_LBK;
  201. immr->im_ioport.iop_pcdir |= PC_ENET_LBK;
  202. immr->im_ioport.iop_pcso &= ~PC_ENET_LBK;
  203. immr->im_ioport.iop_pcdat &= ~PC_ENET_LBK; /* Disable Loopback */
  204. #endif /* PC_ENET_LBK */
  205. /* Configure port C pins to enable CLSN and RENA.
  206. */
  207. immr->im_ioport.iop_pcpar &= ~(PC_ENET_CLSN | PC_ENET_RENA);
  208. immr->im_ioport.iop_pcdir &= ~(PC_ENET_CLSN | PC_ENET_RENA);
  209. immr->im_ioport.iop_pcso |= (PC_ENET_CLSN | PC_ENET_RENA);
  210. /* Configure port A for TCLK and RCLK.
  211. */
  212. immr->im_ioport.iop_papar |= (PA_ENET_TCLK | PA_ENET_RCLK);
  213. immr->im_ioport.iop_padir &= ~(PA_ENET_TCLK | PA_ENET_RCLK);
  214. /*
  215. * Configure Serial Interface clock routing -- see section 16.7.5.3
  216. * First, clear all SCC bits to zero, then set the ones we want.
  217. */
  218. immr->im_cpm.cp_sicr &= ~SICR_ENET_MASK;
  219. immr->im_cpm.cp_sicr |= SICR_ENET_CLKRT;
  220. /*
  221. * Initialize SDCR -- see section 16.9.23.7
  222. * SDMA configuration register
  223. */
  224. immr->im_siu_conf.sc_sdcr = 0x01;
  225. /*
  226. * Setup SCC Ethernet Parameter RAM
  227. */
  228. pram_ptr->sen_genscc.scc_rfcr = 0x18; /* Normal Operation and Mot byte ordering */
  229. pram_ptr->sen_genscc.scc_tfcr = 0x18; /* Mot byte ordering, Normal access */
  230. pram_ptr->sen_genscc.scc_mrblr = DBUF_LENGTH; /* max. ET package len 1520 */
  231. pram_ptr->sen_genscc.scc_rbase = (unsigned int)(&rtx->rxbd[0]); /* Set RXBD tbl start at Dual Port */
  232. pram_ptr->sen_genscc.scc_tbase = (unsigned int)(&rtx->txbd[0]); /* Set TXBD tbl start at Dual Port */
  233. /*
  234. * Setup Receiver Buffer Descriptors (13.14.24.18)
  235. * Settings:
  236. * Empty, Wrap
  237. */
  238. for (i = 0; i < PKTBUFSRX; i++)
  239. {
  240. rtx->rxbd[i].cbd_sc = BD_ENET_RX_EMPTY;
  241. rtx->rxbd[i].cbd_datlen = 0; /* Reset */
  242. rtx->rxbd[i].cbd_bufaddr = (uint)NetRxPackets[i];
  243. }
  244. rtx->rxbd[PKTBUFSRX - 1].cbd_sc |= BD_ENET_RX_WRAP;
  245. /*
  246. * Setup Ethernet Transmitter Buffer Descriptors (13.14.24.19)
  247. * Settings:
  248. * Add PADs to Short FRAMES, Wrap, Last, Tx CRC
  249. */
  250. for (i = 0; i < TX_BUF_CNT; i++)
  251. {
  252. rtx->txbd[i].cbd_sc = (BD_ENET_TX_PAD | BD_ENET_TX_LAST | BD_ENET_TX_TC);
  253. rtx->txbd[i].cbd_datlen = 0; /* Reset */
  254. rtx->txbd[i].cbd_bufaddr = (uint) (&txbuf[0]);
  255. }
  256. rtx->txbd[TX_BUF_CNT - 1].cbd_sc |= BD_ENET_TX_WRAP;
  257. /*
  258. * Enter Command: Initialize Rx Params for SCC
  259. */
  260. do { /* Spin until ready to issue command */
  261. __asm__ ("eieio");
  262. } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
  263. /* Issue command */
  264. immr->im_cpm.cp_cpcr = ((CPM_CR_INIT_RX << 8) | (CPM_CR_ENET << 4) | CPM_CR_FLG);
  265. do { /* Spin until command processed */
  266. __asm__ ("eieio");
  267. } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
  268. /*
  269. * Ethernet Specific Parameter RAM
  270. * see table 13-16, pg. 660,
  271. * pg. 681 (example with suggested settings)
  272. */
  273. pram_ptr->sen_cpres = ~(0x0); /* Preset CRC */
  274. pram_ptr->sen_cmask = 0xdebb20e3; /* Constant Mask for CRC */
  275. pram_ptr->sen_crcec = 0x0; /* Error Counter CRC (unused) */
  276. pram_ptr->sen_alec = 0x0; /* Alignment Error Counter (unused) */
  277. pram_ptr->sen_disfc = 0x0; /* Discard Frame Counter (unused) */
  278. pram_ptr->sen_pads = 0x8888; /* Short Frame PAD Characters */
  279. pram_ptr->sen_retlim = 15; /* Retry Limit Threshold */
  280. pram_ptr->sen_maxflr = 1518; /* MAX Frame Length Register */
  281. pram_ptr->sen_minflr = 64; /* MIN Frame Length Register */
  282. pram_ptr->sen_maxd1 = DBUF_LENGTH; /* MAX DMA1 Length Register */
  283. pram_ptr->sen_maxd2 = DBUF_LENGTH; /* MAX DMA2 Length Register */
  284. pram_ptr->sen_gaddr1 = 0x0; /* Group Address Filter 1 (unused) */
  285. pram_ptr->sen_gaddr2 = 0x0; /* Group Address Filter 2 (unused) */
  286. pram_ptr->sen_gaddr3 = 0x0; /* Group Address Filter 3 (unused) */
  287. pram_ptr->sen_gaddr4 = 0x0; /* Group Address Filter 4 (unused) */
  288. #define ea eth_get_dev()->enetaddr
  289. pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
  290. pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
  291. pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
  292. #undef ea
  293. pram_ptr->sen_pper = 0x0; /* Persistence (unused) */
  294. pram_ptr->sen_iaddr1 = 0x0; /* Individual Address Filter 1 (unused) */
  295. pram_ptr->sen_iaddr2 = 0x0; /* Individual Address Filter 2 (unused) */
  296. pram_ptr->sen_iaddr3 = 0x0; /* Individual Address Filter 3 (unused) */
  297. pram_ptr->sen_iaddr4 = 0x0; /* Individual Address Filter 4 (unused) */
  298. pram_ptr->sen_taddrh = 0x0; /* Tmp Address (MSB) (unused) */
  299. pram_ptr->sen_taddrm = 0x0; /* Tmp Address (unused) */
  300. pram_ptr->sen_taddrl = 0x0; /* Tmp Address (LSB) (unused) */
  301. /*
  302. * Enter Command: Initialize Tx Params for SCC
  303. */
  304. do { /* Spin until ready to issue command */
  305. __asm__ ("eieio");
  306. } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
  307. /* Issue command */
  308. immr->im_cpm.cp_cpcr = ((CPM_CR_INIT_TX << 8) | (CPM_CR_ENET << 4) | CPM_CR_FLG);
  309. do { /* Spin until command processed */
  310. __asm__ ("eieio");
  311. } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
  312. /*
  313. * Mask all Events in SCCM - we use polling mode
  314. */
  315. immr->im_cpm.cp_scc[SCC_ENET].scc_sccm = 0;
  316. /*
  317. * Clear Events in SCCE -- Clear bits by writing 1's
  318. */
  319. immr->im_cpm.cp_scc[SCC_ENET].scc_scce = ~(0x0);
  320. /*
  321. * Initialize GSMR High 32-Bits
  322. * Settings: Normal Mode
  323. */
  324. immr->im_cpm.cp_scc[SCC_ENET].scc_gsmrh = 0;
  325. /*
  326. * Initialize GSMR Low 32-Bits, but do not Enable Transmit/Receive
  327. * Settings:
  328. * TCI = Invert
  329. * TPL = 48 bits
  330. * TPP = Repeating 10's
  331. * MODE = Ethernet
  332. */
  333. immr->im_cpm.cp_scc[SCC_ENET].scc_gsmrl = ( SCC_GSMRL_TCI | \
  334. SCC_GSMRL_TPL_48 | \
  335. SCC_GSMRL_TPP_10 | \
  336. SCC_GSMRL_MODE_ENET);
  337. /*
  338. * Initialize the DSR -- see section 13.14.4 (pg. 513) v0.4
  339. */
  340. immr->im_cpm.cp_scc[SCC_ENET].scc_dsr = 0xd555;
  341. /*
  342. * Initialize the PSMR
  343. * Settings:
  344. * CRC = 32-Bit CCITT
  345. * NIB = Begin searching for SFD 22 bits after RENA
  346. * FDE = Full Duplex Enable
  347. * LPB = Loopback Enable (Needed when FDE is set)
  348. * BRO = Reject broadcast packets
  349. * PROMISCOUS = Catch all packets regardless of dest. MAC adress
  350. */
  351. immr->im_cpm.cp_scc[SCC_ENET].scc_psmr = SCC_PSMR_ENCRC |
  352. SCC_PSMR_NIB22 |
  353. #if defined(CONFIG_SCC_ENET_FULL_DUPLEX)
  354. SCC_PSMR_FDE |
  355. SCC_PSMR_LPB |
  356. #endif
  357. #if defined(CONFIG_SCC_ENET_NO_BROADCAST)
  358. SCC_PSMR_BRO |
  359. #endif
  360. #if defined(CONFIG_SCC_ENET_PROMISCOUS)
  361. SCC_PSMR_PRO |
  362. #endif
  363. 0;
  364. /*
  365. * Configure Ethernet TENA Signal
  366. */
  367. #if (defined(PC_ENET_TENA) && !defined(PB_ENET_TENA))
  368. immr->im_ioport.iop_pcpar |= PC_ENET_TENA;
  369. immr->im_ioport.iop_pcdir &= ~PC_ENET_TENA;
  370. #elif (defined(PB_ENET_TENA) && !defined(PC_ENET_TENA))
  371. immr->im_cpm.cp_pbpar |= PB_ENET_TENA;
  372. immr->im_cpm.cp_pbdir |= PB_ENET_TENA;
  373. #else
  374. #error Configuration Error: exactly ONE of PB_ENET_TENA, PC_ENET_TENA must be defined
  375. #endif
  376. #if defined(CONFIG_ADS) && defined(CONFIG_MPC860)
  377. /*
  378. * Port C is used to control the PHY,MC68160.
  379. */
  380. immr->im_ioport.iop_pcdir |=
  381. (PC_ENET_ETHLOOP | PC_ENET_TPFLDL | PC_ENET_TPSQEL);
  382. immr->im_ioport.iop_pcdat |= PC_ENET_TPFLDL;
  383. immr->im_ioport.iop_pcdat &= ~(PC_ENET_ETHLOOP | PC_ENET_TPSQEL);
  384. *((uint *) BCSR1) &= ~BCSR1_ETHEN;
  385. #endif /* MPC860ADS */
  386. #if defined(CONFIG_AMX860)
  387. /*
  388. * Port B is used to control the PHY,MC68160.
  389. */
  390. immr->im_cpm.cp_pbdir |=
  391. (PB_ENET_ETHLOOP | PB_ENET_TPFLDL | PB_ENET_TPSQEL);
  392. immr->im_cpm.cp_pbdat |= PB_ENET_TPFLDL;
  393. immr->im_cpm.cp_pbdat &= ~(PB_ENET_ETHLOOP | PB_ENET_TPSQEL);
  394. immr->im_ioport.iop_pddir |= PD_ENET_ETH_EN;
  395. immr->im_ioport.iop_pddat &= ~PD_ENET_ETH_EN;
  396. #endif /* AMX860 */
  397. #ifdef CONFIG_RPXCLASSIC
  398. *((uchar *)BCSR0) &= ~BCSR0_ETHLPBK;
  399. *((uchar *)BCSR0) |= (BCSR0_ETHEN | BCSR0_COLTEST | BCSR0_FULLDPLX);
  400. #endif
  401. #ifdef CONFIG_RPXLITE
  402. *((uchar *)BCSR0) |= BCSR0_ETHEN ;
  403. #endif
  404. #ifdef CONFIG_MBX
  405. board_ether_init();
  406. #endif
  407. #if defined(CONFIG_NETVIA)
  408. #if defined(PA_ENET_PDN)
  409. immr->im_ioport.iop_papar &= ~PA_ENET_PDN;
  410. immr->im_ioport.iop_padir |= PA_ENET_PDN;
  411. immr->im_ioport.iop_padat |= PA_ENET_PDN;
  412. #elif defined(PB_ENET_PDN)
  413. immr->im_cpm.cp_pbpar &= ~PB_ENET_PDN;
  414. immr->im_cpm.cp_pbdir |= PB_ENET_PDN;
  415. immr->im_cpm.cp_pbdat |= PB_ENET_PDN;
  416. #elif defined(PC_ENET_PDN)
  417. immr->im_ioport.iop_pcpar &= ~PC_ENET_PDN;
  418. immr->im_ioport.iop_pcdir |= PC_ENET_PDN;
  419. immr->im_ioport.iop_pcdat |= PC_ENET_PDN;
  420. #elif defined(PD_ENET_PDN)
  421. immr->im_ioport.iop_pdpar &= ~PD_ENET_PDN;
  422. immr->im_ioport.iop_pddir |= PD_ENET_PDN;
  423. immr->im_ioport.iop_pddat |= PD_ENET_PDN;
  424. #endif
  425. #endif
  426. /*
  427. * Set the ENT/ENR bits in the GSMR Low -- Enable Transmit/Receive
  428. */
  429. immr->im_cpm.cp_scc[SCC_ENET].scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
  430. /*
  431. * Work around transmit problem with first eth packet
  432. */
  433. #if defined (CONFIG_FADS)
  434. udelay(10000); /* wait 10 ms */
  435. #elif defined (CONFIG_AMX860) || defined(CONFIG_RPXCLASSIC)
  436. udelay(100000); /* wait 100 ms */
  437. #endif
  438. return 1;
  439. }
  440. static void scc_halt(struct eth_device* dev)
  441. {
  442. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  443. immr->im_cpm.cp_scc[SCC_ENET].scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
  444. }
  445. #if 0
  446. void restart(void)
  447. {
  448. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  449. immr->im_cpm.cp_scc[SCC_ENET].scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
  450. }
  451. #endif
  452. #endif /* CFG_CMD_NET, SCC_ENET */