vme_scc.c 30 KB

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