ip22zilog.c 32 KB

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