vme_scc.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. /*
  2. * drivers/char/vme_scc.c: MVME147, MVME162, BVME6000 SCC serial ports
  3. * implementation.
  4. * Copyright 1999 Richard Hirst <richard@sleepie.demon.co.uk>
  5. *
  6. * Based on atari_SCC.c which was
  7. * Copyright 1994-95 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
  8. * Partially based on PC-Linux serial.c by Linus Torvalds and Theodore Ts'o
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file COPYING in the main directory of this archive
  12. * for more details.
  13. *
  14. */
  15. #include <linux/module.h>
  16. #include <linux/kdev_t.h>
  17. #include <asm/io.h>
  18. #include <linux/kernel.h>
  19. #include <linux/ioport.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/errno.h>
  22. #include <linux/tty.h>
  23. #include <linux/tty_flip.h>
  24. #include <linux/mm.h>
  25. #include <linux/serial.h>
  26. #include <linux/fcntl.h>
  27. #include <linux/major.h>
  28. #include <linux/delay.h>
  29. #include <linux/slab.h>
  30. #include <linux/miscdevice.h>
  31. #include <linux/console.h>
  32. #include <linux/init.h>
  33. #include <asm/setup.h>
  34. #include <asm/bootinfo.h>
  35. #ifdef CONFIG_MVME147_SCC
  36. #include <asm/mvme147hw.h>
  37. #endif
  38. #ifdef CONFIG_MVME162_SCC
  39. #include <asm/mvme16xhw.h>
  40. #endif
  41. #ifdef CONFIG_BVME6000_SCC
  42. #include <asm/bvme6000hw.h>
  43. #endif
  44. #include <linux/generic_serial.h>
  45. #include "scc.h"
  46. #define CHANNEL_A 0
  47. #define CHANNEL_B 1
  48. #define SCC_MINOR_BASE 64
  49. /* Shadows for all SCC write registers */
  50. static unsigned char scc_shadow[2][16];
  51. /* Location to access for SCC register access delay */
  52. static volatile unsigned char *scc_del = NULL;
  53. /* To keep track of STATUS_REG state for detection of Ext/Status int source */
  54. static unsigned char scc_last_status_reg[2];
  55. /***************************** Prototypes *****************************/
  56. /* Function prototypes */
  57. static void scc_disable_tx_interrupts(void * ptr);
  58. static void scc_enable_tx_interrupts(void * ptr);
  59. static void scc_disable_rx_interrupts(void * ptr);
  60. static void scc_enable_rx_interrupts(void * ptr);
  61. static int scc_carrier_raised(struct tty_port *port);
  62. static void scc_shutdown_port(void * ptr);
  63. static int scc_set_real_termios(void *ptr);
  64. static void scc_hungup(void *ptr);
  65. static void scc_close(void *ptr);
  66. static int scc_chars_in_buffer(void * ptr);
  67. static int scc_open(struct tty_struct * tty, struct file * filp);
  68. static int scc_ioctl(struct tty_struct * tty, struct file * filp,
  69. unsigned int cmd, unsigned long arg);
  70. static void scc_throttle(struct tty_struct *tty);
  71. static void scc_unthrottle(struct tty_struct *tty);
  72. static irqreturn_t scc_tx_int(int irq, void *data);
  73. static irqreturn_t scc_rx_int(int irq, void *data);
  74. static irqreturn_t scc_stat_int(int irq, void *data);
  75. static irqreturn_t scc_spcond_int(int irq, void *data);
  76. static void scc_setsignals(struct scc_port *port, int dtr, int rts);
  77. static int scc_break_ctl(struct tty_struct *tty, int break_state);
  78. static struct tty_driver *scc_driver;
  79. static struct scc_port scc_ports[2];
  80. /*---------------------------------------------------------------------------
  81. * Interface from generic_serial.c back here
  82. *--------------------------------------------------------------------------*/
  83. static struct real_driver scc_real_driver = {
  84. scc_disable_tx_interrupts,
  85. scc_enable_tx_interrupts,
  86. scc_disable_rx_interrupts,
  87. scc_enable_rx_interrupts,
  88. scc_shutdown_port,
  89. scc_set_real_termios,
  90. scc_chars_in_buffer,
  91. scc_close,
  92. scc_hungup,
  93. NULL
  94. };
  95. static const struct tty_operations scc_ops = {
  96. .open = scc_open,
  97. .close = gs_close,
  98. .write = gs_write,
  99. .put_char = gs_put_char,
  100. .flush_chars = gs_flush_chars,
  101. .write_room = gs_write_room,
  102. .chars_in_buffer = gs_chars_in_buffer,
  103. .flush_buffer = gs_flush_buffer,
  104. .ioctl = scc_ioctl,
  105. .throttle = scc_throttle,
  106. .unthrottle = scc_unthrottle,
  107. .set_termios = gs_set_termios,
  108. .stop = gs_stop,
  109. .start = gs_start,
  110. .hangup = gs_hangup,
  111. .break_ctl = scc_break_ctl,
  112. };
  113. static const struct tty_port_operations scc_port_ops = {
  114. .carrier_raised = scc_carrier_raised,
  115. };
  116. /*----------------------------------------------------------------------------
  117. * vme_scc_init() and support functions
  118. *---------------------------------------------------------------------------*/
  119. static int scc_init_drivers(void)
  120. {
  121. int error;
  122. scc_driver = alloc_tty_driver(2);
  123. if (!scc_driver)
  124. return -ENOMEM;
  125. scc_driver->owner = THIS_MODULE;
  126. scc_driver->driver_name = "scc";
  127. scc_driver->name = "ttyS";
  128. scc_driver->major = TTY_MAJOR;
  129. scc_driver->minor_start = SCC_MINOR_BASE;
  130. scc_driver->type = TTY_DRIVER_TYPE_SERIAL;
  131. scc_driver->subtype = SERIAL_TYPE_NORMAL;
  132. scc_driver->init_termios = tty_std_termios;
  133. scc_driver->init_termios.c_cflag =
  134. B9600 | CS8 | CREAD | HUPCL | CLOCAL;
  135. scc_driver->init_termios.c_ispeed = 9600;
  136. scc_driver->init_termios.c_ospeed = 9600;
  137. scc_driver->flags = TTY_DRIVER_REAL_RAW;
  138. tty_set_operations(scc_driver, &scc_ops);
  139. if ((error = tty_register_driver(scc_driver))) {
  140. printk(KERN_ERR "scc: Couldn't register scc driver, error = %d\n",
  141. error);
  142. put_tty_driver(scc_driver);
  143. return 1;
  144. }
  145. return 0;
  146. }
  147. /* ports[] array is indexed by line no (i.e. [0] for ttyS0, [1] for ttyS1).
  148. */
  149. static void scc_init_portstructs(void)
  150. {
  151. struct scc_port *port;
  152. int i;
  153. for (i = 0; i < 2; i++) {
  154. port = scc_ports + i;
  155. tty_port_init(&port->gs.port);
  156. port->gs.port.ops = &scc_port_ops;
  157. port->gs.magic = SCC_MAGIC;
  158. port->gs.close_delay = HZ/2;
  159. port->gs.closing_wait = 30 * HZ;
  160. port->gs.rd = &scc_real_driver;
  161. #ifdef NEW_WRITE_LOCKING
  162. port->gs.port_write_mutex = MUTEX;
  163. #endif
  164. init_waitqueue_head(&port->gs.port.open_wait);
  165. init_waitqueue_head(&port->gs.port.close_wait);
  166. }
  167. }
  168. #ifdef CONFIG_MVME147_SCC
  169. static int mvme147_scc_init(void)
  170. {
  171. struct scc_port *port;
  172. int error;
  173. printk(KERN_INFO "SCC: MVME147 Serial Driver\n");
  174. /* Init channel A */
  175. port = &scc_ports[0];
  176. port->channel = CHANNEL_A;
  177. port->ctrlp = (volatile unsigned char *)M147_SCC_A_ADDR;
  178. port->datap = port->ctrlp + 1;
  179. port->port_a = &scc_ports[0];
  180. port->port_b = &scc_ports[1];
  181. error = request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
  182. "SCC-A TX", port);
  183. if (error)
  184. goto fail;
  185. error = request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
  186. "SCC-A status", port);
  187. if (error)
  188. goto fail_free_a_tx;
  189. error = request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
  190. "SCC-A RX", port);
  191. if (error)
  192. goto fail_free_a_stat;
  193. error = request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int,
  194. IRQF_DISABLED, "SCC-A special cond", port);
  195. if (error)
  196. goto fail_free_a_rx;
  197. {
  198. SCC_ACCESS_INIT(port);
  199. /* disable interrupts for this channel */
  200. SCCwrite(INT_AND_DMA_REG, 0);
  201. /* Set the interrupt vector */
  202. SCCwrite(INT_VECTOR_REG, MVME147_IRQ_SCC_BASE);
  203. /* Interrupt parameters: vector includes status, status low */
  204. SCCwrite(MASTER_INT_CTRL, MIC_VEC_INCL_STAT);
  205. SCCmod(MASTER_INT_CTRL, 0xff, MIC_MASTER_INT_ENAB);
  206. }
  207. /* Init channel B */
  208. port = &scc_ports[1];
  209. port->channel = CHANNEL_B;
  210. port->ctrlp = (volatile unsigned char *)M147_SCC_B_ADDR;
  211. port->datap = port->ctrlp + 1;
  212. port->port_a = &scc_ports[0];
  213. port->port_b = &scc_ports[1];
  214. error = request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
  215. "SCC-B TX", port);
  216. if (error)
  217. goto fail_free_a_spcond;
  218. error = request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
  219. "SCC-B status", port);
  220. if (error)
  221. goto fail_free_b_tx;
  222. error = request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
  223. "SCC-B RX", port);
  224. if (error)
  225. goto fail_free_b_stat;
  226. error = request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int,
  227. IRQF_DISABLED, "SCC-B special cond", port);
  228. if (error)
  229. goto fail_free_b_rx;
  230. {
  231. SCC_ACCESS_INIT(port);
  232. /* disable interrupts for this channel */
  233. SCCwrite(INT_AND_DMA_REG, 0);
  234. }
  235. /* Ensure interrupts are enabled in the PCC chip */
  236. m147_pcc->serial_cntrl=PCC_LEVEL_SERIAL|PCC_INT_ENAB;
  237. /* Initialise the tty driver structures and register */
  238. scc_init_portstructs();
  239. scc_init_drivers();
  240. return 0;
  241. fail_free_b_rx:
  242. free_irq(MVME147_IRQ_SCCB_RX, port);
  243. fail_free_b_stat:
  244. free_irq(MVME147_IRQ_SCCB_STAT, port);
  245. fail_free_b_tx:
  246. free_irq(MVME147_IRQ_SCCB_TX, port);
  247. fail_free_a_spcond:
  248. free_irq(MVME147_IRQ_SCCA_SPCOND, port);
  249. fail_free_a_rx:
  250. free_irq(MVME147_IRQ_SCCA_RX, port);
  251. fail_free_a_stat:
  252. free_irq(MVME147_IRQ_SCCA_STAT, port);
  253. fail_free_a_tx:
  254. free_irq(MVME147_IRQ_SCCA_TX, port);
  255. fail:
  256. return error;
  257. }
  258. #endif
  259. #ifdef CONFIG_MVME162_SCC
  260. static int mvme162_scc_init(void)
  261. {
  262. struct scc_port *port;
  263. int error;
  264. if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA))
  265. return (-ENODEV);
  266. printk(KERN_INFO "SCC: MVME162 Serial Driver\n");
  267. /* Init channel A */
  268. port = &scc_ports[0];
  269. port->channel = CHANNEL_A;
  270. port->ctrlp = (volatile unsigned char *)MVME_SCC_A_ADDR;
  271. port->datap = port->ctrlp + 2;
  272. port->port_a = &scc_ports[0];
  273. port->port_b = &scc_ports[1];
  274. error = request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
  275. "SCC-A TX", port);
  276. if (error)
  277. goto fail;
  278. error = request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
  279. "SCC-A status", port);
  280. if (error)
  281. goto fail_free_a_tx;
  282. error = request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
  283. "SCC-A RX", port);
  284. if (error)
  285. goto fail_free_a_stat;
  286. error = request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int,
  287. IRQF_DISABLED, "SCC-A special cond", port);
  288. if (error)
  289. goto fail_free_a_rx;
  290. {
  291. SCC_ACCESS_INIT(port);
  292. /* disable interrupts for this channel */
  293. SCCwrite(INT_AND_DMA_REG, 0);
  294. /* Set the interrupt vector */
  295. SCCwrite(INT_VECTOR_REG, MVME162_IRQ_SCC_BASE);
  296. /* Interrupt parameters: vector includes status, status low */
  297. SCCwrite(MASTER_INT_CTRL, MIC_VEC_INCL_STAT);
  298. SCCmod(MASTER_INT_CTRL, 0xff, MIC_MASTER_INT_ENAB);
  299. }
  300. /* Init channel B */
  301. port = &scc_ports[1];
  302. port->channel = CHANNEL_B;
  303. port->ctrlp = (volatile unsigned char *)MVME_SCC_B_ADDR;
  304. port->datap = port->ctrlp + 2;
  305. port->port_a = &scc_ports[0];
  306. port->port_b = &scc_ports[1];
  307. error = request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
  308. "SCC-B TX", port);
  309. if (error)
  310. goto fail_free_a_spcond;
  311. error = request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
  312. "SCC-B status", port);
  313. if (error)
  314. goto fail_free_b_tx;
  315. error = request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
  316. "SCC-B RX", port);
  317. if (error)
  318. goto fail_free_b_stat;
  319. error = request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int,
  320. IRQF_DISABLED, "SCC-B special cond", port);
  321. if (error)
  322. goto fail_free_b_rx;
  323. {
  324. SCC_ACCESS_INIT(port); /* Either channel will do */
  325. /* disable interrupts for this channel */
  326. SCCwrite(INT_AND_DMA_REG, 0);
  327. }
  328. /* Ensure interrupts are enabled in the MC2 chip */
  329. *(volatile char *)0xfff4201d = 0x14;
  330. /* Initialise the tty driver structures and register */
  331. scc_init_portstructs();
  332. scc_init_drivers();
  333. return 0;
  334. fail_free_b_rx:
  335. free_irq(MVME162_IRQ_SCCB_RX, port);
  336. fail_free_b_stat:
  337. free_irq(MVME162_IRQ_SCCB_STAT, port);
  338. fail_free_b_tx:
  339. free_irq(MVME162_IRQ_SCCB_TX, port);
  340. fail_free_a_spcond:
  341. free_irq(MVME162_IRQ_SCCA_SPCOND, port);
  342. fail_free_a_rx:
  343. free_irq(MVME162_IRQ_SCCA_RX, port);
  344. fail_free_a_stat:
  345. free_irq(MVME162_IRQ_SCCA_STAT, port);
  346. fail_free_a_tx:
  347. free_irq(MVME162_IRQ_SCCA_TX, port);
  348. fail:
  349. return error;
  350. }
  351. #endif
  352. #ifdef CONFIG_BVME6000_SCC
  353. static int bvme6000_scc_init(void)
  354. {
  355. struct scc_port *port;
  356. int error;
  357. printk(KERN_INFO "SCC: BVME6000 Serial Driver\n");
  358. /* Init channel A */
  359. port = &scc_ports[0];
  360. port->channel = CHANNEL_A;
  361. port->ctrlp = (volatile unsigned char *)BVME_SCC_A_ADDR;
  362. port->datap = port->ctrlp + 4;
  363. port->port_a = &scc_ports[0];
  364. port->port_b = &scc_ports[1];
  365. error = request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
  366. "SCC-A TX", port);
  367. if (error)
  368. goto fail;
  369. error = request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
  370. "SCC-A status", port);
  371. if (error)
  372. goto fail_free_a_tx;
  373. error = request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
  374. "SCC-A RX", port);
  375. if (error)
  376. goto fail_free_a_stat;
  377. error = request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int,
  378. IRQF_DISABLED, "SCC-A special cond", port);
  379. if (error)
  380. goto fail_free_a_rx;
  381. {
  382. SCC_ACCESS_INIT(port);
  383. /* disable interrupts for this channel */
  384. SCCwrite(INT_AND_DMA_REG, 0);
  385. /* Set the interrupt vector */
  386. SCCwrite(INT_VECTOR_REG, BVME_IRQ_SCC_BASE);
  387. /* Interrupt parameters: vector includes status, status low */
  388. SCCwrite(MASTER_INT_CTRL, MIC_VEC_INCL_STAT);
  389. SCCmod(MASTER_INT_CTRL, 0xff, MIC_MASTER_INT_ENAB);
  390. }
  391. /* Init channel B */
  392. port = &scc_ports[1];
  393. port->channel = CHANNEL_B;
  394. port->ctrlp = (volatile unsigned char *)BVME_SCC_B_ADDR;
  395. port->datap = port->ctrlp + 4;
  396. port->port_a = &scc_ports[0];
  397. port->port_b = &scc_ports[1];
  398. error = request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
  399. "SCC-B TX", port);
  400. if (error)
  401. goto fail_free_a_spcond;
  402. error = request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
  403. "SCC-B status", port);
  404. if (error)
  405. goto fail_free_b_tx;
  406. error = request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
  407. "SCC-B RX", port);
  408. if (error)
  409. goto fail_free_b_stat;
  410. error = request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int,
  411. IRQF_DISABLED, "SCC-B special cond", port);
  412. if (error)
  413. goto fail_free_b_rx;
  414. {
  415. SCC_ACCESS_INIT(port); /* Either channel will do */
  416. /* disable interrupts for this channel */
  417. SCCwrite(INT_AND_DMA_REG, 0);
  418. }
  419. /* Initialise the tty driver structures and register */
  420. scc_init_portstructs();
  421. scc_init_drivers();
  422. return 0;
  423. fail:
  424. free_irq(BVME_IRQ_SCCA_STAT, port);
  425. fail_free_a_tx:
  426. free_irq(BVME_IRQ_SCCA_RX, port);
  427. fail_free_a_stat:
  428. free_irq(BVME_IRQ_SCCA_SPCOND, port);
  429. fail_free_a_rx:
  430. free_irq(BVME_IRQ_SCCB_TX, port);
  431. fail_free_a_spcond:
  432. free_irq(BVME_IRQ_SCCB_STAT, port);
  433. fail_free_b_tx:
  434. free_irq(BVME_IRQ_SCCB_RX, port);
  435. fail_free_b_stat:
  436. free_irq(BVME_IRQ_SCCB_SPCOND, port);
  437. fail_free_b_rx:
  438. return error;
  439. }
  440. #endif
  441. static int vme_scc_init(void)
  442. {
  443. int res = -ENODEV;
  444. #ifdef CONFIG_MVME147_SCC
  445. if (MACH_IS_MVME147)
  446. res = mvme147_scc_init();
  447. #endif
  448. #ifdef CONFIG_MVME162_SCC
  449. if (MACH_IS_MVME16x)
  450. res = mvme162_scc_init();
  451. #endif
  452. #ifdef CONFIG_BVME6000_SCC
  453. if (MACH_IS_BVME6000)
  454. res = bvme6000_scc_init();
  455. #endif
  456. return res;
  457. }
  458. module_init(vme_scc_init);
  459. /*---------------------------------------------------------------------------
  460. * Interrupt handlers
  461. *--------------------------------------------------------------------------*/
  462. static irqreturn_t scc_rx_int(int irq, void *data)
  463. {
  464. unsigned char ch;
  465. struct scc_port *port = data;
  466. struct tty_struct *tty = port->gs.port.tty;
  467. SCC_ACCESS_INIT(port);
  468. ch = SCCread_NB(RX_DATA_REG);
  469. if (!tty) {
  470. printk(KERN_WARNING "scc_rx_int with NULL tty!\n");
  471. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  472. return IRQ_HANDLED;
  473. }
  474. tty_insert_flip_char(tty, ch, 0);
  475. /* Check if another character is already ready; in that case, the
  476. * spcond_int() function must be used, because this character may have an
  477. * error condition that isn't signalled by the interrupt vector used!
  478. */
  479. if (SCCread(INT_PENDING_REG) &
  480. (port->channel == CHANNEL_A ? IPR_A_RX : IPR_B_RX)) {
  481. scc_spcond_int (irq, data);
  482. return IRQ_HANDLED;
  483. }
  484. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  485. tty_flip_buffer_push(tty);
  486. return IRQ_HANDLED;
  487. }
  488. static irqreturn_t scc_spcond_int(int irq, void *data)
  489. {
  490. struct scc_port *port = data;
  491. struct tty_struct *tty = port->gs.port.tty;
  492. unsigned char stat, ch, err;
  493. int int_pending_mask = port->channel == CHANNEL_A ?
  494. IPR_A_RX : IPR_B_RX;
  495. SCC_ACCESS_INIT(port);
  496. if (!tty) {
  497. printk(KERN_WARNING "scc_spcond_int with NULL tty!\n");
  498. SCCwrite(COMMAND_REG, CR_ERROR_RESET);
  499. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  500. return IRQ_HANDLED;
  501. }
  502. do {
  503. stat = SCCread(SPCOND_STATUS_REG);
  504. ch = SCCread_NB(RX_DATA_REG);
  505. if (stat & SCSR_RX_OVERRUN)
  506. err = TTY_OVERRUN;
  507. else if (stat & SCSR_PARITY_ERR)
  508. err = TTY_PARITY;
  509. else if (stat & SCSR_CRC_FRAME_ERR)
  510. err = TTY_FRAME;
  511. else
  512. err = 0;
  513. tty_insert_flip_char(tty, ch, err);
  514. /* ++TeSche: *All* errors have to be cleared manually,
  515. * else the condition persists for the next chars
  516. */
  517. if (err)
  518. SCCwrite(COMMAND_REG, CR_ERROR_RESET);
  519. } while(SCCread(INT_PENDING_REG) & int_pending_mask);
  520. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  521. tty_flip_buffer_push(tty);
  522. return IRQ_HANDLED;
  523. }
  524. static irqreturn_t scc_tx_int(int irq, void *data)
  525. {
  526. struct scc_port *port = data;
  527. SCC_ACCESS_INIT(port);
  528. if (!port->gs.port.tty) {
  529. printk(KERN_WARNING "scc_tx_int with NULL tty!\n");
  530. SCCmod (INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0);
  531. SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET);
  532. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  533. return IRQ_HANDLED;
  534. }
  535. while ((SCCread_NB(STATUS_REG) & SR_TX_BUF_EMPTY)) {
  536. if (port->x_char) {
  537. SCCwrite(TX_DATA_REG, port->x_char);
  538. port->x_char = 0;
  539. }
  540. else if ((port->gs.xmit_cnt <= 0) ||
  541. port->gs.port.tty->stopped ||
  542. port->gs.port.tty->hw_stopped)
  543. break;
  544. else {
  545. SCCwrite(TX_DATA_REG, port->gs.xmit_buf[port->gs.xmit_tail++]);
  546. port->gs.xmit_tail = port->gs.xmit_tail & (SERIAL_XMIT_SIZE-1);
  547. if (--port->gs.xmit_cnt <= 0)
  548. break;
  549. }
  550. }
  551. if ((port->gs.xmit_cnt <= 0) || port->gs.port.tty->stopped ||
  552. port->gs.port.tty->hw_stopped) {
  553. /* disable tx interrupts */
  554. SCCmod (INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0);
  555. SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET); /* disable tx_int on next tx underrun? */
  556. port->gs.port.flags &= ~GS_TX_INTEN;
  557. }
  558. if (port->gs.port.tty && port->gs.xmit_cnt <= port->gs.wakeup_chars)
  559. tty_wakeup(port->gs.port.tty);
  560. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  561. return IRQ_HANDLED;
  562. }
  563. static irqreturn_t scc_stat_int(int irq, void *data)
  564. {
  565. struct scc_port *port = data;
  566. unsigned channel = port->channel;
  567. unsigned char last_sr, sr, changed;
  568. SCC_ACCESS_INIT(port);
  569. last_sr = scc_last_status_reg[channel];
  570. sr = scc_last_status_reg[channel] = SCCread_NB(STATUS_REG);
  571. changed = last_sr ^ sr;
  572. if (changed & SR_DCD) {
  573. port->c_dcd = !!(sr & SR_DCD);
  574. if (!(port->gs.port.flags & ASYNC_CHECK_CD))
  575. ; /* Don't report DCD changes */
  576. else if (port->c_dcd) {
  577. wake_up_interruptible(&port->gs.port.open_wait);
  578. }
  579. else {
  580. if (port->gs.port.tty)
  581. tty_hangup (port->gs.port.tty);
  582. }
  583. }
  584. SCCwrite(COMMAND_REG, CR_EXTSTAT_RESET);
  585. SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
  586. return IRQ_HANDLED;
  587. }
  588. /*---------------------------------------------------------------------------
  589. * generic_serial.c callback funtions
  590. *--------------------------------------------------------------------------*/
  591. static void scc_disable_tx_interrupts(void *ptr)
  592. {
  593. struct scc_port *port = ptr;
  594. unsigned long flags;
  595. SCC_ACCESS_INIT(port);
  596. local_irq_save(flags);
  597. SCCmod(INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0);
  598. port->gs.port.flags &= ~GS_TX_INTEN;
  599. local_irq_restore(flags);
  600. }
  601. static void scc_enable_tx_interrupts(void *ptr)
  602. {
  603. struct scc_port *port = ptr;
  604. unsigned long flags;
  605. SCC_ACCESS_INIT(port);
  606. local_irq_save(flags);
  607. SCCmod(INT_AND_DMA_REG, 0xff, IDR_TX_INT_ENAB);
  608. /* restart the transmitter */
  609. scc_tx_int (0, port);
  610. local_irq_restore(flags);
  611. }
  612. static void scc_disable_rx_interrupts(void *ptr)
  613. {
  614. struct scc_port *port = ptr;
  615. unsigned long flags;
  616. SCC_ACCESS_INIT(port);
  617. local_irq_save(flags);
  618. SCCmod(INT_AND_DMA_REG,
  619. ~(IDR_RX_INT_MASK|IDR_PARERR_AS_SPCOND|IDR_EXTSTAT_INT_ENAB), 0);
  620. local_irq_restore(flags);
  621. }
  622. static void scc_enable_rx_interrupts(void *ptr)
  623. {
  624. struct scc_port *port = ptr;
  625. unsigned long flags;
  626. SCC_ACCESS_INIT(port);
  627. local_irq_save(flags);
  628. SCCmod(INT_AND_DMA_REG, 0xff,
  629. IDR_EXTSTAT_INT_ENAB|IDR_PARERR_AS_SPCOND|IDR_RX_INT_ALL);
  630. local_irq_restore(flags);
  631. }
  632. static int scc_carrier_raised(struct tty_port *port)
  633. {
  634. struct scc_port *sc = container_of(port, struct scc_port, gs.port);
  635. unsigned channel = sc->channel;
  636. return !!(scc_last_status_reg[channel] & SR_DCD);
  637. }
  638. static void scc_shutdown_port(void *ptr)
  639. {
  640. struct scc_port *port = ptr;
  641. port->gs.port.flags &= ~ GS_ACTIVE;
  642. if (port->gs.port.tty && (port->gs.port.tty->termios->c_cflag & HUPCL)) {
  643. scc_setsignals (port, 0, 0);
  644. }
  645. }
  646. static int scc_set_real_termios (void *ptr)
  647. {
  648. /* the SCC has char sizes 5,7,6,8 in that order! */
  649. static int chsize_map[4] = { 0, 2, 1, 3 };
  650. unsigned cflag, baud, chsize, channel, brgval = 0;
  651. unsigned long flags;
  652. struct scc_port *port = ptr;
  653. SCC_ACCESS_INIT(port);
  654. if (!port->gs.port.tty || !port->gs.port.tty->termios) return 0;
  655. channel = port->channel;
  656. if (channel == CHANNEL_A)
  657. return 0; /* Settings controlled by boot PROM */
  658. cflag = port->gs.port.tty->termios->c_cflag;
  659. baud = port->gs.baud;
  660. chsize = (cflag & CSIZE) >> 4;
  661. if (baud == 0) {
  662. /* speed == 0 -> drop DTR */
  663. local_irq_save(flags);
  664. SCCmod(TX_CTRL_REG, ~TCR_DTR, 0);
  665. local_irq_restore(flags);
  666. return 0;
  667. }
  668. else if ((MACH_IS_MVME16x && (baud < 50 || baud > 38400)) ||
  669. (MACH_IS_MVME147 && (baud < 50 || baud > 19200)) ||
  670. (MACH_IS_BVME6000 &&(baud < 50 || baud > 76800))) {
  671. printk(KERN_NOTICE "SCC: Bad speed requested, %d\n", baud);
  672. return 0;
  673. }
  674. if (cflag & CLOCAL)
  675. port->gs.port.flags &= ~ASYNC_CHECK_CD;
  676. else
  677. port->gs.port.flags |= ASYNC_CHECK_CD;
  678. #ifdef CONFIG_MVME147_SCC
  679. if (MACH_IS_MVME147)
  680. brgval = (M147_SCC_PCLK + baud/2) / (16 * 2 * baud) - 2;
  681. #endif
  682. #ifdef CONFIG_MVME162_SCC
  683. if (MACH_IS_MVME16x)
  684. brgval = (MVME_SCC_PCLK + baud/2) / (16 * 2 * baud) - 2;
  685. #endif
  686. #ifdef CONFIG_BVME6000_SCC
  687. if (MACH_IS_BVME6000)
  688. brgval = (BVME_SCC_RTxC + baud/2) / (16 * 2 * baud) - 2;
  689. #endif
  690. /* Now we have all parameters and can go to set them: */
  691. local_irq_save(flags);
  692. /* receiver's character size and auto-enables */
  693. SCCmod(RX_CTRL_REG, ~(RCR_CHSIZE_MASK|RCR_AUTO_ENAB_MODE),
  694. (chsize_map[chsize] << 6) |
  695. ((cflag & CRTSCTS) ? RCR_AUTO_ENAB_MODE : 0));
  696. /* parity and stop bits (both, Tx and Rx), clock mode never changes */
  697. SCCmod (AUX1_CTRL_REG,
  698. ~(A1CR_PARITY_MASK | A1CR_MODE_MASK),
  699. ((cflag & PARENB
  700. ? (cflag & PARODD ? A1CR_PARITY_ODD : A1CR_PARITY_EVEN)
  701. : A1CR_PARITY_NONE)
  702. | (cflag & CSTOPB ? A1CR_MODE_ASYNC_2 : A1CR_MODE_ASYNC_1)));
  703. /* sender's character size, set DTR for valid baud rate */
  704. SCCmod(TX_CTRL_REG, ~TCR_CHSIZE_MASK, chsize_map[chsize] << 5 | TCR_DTR);
  705. /* clock sources never change */
  706. /* disable BRG before changing the value */
  707. SCCmod(DPLL_CTRL_REG, ~DCR_BRG_ENAB, 0);
  708. /* BRG value */
  709. SCCwrite(TIMER_LOW_REG, brgval & 0xff);
  710. SCCwrite(TIMER_HIGH_REG, (brgval >> 8) & 0xff);
  711. /* BRG enable, and clock source never changes */
  712. SCCmod(DPLL_CTRL_REG, 0xff, DCR_BRG_ENAB);
  713. local_irq_restore(flags);
  714. return 0;
  715. }
  716. static int scc_chars_in_buffer (void *ptr)
  717. {
  718. struct scc_port *port = ptr;
  719. SCC_ACCESS_INIT(port);
  720. return (SCCread (SPCOND_STATUS_REG) & SCSR_ALL_SENT) ? 0 : 1;
  721. }
  722. /* Comment taken from sx.c (2.4.0):
  723. I haven't the foggiest why the decrement use count has to happen
  724. here. The whole linux serial drivers stuff needs to be redesigned.
  725. My guess is that this is a hack to minimize the impact of a bug
  726. elsewhere. Thinking about it some more. (try it sometime) Try
  727. running minicom on a serial port that is driven by a modularized
  728. driver. Have the modem hangup. Then remove the driver module. Then
  729. exit minicom. I expect an "oops". -- REW */
  730. static void scc_hungup(void *ptr)
  731. {
  732. scc_disable_tx_interrupts(ptr);
  733. scc_disable_rx_interrupts(ptr);
  734. }
  735. static void scc_close(void *ptr)
  736. {
  737. scc_disable_tx_interrupts(ptr);
  738. scc_disable_rx_interrupts(ptr);
  739. }
  740. /*---------------------------------------------------------------------------
  741. * Internal support functions
  742. *--------------------------------------------------------------------------*/
  743. static void scc_setsignals(struct scc_port *port, int dtr, int rts)
  744. {
  745. unsigned long flags;
  746. unsigned char t;
  747. SCC_ACCESS_INIT(port);
  748. local_irq_save(flags);
  749. t = SCCread(TX_CTRL_REG);
  750. if (dtr >= 0) t = dtr? (t | TCR_DTR): (t & ~TCR_DTR);
  751. if (rts >= 0) t = rts? (t | TCR_RTS): (t & ~TCR_RTS);
  752. SCCwrite(TX_CTRL_REG, t);
  753. local_irq_restore(flags);
  754. }
  755. static void scc_send_xchar(struct tty_struct *tty, char ch)
  756. {
  757. struct scc_port *port = tty->driver_data;
  758. port->x_char = ch;
  759. if (ch)
  760. scc_enable_tx_interrupts(port);
  761. }
  762. /*---------------------------------------------------------------------------
  763. * Driver entrypoints referenced from above
  764. *--------------------------------------------------------------------------*/
  765. static int scc_open (struct tty_struct * tty, struct file * filp)
  766. {
  767. int line = tty->index;
  768. int retval;
  769. struct scc_port *port = &scc_ports[line];
  770. int i, channel = port->channel;
  771. unsigned long flags;
  772. SCC_ACCESS_INIT(port);
  773. #if defined(CONFIG_MVME162_SCC) || defined(CONFIG_MVME147_SCC)
  774. static const struct {
  775. unsigned reg, val;
  776. } mvme_init_tab[] = {
  777. /* Values for MVME162 and MVME147 */
  778. /* no parity, 1 stop bit, async, 1:16 */
  779. { AUX1_CTRL_REG, A1CR_PARITY_NONE|A1CR_MODE_ASYNC_1|A1CR_CLKMODE_x16 },
  780. /* parity error is special cond, ints disabled, no DMA */
  781. { INT_AND_DMA_REG, IDR_PARERR_AS_SPCOND | IDR_RX_INT_DISAB },
  782. /* Rx 8 bits/char, no auto enable, Rx off */
  783. { RX_CTRL_REG, RCR_CHSIZE_8 },
  784. /* DTR off, Tx 8 bits/char, RTS off, Tx off */
  785. { TX_CTRL_REG, TCR_CHSIZE_8 },
  786. /* special features off */
  787. { AUX2_CTRL_REG, 0 },
  788. { CLK_CTRL_REG, CCR_RXCLK_BRG | CCR_TXCLK_BRG },
  789. { DPLL_CTRL_REG, DCR_BRG_ENAB | DCR_BRG_USE_PCLK },
  790. /* Start Rx */
  791. { RX_CTRL_REG, RCR_RX_ENAB | RCR_CHSIZE_8 },
  792. /* Start Tx */
  793. { TX_CTRL_REG, TCR_TX_ENAB | TCR_RTS | TCR_DTR | TCR_CHSIZE_8 },
  794. /* Ext/Stat ints: DCD only */
  795. { INT_CTRL_REG, ICR_ENAB_DCD_INT },
  796. /* Reset Ext/Stat ints */
  797. { COMMAND_REG, CR_EXTSTAT_RESET },
  798. /* ...again */
  799. { COMMAND_REG, CR_EXTSTAT_RESET },
  800. };
  801. #endif
  802. #if defined(CONFIG_BVME6000_SCC)
  803. static const struct {
  804. unsigned reg, val;
  805. } bvme_init_tab[] = {
  806. /* Values for BVME6000 */
  807. /* no parity, 1 stop bit, async, 1:16 */
  808. { AUX1_CTRL_REG, A1CR_PARITY_NONE|A1CR_MODE_ASYNC_1|A1CR_CLKMODE_x16 },
  809. /* parity error is special cond, ints disabled, no DMA */
  810. { INT_AND_DMA_REG, IDR_PARERR_AS_SPCOND | IDR_RX_INT_DISAB },
  811. /* Rx 8 bits/char, no auto enable, Rx off */
  812. { RX_CTRL_REG, RCR_CHSIZE_8 },
  813. /* DTR off, Tx 8 bits/char, RTS off, Tx off */
  814. { TX_CTRL_REG, TCR_CHSIZE_8 },
  815. /* special features off */
  816. { AUX2_CTRL_REG, 0 },
  817. { CLK_CTRL_REG, CCR_RTxC_XTAL | CCR_RXCLK_BRG | CCR_TXCLK_BRG },
  818. { DPLL_CTRL_REG, DCR_BRG_ENAB },
  819. /* Start Rx */
  820. { RX_CTRL_REG, RCR_RX_ENAB | RCR_CHSIZE_8 },
  821. /* Start Tx */
  822. { TX_CTRL_REG, TCR_TX_ENAB | TCR_RTS | TCR_DTR | TCR_CHSIZE_8 },
  823. /* Ext/Stat ints: DCD only */
  824. { INT_CTRL_REG, ICR_ENAB_DCD_INT },
  825. /* Reset Ext/Stat ints */
  826. { COMMAND_REG, CR_EXTSTAT_RESET },
  827. /* ...again */
  828. { COMMAND_REG, CR_EXTSTAT_RESET },
  829. };
  830. #endif
  831. if (!(port->gs.port.flags & ASYNC_INITIALIZED)) {
  832. local_irq_save(flags);
  833. #if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC)
  834. if (MACH_IS_MVME147 || MACH_IS_MVME16x) {
  835. for (i = 0; i < ARRAY_SIZE(mvme_init_tab); ++i)
  836. SCCwrite(mvme_init_tab[i].reg, mvme_init_tab[i].val);
  837. }
  838. #endif
  839. #if defined(CONFIG_BVME6000_SCC)
  840. if (MACH_IS_BVME6000) {
  841. for (i = 0; i < ARRAY_SIZE(bvme_init_tab); ++i)
  842. SCCwrite(bvme_init_tab[i].reg, bvme_init_tab[i].val);
  843. }
  844. #endif
  845. /* remember status register for detection of DCD and CTS changes */
  846. scc_last_status_reg[channel] = SCCread(STATUS_REG);
  847. port->c_dcd = 0; /* Prevent initial 1->0 interrupt */
  848. scc_setsignals (port, 1,1);
  849. local_irq_restore(flags);
  850. }
  851. tty->driver_data = port;
  852. port->gs.port.tty = tty;
  853. port->gs.port.count++;
  854. retval = gs_init_port(&port->gs);
  855. if (retval) {
  856. port->gs.port.count--;
  857. return retval;
  858. }
  859. port->gs.port.flags |= GS_ACTIVE;
  860. retval = gs_block_til_ready(port, filp);
  861. if (retval) {
  862. port->gs.port.count--;
  863. return retval;
  864. }
  865. port->c_dcd = tty_port_carrier_raised(&port->gs.port);
  866. scc_enable_rx_interrupts(port);
  867. return 0;
  868. }
  869. static void scc_throttle (struct tty_struct * tty)
  870. {
  871. struct scc_port *port = tty->driver_data;
  872. unsigned long flags;
  873. SCC_ACCESS_INIT(port);
  874. if (tty->termios->c_cflag & CRTSCTS) {
  875. local_irq_save(flags);
  876. SCCmod(TX_CTRL_REG, ~TCR_RTS, 0);
  877. local_irq_restore(flags);
  878. }
  879. if (I_IXOFF(tty))
  880. scc_send_xchar(tty, STOP_CHAR(tty));
  881. }
  882. static void scc_unthrottle (struct tty_struct * tty)
  883. {
  884. struct scc_port *port = tty->driver_data;
  885. unsigned long flags;
  886. SCC_ACCESS_INIT(port);
  887. if (tty->termios->c_cflag & CRTSCTS) {
  888. local_irq_save(flags);
  889. SCCmod(TX_CTRL_REG, 0xff, TCR_RTS);
  890. local_irq_restore(flags);
  891. }
  892. if (I_IXOFF(tty))
  893. scc_send_xchar(tty, START_CHAR(tty));
  894. }
  895. static int scc_ioctl(struct tty_struct *tty, struct file *file,
  896. unsigned int cmd, unsigned long arg)
  897. {
  898. return -ENOIOCTLCMD;
  899. }
  900. static int scc_break_ctl(struct tty_struct *tty, int break_state)
  901. {
  902. struct scc_port *port = tty->driver_data;
  903. unsigned long flags;
  904. SCC_ACCESS_INIT(port);
  905. local_irq_save(flags);
  906. SCCmod(TX_CTRL_REG, ~TCR_SEND_BREAK,
  907. break_state ? TCR_SEND_BREAK : 0);
  908. local_irq_restore(flags);
  909. return 0;
  910. }
  911. /*---------------------------------------------------------------------------
  912. * Serial console stuff...
  913. *--------------------------------------------------------------------------*/
  914. #define scc_delay() do { __asm__ __volatile__ (" nop; nop"); } while (0)
  915. static void scc_ch_write (char ch)
  916. {
  917. volatile char *p = NULL;
  918. #ifdef CONFIG_MVME147_SCC
  919. if (MACH_IS_MVME147)
  920. p = (volatile char *)M147_SCC_A_ADDR;
  921. #endif
  922. #ifdef CONFIG_MVME162_SCC
  923. if (MACH_IS_MVME16x)
  924. p = (volatile char *)MVME_SCC_A_ADDR;
  925. #endif
  926. #ifdef CONFIG_BVME6000_SCC
  927. if (MACH_IS_BVME6000)
  928. p = (volatile char *)BVME_SCC_A_ADDR;
  929. #endif
  930. do {
  931. scc_delay();
  932. }
  933. while (!(*p & 4));
  934. scc_delay();
  935. *p = 8;
  936. scc_delay();
  937. *p = ch;
  938. }
  939. /* The console must be locked when we get here. */
  940. static void scc_console_write (struct console *co, const char *str, unsigned count)
  941. {
  942. unsigned long flags;
  943. local_irq_save(flags);
  944. while (count--)
  945. {
  946. if (*str == '\n')
  947. scc_ch_write ('\r');
  948. scc_ch_write (*str++);
  949. }
  950. local_irq_restore(flags);
  951. }
  952. static struct tty_driver *scc_console_device(struct console *c, int *index)
  953. {
  954. *index = c->index;
  955. return scc_driver;
  956. }
  957. static struct console sercons = {
  958. .name = "ttyS",
  959. .write = scc_console_write,
  960. .device = scc_console_device,
  961. .flags = CON_PRINTBUFFER,
  962. .index = -1,
  963. };
  964. static int __init vme_scc_console_init(void)
  965. {
  966. if (vme_brdtype == VME_TYPE_MVME147 ||
  967. vme_brdtype == VME_TYPE_MVME162 ||
  968. vme_brdtype == VME_TYPE_MVME172 ||
  969. vme_brdtype == VME_TYPE_BVME4000 ||
  970. vme_brdtype == VME_TYPE_BVME6000)
  971. register_console(&sercons);
  972. return 0;
  973. }
  974. console_initcall(vme_scc_console_init);