serial.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <commproc.h>
  25. #include <command.h>
  26. #include <watchdog.h>
  27. #if !defined(CONFIG_8xx_CONS_NONE) /* No Console at all */
  28. #if defined(CONFIG_8xx_CONS_SMC1) /* Console on SMC1 */
  29. #define SMC_INDEX 0
  30. #undef SCC_INDEX
  31. #define PROFF_SMC PROFF_SMC1
  32. #define CPM_CR_CH_SMC CPM_CR_CH_SMC1
  33. #elif defined(CONFIG_8xx_CONS_SMC2) /* Console on SMC2 */
  34. #define SMC_INDEX 1
  35. #undef SCC_INDEX
  36. #define PROFF_SMC PROFF_SMC2
  37. #define CPM_CR_CH_SMC CPM_CR_CH_SMC2
  38. #elif defined(CONFIG_8xx_CONS_SCC1) /* Console on SCC1 */
  39. #undef SMC_INDEX
  40. #define SCC_INDEX 0
  41. #define PROFF_SCC PROFF_SCC1
  42. #define CPM_CR_CH_SCC CPM_CR_CH_SCC1
  43. #elif defined(CONFIG_8xx_CONS_SCC2) /* Console on SCC2 */
  44. #undef SMC_INDEX
  45. #define SCC_INDEX 1
  46. #define PROFF_SCC PROFF_SCC2
  47. #define CPM_CR_CH_SCC CPM_CR_CH_SCC2
  48. #elif defined(CONFIG_8xx_CONS_SCC3) /* Console on SCC3 */
  49. #undef SMC_INDEX
  50. #define SCC_INDEX 2
  51. #define PROFF_SCC PROFF_SCC3
  52. #define CPM_CR_CH_SCC CPM_CR_CH_SCC3
  53. #elif defined(CONFIG_8xx_CONS_SCC4) /* Console on SCC4 */
  54. #undef SMC_INDEX
  55. #define SCC_INDEX 3
  56. #define PROFF_SCC PROFF_SCC4
  57. #define CPM_CR_CH_SCC CPM_CR_CH_SCC4
  58. #else /* CONFIG_8xx_CONS_? */
  59. #error "console not correctly defined"
  60. #endif
  61. static void serial_setdivisor(volatile cpm8xx_t *cp)
  62. {
  63. DECLARE_GLOBAL_DATA_PTR;
  64. int divisor=gd->cpu_clk/16/gd->baudrate;
  65. if(divisor/16>0x1000) {
  66. /* bad divisor, assume 50Mhz clock and 9600 baud */
  67. divisor=(50*1000*1000)/16/9600;
  68. }
  69. if(divisor<=0x1000) {
  70. cp->cp_brgc1=((divisor-1)<<1) | CPM_BRG_EN;
  71. } else {
  72. cp->cp_brgc1=((divisor/16-1)<<1) | CPM_BRG_EN | CPM_BRG_DIV16;
  73. }
  74. }
  75. #if (defined (CONFIG_8xx_CONS_SMC1) || defined (CONFIG_8xx_CONS_SMC2))
  76. /*
  77. * Minimal serial functions needed to use one of the SMC ports
  78. * as serial console interface.
  79. */
  80. int serial_init (void)
  81. {
  82. volatile immap_t *im = (immap_t *)CFG_IMMR;
  83. volatile smc_t *sp;
  84. volatile smc_uart_t *up;
  85. volatile cbd_t *tbdf, *rbdf;
  86. volatile cpm8xx_t *cp = &(im->im_cpm);
  87. #if (!defined(CONFIG_8xx_CONS_SMC1)) && (defined(CONFIG_MPC823) || defined(CONFIG_MPC850))
  88. volatile iop8xx_t *ip = (iop8xx_t *)&(im->im_ioport);
  89. #endif
  90. uint dpaddr;
  91. /* initialize pointers to SMC */
  92. sp = (smc_t *) &(cp->cp_smc[SMC_INDEX]);
  93. up = (smc_uart_t *) &cp->cp_dparam[PROFF_SMC];
  94. /* Disable transmitter/receiver.
  95. */
  96. sp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
  97. /* Enable SDMA.
  98. */
  99. im->im_siu_conf.sc_sdcr = 1;
  100. /* clear error conditions */
  101. #ifdef CFG_SDSR
  102. im->im_sdma.sdma_sdsr = CFG_SDSR;
  103. #else
  104. im->im_sdma.sdma_sdsr = 0x83;
  105. #endif
  106. /* clear SDMA interrupt mask */
  107. #ifdef CFG_SDMR
  108. im->im_sdma.sdma_sdmr = CFG_SDMR;
  109. #else
  110. im->im_sdma.sdma_sdmr = 0x00;
  111. #endif
  112. #if defined(CONFIG_8xx_CONS_SMC1)
  113. /* Use Port B for SMC1 instead of other functions.
  114. */
  115. cp->cp_pbpar |= 0x000000c0;
  116. cp->cp_pbdir &= ~0x000000c0;
  117. cp->cp_pbodr &= ~0x000000c0;
  118. #else /* CONFIG_8xx_CONS_SMC2 */
  119. # if defined(CONFIG_MPC823) || defined(CONFIG_MPC850)
  120. /* Use Port A for SMC2 instead of other functions.
  121. */
  122. ip->iop_papar |= 0x00c0;
  123. ip->iop_padir &= ~0x00c0;
  124. ip->iop_paodr &= ~0x00c0;
  125. # else /* must be a 860 then */
  126. /* Use Port B for SMC2 instead of other functions.
  127. */
  128. cp->cp_pbpar |= 0x00000c00;
  129. cp->cp_pbdir &= ~0x00000c00;
  130. cp->cp_pbodr &= ~0x00000c00;
  131. # endif
  132. #endif
  133. #if defined(CONFIG_FADS)
  134. /* Enable RS232 */
  135. #if defined(CONFIG_8xx_CONS_SMC1)
  136. *((uint *) BCSR1) &= ~BCSR1_RS232EN_1;
  137. #else
  138. *((uint *) BCSR1) &= ~BCSR1_RS232EN_2;
  139. #endif
  140. #endif /* CONFIG_FADS */
  141. #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
  142. /* Enable Monitor Port Transceiver */
  143. *((uchar *) BCSR0) |= BCSR0_ENMONXCVR ;
  144. #endif /* CONFIG_RPXLITE */
  145. /* Set the physical address of the host memory buffers in
  146. * the buffer descriptors.
  147. */
  148. #ifdef CFG_ALLOC_DPRAM
  149. dpaddr = dpram_alloc_align (sizeof(cbd_t)*2 + 2, 8) ;
  150. #else
  151. dpaddr = CPM_SERIAL_BASE ;
  152. #endif
  153. /* Allocate space for two buffer descriptors in the DP ram.
  154. * For now, this address seems OK, but it may have to
  155. * change with newer versions of the firmware.
  156. * damm: allocating space after the two buffers for rx/tx data
  157. */
  158. rbdf = (cbd_t *)&cp->cp_dpmem[dpaddr];
  159. rbdf->cbd_bufaddr = (uint) (rbdf+2);
  160. rbdf->cbd_sc = 0;
  161. tbdf = rbdf + 1;
  162. tbdf->cbd_bufaddr = ((uint) (rbdf+2)) + 1;
  163. tbdf->cbd_sc = 0;
  164. /* Set up the uart parameters in the parameter ram.
  165. */
  166. up->smc_rbase = dpaddr;
  167. up->smc_tbase = dpaddr+sizeof(cbd_t);
  168. up->smc_rfcr = SMC_EB;
  169. up->smc_tfcr = SMC_EB;
  170. #if defined(CONFIG_MBX)
  171. board_serial_init();
  172. #endif /* CONFIG_MBX */
  173. /* Set UART mode, 8 bit, no parity, one stop.
  174. * Enable receive and transmit.
  175. */
  176. sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
  177. /* Mask all interrupts and remove anything pending.
  178. */
  179. sp->smc_smcm = 0;
  180. sp->smc_smce = 0xff;
  181. /* Set up the baud rate generator.
  182. */
  183. serial_setbrg ();
  184. /* Make the first buffer the only buffer.
  185. */
  186. tbdf->cbd_sc |= BD_SC_WRAP;
  187. rbdf->cbd_sc |= BD_SC_EMPTY | BD_SC_WRAP;
  188. /* Single character receive.
  189. */
  190. up->smc_mrblr = 1;
  191. up->smc_maxidl = 0;
  192. /* Initialize Tx/Rx parameters.
  193. */
  194. while (cp->cp_cpcr & CPM_CR_FLG) /* wait if cp is busy */
  195. ;
  196. cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC, CPM_CR_INIT_TRX) | CPM_CR_FLG;
  197. while (cp->cp_cpcr & CPM_CR_FLG) /* wait if cp is busy */
  198. ;
  199. /* Enable transmitter/receiver.
  200. */
  201. sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
  202. return (0);
  203. }
  204. void
  205. serial_setbrg (void)
  206. {
  207. volatile immap_t *im = (immap_t *)CFG_IMMR;
  208. volatile cpm8xx_t *cp = &(im->im_cpm);
  209. /* Set up the baud rate generator.
  210. * See 8xx_io/commproc.c for details.
  211. *
  212. * Wire BRG1 to SMCx
  213. */
  214. cp->cp_simode = 0x00000000;
  215. serial_setdivisor(cp);
  216. }
  217. #ifdef CONFIG_MODEM_SUPPORT
  218. void disable_putc(void)
  219. {
  220. DECLARE_GLOBAL_DATA_PTR;
  221. gd->be_quiet = 1;
  222. }
  223. void enable_putc(void)
  224. {
  225. DECLARE_GLOBAL_DATA_PTR;
  226. gd->be_quiet = 0;
  227. }
  228. #endif
  229. void
  230. serial_putc(const char c)
  231. {
  232. volatile cbd_t *tbdf;
  233. volatile char *buf;
  234. volatile smc_uart_t *up;
  235. volatile immap_t *im = (immap_t *)CFG_IMMR;
  236. volatile cpm8xx_t *cpmp = &(im->im_cpm);
  237. #ifdef CONFIG_MODEM_SUPPORT
  238. DECLARE_GLOBAL_DATA_PTR;
  239. if (gd->be_quiet)
  240. return;
  241. #endif
  242. if (c == '\n')
  243. serial_putc ('\r');
  244. up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC];
  245. tbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_tbase];
  246. /* Wait for last character to go.
  247. */
  248. buf = (char *)tbdf->cbd_bufaddr;
  249. *buf = c;
  250. tbdf->cbd_datlen = 1;
  251. tbdf->cbd_sc |= BD_SC_READY;
  252. __asm__("eieio");
  253. while (tbdf->cbd_sc & BD_SC_READY) {
  254. WATCHDOG_RESET ();
  255. __asm__("eieio");
  256. }
  257. }
  258. int
  259. serial_getc(void)
  260. {
  261. volatile cbd_t *rbdf;
  262. volatile unsigned char *buf;
  263. volatile smc_uart_t *up;
  264. volatile immap_t *im = (immap_t *)CFG_IMMR;
  265. volatile cpm8xx_t *cpmp = &(im->im_cpm);
  266. unsigned char c;
  267. up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC];
  268. rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
  269. /* Wait for character to show up.
  270. */
  271. buf = (unsigned char *)rbdf->cbd_bufaddr;
  272. while (rbdf->cbd_sc & BD_SC_EMPTY)
  273. WATCHDOG_RESET ();
  274. c = *buf;
  275. rbdf->cbd_sc |= BD_SC_EMPTY;
  276. return(c);
  277. }
  278. int
  279. serial_tstc()
  280. {
  281. volatile cbd_t *rbdf;
  282. volatile smc_uart_t *up;
  283. volatile immap_t *im = (immap_t *)CFG_IMMR;
  284. volatile cpm8xx_t *cpmp = &(im->im_cpm);
  285. up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC];
  286. rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
  287. return(!(rbdf->cbd_sc & BD_SC_EMPTY));
  288. }
  289. #else /* ! CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2 */
  290. int serial_init (void)
  291. {
  292. volatile immap_t *im = (immap_t *)CFG_IMMR;
  293. volatile scc_t *sp;
  294. volatile scc_uart_t *up;
  295. volatile cbd_t *tbdf, *rbdf;
  296. volatile cpm8xx_t *cp = &(im->im_cpm);
  297. uint dpaddr;
  298. #if (SCC_INDEX != 2) || !defined(CONFIG_MPC850)
  299. volatile iop8xx_t *ip = (iop8xx_t *)&(im->im_ioport);
  300. #endif
  301. /* initialize pointers to SCC */
  302. sp = (scc_t *) &(cp->cp_scc[SCC_INDEX]);
  303. up = (scc_uart_t *) &cp->cp_dparam[PROFF_SCC];
  304. #if defined(CONFIG_LWMON) && defined(CONFIG_8xx_CONS_SCC2)
  305. { /* Disable Ethernet, enable Serial */
  306. uchar c;
  307. c = pic_read (0x61);
  308. c &= ~0x40; /* enable COM3 */
  309. c |= 0x80; /* disable Ethernet */
  310. pic_write (0x61, c);
  311. /* enable RTS2 */
  312. cp->cp_pbpar |= 0x2000;
  313. cp->cp_pbdat |= 0x2000;
  314. cp->cp_pbdir |= 0x2000;
  315. }
  316. #endif /* CONFIG_LWMON */
  317. /* Disable transmitter/receiver.
  318. */
  319. sp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
  320. #if (SCC_INDEX == 2) && defined(CONFIG_MPC850)
  321. /*
  322. * The MPC850 has SCC3 on Port B
  323. */
  324. cp->cp_pbpar |= 0x06;
  325. cp->cp_pbdir &= ~0x06;
  326. cp->cp_pbodr &= ~0x06;
  327. #elif (SCC_INDEX < 2) || !defined(CONFIG_IP860)
  328. /*
  329. * Standard configuration for SCC's is on Part A
  330. */
  331. ip->iop_papar |= ((3 << (2 * SCC_INDEX)));
  332. ip->iop_padir &= ~((3 << (2 * SCC_INDEX)));
  333. ip->iop_paodr &= ~((3 << (2 * SCC_INDEX)));
  334. #else
  335. /*
  336. * The IP860 has SCC3 and SCC4 on Port D
  337. */
  338. ip->iop_pdpar |= ((3 << (2 * SCC_INDEX)));
  339. #endif
  340. /* Allocate space for two buffer descriptors in the DP ram.
  341. */
  342. #ifdef CFG_ALLOC_DPRAM
  343. dpaddr = dpram_alloc_align (sizeof(cbd_t)*2 + 2, 8) ;
  344. #else
  345. dpaddr = CPM_SERIAL_BASE ;
  346. #endif
  347. /* Enable SDMA.
  348. */
  349. im->im_siu_conf.sc_sdcr = 0x0001;
  350. /* Set the physical address of the host memory buffers in
  351. * the buffer descriptors.
  352. */
  353. rbdf = (cbd_t *)&cp->cp_dpmem[dpaddr];
  354. rbdf->cbd_bufaddr = (uint) (rbdf+2);
  355. rbdf->cbd_sc = 0;
  356. tbdf = rbdf + 1;
  357. tbdf->cbd_bufaddr = ((uint) (rbdf+2)) + 1;
  358. tbdf->cbd_sc = 0;
  359. /* Set up the baud rate generator.
  360. */
  361. serial_setbrg ();
  362. /* Set up the uart parameters in the parameter ram.
  363. */
  364. up->scc_genscc.scc_rbase = dpaddr;
  365. up->scc_genscc.scc_tbase = dpaddr+sizeof(cbd_t);
  366. /* Initialize Tx/Rx parameters.
  367. */
  368. while (cp->cp_cpcr & CPM_CR_FLG) /* wait if cp is busy */
  369. ;
  370. cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SCC, CPM_CR_INIT_TRX) | CPM_CR_FLG;
  371. while (cp->cp_cpcr & CPM_CR_FLG) /* wait if cp is busy */
  372. ;
  373. up->scc_genscc.scc_rfcr = SCC_EB | 0x05;
  374. up->scc_genscc.scc_tfcr = SCC_EB | 0x05;
  375. up->scc_genscc.scc_mrblr = 1; /* Single character receive */
  376. up->scc_maxidl = 0; /* disable max idle */
  377. up->scc_brkcr = 1; /* send one break character on stop TX */
  378. up->scc_parec = 0;
  379. up->scc_frmec = 0;
  380. up->scc_nosec = 0;
  381. up->scc_brkec = 0;
  382. up->scc_uaddr1 = 0;
  383. up->scc_uaddr2 = 0;
  384. up->scc_toseq = 0;
  385. up->scc_char1 = 0x8000;
  386. up->scc_char2 = 0x8000;
  387. up->scc_char3 = 0x8000;
  388. up->scc_char4 = 0x8000;
  389. up->scc_char5 = 0x8000;
  390. up->scc_char6 = 0x8000;
  391. up->scc_char7 = 0x8000;
  392. up->scc_char8 = 0x8000;
  393. up->scc_rccm = 0xc0ff;
  394. /* Set low latency / small fifo.
  395. */
  396. sp->scc_gsmrh = SCC_GSMRH_RFW;
  397. /* Set SCC(x) clock mode to 16x
  398. * See 8xx_io/commproc.c for details.
  399. *
  400. * Wire BRG1 to SCCn
  401. */
  402. /* Set UART mode, clock divider 16 on Tx and Rx
  403. */
  404. sp->scc_gsmrl |=
  405. (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
  406. sp->scc_psmr |= SCU_PSMR_CL;
  407. /* Mask all interrupts and remove anything pending.
  408. */
  409. sp->scc_sccm = 0;
  410. sp->scc_scce = 0xffff;
  411. sp->scc_dsr = 0x7e7e;
  412. sp->scc_psmr = 0x3000;
  413. /* Make the first buffer the only buffer.
  414. */
  415. tbdf->cbd_sc |= BD_SC_WRAP;
  416. rbdf->cbd_sc |= BD_SC_EMPTY | BD_SC_WRAP;
  417. /* Enable transmitter/receiver.
  418. */
  419. sp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
  420. return (0);
  421. }
  422. void
  423. serial_setbrg (void)
  424. {
  425. volatile immap_t *im = (immap_t *)CFG_IMMR;
  426. volatile cpm8xx_t *cp = &(im->im_cpm);
  427. /* Set up the baud rate generator.
  428. * See 8xx_io/commproc.c for details.
  429. *
  430. * Wire BRG1 to SCCx
  431. */
  432. cp->cp_sicr &= ~(0x000000FF << (8 * SCC_INDEX));
  433. serial_setdivisor(cp);
  434. }
  435. void
  436. serial_putc(const char c)
  437. {
  438. volatile cbd_t *tbdf;
  439. volatile char *buf;
  440. volatile scc_uart_t *up;
  441. volatile immap_t *im = (immap_t *)CFG_IMMR;
  442. volatile cpm8xx_t *cpmp = &(im->im_cpm);
  443. if (c == '\n')
  444. serial_putc ('\r');
  445. up = (scc_uart_t *)&cpmp->cp_dparam[PROFF_SCC];
  446. tbdf = (cbd_t *)&cpmp->cp_dpmem[up->scc_genscc.scc_tbase];
  447. /* Wait for last character to go.
  448. */
  449. buf = (char *)tbdf->cbd_bufaddr;
  450. *buf = c;
  451. tbdf->cbd_datlen = 1;
  452. tbdf->cbd_sc |= BD_SC_READY;
  453. __asm__("eieio");
  454. while (tbdf->cbd_sc & BD_SC_READY) {
  455. __asm__("eieio");
  456. WATCHDOG_RESET ();
  457. }
  458. }
  459. int
  460. serial_getc(void)
  461. {
  462. volatile cbd_t *rbdf;
  463. volatile unsigned char *buf;
  464. volatile scc_uart_t *up;
  465. volatile immap_t *im = (immap_t *)CFG_IMMR;
  466. volatile cpm8xx_t *cpmp = &(im->im_cpm);
  467. unsigned char c;
  468. up = (scc_uart_t *)&cpmp->cp_dparam[PROFF_SCC];
  469. rbdf = (cbd_t *)&cpmp->cp_dpmem[up->scc_genscc.scc_rbase];
  470. /* Wait for character to show up.
  471. */
  472. buf = (unsigned char *)rbdf->cbd_bufaddr;
  473. while (rbdf->cbd_sc & BD_SC_EMPTY)
  474. WATCHDOG_RESET ();
  475. c = *buf;
  476. rbdf->cbd_sc |= BD_SC_EMPTY;
  477. return(c);
  478. }
  479. int
  480. serial_tstc()
  481. {
  482. volatile cbd_t *rbdf;
  483. volatile scc_uart_t *up;
  484. volatile immap_t *im = (immap_t *)CFG_IMMR;
  485. volatile cpm8xx_t *cpmp = &(im->im_cpm);
  486. up = (scc_uart_t *)&cpmp->cp_dparam[PROFF_SCC];
  487. rbdf = (cbd_t *)&cpmp->cp_dpmem[up->scc_genscc.scc_rbase];
  488. return(!(rbdf->cbd_sc & BD_SC_EMPTY));
  489. }
  490. #endif /* CONFIG_8xx_CONS_SMC1, CONFIG_8xx_CONS_SMC2 */
  491. void
  492. serial_puts (const char *s)
  493. {
  494. while (*s) {
  495. serial_putc (*s++);
  496. }
  497. }
  498. #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
  499. void
  500. kgdb_serial_init(void)
  501. {
  502. #if defined(CONFIG_8xx_CONS_SMC1)
  503. serial_printf("[on SMC1] ");
  504. #elif defined(CONFIG_8xx_CONS_SMC2)
  505. serial_printf("[on SMC2] ");
  506. #elif defined(CONFIG_8xx_CONS_SCC1)
  507. serial_printf("[on SCC1] ");
  508. #elif defined(CONFIG_8xx_CONS_SCC2)
  509. serial_printf("[on SCC2] ");
  510. #elif defined(CONFIG_8xx_CONS_SCC3)
  511. serial_printf("[on SCC3] ");
  512. #elif defined(CONFIG_8xx_CONS_SCC4)
  513. serial_printf("[on SCC4] ");
  514. #endif
  515. }
  516. void
  517. putDebugChar (int c)
  518. {
  519. serial_putc (c);
  520. }
  521. void
  522. putDebugStr (const char *str)
  523. {
  524. serial_puts (str);
  525. }
  526. int
  527. getDebugChar (void)
  528. {
  529. return serial_getc();
  530. }
  531. void
  532. kgdb_interruptible (int yes)
  533. {
  534. return;
  535. }
  536. #endif /* CFG_CMD_KGDB */
  537. #endif /* CONFIG_8xx_CONS_NONE */