sunsab.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /* sunsab.c: ASYNC Driver for the SIEMENS SAB82532 DUSCC.
  2. *
  3. * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
  4. * Copyright (C) 2002 David S. Miller (davem@redhat.com)
  5. *
  6. * Rewrote buffer handling to use CIRC(Circular Buffer) macros.
  7. * Maxim Krasnyanskiy <maxk@qualcomm.com>
  8. *
  9. * Fixed to use tty_get_baud_rate, and to allow for arbitrary baud
  10. * rates to be programmed into the UART. Also eliminated a lot of
  11. * duplicated code in the console setup.
  12. * Theodore Ts'o <tytso@mit.edu>, 2001-Oct-12
  13. *
  14. * Ported to new 2.5.x UART layer.
  15. * David S. Miller <davem@redhat.com>
  16. */
  17. #include <linux/config.h>
  18. #include <linux/module.h>
  19. #include <linux/kernel.h>
  20. #include <linux/sched.h>
  21. #include <linux/errno.h>
  22. #include <linux/tty.h>
  23. #include <linux/tty_flip.h>
  24. #include <linux/major.h>
  25. #include <linux/string.h>
  26. #include <linux/ptrace.h>
  27. #include <linux/ioport.h>
  28. #include <linux/circ_buf.h>
  29. #include <linux/serial.h>
  30. #include <linux/sysrq.h>
  31. #include <linux/console.h>
  32. #include <linux/spinlock.h>
  33. #include <linux/slab.h>
  34. #include <linux/delay.h>
  35. #include <linux/init.h>
  36. #include <asm/io.h>
  37. #include <asm/irq.h>
  38. #include <asm/oplib.h>
  39. #include <asm/ebus.h>
  40. #if defined(CONFIG_SERIAL_SUNZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  41. #define SUPPORT_SYSRQ
  42. #endif
  43. #include <linux/serial_core.h>
  44. #include "suncore.h"
  45. #include "sunsab.h"
  46. struct uart_sunsab_port {
  47. struct uart_port port; /* Generic UART port */
  48. union sab82532_async_regs __iomem *regs; /* Chip registers */
  49. unsigned long irqflags; /* IRQ state flags */
  50. int dsr; /* Current DSR state */
  51. unsigned int cec_timeout; /* Chip poll timeout... */
  52. unsigned int tec_timeout; /* likewise */
  53. unsigned char interrupt_mask0;/* ISR0 masking */
  54. unsigned char interrupt_mask1;/* ISR1 masking */
  55. unsigned char pvr_dtr_bit; /* Which PVR bit is DTR */
  56. unsigned char pvr_dsr_bit; /* Which PVR bit is DSR */
  57. int type; /* SAB82532 version */
  58. /* Setting configuration bits while the transmitter is active
  59. * can cause garbage characters to get emitted by the chip.
  60. * Therefore, we cache such writes here and do the real register
  61. * write the next time the transmitter becomes idle.
  62. */
  63. unsigned int cached_ebrg;
  64. unsigned char cached_mode;
  65. unsigned char cached_pvr;
  66. unsigned char cached_dafo;
  67. };
  68. /*
  69. * This assumes you have a 29.4912 MHz clock for your UART.
  70. */
  71. #define SAB_BASE_BAUD ( 29491200 / 16 )
  72. static char *sab82532_version[16] = {
  73. "V1.0", "V2.0", "V3.2", "V(0x03)",
  74. "V(0x04)", "V(0x05)", "V(0x06)", "V(0x07)",
  75. "V(0x08)", "V(0x09)", "V(0x0a)", "V(0x0b)",
  76. "V(0x0c)", "V(0x0d)", "V(0x0e)", "V(0x0f)"
  77. };
  78. #define SAB82532_MAX_TEC_TIMEOUT 200000 /* 1 character time (at 50 baud) */
  79. #define SAB82532_MAX_CEC_TIMEOUT 50000 /* 2.5 TX CLKs (at 50 baud) */
  80. #define SAB82532_RECV_FIFO_SIZE 32 /* Standard async fifo sizes */
  81. #define SAB82532_XMIT_FIFO_SIZE 32
  82. static __inline__ void sunsab_tec_wait(struct uart_sunsab_port *up)
  83. {
  84. int timeout = up->tec_timeout;
  85. while ((readb(&up->regs->r.star) & SAB82532_STAR_TEC) && --timeout)
  86. udelay(1);
  87. }
  88. static __inline__ void sunsab_cec_wait(struct uart_sunsab_port *up)
  89. {
  90. int timeout = up->cec_timeout;
  91. while ((readb(&up->regs->r.star) & SAB82532_STAR_CEC) && --timeout)
  92. udelay(1);
  93. }
  94. static struct tty_struct *
  95. receive_chars(struct uart_sunsab_port *up,
  96. union sab82532_irq_status *stat,
  97. struct pt_regs *regs)
  98. {
  99. struct tty_struct *tty = NULL;
  100. unsigned char buf[32];
  101. int saw_console_brk = 0;
  102. int free_fifo = 0;
  103. int count = 0;
  104. int i;
  105. if (up->port.info != NULL) /* Unopened serial console */
  106. tty = up->port.info->tty;
  107. /* Read number of BYTES (Character + Status) available. */
  108. if (stat->sreg.isr0 & SAB82532_ISR0_RPF) {
  109. count = SAB82532_RECV_FIFO_SIZE;
  110. free_fifo++;
  111. }
  112. if (stat->sreg.isr0 & SAB82532_ISR0_TCD) {
  113. count = readb(&up->regs->r.rbcl) & (SAB82532_RECV_FIFO_SIZE - 1);
  114. free_fifo++;
  115. }
  116. /* Issue a FIFO read command in case we where idle. */
  117. if (stat->sreg.isr0 & SAB82532_ISR0_TIME) {
  118. sunsab_cec_wait(up);
  119. writeb(SAB82532_CMDR_RFRD, &up->regs->w.cmdr);
  120. return tty;
  121. }
  122. if (stat->sreg.isr0 & SAB82532_ISR0_RFO)
  123. free_fifo++;
  124. /* Read the FIFO. */
  125. for (i = 0; i < count; i++)
  126. buf[i] = readb(&up->regs->r.rfifo[i]);
  127. /* Issue Receive Message Complete command. */
  128. if (free_fifo) {
  129. sunsab_cec_wait(up);
  130. writeb(SAB82532_CMDR_RMC, &up->regs->w.cmdr);
  131. }
  132. /* Count may be zero for BRK, so we check for it here */
  133. if ((stat->sreg.isr1 & SAB82532_ISR1_BRK) &&
  134. (up->port.line == up->port.cons->index))
  135. saw_console_brk = 1;
  136. for (i = 0; i < count; i++) {
  137. unsigned char ch = buf[i];
  138. if (tty == NULL) {
  139. uart_handle_sysrq_char(&up->port, ch, regs);
  140. continue;
  141. }
  142. if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
  143. tty->flip.work.func((void *)tty);
  144. if (tty->flip.count >= TTY_FLIPBUF_SIZE)
  145. return tty; // if TTY_DONT_FLIP is set
  146. }
  147. *tty->flip.char_buf_ptr = ch;
  148. *tty->flip.flag_buf_ptr = TTY_NORMAL;
  149. up->port.icount.rx++;
  150. if (unlikely(stat->sreg.isr0 & (SAB82532_ISR0_PERR |
  151. SAB82532_ISR0_FERR |
  152. SAB82532_ISR0_RFO)) ||
  153. unlikely(stat->sreg.isr1 & SAB82532_ISR1_BRK)) {
  154. /*
  155. * For statistics only
  156. */
  157. if (stat->sreg.isr1 & SAB82532_ISR1_BRK) {
  158. stat->sreg.isr0 &= ~(SAB82532_ISR0_PERR |
  159. SAB82532_ISR0_FERR);
  160. up->port.icount.brk++;
  161. /*
  162. * We do the SysRQ and SAK checking
  163. * here because otherwise the break
  164. * may get masked by ignore_status_mask
  165. * or read_status_mask.
  166. */
  167. if (uart_handle_break(&up->port))
  168. continue;
  169. } else if (stat->sreg.isr0 & SAB82532_ISR0_PERR)
  170. up->port.icount.parity++;
  171. else if (stat->sreg.isr0 & SAB82532_ISR0_FERR)
  172. up->port.icount.frame++;
  173. if (stat->sreg.isr0 & SAB82532_ISR0_RFO)
  174. up->port.icount.overrun++;
  175. /*
  176. * Mask off conditions which should be ingored.
  177. */
  178. stat->sreg.isr0 &= (up->port.read_status_mask & 0xff);
  179. stat->sreg.isr1 &= ((up->port.read_status_mask >> 8) & 0xff);
  180. if (stat->sreg.isr1 & SAB82532_ISR1_BRK) {
  181. *tty->flip.flag_buf_ptr = TTY_BREAK;
  182. } else if (stat->sreg.isr0 & SAB82532_ISR0_PERR)
  183. *tty->flip.flag_buf_ptr = TTY_PARITY;
  184. else if (stat->sreg.isr0 & SAB82532_ISR0_FERR)
  185. *tty->flip.flag_buf_ptr = TTY_FRAME;
  186. }
  187. if (uart_handle_sysrq_char(&up->port, ch, regs))
  188. continue;
  189. if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 &&
  190. (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0){
  191. tty->flip.flag_buf_ptr++;
  192. tty->flip.char_buf_ptr++;
  193. tty->flip.count++;
  194. }
  195. if ((stat->sreg.isr0 & SAB82532_ISR0_RFO) &&
  196. tty->flip.count < TTY_FLIPBUF_SIZE) {
  197. /*
  198. * Overrun is special, since it's reported
  199. * immediately, and doesn't affect the current
  200. * character.
  201. */
  202. *tty->flip.flag_buf_ptr = TTY_OVERRUN;
  203. tty->flip.flag_buf_ptr++;
  204. tty->flip.char_buf_ptr++;
  205. tty->flip.count++;
  206. }
  207. }
  208. if (saw_console_brk)
  209. sun_do_break();
  210. return tty;
  211. }
  212. static void sunsab_stop_tx(struct uart_port *);
  213. static void sunsab_tx_idle(struct uart_sunsab_port *);
  214. static void transmit_chars(struct uart_sunsab_port *up,
  215. union sab82532_irq_status *stat)
  216. {
  217. struct circ_buf *xmit = &up->port.info->xmit;
  218. int i;
  219. if (stat->sreg.isr1 & SAB82532_ISR1_ALLS) {
  220. up->interrupt_mask1 |= SAB82532_IMR1_ALLS;
  221. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  222. set_bit(SAB82532_ALLS, &up->irqflags);
  223. }
  224. #if 0 /* bde@nwlink.com says this check causes problems */
  225. if (!(stat->sreg.isr1 & SAB82532_ISR1_XPR))
  226. return;
  227. #endif
  228. if (!(readb(&up->regs->r.star) & SAB82532_STAR_XFW))
  229. return;
  230. set_bit(SAB82532_XPR, &up->irqflags);
  231. sunsab_tx_idle(up);
  232. if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
  233. up->interrupt_mask1 |= SAB82532_IMR1_XPR;
  234. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  235. return;
  236. }
  237. up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR);
  238. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  239. clear_bit(SAB82532_ALLS, &up->irqflags);
  240. /* Stuff 32 bytes into Transmit FIFO. */
  241. clear_bit(SAB82532_XPR, &up->irqflags);
  242. for (i = 0; i < up->port.fifosize; i++) {
  243. writeb(xmit->buf[xmit->tail],
  244. &up->regs->w.xfifo[i]);
  245. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  246. up->port.icount.tx++;
  247. if (uart_circ_empty(xmit))
  248. break;
  249. }
  250. /* Issue a Transmit Frame command. */
  251. sunsab_cec_wait(up);
  252. writeb(SAB82532_CMDR_XF, &up->regs->w.cmdr);
  253. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  254. uart_write_wakeup(&up->port);
  255. if (uart_circ_empty(xmit))
  256. sunsab_stop_tx(&up->port);
  257. }
  258. static void check_status(struct uart_sunsab_port *up,
  259. union sab82532_irq_status *stat)
  260. {
  261. if (stat->sreg.isr0 & SAB82532_ISR0_CDSC)
  262. uart_handle_dcd_change(&up->port,
  263. !(readb(&up->regs->r.vstr) & SAB82532_VSTR_CD));
  264. if (stat->sreg.isr1 & SAB82532_ISR1_CSC)
  265. uart_handle_cts_change(&up->port,
  266. (readb(&up->regs->r.star) & SAB82532_STAR_CTS));
  267. if ((readb(&up->regs->r.pvr) & up->pvr_dsr_bit) ^ up->dsr) {
  268. up->dsr = (readb(&up->regs->r.pvr) & up->pvr_dsr_bit) ? 0 : 1;
  269. up->port.icount.dsr++;
  270. }
  271. wake_up_interruptible(&up->port.info->delta_msr_wait);
  272. }
  273. static irqreturn_t sunsab_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  274. {
  275. struct uart_sunsab_port *up = dev_id;
  276. struct tty_struct *tty;
  277. union sab82532_irq_status status;
  278. unsigned long flags;
  279. spin_lock_irqsave(&up->port.lock, flags);
  280. status.stat = 0;
  281. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISA0)
  282. status.sreg.isr0 = readb(&up->regs->r.isr0);
  283. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISA1)
  284. status.sreg.isr1 = readb(&up->regs->r.isr1);
  285. tty = NULL;
  286. if (status.stat) {
  287. if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
  288. SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) ||
  289. (status.sreg.isr1 & SAB82532_ISR1_BRK))
  290. tty = receive_chars(up, &status, regs);
  291. if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) ||
  292. (status.sreg.isr1 & SAB82532_ISR1_CSC))
  293. check_status(up, &status);
  294. if (status.sreg.isr1 & (SAB82532_ISR1_ALLS | SAB82532_ISR1_XPR))
  295. transmit_chars(up, &status);
  296. }
  297. spin_unlock(&up->port.lock);
  298. if (tty)
  299. tty_flip_buffer_push(tty);
  300. up++;
  301. spin_lock(&up->port.lock);
  302. status.stat = 0;
  303. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISB0)
  304. status.sreg.isr0 = readb(&up->regs->r.isr0);
  305. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISB1)
  306. status.sreg.isr1 = readb(&up->regs->r.isr1);
  307. tty = NULL;
  308. if (status.stat) {
  309. if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
  310. SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) ||
  311. (status.sreg.isr1 & SAB82532_ISR1_BRK))
  312. tty = receive_chars(up, &status, regs);
  313. if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) ||
  314. (status.sreg.isr1 & (SAB82532_ISR1_BRK | SAB82532_ISR1_CSC)))
  315. check_status(up, &status);
  316. if (status.sreg.isr1 & (SAB82532_ISR1_ALLS | SAB82532_ISR1_XPR))
  317. transmit_chars(up, &status);
  318. }
  319. spin_unlock_irqrestore(&up->port.lock, flags);
  320. if (tty)
  321. tty_flip_buffer_push(tty);
  322. return IRQ_HANDLED;
  323. }
  324. /* port->lock is not held. */
  325. static unsigned int sunsab_tx_empty(struct uart_port *port)
  326. {
  327. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  328. int ret;
  329. /* Do not need a lock for a state test like this. */
  330. if (test_bit(SAB82532_ALLS, &up->irqflags))
  331. ret = TIOCSER_TEMT;
  332. else
  333. ret = 0;
  334. return ret;
  335. }
  336. /* port->lock held by caller. */
  337. static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl)
  338. {
  339. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  340. if (mctrl & TIOCM_RTS) {
  341. up->cached_mode &= ~SAB82532_MODE_FRTS;
  342. up->cached_mode |= SAB82532_MODE_RTS;
  343. } else {
  344. up->cached_mode |= (SAB82532_MODE_FRTS |
  345. SAB82532_MODE_RTS);
  346. }
  347. if (mctrl & TIOCM_DTR) {
  348. up->cached_pvr &= ~(up->pvr_dtr_bit);
  349. } else {
  350. up->cached_pvr |= up->pvr_dtr_bit;
  351. }
  352. set_bit(SAB82532_REGS_PENDING, &up->irqflags);
  353. if (test_bit(SAB82532_XPR, &up->irqflags))
  354. sunsab_tx_idle(up);
  355. }
  356. /* port->lock is held by caller and interrupts are disabled. */
  357. static unsigned int sunsab_get_mctrl(struct uart_port *port)
  358. {
  359. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  360. unsigned char val;
  361. unsigned int result;
  362. result = 0;
  363. val = readb(&up->regs->r.pvr);
  364. result |= (val & up->pvr_dsr_bit) ? 0 : TIOCM_DSR;
  365. val = readb(&up->regs->r.vstr);
  366. result |= (val & SAB82532_VSTR_CD) ? 0 : TIOCM_CAR;
  367. val = readb(&up->regs->r.star);
  368. result |= (val & SAB82532_STAR_CTS) ? TIOCM_CTS : 0;
  369. return result;
  370. }
  371. /* port->lock held by caller. */
  372. static void sunsab_stop_tx(struct uart_port *port)
  373. {
  374. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  375. up->interrupt_mask1 |= SAB82532_IMR1_XPR;
  376. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  377. }
  378. /* port->lock held by caller. */
  379. static void sunsab_tx_idle(struct uart_sunsab_port *up)
  380. {
  381. if (test_bit(SAB82532_REGS_PENDING, &up->irqflags)) {
  382. u8 tmp;
  383. clear_bit(SAB82532_REGS_PENDING, &up->irqflags);
  384. writeb(up->cached_mode, &up->regs->rw.mode);
  385. writeb(up->cached_pvr, &up->regs->rw.pvr);
  386. writeb(up->cached_dafo, &up->regs->w.dafo);
  387. writeb(up->cached_ebrg & 0xff, &up->regs->w.bgr);
  388. tmp = readb(&up->regs->rw.ccr2);
  389. tmp &= ~0xc0;
  390. tmp |= (up->cached_ebrg >> 2) & 0xc0;
  391. writeb(tmp, &up->regs->rw.ccr2);
  392. }
  393. }
  394. /* port->lock held by caller. */
  395. static void sunsab_start_tx(struct uart_port *port)
  396. {
  397. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  398. struct circ_buf *xmit = &up->port.info->xmit;
  399. int i;
  400. up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR);
  401. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  402. if (!test_bit(SAB82532_XPR, &up->irqflags))
  403. return;
  404. clear_bit(SAB82532_ALLS, &up->irqflags);
  405. clear_bit(SAB82532_XPR, &up->irqflags);
  406. for (i = 0; i < up->port.fifosize; i++) {
  407. writeb(xmit->buf[xmit->tail],
  408. &up->regs->w.xfifo[i]);
  409. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  410. up->port.icount.tx++;
  411. if (uart_circ_empty(xmit))
  412. break;
  413. }
  414. /* Issue a Transmit Frame command. */
  415. sunsab_cec_wait(up);
  416. writeb(SAB82532_CMDR_XF, &up->regs->w.cmdr);
  417. }
  418. /* port->lock is not held. */
  419. static void sunsab_send_xchar(struct uart_port *port, char ch)
  420. {
  421. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  422. unsigned long flags;
  423. spin_lock_irqsave(&up->port.lock, flags);
  424. sunsab_tec_wait(up);
  425. writeb(ch, &up->regs->w.tic);
  426. spin_unlock_irqrestore(&up->port.lock, flags);
  427. }
  428. /* port->lock held by caller. */
  429. static void sunsab_stop_rx(struct uart_port *port)
  430. {
  431. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  432. up->interrupt_mask0 |= SAB82532_ISR0_TCD;
  433. writeb(up->interrupt_mask1, &up->regs->w.imr0);
  434. }
  435. /* port->lock held by caller. */
  436. static void sunsab_enable_ms(struct uart_port *port)
  437. {
  438. /* For now we always receive these interrupts. */
  439. }
  440. /* port->lock is not held. */
  441. static void sunsab_break_ctl(struct uart_port *port, int break_state)
  442. {
  443. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  444. unsigned long flags;
  445. unsigned char val;
  446. spin_lock_irqsave(&up->port.lock, flags);
  447. val = up->cached_dafo;
  448. if (break_state)
  449. val |= SAB82532_DAFO_XBRK;
  450. else
  451. val &= ~SAB82532_DAFO_XBRK;
  452. up->cached_dafo = val;
  453. set_bit(SAB82532_REGS_PENDING, &up->irqflags);
  454. if (test_bit(SAB82532_XPR, &up->irqflags))
  455. sunsab_tx_idle(up);
  456. spin_unlock_irqrestore(&up->port.lock, flags);
  457. }
  458. /* port->lock is not held. */
  459. static int sunsab_startup(struct uart_port *port)
  460. {
  461. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  462. unsigned long flags;
  463. unsigned char tmp;
  464. spin_lock_irqsave(&up->port.lock, flags);
  465. /*
  466. * Wait for any commands or immediate characters
  467. */
  468. sunsab_cec_wait(up);
  469. sunsab_tec_wait(up);
  470. /*
  471. * Clear the FIFO buffers.
  472. */
  473. writeb(SAB82532_CMDR_RRES, &up->regs->w.cmdr);
  474. sunsab_cec_wait(up);
  475. writeb(SAB82532_CMDR_XRES, &up->regs->w.cmdr);
  476. /*
  477. * Clear the interrupt registers.
  478. */
  479. (void) readb(&up->regs->r.isr0);
  480. (void) readb(&up->regs->r.isr1);
  481. /*
  482. * Now, initialize the UART
  483. */
  484. writeb(0, &up->regs->w.ccr0); /* power-down */
  485. writeb(SAB82532_CCR0_MCE | SAB82532_CCR0_SC_NRZ |
  486. SAB82532_CCR0_SM_ASYNC, &up->regs->w.ccr0);
  487. writeb(SAB82532_CCR1_ODS | SAB82532_CCR1_BCR | 7, &up->regs->w.ccr1);
  488. writeb(SAB82532_CCR2_BDF | SAB82532_CCR2_SSEL |
  489. SAB82532_CCR2_TOE, &up->regs->w.ccr2);
  490. writeb(0, &up->regs->w.ccr3);
  491. writeb(SAB82532_CCR4_MCK4 | SAB82532_CCR4_EBRG, &up->regs->w.ccr4);
  492. up->cached_mode = (SAB82532_MODE_RTS | SAB82532_MODE_FCTS |
  493. SAB82532_MODE_RAC);
  494. writeb(up->cached_mode, &up->regs->w.mode);
  495. writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc);
  496. tmp = readb(&up->regs->rw.ccr0);
  497. tmp |= SAB82532_CCR0_PU; /* power-up */
  498. writeb(tmp, &up->regs->rw.ccr0);
  499. /*
  500. * Finally, enable interrupts
  501. */
  502. up->interrupt_mask0 = (SAB82532_IMR0_PERR | SAB82532_IMR0_FERR |
  503. SAB82532_IMR0_PLLA);
  504. writeb(up->interrupt_mask0, &up->regs->w.imr0);
  505. up->interrupt_mask1 = (SAB82532_IMR1_BRKT | SAB82532_IMR1_ALLS |
  506. SAB82532_IMR1_XOFF | SAB82532_IMR1_TIN |
  507. SAB82532_IMR1_CSC | SAB82532_IMR1_XON |
  508. SAB82532_IMR1_XPR);
  509. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  510. set_bit(SAB82532_ALLS, &up->irqflags);
  511. set_bit(SAB82532_XPR, &up->irqflags);
  512. spin_unlock_irqrestore(&up->port.lock, flags);
  513. return 0;
  514. }
  515. /* port->lock is not held. */
  516. static void sunsab_shutdown(struct uart_port *port)
  517. {
  518. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  519. unsigned long flags;
  520. spin_lock_irqsave(&up->port.lock, flags);
  521. /* Disable Interrupts */
  522. up->interrupt_mask0 = 0xff;
  523. writeb(up->interrupt_mask0, &up->regs->w.imr0);
  524. up->interrupt_mask1 = 0xff;
  525. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  526. /* Disable break condition */
  527. up->cached_dafo = readb(&up->regs->rw.dafo);
  528. up->cached_dafo &= ~SAB82532_DAFO_XBRK;
  529. writeb(up->cached_dafo, &up->regs->rw.dafo);
  530. /* Disable Receiver */
  531. up->cached_mode &= ~SAB82532_MODE_RAC;
  532. writeb(up->cached_mode, &up->regs->rw.mode);
  533. /*
  534. * XXX FIXME
  535. *
  536. * If the chip is powered down here the system hangs/crashes during
  537. * reboot or shutdown. This needs to be investigated further,
  538. * similar behaviour occurs in 2.4 when the driver is configured
  539. * as a module only. One hint may be that data is sometimes
  540. * transmitted at 9600 baud during shutdown (regardless of the
  541. * speed the chip was configured for when the port was open).
  542. */
  543. #if 0
  544. /* Power Down */
  545. tmp = readb(&up->regs->rw.ccr0);
  546. tmp &= ~SAB82532_CCR0_PU;
  547. writeb(tmp, &up->regs->rw.ccr0);
  548. #endif
  549. spin_unlock_irqrestore(&up->port.lock, flags);
  550. }
  551. /*
  552. * This is used to figure out the divisor speeds.
  553. *
  554. * The formula is: Baud = SAB_BASE_BAUD / ((N + 1) * (1 << M)),
  555. *
  556. * with 0 <= N < 64 and 0 <= M < 16
  557. */
  558. static void calc_ebrg(int baud, int *n_ret, int *m_ret)
  559. {
  560. int n, m;
  561. if (baud == 0) {
  562. *n_ret = 0;
  563. *m_ret = 0;
  564. return;
  565. }
  566. /*
  567. * We scale numbers by 10 so that we get better accuracy
  568. * without having to use floating point. Here we increment m
  569. * until n is within the valid range.
  570. */
  571. n = (SAB_BASE_BAUD * 10) / baud;
  572. m = 0;
  573. while (n >= 640) {
  574. n = n / 2;
  575. m++;
  576. }
  577. n = (n+5) / 10;
  578. /*
  579. * We try very hard to avoid speeds with M == 0 since they may
  580. * not work correctly for XTAL frequences above 10 MHz.
  581. */
  582. if ((m == 0) && ((n & 1) == 0)) {
  583. n = n / 2;
  584. m++;
  585. }
  586. *n_ret = n - 1;
  587. *m_ret = m;
  588. }
  589. /* Internal routine, port->lock is held and local interrupts are disabled. */
  590. static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag,
  591. unsigned int iflag, unsigned int baud,
  592. unsigned int quot)
  593. {
  594. unsigned char dafo;
  595. int bits, n, m;
  596. /* Byte size and parity */
  597. switch (cflag & CSIZE) {
  598. case CS5: dafo = SAB82532_DAFO_CHL5; bits = 7; break;
  599. case CS6: dafo = SAB82532_DAFO_CHL6; bits = 8; break;
  600. case CS7: dafo = SAB82532_DAFO_CHL7; bits = 9; break;
  601. case CS8: dafo = SAB82532_DAFO_CHL8; bits = 10; break;
  602. /* Never happens, but GCC is too dumb to figure it out */
  603. default: dafo = SAB82532_DAFO_CHL5; bits = 7; break;
  604. }
  605. if (cflag & CSTOPB) {
  606. dafo |= SAB82532_DAFO_STOP;
  607. bits++;
  608. }
  609. if (cflag & PARENB) {
  610. dafo |= SAB82532_DAFO_PARE;
  611. bits++;
  612. }
  613. if (cflag & PARODD) {
  614. dafo |= SAB82532_DAFO_PAR_ODD;
  615. } else {
  616. dafo |= SAB82532_DAFO_PAR_EVEN;
  617. }
  618. up->cached_dafo = dafo;
  619. calc_ebrg(baud, &n, &m);
  620. up->cached_ebrg = n | (m << 6);
  621. up->tec_timeout = (10 * 1000000) / baud;
  622. up->cec_timeout = up->tec_timeout >> 2;
  623. /* CTS flow control flags */
  624. /* We encode read_status_mask and ignore_status_mask like so:
  625. *
  626. * ---------------------
  627. * | ... | ISR1 | ISR0 |
  628. * ---------------------
  629. * .. 15 8 7 0
  630. */
  631. up->port.read_status_mask = (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
  632. SAB82532_ISR0_RFO | SAB82532_ISR0_RPF |
  633. SAB82532_ISR0_CDSC);
  634. up->port.read_status_mask |= (SAB82532_ISR1_CSC |
  635. SAB82532_ISR1_ALLS |
  636. SAB82532_ISR1_XPR) << 8;
  637. if (iflag & INPCK)
  638. up->port.read_status_mask |= (SAB82532_ISR0_PERR |
  639. SAB82532_ISR0_FERR);
  640. if (iflag & (BRKINT | PARMRK))
  641. up->port.read_status_mask |= (SAB82532_ISR1_BRK << 8);
  642. /*
  643. * Characteres to ignore
  644. */
  645. up->port.ignore_status_mask = 0;
  646. if (iflag & IGNPAR)
  647. up->port.ignore_status_mask |= (SAB82532_ISR0_PERR |
  648. SAB82532_ISR0_FERR);
  649. if (iflag & IGNBRK) {
  650. up->port.ignore_status_mask |= (SAB82532_ISR1_BRK << 8);
  651. /*
  652. * If we're ignoring parity and break indicators,
  653. * ignore overruns too (for real raw support).
  654. */
  655. if (iflag & IGNPAR)
  656. up->port.ignore_status_mask |= SAB82532_ISR0_RFO;
  657. }
  658. /*
  659. * ignore all characters if CREAD is not set
  660. */
  661. if ((cflag & CREAD) == 0)
  662. up->port.ignore_status_mask |= (SAB82532_ISR0_RPF |
  663. SAB82532_ISR0_TCD);
  664. uart_update_timeout(&up->port, cflag,
  665. (up->port.uartclk / (16 * quot)));
  666. /* Now schedule a register update when the chip's
  667. * transmitter is idle.
  668. */
  669. up->cached_mode |= SAB82532_MODE_RAC;
  670. set_bit(SAB82532_REGS_PENDING, &up->irqflags);
  671. if (test_bit(SAB82532_XPR, &up->irqflags))
  672. sunsab_tx_idle(up);
  673. }
  674. /* port->lock is not held. */
  675. static void sunsab_set_termios(struct uart_port *port, struct termios *termios,
  676. struct termios *old)
  677. {
  678. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  679. unsigned long flags;
  680. unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
  681. unsigned int quot = uart_get_divisor(port, baud);
  682. spin_lock_irqsave(&up->port.lock, flags);
  683. sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud, quot);
  684. spin_unlock_irqrestore(&up->port.lock, flags);
  685. }
  686. static const char *sunsab_type(struct uart_port *port)
  687. {
  688. struct uart_sunsab_port *up = (void *)port;
  689. static char buf[36];
  690. sprintf(buf, "SAB82532 %s", sab82532_version[up->type]);
  691. return buf;
  692. }
  693. static void sunsab_release_port(struct uart_port *port)
  694. {
  695. }
  696. static int sunsab_request_port(struct uart_port *port)
  697. {
  698. return 0;
  699. }
  700. static void sunsab_config_port(struct uart_port *port, int flags)
  701. {
  702. }
  703. static int sunsab_verify_port(struct uart_port *port, struct serial_struct *ser)
  704. {
  705. return -EINVAL;
  706. }
  707. static struct uart_ops sunsab_pops = {
  708. .tx_empty = sunsab_tx_empty,
  709. .set_mctrl = sunsab_set_mctrl,
  710. .get_mctrl = sunsab_get_mctrl,
  711. .stop_tx = sunsab_stop_tx,
  712. .start_tx = sunsab_start_tx,
  713. .send_xchar = sunsab_send_xchar,
  714. .stop_rx = sunsab_stop_rx,
  715. .enable_ms = sunsab_enable_ms,
  716. .break_ctl = sunsab_break_ctl,
  717. .startup = sunsab_startup,
  718. .shutdown = sunsab_shutdown,
  719. .set_termios = sunsab_set_termios,
  720. .type = sunsab_type,
  721. .release_port = sunsab_release_port,
  722. .request_port = sunsab_request_port,
  723. .config_port = sunsab_config_port,
  724. .verify_port = sunsab_verify_port,
  725. };
  726. static struct uart_driver sunsab_reg = {
  727. .owner = THIS_MODULE,
  728. .driver_name = "serial",
  729. .devfs_name = "tts/",
  730. .dev_name = "ttyS",
  731. .major = TTY_MAJOR,
  732. };
  733. static struct uart_sunsab_port *sunsab_ports;
  734. static int num_channels;
  735. #ifdef CONFIG_SERIAL_SUNSAB_CONSOLE
  736. static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char c)
  737. {
  738. unsigned long flags;
  739. spin_lock_irqsave(&up->port.lock, flags);
  740. sunsab_tec_wait(up);
  741. writeb(c, &up->regs->w.tic);
  742. spin_unlock_irqrestore(&up->port.lock, flags);
  743. }
  744. static void sunsab_console_write(struct console *con, const char *s, unsigned n)
  745. {
  746. struct uart_sunsab_port *up = &sunsab_ports[con->index];
  747. int i;
  748. for (i = 0; i < n; i++) {
  749. if (*s == '\n')
  750. sunsab_console_putchar(up, '\r');
  751. sunsab_console_putchar(up, *s++);
  752. }
  753. sunsab_tec_wait(up);
  754. }
  755. static int sunsab_console_setup(struct console *con, char *options)
  756. {
  757. struct uart_sunsab_port *up = &sunsab_ports[con->index];
  758. unsigned long flags;
  759. unsigned int baud, quot;
  760. printk("Console: ttyS%d (SAB82532)\n",
  761. (sunsab_reg.minor - 64) + con->index);
  762. sunserial_console_termios(con);
  763. /* Firmware console speed is limited to 150-->38400 baud so
  764. * this hackish cflag thing is OK.
  765. */
  766. switch (con->cflag & CBAUD) {
  767. case B150: baud = 150; break;
  768. case B300: baud = 300; break;
  769. case B600: baud = 600; break;
  770. case B1200: baud = 1200; break;
  771. case B2400: baud = 2400; break;
  772. case B4800: baud = 4800; break;
  773. default: case B9600: baud = 9600; break;
  774. case B19200: baud = 19200; break;
  775. case B38400: baud = 38400; break;
  776. };
  777. /*
  778. * Temporary fix.
  779. */
  780. spin_lock_init(&up->port.lock);
  781. /*
  782. * Initialize the hardware
  783. */
  784. sunsab_startup(&up->port);
  785. spin_lock_irqsave(&up->port.lock, flags);
  786. /*
  787. * Finally, enable interrupts
  788. */
  789. up->interrupt_mask0 = SAB82532_IMR0_PERR | SAB82532_IMR0_FERR |
  790. SAB82532_IMR0_PLLA | SAB82532_IMR0_CDSC;
  791. writeb(up->interrupt_mask0, &up->regs->w.imr0);
  792. up->interrupt_mask1 = SAB82532_IMR1_BRKT | SAB82532_IMR1_ALLS |
  793. SAB82532_IMR1_XOFF | SAB82532_IMR1_TIN |
  794. SAB82532_IMR1_CSC | SAB82532_IMR1_XON |
  795. SAB82532_IMR1_XPR;
  796. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  797. quot = uart_get_divisor(&up->port, baud);
  798. sunsab_convert_to_sab(up, con->cflag, 0, baud, quot);
  799. sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS);
  800. spin_unlock_irqrestore(&up->port.lock, flags);
  801. return 0;
  802. }
  803. static struct console sunsab_console = {
  804. .name = "ttyS",
  805. .write = sunsab_console_write,
  806. .device = uart_console_device,
  807. .setup = sunsab_console_setup,
  808. .flags = CON_PRINTBUFFER,
  809. .index = -1,
  810. .data = &sunsab_reg,
  811. };
  812. #define SUNSAB_CONSOLE (&sunsab_console)
  813. static void __init sunsab_console_init(void)
  814. {
  815. int i;
  816. if (con_is_present())
  817. return;
  818. for (i = 0; i < num_channels; i++) {
  819. int this_minor = sunsab_reg.minor + i;
  820. if ((this_minor - 64) == (serial_console - 1))
  821. break;
  822. }
  823. if (i == num_channels)
  824. return;
  825. sunsab_console.index = i;
  826. register_console(&sunsab_console);
  827. }
  828. #else
  829. #define SUNSAB_CONSOLE (NULL)
  830. #define sunsab_console_init() do { } while (0)
  831. #endif
  832. static void __init for_each_sab_edev(void (*callback)(struct linux_ebus_device *, void *), void *arg)
  833. {
  834. struct linux_ebus *ebus;
  835. struct linux_ebus_device *edev = NULL;
  836. for_each_ebus(ebus) {
  837. for_each_ebusdev(edev, ebus) {
  838. if (!strcmp(edev->prom_name, "se")) {
  839. callback(edev, arg);
  840. continue;
  841. } else if (!strcmp(edev->prom_name, "serial")) {
  842. char compat[32];
  843. int clen;
  844. /* On RIO this can be an SE, check it. We could
  845. * just check ebus->is_rio, but this is more portable.
  846. */
  847. clen = prom_getproperty(edev->prom_node, "compatible",
  848. compat, sizeof(compat));
  849. if (clen > 0) {
  850. if (strncmp(compat, "sab82532", 8) == 0) {
  851. callback(edev, arg);
  852. continue;
  853. }
  854. }
  855. }
  856. }
  857. }
  858. }
  859. static void __init sab_count_callback(struct linux_ebus_device *edev, void *arg)
  860. {
  861. int *count_p = arg;
  862. (*count_p)++;
  863. }
  864. static void __init sab_attach_callback(struct linux_ebus_device *edev, void *arg)
  865. {
  866. int *instance_p = arg;
  867. struct uart_sunsab_port *up;
  868. unsigned long regs, offset;
  869. int i;
  870. /* Note: ports are located in reverse order */
  871. regs = edev->resource[0].start;
  872. offset = sizeof(union sab82532_async_regs);
  873. for (i = 0; i < 2; i++) {
  874. up = &sunsab_ports[(*instance_p * 2) + 1 - i];
  875. memset(up, 0, sizeof(*up));
  876. up->regs = ioremap(regs + offset, sizeof(union sab82532_async_regs));
  877. up->port.irq = edev->irqs[0];
  878. up->port.fifosize = SAB82532_XMIT_FIFO_SIZE;
  879. up->port.mapbase = (unsigned long)up->regs;
  880. up->port.iotype = SERIAL_IO_MEM;
  881. writeb(SAB82532_IPC_IC_ACT_LOW, &up->regs->w.ipc);
  882. offset -= sizeof(union sab82532_async_regs);
  883. }
  884. (*instance_p)++;
  885. }
  886. static int __init probe_for_sabs(void)
  887. {
  888. int this_sab = 0;
  889. /* Find device instances. */
  890. for_each_sab_edev(&sab_count_callback, &this_sab);
  891. if (!this_sab)
  892. return -ENODEV;
  893. /* Allocate tables. */
  894. sunsab_ports = kmalloc(sizeof(struct uart_sunsab_port) * this_sab * 2,
  895. GFP_KERNEL);
  896. if (!sunsab_ports)
  897. return -ENOMEM;
  898. num_channels = this_sab * 2;
  899. this_sab = 0;
  900. for_each_sab_edev(&sab_attach_callback, &this_sab);
  901. return 0;
  902. }
  903. static void __init sunsab_init_hw(void)
  904. {
  905. int i;
  906. for (i = 0; i < num_channels; i++) {
  907. struct uart_sunsab_port *up = &sunsab_ports[i];
  908. up->port.line = i;
  909. up->port.ops = &sunsab_pops;
  910. up->port.type = PORT_SUNSAB;
  911. up->port.uartclk = SAB_BASE_BAUD;
  912. up->type = readb(&up->regs->r.vstr) & 0x0f;
  913. writeb(~((1 << 1) | (1 << 2) | (1 << 4)), &up->regs->w.pcr);
  914. writeb(0xff, &up->regs->w.pim);
  915. if (up->port.line == 0) {
  916. up->pvr_dsr_bit = (1 << 0);
  917. up->pvr_dtr_bit = (1 << 1);
  918. } else {
  919. up->pvr_dsr_bit = (1 << 3);
  920. up->pvr_dtr_bit = (1 << 2);
  921. }
  922. up->cached_pvr = (1 << 1) | (1 << 2) | (1 << 4);
  923. writeb(up->cached_pvr, &up->regs->w.pvr);
  924. up->cached_mode = readb(&up->regs->rw.mode);
  925. up->cached_mode |= SAB82532_MODE_FRTS;
  926. writeb(up->cached_mode, &up->regs->rw.mode);
  927. up->cached_mode |= SAB82532_MODE_RTS;
  928. writeb(up->cached_mode, &up->regs->rw.mode);
  929. up->tec_timeout = SAB82532_MAX_TEC_TIMEOUT;
  930. up->cec_timeout = SAB82532_MAX_CEC_TIMEOUT;
  931. if (!(up->port.line & 0x01)) {
  932. if (request_irq(up->port.irq, sunsab_interrupt,
  933. SA_SHIRQ, "serial(sab82532)", up)) {
  934. printk("sunsab%d: can't get IRQ %x\n",
  935. i, up->port.irq);
  936. continue;
  937. }
  938. }
  939. }
  940. }
  941. static int __init sunsab_init(void)
  942. {
  943. int ret = probe_for_sabs();
  944. int i;
  945. if (ret < 0)
  946. return ret;
  947. sunsab_init_hw();
  948. sunsab_reg.minor = sunserial_current_minor;
  949. sunsab_reg.nr = num_channels;
  950. sunsab_reg.cons = SUNSAB_CONSOLE;
  951. ret = uart_register_driver(&sunsab_reg);
  952. if (ret < 0) {
  953. int i;
  954. for (i = 0; i < num_channels; i++) {
  955. struct uart_sunsab_port *up = &sunsab_ports[i];
  956. if (!(up->port.line & 0x01))
  957. free_irq(up->port.irq, up);
  958. iounmap(up->regs);
  959. }
  960. kfree(sunsab_ports);
  961. sunsab_ports = NULL;
  962. return ret;
  963. }
  964. sunserial_current_minor += num_channels;
  965. sunsab_console_init();
  966. for (i = 0; i < num_channels; i++) {
  967. struct uart_sunsab_port *up = &sunsab_ports[i];
  968. uart_add_one_port(&sunsab_reg, &up->port);
  969. }
  970. return 0;
  971. }
  972. static void __exit sunsab_exit(void)
  973. {
  974. int i;
  975. for (i = 0; i < num_channels; i++) {
  976. struct uart_sunsab_port *up = &sunsab_ports[i];
  977. uart_remove_one_port(&sunsab_reg, &up->port);
  978. if (!(up->port.line & 0x01))
  979. free_irq(up->port.irq, up);
  980. iounmap(up->regs);
  981. }
  982. sunserial_current_minor -= num_channels;
  983. uart_unregister_driver(&sunsab_reg);
  984. kfree(sunsab_ports);
  985. sunsab_ports = NULL;
  986. }
  987. module_init(sunsab_init);
  988. module_exit(sunsab_exit);
  989. MODULE_AUTHOR("Eddie C. Dost and David S. Miller");
  990. MODULE_DESCRIPTION("Sun SAB82532 serial port driver");
  991. MODULE_LICENSE("GPL");