ip22zilog.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Driver for Zilog serial chips found on SGI workstations and
  4. * servers. This driver could actually be made more generic.
  5. *
  6. * This is based on the drivers/serial/sunzilog.c code as of 2.6.0-test7 and the
  7. * old drivers/sgi/char/sgiserial.c code which itself is based of the original
  8. * drivers/sbus/char/zs.c code. A lot of code has been simply moved over
  9. * directly from there but much has been rewritten. Credits therefore go out
  10. * to David S. Miller, Eddie C. Dost, Pete Zaitcev, Ted Ts'o and Alex Buell
  11. * for their work there.
  12. *
  13. * Copyright (C) 2002 Ralf Baechle (ralf@linux-mips.org)
  14. * Copyright (C) 2002 David S. Miller (davem@redhat.com)
  15. */
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/errno.h>
  19. #include <linux/delay.h>
  20. #include <linux/tty.h>
  21. #include <linux/tty_flip.h>
  22. #include <linux/major.h>
  23. #include <linux/string.h>
  24. #include <linux/ptrace.h>
  25. #include <linux/ioport.h>
  26. #include <linux/slab.h>
  27. #include <linux/circ_buf.h>
  28. #include <linux/serial.h>
  29. #include <linux/sysrq.h>
  30. #include <linux/console.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/init.h>
  33. #include <linux/io.h>
  34. #include <asm/irq.h>
  35. #include <asm/sgialib.h>
  36. #include <asm/sgi/ioc.h>
  37. #include <asm/sgi/hpc3.h>
  38. #include <asm/sgi/ip22.h>
  39. #include <linux/serial_core.h>
  40. #include "ip22zilog.h"
  41. /*
  42. * On IP22 we need to delay after register accesses but we do not need to
  43. * flush writes.
  44. */
  45. #define ZSDELAY() udelay(5)
  46. #define ZSDELAY_LONG() udelay(20)
  47. #define ZS_WSYNC(channel) do { } while (0)
  48. #define NUM_IP22ZILOG 1
  49. #define NUM_CHANNELS (NUM_IP22ZILOG * 2)
  50. #define ZS_CLOCK 3672000 /* Zilog input clock rate. */
  51. #define ZS_CLOCK_DIVISOR 16 /* Divisor this driver uses. */
  52. /*
  53. * We wrap our port structure around the generic uart_port.
  54. */
  55. struct uart_ip22zilog_port {
  56. struct uart_port port;
  57. /* IRQ servicing chain. */
  58. struct uart_ip22zilog_port *next;
  59. /* Current values of Zilog write registers. */
  60. unsigned char curregs[NUM_ZSREGS];
  61. unsigned int flags;
  62. #define IP22ZILOG_FLAG_IS_CONS 0x00000004
  63. #define IP22ZILOG_FLAG_IS_KGDB 0x00000008
  64. #define IP22ZILOG_FLAG_MODEM_STATUS 0x00000010
  65. #define IP22ZILOG_FLAG_IS_CHANNEL_A 0x00000020
  66. #define IP22ZILOG_FLAG_REGS_HELD 0x00000040
  67. #define IP22ZILOG_FLAG_TX_STOPPED 0x00000080
  68. #define IP22ZILOG_FLAG_TX_ACTIVE 0x00000100
  69. #define IP22ZILOG_FLAG_RESET_DONE 0x00000200
  70. unsigned int tty_break;
  71. unsigned char parity_mask;
  72. unsigned char prev_status;
  73. };
  74. #define ZILOG_CHANNEL_FROM_PORT(PORT) ((struct zilog_channel *)((PORT)->membase))
  75. #define UART_ZILOG(PORT) ((struct uart_ip22zilog_port *)(PORT))
  76. #define IP22ZILOG_GET_CURR_REG(PORT, REGNUM) \
  77. (UART_ZILOG(PORT)->curregs[REGNUM])
  78. #define IP22ZILOG_SET_CURR_REG(PORT, REGNUM, REGVAL) \
  79. ((UART_ZILOG(PORT)->curregs[REGNUM]) = (REGVAL))
  80. #define ZS_IS_CONS(UP) ((UP)->flags & IP22ZILOG_FLAG_IS_CONS)
  81. #define ZS_IS_KGDB(UP) ((UP)->flags & IP22ZILOG_FLAG_IS_KGDB)
  82. #define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & IP22ZILOG_FLAG_MODEM_STATUS)
  83. #define ZS_IS_CHANNEL_A(UP) ((UP)->flags & IP22ZILOG_FLAG_IS_CHANNEL_A)
  84. #define ZS_REGS_HELD(UP) ((UP)->flags & IP22ZILOG_FLAG_REGS_HELD)
  85. #define ZS_TX_STOPPED(UP) ((UP)->flags & IP22ZILOG_FLAG_TX_STOPPED)
  86. #define ZS_TX_ACTIVE(UP) ((UP)->flags & IP22ZILOG_FLAG_TX_ACTIVE)
  87. /* Reading and writing Zilog8530 registers. The delays are to make this
  88. * driver work on the IP22 which needs a settling delay after each chip
  89. * register access, other machines handle this in hardware via auxiliary
  90. * flip-flops which implement the settle time we do in software.
  91. *
  92. * The port lock must be held and local IRQs must be disabled
  93. * when {read,write}_zsreg is invoked.
  94. */
  95. static unsigned char read_zsreg(struct zilog_channel *channel,
  96. unsigned char reg)
  97. {
  98. unsigned char retval;
  99. writeb(reg, &channel->control);
  100. ZSDELAY();
  101. retval = readb(&channel->control);
  102. ZSDELAY();
  103. return retval;
  104. }
  105. static void write_zsreg(struct zilog_channel *channel,
  106. unsigned char reg, unsigned char value)
  107. {
  108. writeb(reg, &channel->control);
  109. ZSDELAY();
  110. writeb(value, &channel->control);
  111. ZSDELAY();
  112. }
  113. static void ip22zilog_clear_fifo(struct zilog_channel *channel)
  114. {
  115. int i;
  116. for (i = 0; i < 32; i++) {
  117. unsigned char regval;
  118. regval = readb(&channel->control);
  119. ZSDELAY();
  120. if (regval & Rx_CH_AV)
  121. break;
  122. regval = read_zsreg(channel, R1);
  123. readb(&channel->data);
  124. ZSDELAY();
  125. if (regval & (PAR_ERR | Rx_OVR | CRC_ERR)) {
  126. writeb(ERR_RES, &channel->control);
  127. ZSDELAY();
  128. ZS_WSYNC(channel);
  129. }
  130. }
  131. }
  132. /* This function must only be called when the TX is not busy. The UART
  133. * port lock must be held and local interrupts disabled.
  134. */
  135. static void __load_zsregs(struct zilog_channel *channel, unsigned char *regs)
  136. {
  137. int i;
  138. /* Let pending transmits finish. */
  139. for (i = 0; i < 1000; i++) {
  140. unsigned char stat = read_zsreg(channel, R1);
  141. if (stat & ALL_SNT)
  142. break;
  143. udelay(100);
  144. }
  145. writeb(ERR_RES, &channel->control);
  146. ZSDELAY();
  147. ZS_WSYNC(channel);
  148. ip22zilog_clear_fifo(channel);
  149. /* Disable all interrupts. */
  150. write_zsreg(channel, R1,
  151. regs[R1] & ~(RxINT_MASK | TxINT_ENAB | EXT_INT_ENAB));
  152. /* Set parity, sync config, stop bits, and clock divisor. */
  153. write_zsreg(channel, R4, regs[R4]);
  154. /* Set misc. TX/RX control bits. */
  155. write_zsreg(channel, R10, regs[R10]);
  156. /* Set TX/RX controls sans the enable bits. */
  157. write_zsreg(channel, R3, regs[R3] & ~RxENAB);
  158. write_zsreg(channel, R5, regs[R5] & ~TxENAB);
  159. /* Synchronous mode config. */
  160. write_zsreg(channel, R6, regs[R6]);
  161. write_zsreg(channel, R7, regs[R7]);
  162. /* Don't mess with the interrupt vector (R2, unused by us) and
  163. * master interrupt control (R9). We make sure this is setup
  164. * properly at probe time then never touch it again.
  165. */
  166. /* Disable baud generator. */
  167. write_zsreg(channel, R14, regs[R14] & ~BRENAB);
  168. /* Clock mode control. */
  169. write_zsreg(channel, R11, regs[R11]);
  170. /* Lower and upper byte of baud rate generator divisor. */
  171. write_zsreg(channel, R12, regs[R12]);
  172. write_zsreg(channel, R13, regs[R13]);
  173. /* Now rewrite R14, with BRENAB (if set). */
  174. write_zsreg(channel, R14, regs[R14]);
  175. /* External status interrupt control. */
  176. write_zsreg(channel, R15, regs[R15]);
  177. /* Reset external status interrupts. */
  178. write_zsreg(channel, R0, RES_EXT_INT);
  179. write_zsreg(channel, R0, RES_EXT_INT);
  180. /* Rewrite R3/R5, this time without enables masked. */
  181. write_zsreg(channel, R3, regs[R3]);
  182. write_zsreg(channel, R5, regs[R5]);
  183. /* Rewrite R1, this time without IRQ enabled masked. */
  184. write_zsreg(channel, R1, regs[R1]);
  185. }
  186. /* Reprogram the Zilog channel HW registers with the copies found in the
  187. * software state struct. If the transmitter is busy, we defer this update
  188. * until the next TX complete interrupt. Else, we do it right now.
  189. *
  190. * The UART port lock must be held and local interrupts disabled.
  191. */
  192. static void ip22zilog_maybe_update_regs(struct uart_ip22zilog_port *up,
  193. struct zilog_channel *channel)
  194. {
  195. if (!ZS_REGS_HELD(up)) {
  196. if (ZS_TX_ACTIVE(up)) {
  197. up->flags |= IP22ZILOG_FLAG_REGS_HELD;
  198. } else {
  199. __load_zsregs(channel, up->curregs);
  200. }
  201. }
  202. }
  203. #define Rx_BRK 0x0100 /* BREAK event software flag. */
  204. #define Rx_SYS 0x0200 /* SysRq event software flag. */
  205. static bool ip22zilog_receive_chars(struct uart_ip22zilog_port *up,
  206. struct zilog_channel *channel)
  207. {
  208. unsigned int r1;
  209. u8 ch, flag;
  210. bool push = up->port.state != NULL;
  211. for (;;) {
  212. ch = readb(&channel->control);
  213. ZSDELAY();
  214. if (!(ch & Rx_CH_AV))
  215. break;
  216. r1 = read_zsreg(channel, R1);
  217. if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
  218. writeb(ERR_RES, &channel->control);
  219. ZSDELAY();
  220. ZS_WSYNC(channel);
  221. }
  222. ch = readb(&channel->data);
  223. ZSDELAY();
  224. ch &= up->parity_mask;
  225. /* Handle the null char got when BREAK is removed. */
  226. if (!ch)
  227. r1 |= up->tty_break;
  228. /* A real serial line, record the character and status. */
  229. flag = TTY_NORMAL;
  230. up->port.icount.rx++;
  231. if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | Rx_SYS | Rx_BRK)) {
  232. up->tty_break = 0;
  233. if (r1 & (Rx_SYS | Rx_BRK)) {
  234. up->port.icount.brk++;
  235. if (r1 & Rx_SYS)
  236. continue;
  237. r1 &= ~(PAR_ERR | CRC_ERR);
  238. }
  239. else if (r1 & PAR_ERR)
  240. up->port.icount.parity++;
  241. else if (r1 & CRC_ERR)
  242. up->port.icount.frame++;
  243. if (r1 & Rx_OVR)
  244. up->port.icount.overrun++;
  245. r1 &= up->port.read_status_mask;
  246. if (r1 & Rx_BRK)
  247. flag = TTY_BREAK;
  248. else if (r1 & PAR_ERR)
  249. flag = TTY_PARITY;
  250. else if (r1 & CRC_ERR)
  251. flag = TTY_FRAME;
  252. }
  253. if (uart_handle_sysrq_char(&up->port, ch))
  254. continue;
  255. if (push)
  256. uart_insert_char(&up->port, r1, Rx_OVR, ch, flag);
  257. }
  258. return push;
  259. }
  260. static void ip22zilog_status_handle(struct uart_ip22zilog_port *up,
  261. struct zilog_channel *channel)
  262. {
  263. unsigned char status;
  264. status = readb(&channel->control);
  265. ZSDELAY();
  266. writeb(RES_EXT_INT, &channel->control);
  267. ZSDELAY();
  268. ZS_WSYNC(channel);
  269. if (up->curregs[R15] & BRKIE) {
  270. if ((status & BRK_ABRT) && !(up->prev_status & BRK_ABRT)) {
  271. if (uart_handle_break(&up->port))
  272. up->tty_break = Rx_SYS;
  273. else
  274. up->tty_break = Rx_BRK;
  275. }
  276. }
  277. if (ZS_WANTS_MODEM_STATUS(up)) {
  278. if (status & SYNC)
  279. up->port.icount.dsr++;
  280. /* The Zilog just gives us an interrupt when DCD/CTS/etc. change.
  281. * But it does not tell us which bit has changed, we have to keep
  282. * track of this ourselves.
  283. */
  284. if ((status ^ up->prev_status) ^ DCD)
  285. uart_handle_dcd_change(&up->port,
  286. (status & DCD));
  287. if ((status ^ up->prev_status) ^ CTS)
  288. uart_handle_cts_change(&up->port,
  289. (status & CTS));
  290. wake_up_interruptible(&up->port.state->port.delta_msr_wait);
  291. }
  292. up->prev_status = status;
  293. }
  294. static void ip22zilog_transmit_chars(struct uart_ip22zilog_port *up,
  295. struct zilog_channel *channel)
  296. {
  297. struct tty_port *tport;
  298. unsigned char c;
  299. if (ZS_IS_CONS(up)) {
  300. unsigned char status = readb(&channel->control);
  301. ZSDELAY();
  302. /* TX still busy? Just wait for the next TX done interrupt.
  303. *
  304. * It can occur because of how we do serial console writes. It would
  305. * be nice to transmit console writes just like we normally would for
  306. * a TTY line. (ie. buffered and TX interrupt driven). That is not
  307. * easy because console writes cannot sleep. One solution might be
  308. * to poll on enough port->xmit space becoming free. -DaveM
  309. */
  310. if (!(status & Tx_BUF_EMP))
  311. return;
  312. }
  313. up->flags &= ~IP22ZILOG_FLAG_TX_ACTIVE;
  314. if (ZS_REGS_HELD(up)) {
  315. __load_zsregs(channel, up->curregs);
  316. up->flags &= ~IP22ZILOG_FLAG_REGS_HELD;
  317. }
  318. if (ZS_TX_STOPPED(up)) {
  319. up->flags &= ~IP22ZILOG_FLAG_TX_STOPPED;
  320. goto ack_tx_int;
  321. }
  322. if (up->port.x_char) {
  323. up->flags |= IP22ZILOG_FLAG_TX_ACTIVE;
  324. writeb(up->port.x_char, &channel->data);
  325. ZSDELAY();
  326. ZS_WSYNC(channel);
  327. up->port.icount.tx++;
  328. up->port.x_char = 0;
  329. return;
  330. }
  331. if (up->port.state == NULL)
  332. goto ack_tx_int;
  333. tport = &up->port.state->port;
  334. if (uart_tx_stopped(&up->port))
  335. goto ack_tx_int;
  336. if (!uart_fifo_get(&up->port, &c))
  337. goto ack_tx_int;
  338. up->flags |= IP22ZILOG_FLAG_TX_ACTIVE;
  339. writeb(c, &channel->data);
  340. ZSDELAY();
  341. ZS_WSYNC(channel);
  342. if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
  343. uart_write_wakeup(&up->port);
  344. return;
  345. ack_tx_int:
  346. writeb(RES_Tx_P, &channel->control);
  347. ZSDELAY();
  348. ZS_WSYNC(channel);
  349. }
  350. static irqreturn_t ip22zilog_interrupt(int irq, void *dev_id)
  351. {
  352. struct uart_ip22zilog_port *up = dev_id;
  353. while (up) {
  354. struct zilog_channel *channel
  355. = ZILOG_CHANNEL_FROM_PORT(&up->port);
  356. unsigned char r3;
  357. bool push = false;
  358. uart_port_lock(&up->port);
  359. r3 = read_zsreg(channel, R3);
  360. /* Channel A */
  361. if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
  362. writeb(RES_H_IUS, &channel->control);
  363. ZSDELAY();
  364. ZS_WSYNC(channel);
  365. if (r3 & CHARxIP)
  366. push = ip22zilog_receive_chars(up, channel);
  367. if (r3 & CHAEXT)
  368. ip22zilog_status_handle(up, channel);
  369. if (r3 & CHATxIP)
  370. ip22zilog_transmit_chars(up, channel);
  371. }
  372. uart_port_unlock(&up->port);
  373. if (push)
  374. tty_flip_buffer_push(&up->port.state->port);
  375. /* Channel B */
  376. up = up->next;
  377. channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
  378. push = false;
  379. uart_port_lock(&up->port);
  380. if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
  381. writeb(RES_H_IUS, &channel->control);
  382. ZSDELAY();
  383. ZS_WSYNC(channel);
  384. if (r3 & CHBRxIP)
  385. push = ip22zilog_receive_chars(up, channel);
  386. if (r3 & CHBEXT)
  387. ip22zilog_status_handle(up, channel);
  388. if (r3 & CHBTxIP)
  389. ip22zilog_transmit_chars(up, channel);
  390. }
  391. uart_port_unlock(&up->port);
  392. if (push)
  393. tty_flip_buffer_push(&up->port.state->port);
  394. up = up->next;
  395. }
  396. return IRQ_HANDLED;
  397. }
  398. /* A convenient way to quickly get R0 status. The caller must _not_ hold the
  399. * port lock, it is acquired here.
  400. */
  401. static __inline__ unsigned char ip22zilog_read_channel_status(struct uart_port *port)
  402. {
  403. struct zilog_channel *channel;
  404. unsigned char status;
  405. channel = ZILOG_CHANNEL_FROM_PORT(port);
  406. status = readb(&channel->control);
  407. ZSDELAY();
  408. return status;
  409. }
  410. /* The port lock is not held. */
  411. static unsigned int ip22zilog_tx_empty(struct uart_port *port)
  412. {
  413. unsigned long flags;
  414. unsigned char status;
  415. unsigned int ret;
  416. uart_port_lock_irqsave(port, &flags);
  417. status = ip22zilog_read_channel_status(port);
  418. uart_port_unlock_irqrestore(port, flags);
  419. if (status & Tx_BUF_EMP)
  420. ret = TIOCSER_TEMT;
  421. else
  422. ret = 0;
  423. return ret;
  424. }
  425. /* The port lock is held and interrupts are disabled. */
  426. static unsigned int ip22zilog_get_mctrl(struct uart_port *port)
  427. {
  428. unsigned char status;
  429. unsigned int ret;
  430. status = ip22zilog_read_channel_status(port);
  431. ret = 0;
  432. if (status & DCD)
  433. ret |= TIOCM_CAR;
  434. if (status & SYNC)
  435. ret |= TIOCM_DSR;
  436. if (status & CTS)
  437. ret |= TIOCM_CTS;
  438. return ret;
  439. }
  440. /* The port lock is held and interrupts are disabled. */
  441. static void ip22zilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
  442. {
  443. struct uart_ip22zilog_port *up =
  444. container_of(port, struct uart_ip22zilog_port, port);
  445. struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
  446. unsigned char set_bits, clear_bits;
  447. set_bits = clear_bits = 0;
  448. if (mctrl & TIOCM_RTS)
  449. set_bits |= RTS;
  450. else
  451. clear_bits |= RTS;
  452. if (mctrl & TIOCM_DTR)
  453. set_bits |= DTR;
  454. else
  455. clear_bits |= DTR;
  456. /* NOTE: Not subject to 'transmitter active' rule. */
  457. up->curregs[R5] |= set_bits;
  458. up->curregs[R5] &= ~clear_bits;
  459. write_zsreg(channel, R5, up->curregs[R5]);
  460. }
  461. /* The port lock is held and interrupts are disabled. */
  462. static void ip22zilog_stop_tx(struct uart_port *port)
  463. {
  464. struct uart_ip22zilog_port *up =
  465. container_of(port, struct uart_ip22zilog_port, port);
  466. up->flags |= IP22ZILOG_FLAG_TX_STOPPED;
  467. }
  468. /* The port lock is held and interrupts are disabled. */
  469. static void ip22zilog_start_tx(struct uart_port *port)
  470. {
  471. struct uart_ip22zilog_port *up =
  472. container_of(port, struct uart_ip22zilog_port, port);
  473. struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
  474. unsigned char status;
  475. up->flags |= IP22ZILOG_FLAG_TX_ACTIVE;
  476. up->flags &= ~IP22ZILOG_FLAG_TX_STOPPED;
  477. status = readb(&channel->control);
  478. ZSDELAY();
  479. /* TX busy? Just wait for the TX done interrupt. */
  480. if (!(status & Tx_BUF_EMP))
  481. return;
  482. /* Send the first character to jump-start the TX done
  483. * IRQ sending engine.
  484. */
  485. if (port->x_char) {
  486. writeb(port->x_char, &channel->data);
  487. ZSDELAY();
  488. ZS_WSYNC(channel);
  489. port->icount.tx++;
  490. port->x_char = 0;
  491. } else {
  492. struct tty_port *tport = &port->state->port;
  493. unsigned char c;
  494. if (!uart_fifo_get(port, &c))
  495. return;
  496. writeb(c, &channel->data);
  497. ZSDELAY();
  498. ZS_WSYNC(channel);
  499. if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
  500. uart_write_wakeup(&up->port);
  501. }
  502. }
  503. /* The port lock is held and interrupts are disabled. */
  504. static void ip22zilog_stop_rx(struct uart_port *port)
  505. {
  506. struct uart_ip22zilog_port *up = UART_ZILOG(port);
  507. struct zilog_channel *channel;
  508. if (ZS_IS_CONS(up))
  509. return;
  510. channel = ZILOG_CHANNEL_FROM_PORT(port);
  511. /* Disable all RX interrupts. */
  512. up->curregs[R1] &= ~RxINT_MASK;
  513. ip22zilog_maybe_update_regs(up, channel);
  514. }
  515. /* The port lock is held. */
  516. static void ip22zilog_enable_ms(struct uart_port *port)
  517. {
  518. struct uart_ip22zilog_port *up =
  519. container_of(port, struct uart_ip22zilog_port, port);
  520. struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
  521. unsigned char new_reg;
  522. new_reg = up->curregs[R15] | (DCDIE | SYNCIE | CTSIE);
  523. if (new_reg != up->curregs[R15]) {
  524. up->curregs[R15] = new_reg;
  525. /* NOTE: Not subject to 'transmitter active' rule. */
  526. write_zsreg(channel, R15, up->curregs[R15]);
  527. }
  528. }
  529. /* The port lock is not held. */
  530. static void ip22zilog_break_ctl(struct uart_port *port, int break_state)
  531. {
  532. struct uart_ip22zilog_port *up =
  533. container_of(port, struct uart_ip22zilog_port, port);
  534. struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
  535. unsigned char set_bits, clear_bits, new_reg;
  536. unsigned long flags;
  537. set_bits = clear_bits = 0;
  538. if (break_state)
  539. set_bits |= SND_BRK;
  540. else
  541. clear_bits |= SND_BRK;
  542. uart_port_lock_irqsave(port, &flags);
  543. new_reg = (up->curregs[R5] | set_bits) & ~clear_bits;
  544. if (new_reg != up->curregs[R5]) {
  545. up->curregs[R5] = new_reg;
  546. /* NOTE: Not subject to 'transmitter active' rule. */
  547. write_zsreg(channel, R5, up->curregs[R5]);
  548. }
  549. uart_port_unlock_irqrestore(port, flags);
  550. }
  551. static void __ip22zilog_reset(struct uart_ip22zilog_port *up)
  552. {
  553. struct zilog_channel *channel;
  554. int i;
  555. if (up->flags & IP22ZILOG_FLAG_RESET_DONE)
  556. return;
  557. /* Let pending transmits finish. */
  558. channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
  559. for (i = 0; i < 1000; i++) {
  560. unsigned char stat = read_zsreg(channel, R1);
  561. if (stat & ALL_SNT)
  562. break;
  563. udelay(100);
  564. }
  565. if (!ZS_IS_CHANNEL_A(up)) {
  566. up++;
  567. channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
  568. }
  569. write_zsreg(channel, R9, FHWRES);
  570. ZSDELAY_LONG();
  571. (void) read_zsreg(channel, R0);
  572. up->flags |= IP22ZILOG_FLAG_RESET_DONE;
  573. up->next->flags |= IP22ZILOG_FLAG_RESET_DONE;
  574. }
  575. static void __ip22zilog_startup(struct uart_ip22zilog_port *up)
  576. {
  577. struct zilog_channel *channel;
  578. channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
  579. __ip22zilog_reset(up);
  580. __load_zsregs(channel, up->curregs);
  581. /* set master interrupt enable */
  582. write_zsreg(channel, R9, up->curregs[R9]);
  583. up->prev_status = readb(&channel->control);
  584. /* Enable receiver and transmitter. */
  585. up->curregs[R3] |= RxENAB;
  586. up->curregs[R5] |= TxENAB;
  587. up->curregs[R1] |= EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB;
  588. ip22zilog_maybe_update_regs(up, channel);
  589. }
  590. static int ip22zilog_startup(struct uart_port *port)
  591. {
  592. struct uart_ip22zilog_port *up = UART_ZILOG(port);
  593. unsigned long flags;
  594. if (ZS_IS_CONS(up))
  595. return 0;
  596. uart_port_lock_irqsave(port, &flags);
  597. __ip22zilog_startup(up);
  598. uart_port_unlock_irqrestore(port, flags);
  599. return 0;
  600. }
  601. /*
  602. * The test for ZS_IS_CONS is explained by the following e-mail:
  603. *****
  604. * From: Russell King <rmk@arm.linux.org.uk>
  605. * Date: Sun, 8 Dec 2002 10:18:38 +0000
  606. *
  607. * On Sun, Dec 08, 2002 at 02:43:36AM -0500, Pete Zaitcev wrote:
  608. * > I boot my 2.5 boxes using "console=ttyS0,9600" argument,
  609. * > and I noticed that something is not right with reference
  610. * > counting in this case. It seems that when the console
  611. * > is open by kernel initially, this is not accounted
  612. * > as an open, and uart_startup is not called.
  613. *
  614. * That is correct. We are unable to call uart_startup when the serial
  615. * console is initialised because it may need to allocate memory (as
  616. * request_irq does) and the memory allocators may not have been
  617. * initialised.
  618. *
  619. * 1. initialise the port into a state where it can send characters in the
  620. * console write method.
  621. *
  622. * 2. don't do the actual hardware shutdown in your shutdown() method (but
  623. * do the normal software shutdown - ie, free irqs etc)
  624. *****
  625. */
  626. static void ip22zilog_shutdown(struct uart_port *port)
  627. {
  628. struct uart_ip22zilog_port *up = UART_ZILOG(port);
  629. struct zilog_channel *channel;
  630. unsigned long flags;
  631. if (ZS_IS_CONS(up))
  632. return;
  633. uart_port_lock_irqsave(port, &flags);
  634. channel = ZILOG_CHANNEL_FROM_PORT(port);
  635. /* Disable receiver and transmitter. */
  636. up->curregs[R3] &= ~RxENAB;
  637. up->curregs[R5] &= ~TxENAB;
  638. /* Disable all interrupts and BRK assertion. */
  639. up->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK);
  640. up->curregs[R5] &= ~SND_BRK;
  641. ip22zilog_maybe_update_regs(up, channel);
  642. uart_port_unlock_irqrestore(port, flags);
  643. }
  644. /* Shared by TTY driver and serial console setup. The port lock is held
  645. * and local interrupts are disabled.
  646. */
  647. static void
  648. ip22zilog_convert_to_zs(struct uart_ip22zilog_port *up, unsigned int cflag,
  649. unsigned int iflag, int brg)
  650. {
  651. up->curregs[R10] = NRZ;
  652. up->curregs[R11] = TCBR | RCBR;
  653. /* Program BAUD and clock source. */
  654. up->curregs[R4] &= ~XCLK_MASK;
  655. up->curregs[R4] |= X16CLK;
  656. up->curregs[R12] = brg & 0xff;
  657. up->curregs[R13] = (brg >> 8) & 0xff;
  658. up->curregs[R14] = BRENAB;
  659. /* Character size, stop bits, and parity. */
  660. up->curregs[3] &= ~RxN_MASK;
  661. up->curregs[5] &= ~TxN_MASK;
  662. switch (cflag & CSIZE) {
  663. case CS5:
  664. up->curregs[3] |= Rx5;
  665. up->curregs[5] |= Tx5;
  666. up->parity_mask = 0x1f;
  667. break;
  668. case CS6:
  669. up->curregs[3] |= Rx6;
  670. up->curregs[5] |= Tx6;
  671. up->parity_mask = 0x3f;
  672. break;
  673. case CS7:
  674. up->curregs[3] |= Rx7;
  675. up->curregs[5] |= Tx7;
  676. up->parity_mask = 0x7f;
  677. break;
  678. case CS8:
  679. default:
  680. up->curregs[3] |= Rx8;
  681. up->curregs[5] |= Tx8;
  682. up->parity_mask = 0xff;
  683. break;
  684. }
  685. up->curregs[4] &= ~0x0c;
  686. if (cflag & CSTOPB)
  687. up->curregs[4] |= SB2;
  688. else
  689. up->curregs[4] |= SB1;
  690. if (cflag & PARENB)
  691. up->curregs[4] |= PAR_ENAB;
  692. else
  693. up->curregs[4] &= ~PAR_ENAB;
  694. if (!(cflag & PARODD))
  695. up->curregs[4] |= PAR_EVEN;
  696. else
  697. up->curregs[4] &= ~PAR_EVEN;
  698. up->port.read_status_mask = Rx_OVR;
  699. if (iflag & INPCK)
  700. up->port.read_status_mask |= CRC_ERR | PAR_ERR;
  701. if (iflag & (IGNBRK | BRKINT | PARMRK))
  702. up->port.read_status_mask |= BRK_ABRT;
  703. up->port.ignore_status_mask = 0;
  704. if (iflag & IGNPAR)
  705. up->port.ignore_status_mask |= CRC_ERR | PAR_ERR;
  706. if (iflag & IGNBRK) {
  707. up->port.ignore_status_mask |= BRK_ABRT;
  708. if (iflag & IGNPAR)
  709. up->port.ignore_status_mask |= Rx_OVR;
  710. }
  711. if ((cflag & CREAD) == 0)
  712. up->port.ignore_status_mask = 0xff;
  713. }
  714. /* The port lock is not held. */
  715. static void
  716. ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios,
  717. const struct ktermios *old)
  718. {
  719. struct uart_ip22zilog_port *up =
  720. container_of(port, struct uart_ip22zilog_port, port);
  721. unsigned long flags;
  722. int baud, brg;
  723. baud = uart_get_baud_rate(port, termios, old, 1200, 76800);
  724. uart_port_lock_irqsave(&up->port, &flags);
  725. brg = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR);
  726. ip22zilog_convert_to_zs(up, termios->c_cflag, termios->c_iflag, brg);
  727. if (UART_ENABLE_MS(&up->port, termios->c_cflag))
  728. up->flags |= IP22ZILOG_FLAG_MODEM_STATUS;
  729. else
  730. up->flags &= ~IP22ZILOG_FLAG_MODEM_STATUS;
  731. ip22zilog_maybe_update_regs(up, ZILOG_CHANNEL_FROM_PORT(port));
  732. uart_update_timeout(port, termios->c_cflag, baud);
  733. uart_port_unlock_irqrestore(&up->port, flags);
  734. }
  735. static const char *ip22zilog_type(struct uart_port *port)
  736. {
  737. return "IP22-Zilog";
  738. }
  739. /* We do not request/release mappings of the registers here, this
  740. * happens at early serial probe time.
  741. */
  742. static void ip22zilog_release_port(struct uart_port *port)
  743. {
  744. }
  745. static int ip22zilog_request_port(struct uart_port *port)
  746. {
  747. return 0;
  748. }
  749. /* These do not need to do anything interesting either. */
  750. static void ip22zilog_config_port(struct uart_port *port, int flags)
  751. {
  752. }
  753. /* We do not support letting the user mess with the divisor, IRQ, etc. */
  754. static int ip22zilog_verify_port(struct uart_port *port, struct serial_struct *ser)
  755. {
  756. return -EINVAL;
  757. }
  758. static const struct uart_ops ip22zilog_pops = {
  759. .tx_empty = ip22zilog_tx_empty,
  760. .set_mctrl = ip22zilog_set_mctrl,
  761. .get_mctrl = ip22zilog_get_mctrl,
  762. .stop_tx = ip22zilog_stop_tx,
  763. .start_tx = ip22zilog_start_tx,
  764. .stop_rx = ip22zilog_stop_rx,
  765. .enable_ms = ip22zilog_enable_ms,
  766. .break_ctl = ip22zilog_break_ctl,
  767. .startup = ip22zilog_startup,
  768. .shutdown = ip22zilog_shutdown,
  769. .set_termios = ip22zilog_set_termios,
  770. .type = ip22zilog_type,
  771. .release_port = ip22zilog_release_port,
  772. .request_port = ip22zilog_request_port,
  773. .config_port = ip22zilog_config_port,
  774. .verify_port = ip22zilog_verify_port,
  775. };
  776. static struct uart_ip22zilog_port *ip22zilog_port_table;
  777. static struct zilog_layout **ip22zilog_chip_regs;
  778. static struct uart_ip22zilog_port *ip22zilog_irq_chain;
  779. static int zilog_irq = -1;
  780. static void * __init alloc_one_table(unsigned long size)
  781. {
  782. return kzalloc(size, GFP_KERNEL);
  783. }
  784. static void __init ip22zilog_alloc_tables(void)
  785. {
  786. ip22zilog_port_table = (struct uart_ip22zilog_port *)
  787. alloc_one_table(NUM_CHANNELS * sizeof(struct uart_ip22zilog_port));
  788. ip22zilog_chip_regs = (struct zilog_layout **)
  789. alloc_one_table(NUM_IP22ZILOG * sizeof(struct zilog_layout *));
  790. if (ip22zilog_port_table == NULL || ip22zilog_chip_regs == NULL) {
  791. panic("IP22-Zilog: Cannot allocate IP22-Zilog tables.");
  792. }
  793. }
  794. /* Get the address of the registers for IP22-Zilog instance CHIP. */
  795. static struct zilog_layout * __init get_zs(int chip)
  796. {
  797. unsigned long base;
  798. if (chip < 0 || chip >= NUM_IP22ZILOG) {
  799. panic("IP22-Zilog: Illegal chip number %d in get_zs.", chip);
  800. }
  801. /* Not probe-able, hard code it. */
  802. base = (unsigned long) &sgioc->uart;
  803. zilog_irq = SGI_SERIAL_IRQ;
  804. request_mem_region(base, 8, "IP22-Zilog");
  805. return (struct zilog_layout *) base;
  806. }
  807. #define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
  808. #ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE
  809. static void ip22zilog_put_char(struct uart_port *port, unsigned char ch)
  810. {
  811. struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
  812. int loops = ZS_PUT_CHAR_MAX_DELAY;
  813. /* This is a timed polling loop so do not switch the explicit
  814. * udelay with ZSDELAY as that is a NOP on some platforms. -DaveM
  815. */
  816. do {
  817. unsigned char val = readb(&channel->control);
  818. if (val & Tx_BUF_EMP) {
  819. ZSDELAY();
  820. break;
  821. }
  822. udelay(5);
  823. } while (--loops);
  824. writeb(ch, &channel->data);
  825. ZSDELAY();
  826. ZS_WSYNC(channel);
  827. }
  828. static void
  829. ip22zilog_console_write(struct console *con, const char *s, unsigned int count)
  830. {
  831. struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
  832. unsigned long flags;
  833. uart_port_lock_irqsave(&up->port, &flags);
  834. uart_console_write(&up->port, s, count, ip22zilog_put_char);
  835. udelay(2);
  836. uart_port_unlock_irqrestore(&up->port, flags);
  837. }
  838. static int __init ip22zilog_console_setup(struct console *con, char *options)
  839. {
  840. struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
  841. unsigned long flags;
  842. int baud = 9600, bits = 8;
  843. int parity = 'n';
  844. int flow = 'n';
  845. up->flags |= IP22ZILOG_FLAG_IS_CONS;
  846. printk(KERN_INFO "Console: ttyS%d (IP22-Zilog)\n", con->index);
  847. uart_port_lock_irqsave(&up->port, &flags);
  848. up->curregs[R15] |= BRKIE;
  849. __ip22zilog_startup(up);
  850. uart_port_unlock_irqrestore(&up->port, flags);
  851. if (options)
  852. uart_parse_options(options, &baud, &parity, &bits, &flow);
  853. return uart_set_options(&up->port, con, baud, parity, bits, flow);
  854. }
  855. static struct uart_driver ip22zilog_reg;
  856. static struct console ip22zilog_console = {
  857. .name = "ttyS",
  858. .write = ip22zilog_console_write,
  859. .device = uart_console_device,
  860. .setup = ip22zilog_console_setup,
  861. .flags = CON_PRINTBUFFER,
  862. .index = -1,
  863. .data = &ip22zilog_reg,
  864. };
  865. #endif /* CONFIG_SERIAL_IP22_ZILOG_CONSOLE */
  866. static struct uart_driver ip22zilog_reg = {
  867. .owner = THIS_MODULE,
  868. .driver_name = "serial",
  869. .dev_name = "ttyS",
  870. .major = TTY_MAJOR,
  871. .minor = 64,
  872. .nr = NUM_CHANNELS,
  873. #ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE
  874. .cons = &ip22zilog_console,
  875. #endif
  876. };
  877. static void __init ip22zilog_prepare(void)
  878. {
  879. unsigned char sysrq_on = IS_ENABLED(CONFIG_SERIAL_IP22_ZILOG_CONSOLE);
  880. struct uart_ip22zilog_port *up;
  881. struct zilog_layout *rp;
  882. int channel, chip;
  883. /*
  884. * Temporary fix.
  885. */
  886. for (channel = 0; channel < NUM_CHANNELS; channel++)
  887. spin_lock_init(&ip22zilog_port_table[channel].port.lock);
  888. ip22zilog_irq_chain = &ip22zilog_port_table[NUM_CHANNELS - 1];
  889. up = &ip22zilog_port_table[0];
  890. for (channel = NUM_CHANNELS - 1 ; channel > 0; channel--)
  891. up[channel].next = &up[channel - 1];
  892. up[channel].next = NULL;
  893. for (chip = 0; chip < NUM_IP22ZILOG; chip++) {
  894. if (!ip22zilog_chip_regs[chip]) {
  895. ip22zilog_chip_regs[chip] = rp = get_zs(chip);
  896. up[(chip * 2) + 0].port.membase = (char *) &rp->channelB;
  897. up[(chip * 2) + 1].port.membase = (char *) &rp->channelA;
  898. /* In theory mapbase is the physical address ... */
  899. up[(chip * 2) + 0].port.mapbase =
  900. (unsigned long) ioremap((unsigned long) &rp->channelB, 8);
  901. up[(chip * 2) + 1].port.mapbase =
  902. (unsigned long) ioremap((unsigned long) &rp->channelA, 8);
  903. }
  904. /* Channel A */
  905. up[(chip * 2) + 0].port.iotype = UPIO_MEM;
  906. up[(chip * 2) + 0].port.irq = zilog_irq;
  907. up[(chip * 2) + 0].port.uartclk = ZS_CLOCK;
  908. up[(chip * 2) + 0].port.fifosize = 1;
  909. up[(chip * 2) + 0].port.has_sysrq = sysrq_on;
  910. up[(chip * 2) + 0].port.ops = &ip22zilog_pops;
  911. up[(chip * 2) + 0].port.type = PORT_IP22ZILOG;
  912. up[(chip * 2) + 0].port.flags = 0;
  913. up[(chip * 2) + 0].port.line = (chip * 2) + 0;
  914. up[(chip * 2) + 0].flags = 0;
  915. /* Channel B */
  916. up[(chip * 2) + 1].port.iotype = UPIO_MEM;
  917. up[(chip * 2) + 1].port.irq = zilog_irq;
  918. up[(chip * 2) + 1].port.uartclk = ZS_CLOCK;
  919. up[(chip * 2) + 1].port.fifosize = 1;
  920. up[(chip * 2) + 1].port.has_sysrq = sysrq_on;
  921. up[(chip * 2) + 1].port.ops = &ip22zilog_pops;
  922. up[(chip * 2) + 1].port.type = PORT_IP22ZILOG;
  923. up[(chip * 2) + 1].port.line = (chip * 2) + 1;
  924. up[(chip * 2) + 1].flags |= IP22ZILOG_FLAG_IS_CHANNEL_A;
  925. }
  926. for (channel = 0; channel < NUM_CHANNELS; channel++) {
  927. struct uart_ip22zilog_port *up = &ip22zilog_port_table[channel];
  928. int brg;
  929. /* Normal serial TTY. */
  930. up->parity_mask = 0xff;
  931. up->curregs[R1] = EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB;
  932. up->curregs[R4] = PAR_EVEN | X16CLK | SB1;
  933. up->curregs[R3] = RxENAB | Rx8;
  934. up->curregs[R5] = TxENAB | Tx8;
  935. up->curregs[R9] = NV | MIE;
  936. up->curregs[R10] = NRZ;
  937. up->curregs[R11] = TCBR | RCBR;
  938. brg = BPS_TO_BRG(9600, ZS_CLOCK / ZS_CLOCK_DIVISOR);
  939. up->curregs[R12] = (brg & 0xff);
  940. up->curregs[R13] = (brg >> 8) & 0xff;
  941. up->curregs[R14] = BRENAB;
  942. }
  943. }
  944. static int __init ip22zilog_ports_init(void)
  945. {
  946. int ret;
  947. printk(KERN_INFO "Serial: IP22 Zilog driver (%d chips).\n", NUM_IP22ZILOG);
  948. ip22zilog_prepare();
  949. if (request_irq(zilog_irq, ip22zilog_interrupt, 0,
  950. "IP22-Zilog", ip22zilog_irq_chain)) {
  951. panic("IP22-Zilog: Unable to register zs interrupt handler.\n");
  952. }
  953. ret = uart_register_driver(&ip22zilog_reg);
  954. if (ret == 0) {
  955. int i;
  956. for (i = 0; i < NUM_CHANNELS; i++) {
  957. struct uart_ip22zilog_port *up = &ip22zilog_port_table[i];
  958. uart_add_one_port(&ip22zilog_reg, &up->port);
  959. }
  960. }
  961. return ret;
  962. }
  963. static int __init ip22zilog_init(void)
  964. {
  965. /* IP22 Zilog setup is hard coded, no probing to do. */
  966. ip22zilog_alloc_tables();
  967. ip22zilog_ports_init();
  968. return 0;
  969. }
  970. static void __exit ip22zilog_exit(void)
  971. {
  972. int i;
  973. struct uart_ip22zilog_port *up;
  974. for (i = 0; i < NUM_CHANNELS; i++) {
  975. up = &ip22zilog_port_table[i];
  976. uart_remove_one_port(&ip22zilog_reg, &up->port);
  977. }
  978. /* Free IO mem */
  979. up = &ip22zilog_port_table[0];
  980. for (i = 0; i < NUM_IP22ZILOG; i++) {
  981. if (up[(i * 2) + 0].port.mapbase) {
  982. iounmap((void*)up[(i * 2) + 0].port.mapbase);
  983. up[(i * 2) + 0].port.mapbase = 0;
  984. }
  985. if (up[(i * 2) + 1].port.mapbase) {
  986. iounmap((void*)up[(i * 2) + 1].port.mapbase);
  987. up[(i * 2) + 1].port.mapbase = 0;
  988. }
  989. }
  990. uart_unregister_driver(&ip22zilog_reg);
  991. }
  992. module_init(ip22zilog_init);
  993. module_exit(ip22zilog_exit);
  994. /* David wrote it but I'm to blame for the bugs ... */
  995. MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
  996. MODULE_DESCRIPTION("SGI Zilog serial port driver");
  997. MODULE_LICENSE("GPL");