sunsab.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  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 *, unsigned int);
  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. uart_write_wakeup(&up->port);
  236. return;
  237. }
  238. up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR);
  239. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  240. clear_bit(SAB82532_ALLS, &up->irqflags);
  241. /* Stuff 32 bytes into Transmit FIFO. */
  242. clear_bit(SAB82532_XPR, &up->irqflags);
  243. for (i = 0; i < up->port.fifosize; i++) {
  244. writeb(xmit->buf[xmit->tail],
  245. &up->regs->w.xfifo[i]);
  246. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  247. up->port.icount.tx++;
  248. if (uart_circ_empty(xmit))
  249. break;
  250. }
  251. /* Issue a Transmit Frame command. */
  252. sunsab_cec_wait(up);
  253. writeb(SAB82532_CMDR_XF, &up->regs->w.cmdr);
  254. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  255. uart_write_wakeup(&up->port);
  256. if (uart_circ_empty(xmit))
  257. sunsab_stop_tx(&up->port, 0);
  258. }
  259. static void check_status(struct uart_sunsab_port *up,
  260. union sab82532_irq_status *stat)
  261. {
  262. if (stat->sreg.isr0 & SAB82532_ISR0_CDSC)
  263. uart_handle_dcd_change(&up->port,
  264. !(readb(&up->regs->r.vstr) & SAB82532_VSTR_CD));
  265. if (stat->sreg.isr1 & SAB82532_ISR1_CSC)
  266. uart_handle_cts_change(&up->port,
  267. (readb(&up->regs->r.star) & SAB82532_STAR_CTS));
  268. if ((readb(&up->regs->r.pvr) & up->pvr_dsr_bit) ^ up->dsr) {
  269. up->dsr = (readb(&up->regs->r.pvr) & up->pvr_dsr_bit) ? 0 : 1;
  270. up->port.icount.dsr++;
  271. }
  272. wake_up_interruptible(&up->port.info->delta_msr_wait);
  273. }
  274. static irqreturn_t sunsab_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  275. {
  276. struct uart_sunsab_port *up = dev_id;
  277. struct tty_struct *tty;
  278. union sab82532_irq_status status;
  279. unsigned long flags;
  280. spin_lock_irqsave(&up->port.lock, flags);
  281. status.stat = 0;
  282. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISA0)
  283. status.sreg.isr0 = readb(&up->regs->r.isr0);
  284. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISA1)
  285. status.sreg.isr1 = readb(&up->regs->r.isr1);
  286. tty = NULL;
  287. if (status.stat) {
  288. if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
  289. SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) ||
  290. (status.sreg.isr1 & SAB82532_ISR1_BRK))
  291. tty = receive_chars(up, &status, regs);
  292. if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) ||
  293. (status.sreg.isr1 & SAB82532_ISR1_CSC))
  294. check_status(up, &status);
  295. if (status.sreg.isr1 & (SAB82532_ISR1_ALLS | SAB82532_ISR1_XPR))
  296. transmit_chars(up, &status);
  297. }
  298. spin_unlock(&up->port.lock);
  299. if (tty)
  300. tty_flip_buffer_push(tty);
  301. up++;
  302. spin_lock(&up->port.lock);
  303. status.stat = 0;
  304. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISB0)
  305. status.sreg.isr0 = readb(&up->regs->r.isr0);
  306. if (readb(&up->regs->r.gis) & SAB82532_GIS_ISB1)
  307. status.sreg.isr1 = readb(&up->regs->r.isr1);
  308. tty = NULL;
  309. if (status.stat) {
  310. if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
  311. SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) ||
  312. (status.sreg.isr1 & SAB82532_ISR1_BRK))
  313. tty = receive_chars(up, &status, regs);
  314. if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) ||
  315. (status.sreg.isr1 & (SAB82532_ISR1_BRK | SAB82532_ISR1_CSC)))
  316. check_status(up, &status);
  317. if (status.sreg.isr1 & (SAB82532_ISR1_ALLS | SAB82532_ISR1_XPR))
  318. transmit_chars(up, &status);
  319. }
  320. spin_unlock_irqrestore(&up->port.lock, flags);
  321. if (tty)
  322. tty_flip_buffer_push(tty);
  323. return IRQ_HANDLED;
  324. }
  325. /* port->lock is not held. */
  326. static unsigned int sunsab_tx_empty(struct uart_port *port)
  327. {
  328. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  329. int ret;
  330. /* Do not need a lock for a state test like this. */
  331. if (test_bit(SAB82532_ALLS, &up->irqflags))
  332. ret = TIOCSER_TEMT;
  333. else
  334. ret = 0;
  335. return ret;
  336. }
  337. /* port->lock held by caller. */
  338. static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl)
  339. {
  340. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  341. if (mctrl & TIOCM_RTS) {
  342. up->cached_mode &= ~SAB82532_MODE_FRTS;
  343. up->cached_mode |= SAB82532_MODE_RTS;
  344. } else {
  345. up->cached_mode |= (SAB82532_MODE_FRTS |
  346. SAB82532_MODE_RTS);
  347. }
  348. if (mctrl & TIOCM_DTR) {
  349. up->cached_pvr &= ~(up->pvr_dtr_bit);
  350. } else {
  351. up->cached_pvr |= up->pvr_dtr_bit;
  352. }
  353. set_bit(SAB82532_REGS_PENDING, &up->irqflags);
  354. if (test_bit(SAB82532_XPR, &up->irqflags))
  355. sunsab_tx_idle(up);
  356. }
  357. /* port->lock is not held. */
  358. static unsigned int sunsab_get_mctrl(struct uart_port *port)
  359. {
  360. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  361. unsigned long flags;
  362. unsigned char val;
  363. unsigned int result;
  364. result = 0;
  365. spin_lock_irqsave(&up->port.lock, flags);
  366. val = readb(&up->regs->r.pvr);
  367. result |= (val & up->pvr_dsr_bit) ? 0 : TIOCM_DSR;
  368. val = readb(&up->regs->r.vstr);
  369. result |= (val & SAB82532_VSTR_CD) ? 0 : TIOCM_CAR;
  370. val = readb(&up->regs->r.star);
  371. result |= (val & SAB82532_STAR_CTS) ? TIOCM_CTS : 0;
  372. spin_unlock_irqrestore(&up->port.lock, flags);
  373. return result;
  374. }
  375. /* port->lock held by caller. */
  376. static void sunsab_stop_tx(struct uart_port *port, unsigned int tty_stop)
  377. {
  378. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  379. up->interrupt_mask1 |= SAB82532_IMR1_XPR;
  380. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  381. }
  382. /* port->lock held by caller. */
  383. static void sunsab_tx_idle(struct uart_sunsab_port *up)
  384. {
  385. if (test_bit(SAB82532_REGS_PENDING, &up->irqflags)) {
  386. u8 tmp;
  387. clear_bit(SAB82532_REGS_PENDING, &up->irqflags);
  388. writeb(up->cached_mode, &up->regs->rw.mode);
  389. writeb(up->cached_pvr, &up->regs->rw.pvr);
  390. writeb(up->cached_dafo, &up->regs->w.dafo);
  391. writeb(up->cached_ebrg & 0xff, &up->regs->w.bgr);
  392. tmp = readb(&up->regs->rw.ccr2);
  393. tmp &= ~0xc0;
  394. tmp |= (up->cached_ebrg >> 2) & 0xc0;
  395. writeb(tmp, &up->regs->rw.ccr2);
  396. }
  397. }
  398. /* port->lock held by caller. */
  399. static void sunsab_start_tx(struct uart_port *port, unsigned int tty_start)
  400. {
  401. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  402. struct circ_buf *xmit = &up->port.info->xmit;
  403. int i;
  404. up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR);
  405. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  406. if (!test_bit(SAB82532_XPR, &up->irqflags))
  407. return;
  408. clear_bit(SAB82532_ALLS, &up->irqflags);
  409. clear_bit(SAB82532_XPR, &up->irqflags);
  410. for (i = 0; i < up->port.fifosize; i++) {
  411. writeb(xmit->buf[xmit->tail],
  412. &up->regs->w.xfifo[i]);
  413. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  414. up->port.icount.tx++;
  415. if (uart_circ_empty(xmit))
  416. break;
  417. }
  418. /* Issue a Transmit Frame command. */
  419. sunsab_cec_wait(up);
  420. writeb(SAB82532_CMDR_XF, &up->regs->w.cmdr);
  421. }
  422. /* port->lock is not held. */
  423. static void sunsab_send_xchar(struct uart_port *port, char ch)
  424. {
  425. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  426. unsigned long flags;
  427. spin_lock_irqsave(&up->port.lock, flags);
  428. sunsab_tec_wait(up);
  429. writeb(ch, &up->regs->w.tic);
  430. spin_unlock_irqrestore(&up->port.lock, flags);
  431. }
  432. /* port->lock held by caller. */
  433. static void sunsab_stop_rx(struct uart_port *port)
  434. {
  435. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  436. up->interrupt_mask0 |= SAB82532_ISR0_TCD;
  437. writeb(up->interrupt_mask1, &up->regs->w.imr0);
  438. }
  439. /* port->lock held by caller. */
  440. static void sunsab_enable_ms(struct uart_port *port)
  441. {
  442. /* For now we always receive these interrupts. */
  443. }
  444. /* port->lock is not held. */
  445. static void sunsab_break_ctl(struct uart_port *port, int break_state)
  446. {
  447. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  448. unsigned long flags;
  449. unsigned char val;
  450. spin_lock_irqsave(&up->port.lock, flags);
  451. val = up->cached_dafo;
  452. if (break_state)
  453. val |= SAB82532_DAFO_XBRK;
  454. else
  455. val &= ~SAB82532_DAFO_XBRK;
  456. up->cached_dafo = val;
  457. set_bit(SAB82532_REGS_PENDING, &up->irqflags);
  458. if (test_bit(SAB82532_XPR, &up->irqflags))
  459. sunsab_tx_idle(up);
  460. spin_unlock_irqrestore(&up->port.lock, flags);
  461. }
  462. /* port->lock is not held. */
  463. static int sunsab_startup(struct uart_port *port)
  464. {
  465. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  466. unsigned long flags;
  467. unsigned char tmp;
  468. spin_lock_irqsave(&up->port.lock, flags);
  469. /*
  470. * Wait for any commands or immediate characters
  471. */
  472. sunsab_cec_wait(up);
  473. sunsab_tec_wait(up);
  474. /*
  475. * Clear the FIFO buffers.
  476. */
  477. writeb(SAB82532_CMDR_RRES, &up->regs->w.cmdr);
  478. sunsab_cec_wait(up);
  479. writeb(SAB82532_CMDR_XRES, &up->regs->w.cmdr);
  480. /*
  481. * Clear the interrupt registers.
  482. */
  483. (void) readb(&up->regs->r.isr0);
  484. (void) readb(&up->regs->r.isr1);
  485. /*
  486. * Now, initialize the UART
  487. */
  488. writeb(0, &up->regs->w.ccr0); /* power-down */
  489. writeb(SAB82532_CCR0_MCE | SAB82532_CCR0_SC_NRZ |
  490. SAB82532_CCR0_SM_ASYNC, &up->regs->w.ccr0);
  491. writeb(SAB82532_CCR1_ODS | SAB82532_CCR1_BCR | 7, &up->regs->w.ccr1);
  492. writeb(SAB82532_CCR2_BDF | SAB82532_CCR2_SSEL |
  493. SAB82532_CCR2_TOE, &up->regs->w.ccr2);
  494. writeb(0, &up->regs->w.ccr3);
  495. writeb(SAB82532_CCR4_MCK4 | SAB82532_CCR4_EBRG, &up->regs->w.ccr4);
  496. up->cached_mode = (SAB82532_MODE_RTS | SAB82532_MODE_FCTS |
  497. SAB82532_MODE_RAC);
  498. writeb(up->cached_mode, &up->regs->w.mode);
  499. writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc);
  500. tmp = readb(&up->regs->rw.ccr0);
  501. tmp |= SAB82532_CCR0_PU; /* power-up */
  502. writeb(tmp, &up->regs->rw.ccr0);
  503. /*
  504. * Finally, enable interrupts
  505. */
  506. up->interrupt_mask0 = (SAB82532_IMR0_PERR | SAB82532_IMR0_FERR |
  507. SAB82532_IMR0_PLLA);
  508. writeb(up->interrupt_mask0, &up->regs->w.imr0);
  509. up->interrupt_mask1 = (SAB82532_IMR1_BRKT | SAB82532_IMR1_ALLS |
  510. SAB82532_IMR1_XOFF | SAB82532_IMR1_TIN |
  511. SAB82532_IMR1_CSC | SAB82532_IMR1_XON |
  512. SAB82532_IMR1_XPR);
  513. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  514. set_bit(SAB82532_ALLS, &up->irqflags);
  515. set_bit(SAB82532_XPR, &up->irqflags);
  516. spin_unlock_irqrestore(&up->port.lock, flags);
  517. return 0;
  518. }
  519. /* port->lock is not held. */
  520. static void sunsab_shutdown(struct uart_port *port)
  521. {
  522. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  523. unsigned long flags;
  524. spin_lock_irqsave(&up->port.lock, flags);
  525. /* Disable Interrupts */
  526. up->interrupt_mask0 = 0xff;
  527. writeb(up->interrupt_mask0, &up->regs->w.imr0);
  528. up->interrupt_mask1 = 0xff;
  529. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  530. /* Disable break condition */
  531. up->cached_dafo = readb(&up->regs->rw.dafo);
  532. up->cached_dafo &= ~SAB82532_DAFO_XBRK;
  533. writeb(up->cached_dafo, &up->regs->rw.dafo);
  534. /* Disable Receiver */
  535. up->cached_mode &= ~SAB82532_MODE_RAC;
  536. writeb(up->cached_mode, &up->regs->rw.mode);
  537. /*
  538. * XXX FIXME
  539. *
  540. * If the chip is powered down here the system hangs/crashes during
  541. * reboot or shutdown. This needs to be investigated further,
  542. * similar behaviour occurs in 2.4 when the driver is configured
  543. * as a module only. One hint may be that data is sometimes
  544. * transmitted at 9600 baud during shutdown (regardless of the
  545. * speed the chip was configured for when the port was open).
  546. */
  547. #if 0
  548. /* Power Down */
  549. tmp = readb(&up->regs->rw.ccr0);
  550. tmp &= ~SAB82532_CCR0_PU;
  551. writeb(tmp, &up->regs->rw.ccr0);
  552. #endif
  553. spin_unlock_irqrestore(&up->port.lock, flags);
  554. }
  555. /*
  556. * This is used to figure out the divisor speeds.
  557. *
  558. * The formula is: Baud = SAB_BASE_BAUD / ((N + 1) * (1 << M)),
  559. *
  560. * with 0 <= N < 64 and 0 <= M < 16
  561. */
  562. static void calc_ebrg(int baud, int *n_ret, int *m_ret)
  563. {
  564. int n, m;
  565. if (baud == 0) {
  566. *n_ret = 0;
  567. *m_ret = 0;
  568. return;
  569. }
  570. /*
  571. * We scale numbers by 10 so that we get better accuracy
  572. * without having to use floating point. Here we increment m
  573. * until n is within the valid range.
  574. */
  575. n = (SAB_BASE_BAUD * 10) / baud;
  576. m = 0;
  577. while (n >= 640) {
  578. n = n / 2;
  579. m++;
  580. }
  581. n = (n+5) / 10;
  582. /*
  583. * We try very hard to avoid speeds with M == 0 since they may
  584. * not work correctly for XTAL frequences above 10 MHz.
  585. */
  586. if ((m == 0) && ((n & 1) == 0)) {
  587. n = n / 2;
  588. m++;
  589. }
  590. *n_ret = n - 1;
  591. *m_ret = m;
  592. }
  593. /* Internal routine, port->lock is held and local interrupts are disabled. */
  594. static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag,
  595. unsigned int iflag, unsigned int baud,
  596. unsigned int quot)
  597. {
  598. unsigned char dafo;
  599. int bits, n, m;
  600. /* Byte size and parity */
  601. switch (cflag & CSIZE) {
  602. case CS5: dafo = SAB82532_DAFO_CHL5; bits = 7; break;
  603. case CS6: dafo = SAB82532_DAFO_CHL6; bits = 8; break;
  604. case CS7: dafo = SAB82532_DAFO_CHL7; bits = 9; break;
  605. case CS8: dafo = SAB82532_DAFO_CHL8; bits = 10; break;
  606. /* Never happens, but GCC is too dumb to figure it out */
  607. default: dafo = SAB82532_DAFO_CHL5; bits = 7; break;
  608. }
  609. if (cflag & CSTOPB) {
  610. dafo |= SAB82532_DAFO_STOP;
  611. bits++;
  612. }
  613. if (cflag & PARENB) {
  614. dafo |= SAB82532_DAFO_PARE;
  615. bits++;
  616. }
  617. if (cflag & PARODD) {
  618. dafo |= SAB82532_DAFO_PAR_ODD;
  619. } else {
  620. dafo |= SAB82532_DAFO_PAR_EVEN;
  621. }
  622. up->cached_dafo = dafo;
  623. calc_ebrg(baud, &n, &m);
  624. up->cached_ebrg = n | (m << 6);
  625. up->tec_timeout = (10 * 1000000) / baud;
  626. up->cec_timeout = up->tec_timeout >> 2;
  627. /* CTS flow control flags */
  628. /* We encode read_status_mask and ignore_status_mask like so:
  629. *
  630. * ---------------------
  631. * | ... | ISR1 | ISR0 |
  632. * ---------------------
  633. * .. 15 8 7 0
  634. */
  635. up->port.read_status_mask = (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME |
  636. SAB82532_ISR0_RFO | SAB82532_ISR0_RPF |
  637. SAB82532_ISR0_CDSC);
  638. up->port.read_status_mask |= (SAB82532_ISR1_CSC |
  639. SAB82532_ISR1_ALLS |
  640. SAB82532_ISR1_XPR) << 8;
  641. if (iflag & INPCK)
  642. up->port.read_status_mask |= (SAB82532_ISR0_PERR |
  643. SAB82532_ISR0_FERR);
  644. if (iflag & (BRKINT | PARMRK))
  645. up->port.read_status_mask |= (SAB82532_ISR1_BRK << 8);
  646. /*
  647. * Characteres to ignore
  648. */
  649. up->port.ignore_status_mask = 0;
  650. if (iflag & IGNPAR)
  651. up->port.ignore_status_mask |= (SAB82532_ISR0_PERR |
  652. SAB82532_ISR0_FERR);
  653. if (iflag & IGNBRK) {
  654. up->port.ignore_status_mask |= (SAB82532_ISR1_BRK << 8);
  655. /*
  656. * If we're ignoring parity and break indicators,
  657. * ignore overruns too (for real raw support).
  658. */
  659. if (iflag & IGNPAR)
  660. up->port.ignore_status_mask |= SAB82532_ISR0_RFO;
  661. }
  662. /*
  663. * ignore all characters if CREAD is not set
  664. */
  665. if ((cflag & CREAD) == 0)
  666. up->port.ignore_status_mask |= (SAB82532_ISR0_RPF |
  667. SAB82532_ISR0_TCD);
  668. uart_update_timeout(&up->port, cflag,
  669. (up->port.uartclk / (16 * quot)));
  670. /* Now schedule a register update when the chip's
  671. * transmitter is idle.
  672. */
  673. up->cached_mode |= SAB82532_MODE_RAC;
  674. set_bit(SAB82532_REGS_PENDING, &up->irqflags);
  675. if (test_bit(SAB82532_XPR, &up->irqflags))
  676. sunsab_tx_idle(up);
  677. }
  678. /* port->lock is not held. */
  679. static void sunsab_set_termios(struct uart_port *port, struct termios *termios,
  680. struct termios *old)
  681. {
  682. struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
  683. unsigned long flags;
  684. unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
  685. unsigned int quot = uart_get_divisor(port, baud);
  686. spin_lock_irqsave(&up->port.lock, flags);
  687. sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud, quot);
  688. spin_unlock_irqrestore(&up->port.lock, flags);
  689. }
  690. static const char *sunsab_type(struct uart_port *port)
  691. {
  692. struct uart_sunsab_port *up = (void *)port;
  693. static char buf[36];
  694. sprintf(buf, "SAB82532 %s", sab82532_version[up->type]);
  695. return buf;
  696. }
  697. static void sunsab_release_port(struct uart_port *port)
  698. {
  699. }
  700. static int sunsab_request_port(struct uart_port *port)
  701. {
  702. return 0;
  703. }
  704. static void sunsab_config_port(struct uart_port *port, int flags)
  705. {
  706. }
  707. static int sunsab_verify_port(struct uart_port *port, struct serial_struct *ser)
  708. {
  709. return -EINVAL;
  710. }
  711. static struct uart_ops sunsab_pops = {
  712. .tx_empty = sunsab_tx_empty,
  713. .set_mctrl = sunsab_set_mctrl,
  714. .get_mctrl = sunsab_get_mctrl,
  715. .stop_tx = sunsab_stop_tx,
  716. .start_tx = sunsab_start_tx,
  717. .send_xchar = sunsab_send_xchar,
  718. .stop_rx = sunsab_stop_rx,
  719. .enable_ms = sunsab_enable_ms,
  720. .break_ctl = sunsab_break_ctl,
  721. .startup = sunsab_startup,
  722. .shutdown = sunsab_shutdown,
  723. .set_termios = sunsab_set_termios,
  724. .type = sunsab_type,
  725. .release_port = sunsab_release_port,
  726. .request_port = sunsab_request_port,
  727. .config_port = sunsab_config_port,
  728. .verify_port = sunsab_verify_port,
  729. };
  730. static struct uart_driver sunsab_reg = {
  731. .owner = THIS_MODULE,
  732. .driver_name = "serial",
  733. .devfs_name = "tts/",
  734. .dev_name = "ttyS",
  735. .major = TTY_MAJOR,
  736. };
  737. static struct uart_sunsab_port *sunsab_ports;
  738. static int num_channels;
  739. #ifdef CONFIG_SERIAL_SUNSAB_CONSOLE
  740. static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char c)
  741. {
  742. unsigned long flags;
  743. spin_lock_irqsave(&up->port.lock, flags);
  744. sunsab_tec_wait(up);
  745. writeb(c, &up->regs->w.tic);
  746. spin_unlock_irqrestore(&up->port.lock, flags);
  747. }
  748. static void sunsab_console_write(struct console *con, const char *s, unsigned n)
  749. {
  750. struct uart_sunsab_port *up = &sunsab_ports[con->index];
  751. int i;
  752. for (i = 0; i < n; i++) {
  753. if (*s == '\n')
  754. sunsab_console_putchar(up, '\r');
  755. sunsab_console_putchar(up, *s++);
  756. }
  757. sunsab_tec_wait(up);
  758. }
  759. static int sunsab_console_setup(struct console *con, char *options)
  760. {
  761. struct uart_sunsab_port *up = &sunsab_ports[con->index];
  762. unsigned long flags;
  763. unsigned int baud, quot;
  764. printk("Console: ttyS%d (SAB82532)\n",
  765. (sunsab_reg.minor - 64) + con->index);
  766. sunserial_console_termios(con);
  767. /* Firmware console speed is limited to 150-->38400 baud so
  768. * this hackish cflag thing is OK.
  769. */
  770. switch (con->cflag & CBAUD) {
  771. case B150: baud = 150; break;
  772. case B300: baud = 300; break;
  773. case B600: baud = 600; break;
  774. case B1200: baud = 1200; break;
  775. case B2400: baud = 2400; break;
  776. case B4800: baud = 4800; break;
  777. default: case B9600: baud = 9600; break;
  778. case B19200: baud = 19200; break;
  779. case B38400: baud = 38400; break;
  780. };
  781. /*
  782. * Temporary fix.
  783. */
  784. spin_lock_init(&up->port.lock);
  785. /*
  786. * Initialize the hardware
  787. */
  788. sunsab_startup(&up->port);
  789. spin_lock_irqsave(&up->port.lock, flags);
  790. /*
  791. * Finally, enable interrupts
  792. */
  793. up->interrupt_mask0 = SAB82532_IMR0_PERR | SAB82532_IMR0_FERR |
  794. SAB82532_IMR0_PLLA | SAB82532_IMR0_CDSC;
  795. writeb(up->interrupt_mask0, &up->regs->w.imr0);
  796. up->interrupt_mask1 = SAB82532_IMR1_BRKT | SAB82532_IMR1_ALLS |
  797. SAB82532_IMR1_XOFF | SAB82532_IMR1_TIN |
  798. SAB82532_IMR1_CSC | SAB82532_IMR1_XON |
  799. SAB82532_IMR1_XPR;
  800. writeb(up->interrupt_mask1, &up->regs->w.imr1);
  801. quot = uart_get_divisor(&up->port, baud);
  802. sunsab_convert_to_sab(up, con->cflag, 0, baud, quot);
  803. sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS);
  804. spin_unlock_irqrestore(&up->port.lock, flags);
  805. return 0;
  806. }
  807. static struct console sunsab_console = {
  808. .name = "ttyS",
  809. .write = sunsab_console_write,
  810. .device = uart_console_device,
  811. .setup = sunsab_console_setup,
  812. .flags = CON_PRINTBUFFER,
  813. .index = -1,
  814. .data = &sunsab_reg,
  815. };
  816. #define SUNSAB_CONSOLE (&sunsab_console)
  817. static void __init sunsab_console_init(void)
  818. {
  819. int i;
  820. if (con_is_present())
  821. return;
  822. for (i = 0; i < num_channels; i++) {
  823. int this_minor = sunsab_reg.minor + i;
  824. if ((this_minor - 64) == (serial_console - 1))
  825. break;
  826. }
  827. if (i == num_channels)
  828. return;
  829. sunsab_console.index = i;
  830. register_console(&sunsab_console);
  831. }
  832. #else
  833. #define SUNSAB_CONSOLE (NULL)
  834. #define sunsab_console_init() do { } while (0)
  835. #endif
  836. static void __init for_each_sab_edev(void (*callback)(struct linux_ebus_device *, void *), void *arg)
  837. {
  838. struct linux_ebus *ebus;
  839. struct linux_ebus_device *edev = NULL;
  840. for_each_ebus(ebus) {
  841. for_each_ebusdev(edev, ebus) {
  842. if (!strcmp(edev->prom_name, "se")) {
  843. callback(edev, arg);
  844. continue;
  845. } else if (!strcmp(edev->prom_name, "serial")) {
  846. char compat[32];
  847. int clen;
  848. /* On RIO this can be an SE, check it. We could
  849. * just check ebus->is_rio, but this is more portable.
  850. */
  851. clen = prom_getproperty(edev->prom_node, "compatible",
  852. compat, sizeof(compat));
  853. if (clen > 0) {
  854. if (strncmp(compat, "sab82532", 8) == 0) {
  855. callback(edev, arg);
  856. continue;
  857. }
  858. }
  859. }
  860. }
  861. }
  862. }
  863. static void __init sab_count_callback(struct linux_ebus_device *edev, void *arg)
  864. {
  865. int *count_p = arg;
  866. (*count_p)++;
  867. }
  868. static void __init sab_attach_callback(struct linux_ebus_device *edev, void *arg)
  869. {
  870. int *instance_p = arg;
  871. struct uart_sunsab_port *up;
  872. unsigned long regs, offset;
  873. int i;
  874. /* Note: ports are located in reverse order */
  875. regs = edev->resource[0].start;
  876. offset = sizeof(union sab82532_async_regs);
  877. for (i = 0; i < 2; i++) {
  878. up = &sunsab_ports[(*instance_p * 2) + 1 - i];
  879. memset(up, 0, sizeof(*up));
  880. up->regs = ioremap(regs + offset, sizeof(union sab82532_async_regs));
  881. up->port.irq = edev->irqs[0];
  882. up->port.fifosize = SAB82532_XMIT_FIFO_SIZE;
  883. up->port.mapbase = (unsigned long)up->regs;
  884. up->port.iotype = SERIAL_IO_MEM;
  885. writeb(SAB82532_IPC_IC_ACT_LOW, &up->regs->w.ipc);
  886. offset -= sizeof(union sab82532_async_regs);
  887. }
  888. (*instance_p)++;
  889. }
  890. static int __init probe_for_sabs(void)
  891. {
  892. int this_sab = 0;
  893. /* Find device instances. */
  894. for_each_sab_edev(&sab_count_callback, &this_sab);
  895. if (!this_sab)
  896. return -ENODEV;
  897. /* Allocate tables. */
  898. sunsab_ports = kmalloc(sizeof(struct uart_sunsab_port) * this_sab * 2,
  899. GFP_KERNEL);
  900. if (!sunsab_ports)
  901. return -ENOMEM;
  902. num_channels = this_sab * 2;
  903. this_sab = 0;
  904. for_each_sab_edev(&sab_attach_callback, &this_sab);
  905. return 0;
  906. }
  907. static void __init sunsab_init_hw(void)
  908. {
  909. int i;
  910. for (i = 0; i < num_channels; i++) {
  911. struct uart_sunsab_port *up = &sunsab_ports[i];
  912. up->port.line = i;
  913. up->port.ops = &sunsab_pops;
  914. up->port.type = PORT_SUNSAB;
  915. up->port.uartclk = SAB_BASE_BAUD;
  916. up->type = readb(&up->regs->r.vstr) & 0x0f;
  917. writeb(~((1 << 1) | (1 << 2) | (1 << 4)), &up->regs->w.pcr);
  918. writeb(0xff, &up->regs->w.pim);
  919. if (up->port.line == 0) {
  920. up->pvr_dsr_bit = (1 << 0);
  921. up->pvr_dtr_bit = (1 << 1);
  922. } else {
  923. up->pvr_dsr_bit = (1 << 3);
  924. up->pvr_dtr_bit = (1 << 2);
  925. }
  926. up->cached_pvr = (1 << 1) | (1 << 2) | (1 << 4);
  927. writeb(up->cached_pvr, &up->regs->w.pvr);
  928. up->cached_mode = readb(&up->regs->rw.mode);
  929. up->cached_mode |= SAB82532_MODE_FRTS;
  930. writeb(up->cached_mode, &up->regs->rw.mode);
  931. up->cached_mode |= SAB82532_MODE_RTS;
  932. writeb(up->cached_mode, &up->regs->rw.mode);
  933. up->tec_timeout = SAB82532_MAX_TEC_TIMEOUT;
  934. up->cec_timeout = SAB82532_MAX_CEC_TIMEOUT;
  935. if (!(up->port.line & 0x01)) {
  936. if (request_irq(up->port.irq, sunsab_interrupt,
  937. SA_SHIRQ, "serial(sab82532)", up)) {
  938. printk("sunsab%d: can't get IRQ %x\n",
  939. i, up->port.irq);
  940. continue;
  941. }
  942. }
  943. }
  944. }
  945. static int __init sunsab_init(void)
  946. {
  947. int ret = probe_for_sabs();
  948. int i;
  949. if (ret < 0)
  950. return ret;
  951. sunsab_init_hw();
  952. sunsab_reg.minor = sunserial_current_minor;
  953. sunsab_reg.nr = num_channels;
  954. sunsab_reg.cons = SUNSAB_CONSOLE;
  955. ret = uart_register_driver(&sunsab_reg);
  956. if (ret < 0) {
  957. int i;
  958. for (i = 0; i < num_channels; i++) {
  959. struct uart_sunsab_port *up = &sunsab_ports[i];
  960. if (!(up->port.line & 0x01))
  961. free_irq(up->port.irq, up);
  962. iounmap(up->regs);
  963. }
  964. kfree(sunsab_ports);
  965. sunsab_ports = NULL;
  966. return ret;
  967. }
  968. sunserial_current_minor += num_channels;
  969. sunsab_console_init();
  970. for (i = 0; i < num_channels; i++) {
  971. struct uart_sunsab_port *up = &sunsab_ports[i];
  972. uart_add_one_port(&sunsab_reg, &up->port);
  973. }
  974. return 0;
  975. }
  976. static void __exit sunsab_exit(void)
  977. {
  978. int i;
  979. for (i = 0; i < num_channels; i++) {
  980. struct uart_sunsab_port *up = &sunsab_ports[i];
  981. uart_remove_one_port(&sunsab_reg, &up->port);
  982. if (!(up->port.line & 0x01))
  983. free_irq(up->port.irq, up);
  984. iounmap(up->regs);
  985. }
  986. sunserial_current_minor -= num_channels;
  987. uart_unregister_driver(&sunsab_reg);
  988. kfree(sunsab_ports);
  989. sunsab_ports = NULL;
  990. }
  991. module_init(sunsab_init);
  992. module_exit(sunsab_exit);
  993. MODULE_AUTHOR("Eddie C. Dost and David S. Miller");
  994. MODULE_DESCRIPTION("Sun SAB82532 serial port driver");
  995. MODULE_LICENSE("GPL");