serial_txx9.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. /*
  2. * drivers/serial/serial_txx9.c
  3. *
  4. * Derived from many drivers using generic_serial interface,
  5. * especially serial_tx3912.c by Steven J. Hill and r39xx_serial.c
  6. * (was in Linux/VR tree) by Jim Pick.
  7. *
  8. * Copyright (C) 1999 Harald Koerfgen
  9. * Copyright (C) 2000 Jim Pick <jim@jimpick.com>
  10. * Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
  11. * Copyright (C) 2000-2002 Toshiba Corporation
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. *
  17. * Serial driver for TX3927/TX4927/TX4925/TX4938 internal SIO controller
  18. *
  19. * Revision History:
  20. * 0.30 Initial revision. (Renamed from serial_txx927.c)
  21. * 0.31 Use save_flags instead of local_irq_save.
  22. * 0.32 Support SCLK.
  23. * 0.33 Switch TXX9_TTY_NAME by CONFIG_SERIAL_TXX9_STDSERIAL.
  24. * Support TIOCSERGETLSR.
  25. * 0.34 Support slow baudrate.
  26. * 0.40 Merge codes from mainstream kernel (2.4.22).
  27. * 0.41 Fix console checking in rs_shutdown_port().
  28. * Disable flow-control in serial_console_write().
  29. * 0.42 Fix minor compiler warning.
  30. * 1.00 Kernel 2.6. Converted to new serial core (based on 8250.c).
  31. * 1.01 Set fifosize to make tx_empry called properly.
  32. * Use standard uart_get_divisor.
  33. * 1.02 Cleanup. (import 8250.c changes)
  34. * 1.03 Fix low-latency mode. (import 8250.c changes)
  35. * 1.04 Remove usage of deprecated functions, cleanup.
  36. */
  37. #include <linux/config.h>
  38. #if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  39. #define SUPPORT_SYSRQ
  40. #endif
  41. #include <linux/module.h>
  42. #include <linux/ioport.h>
  43. #include <linux/init.h>
  44. #include <linux/console.h>
  45. #include <linux/sysrq.h>
  46. #include <linux/delay.h>
  47. #include <linux/device.h>
  48. #include <linux/pci.h>
  49. #include <linux/tty.h>
  50. #include <linux/tty_flip.h>
  51. #include <linux/serial_core.h>
  52. #include <linux/serial.h>
  53. #include <linux/mutex.h>
  54. #include <asm/io.h>
  55. #include <asm/irq.h>
  56. static char *serial_version = "1.04";
  57. static char *serial_name = "TX39/49 Serial driver";
  58. #define PASS_LIMIT 256
  59. #if !defined(CONFIG_SERIAL_TXX9_STDSERIAL)
  60. /* "ttyS" is used for standard serial driver */
  61. #define TXX9_TTY_NAME "ttyTX"
  62. #define TXX9_TTY_DEVFS_NAME "tttx/"
  63. #define TXX9_TTY_MINOR_START (64 + 64) /* ttyTX0(128), ttyTX1(129) */
  64. #else
  65. /* acts like standard serial driver */
  66. #define TXX9_TTY_NAME "ttyS"
  67. #define TXX9_TTY_DEVFS_NAME "tts/"
  68. #define TXX9_TTY_MINOR_START 64
  69. #endif
  70. #define TXX9_TTY_MAJOR TTY_MAJOR
  71. /* flag aliases */
  72. #define UPF_TXX9_HAVE_CTS_LINE UPF_BUGGY_UART
  73. #define UPF_TXX9_USE_SCLK UPF_MAGIC_MULTIPLIER
  74. #ifdef CONFIG_PCI
  75. /* support for Toshiba TC86C001 SIO */
  76. #define ENABLE_SERIAL_TXX9_PCI
  77. #endif
  78. /*
  79. * Number of serial ports
  80. */
  81. #ifdef ENABLE_SERIAL_TXX9_PCI
  82. #define NR_PCI_BOARDS 4
  83. #define UART_NR (4 + NR_PCI_BOARDS)
  84. #else
  85. #define UART_NR 4
  86. #endif
  87. struct uart_txx9_port {
  88. struct uart_port port;
  89. /*
  90. * We provide a per-port pm hook.
  91. */
  92. void (*pm)(struct uart_port *port,
  93. unsigned int state, unsigned int old);
  94. };
  95. #define TXX9_REGION_SIZE 0x24
  96. /* TXX9 Serial Registers */
  97. #define TXX9_SILCR 0x00
  98. #define TXX9_SIDICR 0x04
  99. #define TXX9_SIDISR 0x08
  100. #define TXX9_SICISR 0x0c
  101. #define TXX9_SIFCR 0x10
  102. #define TXX9_SIFLCR 0x14
  103. #define TXX9_SIBGR 0x18
  104. #define TXX9_SITFIFO 0x1c
  105. #define TXX9_SIRFIFO 0x20
  106. /* SILCR : Line Control */
  107. #define TXX9_SILCR_SCS_MASK 0x00000060
  108. #define TXX9_SILCR_SCS_IMCLK 0x00000000
  109. #define TXX9_SILCR_SCS_IMCLK_BG 0x00000020
  110. #define TXX9_SILCR_SCS_SCLK 0x00000040
  111. #define TXX9_SILCR_SCS_SCLK_BG 0x00000060
  112. #define TXX9_SILCR_UEPS 0x00000010
  113. #define TXX9_SILCR_UPEN 0x00000008
  114. #define TXX9_SILCR_USBL_MASK 0x00000004
  115. #define TXX9_SILCR_USBL_1BIT 0x00000000
  116. #define TXX9_SILCR_USBL_2BIT 0x00000004
  117. #define TXX9_SILCR_UMODE_MASK 0x00000003
  118. #define TXX9_SILCR_UMODE_8BIT 0x00000000
  119. #define TXX9_SILCR_UMODE_7BIT 0x00000001
  120. /* SIDICR : DMA/Int. Control */
  121. #define TXX9_SIDICR_TDE 0x00008000
  122. #define TXX9_SIDICR_RDE 0x00004000
  123. #define TXX9_SIDICR_TIE 0x00002000
  124. #define TXX9_SIDICR_RIE 0x00001000
  125. #define TXX9_SIDICR_SPIE 0x00000800
  126. #define TXX9_SIDICR_CTSAC 0x00000600
  127. #define TXX9_SIDICR_STIE_MASK 0x0000003f
  128. #define TXX9_SIDICR_STIE_OERS 0x00000020
  129. #define TXX9_SIDICR_STIE_CTSS 0x00000010
  130. #define TXX9_SIDICR_STIE_RBRKD 0x00000008
  131. #define TXX9_SIDICR_STIE_TRDY 0x00000004
  132. #define TXX9_SIDICR_STIE_TXALS 0x00000002
  133. #define TXX9_SIDICR_STIE_UBRKD 0x00000001
  134. /* SIDISR : DMA/Int. Status */
  135. #define TXX9_SIDISR_UBRK 0x00008000
  136. #define TXX9_SIDISR_UVALID 0x00004000
  137. #define TXX9_SIDISR_UFER 0x00002000
  138. #define TXX9_SIDISR_UPER 0x00001000
  139. #define TXX9_SIDISR_UOER 0x00000800
  140. #define TXX9_SIDISR_ERI 0x00000400
  141. #define TXX9_SIDISR_TOUT 0x00000200
  142. #define TXX9_SIDISR_TDIS 0x00000100
  143. #define TXX9_SIDISR_RDIS 0x00000080
  144. #define TXX9_SIDISR_STIS 0x00000040
  145. #define TXX9_SIDISR_RFDN_MASK 0x0000001f
  146. /* SICISR : Change Int. Status */
  147. #define TXX9_SICISR_OERS 0x00000020
  148. #define TXX9_SICISR_CTSS 0x00000010
  149. #define TXX9_SICISR_RBRKD 0x00000008
  150. #define TXX9_SICISR_TRDY 0x00000004
  151. #define TXX9_SICISR_TXALS 0x00000002
  152. #define TXX9_SICISR_UBRKD 0x00000001
  153. /* SIFCR : FIFO Control */
  154. #define TXX9_SIFCR_SWRST 0x00008000
  155. #define TXX9_SIFCR_RDIL_MASK 0x00000180
  156. #define TXX9_SIFCR_RDIL_1 0x00000000
  157. #define TXX9_SIFCR_RDIL_4 0x00000080
  158. #define TXX9_SIFCR_RDIL_8 0x00000100
  159. #define TXX9_SIFCR_RDIL_12 0x00000180
  160. #define TXX9_SIFCR_RDIL_MAX 0x00000180
  161. #define TXX9_SIFCR_TDIL_MASK 0x00000018
  162. #define TXX9_SIFCR_TDIL_MASK 0x00000018
  163. #define TXX9_SIFCR_TDIL_1 0x00000000
  164. #define TXX9_SIFCR_TDIL_4 0x00000001
  165. #define TXX9_SIFCR_TDIL_8 0x00000010
  166. #define TXX9_SIFCR_TDIL_MAX 0x00000010
  167. #define TXX9_SIFCR_TFRST 0x00000004
  168. #define TXX9_SIFCR_RFRST 0x00000002
  169. #define TXX9_SIFCR_FRSTE 0x00000001
  170. #define TXX9_SIO_TX_FIFO 8
  171. #define TXX9_SIO_RX_FIFO 16
  172. /* SIFLCR : Flow Control */
  173. #define TXX9_SIFLCR_RCS 0x00001000
  174. #define TXX9_SIFLCR_TES 0x00000800
  175. #define TXX9_SIFLCR_RTSSC 0x00000200
  176. #define TXX9_SIFLCR_RSDE 0x00000100
  177. #define TXX9_SIFLCR_TSDE 0x00000080
  178. #define TXX9_SIFLCR_RTSTL_MASK 0x0000001e
  179. #define TXX9_SIFLCR_RTSTL_MAX 0x0000001e
  180. #define TXX9_SIFLCR_TBRK 0x00000001
  181. /* SIBGR : Baudrate Control */
  182. #define TXX9_SIBGR_BCLK_MASK 0x00000300
  183. #define TXX9_SIBGR_BCLK_T0 0x00000000
  184. #define TXX9_SIBGR_BCLK_T2 0x00000100
  185. #define TXX9_SIBGR_BCLK_T4 0x00000200
  186. #define TXX9_SIBGR_BCLK_T6 0x00000300
  187. #define TXX9_SIBGR_BRD_MASK 0x000000ff
  188. static inline unsigned int sio_in(struct uart_txx9_port *up, int offset)
  189. {
  190. switch (up->port.iotype) {
  191. default:
  192. return *(volatile u32 *)(up->port.membase + offset);
  193. case UPIO_PORT:
  194. return inl(up->port.iobase + offset);
  195. }
  196. }
  197. static inline void
  198. sio_out(struct uart_txx9_port *up, int offset, int value)
  199. {
  200. switch (up->port.iotype) {
  201. default:
  202. *(volatile u32 *)(up->port.membase + offset) = value;
  203. break;
  204. case UPIO_PORT:
  205. outl(value, up->port.iobase + offset);
  206. break;
  207. }
  208. }
  209. static inline void
  210. sio_mask(struct uart_txx9_port *up, int offset, unsigned int value)
  211. {
  212. sio_out(up, offset, sio_in(up, offset) & ~value);
  213. }
  214. static inline void
  215. sio_set(struct uart_txx9_port *up, int offset, unsigned int value)
  216. {
  217. sio_out(up, offset, sio_in(up, offset) | value);
  218. }
  219. static inline void
  220. sio_quot_set(struct uart_txx9_port *up, int quot)
  221. {
  222. quot >>= 1;
  223. if (quot < 256)
  224. sio_out(up, TXX9_SIBGR, quot | TXX9_SIBGR_BCLK_T0);
  225. else if (quot < (256 << 2))
  226. sio_out(up, TXX9_SIBGR, (quot >> 2) | TXX9_SIBGR_BCLK_T2);
  227. else if (quot < (256 << 4))
  228. sio_out(up, TXX9_SIBGR, (quot >> 4) | TXX9_SIBGR_BCLK_T4);
  229. else if (quot < (256 << 6))
  230. sio_out(up, TXX9_SIBGR, (quot >> 6) | TXX9_SIBGR_BCLK_T6);
  231. else
  232. sio_out(up, TXX9_SIBGR, 0xff | TXX9_SIBGR_BCLK_T6);
  233. }
  234. static void serial_txx9_stop_tx(struct uart_port *port)
  235. {
  236. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  237. unsigned long flags;
  238. spin_lock_irqsave(&up->port.lock, flags);
  239. sio_mask(up, TXX9_SIDICR, TXX9_SIDICR_TIE);
  240. spin_unlock_irqrestore(&up->port.lock, flags);
  241. }
  242. static void serial_txx9_start_tx(struct uart_port *port)
  243. {
  244. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  245. unsigned long flags;
  246. spin_lock_irqsave(&up->port.lock, flags);
  247. sio_set(up, TXX9_SIDICR, TXX9_SIDICR_TIE);
  248. spin_unlock_irqrestore(&up->port.lock, flags);
  249. }
  250. static void serial_txx9_stop_rx(struct uart_port *port)
  251. {
  252. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  253. unsigned long flags;
  254. spin_lock_irqsave(&up->port.lock, flags);
  255. up->port.read_status_mask &= ~TXX9_SIDISR_RDIS;
  256. #if 0
  257. sio_mask(up, TXX9_SIDICR, TXX9_SIDICR_RIE);
  258. #endif
  259. spin_unlock_irqrestore(&up->port.lock, flags);
  260. }
  261. static void serial_txx9_enable_ms(struct uart_port *port)
  262. {
  263. /* TXX9-SIO can not control DTR... */
  264. }
  265. static inline void
  266. receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *regs)
  267. {
  268. struct tty_struct *tty = up->port.info->tty;
  269. unsigned char ch;
  270. unsigned int disr = *status;
  271. int max_count = 256;
  272. char flag;
  273. do {
  274. ch = sio_in(up, TXX9_SIRFIFO);
  275. flag = TTY_NORMAL;
  276. up->port.icount.rx++;
  277. if (unlikely(disr & (TXX9_SIDISR_UBRK | TXX9_SIDISR_UPER |
  278. TXX9_SIDISR_UFER | TXX9_SIDISR_UOER))) {
  279. /*
  280. * For statistics only
  281. */
  282. if (disr & TXX9_SIDISR_UBRK) {
  283. disr &= ~(TXX9_SIDISR_UFER | TXX9_SIDISR_UPER);
  284. up->port.icount.brk++;
  285. /*
  286. * We do the SysRQ and SAK checking
  287. * here because otherwise the break
  288. * may get masked by ignore_status_mask
  289. * or read_status_mask.
  290. */
  291. if (uart_handle_break(&up->port))
  292. goto ignore_char;
  293. } else if (disr & TXX9_SIDISR_UPER)
  294. up->port.icount.parity++;
  295. else if (disr & TXX9_SIDISR_UFER)
  296. up->port.icount.frame++;
  297. if (disr & TXX9_SIDISR_UOER)
  298. up->port.icount.overrun++;
  299. /*
  300. * Mask off conditions which should be ingored.
  301. */
  302. disr &= up->port.read_status_mask;
  303. if (disr & TXX9_SIDISR_UBRK) {
  304. flag = TTY_BREAK;
  305. } else if (disr & TXX9_SIDISR_UPER)
  306. flag = TTY_PARITY;
  307. else if (disr & TXX9_SIDISR_UFER)
  308. flag = TTY_FRAME;
  309. }
  310. if (uart_handle_sysrq_char(&up->port, ch, regs))
  311. goto ignore_char;
  312. uart_insert_char(&up->port, disr, TXX9_SIDISR_UOER, ch, flag);
  313. ignore_char:
  314. disr = sio_in(up, TXX9_SIDISR);
  315. } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0));
  316. spin_unlock(&up->port.lock);
  317. tty_flip_buffer_push(tty);
  318. spin_lock(&up->port.lock);
  319. *status = disr;
  320. }
  321. static inline void transmit_chars(struct uart_txx9_port *up)
  322. {
  323. struct circ_buf *xmit = &up->port.info->xmit;
  324. int count;
  325. if (up->port.x_char) {
  326. sio_out(up, TXX9_SITFIFO, up->port.x_char);
  327. up->port.icount.tx++;
  328. up->port.x_char = 0;
  329. return;
  330. }
  331. if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
  332. serial_txx9_stop_tx(&up->port);
  333. return;
  334. }
  335. count = TXX9_SIO_TX_FIFO;
  336. do {
  337. sio_out(up, TXX9_SITFIFO, xmit->buf[xmit->tail]);
  338. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  339. up->port.icount.tx++;
  340. if (uart_circ_empty(xmit))
  341. break;
  342. } while (--count > 0);
  343. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  344. uart_write_wakeup(&up->port);
  345. if (uart_circ_empty(xmit))
  346. serial_txx9_stop_tx(&up->port);
  347. }
  348. static irqreturn_t serial_txx9_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  349. {
  350. int pass_counter = 0;
  351. struct uart_txx9_port *up = dev_id;
  352. unsigned int status;
  353. while (1) {
  354. spin_lock(&up->port.lock);
  355. status = sio_in(up, TXX9_SIDISR);
  356. if (!(sio_in(up, TXX9_SIDICR) & TXX9_SIDICR_TIE))
  357. status &= ~TXX9_SIDISR_TDIS;
  358. if (!(status & (TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS |
  359. TXX9_SIDISR_TOUT))) {
  360. spin_unlock(&up->port.lock);
  361. break;
  362. }
  363. if (status & TXX9_SIDISR_RDIS)
  364. receive_chars(up, &status, regs);
  365. if (status & TXX9_SIDISR_TDIS)
  366. transmit_chars(up);
  367. /* Clear TX/RX Int. Status */
  368. sio_mask(up, TXX9_SIDISR,
  369. TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS |
  370. TXX9_SIDISR_TOUT);
  371. spin_unlock(&up->port.lock);
  372. if (pass_counter++ > PASS_LIMIT)
  373. break;
  374. }
  375. return pass_counter ? IRQ_HANDLED : IRQ_NONE;
  376. }
  377. static unsigned int serial_txx9_tx_empty(struct uart_port *port)
  378. {
  379. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  380. unsigned long flags;
  381. unsigned int ret;
  382. spin_lock_irqsave(&up->port.lock, flags);
  383. ret = (sio_in(up, TXX9_SICISR) & TXX9_SICISR_TXALS) ? TIOCSER_TEMT : 0;
  384. spin_unlock_irqrestore(&up->port.lock, flags);
  385. return ret;
  386. }
  387. static unsigned int serial_txx9_get_mctrl(struct uart_port *port)
  388. {
  389. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  390. unsigned int ret;
  391. ret = ((sio_in(up, TXX9_SIFLCR) & TXX9_SIFLCR_RTSSC) ? 0 : TIOCM_RTS)
  392. | ((sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS) ? 0 : TIOCM_CTS);
  393. return ret;
  394. }
  395. static void serial_txx9_set_mctrl(struct uart_port *port, unsigned int mctrl)
  396. {
  397. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  398. unsigned long flags;
  399. spin_lock_irqsave(&up->port.lock, flags);
  400. if (mctrl & TIOCM_RTS)
  401. sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSSC);
  402. else
  403. sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSSC);
  404. spin_unlock_irqrestore(&up->port.lock, flags);
  405. }
  406. static void serial_txx9_break_ctl(struct uart_port *port, int break_state)
  407. {
  408. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  409. unsigned long flags;
  410. spin_lock_irqsave(&up->port.lock, flags);
  411. if (break_state == -1)
  412. sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK);
  413. else
  414. sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK);
  415. spin_unlock_irqrestore(&up->port.lock, flags);
  416. }
  417. static int serial_txx9_startup(struct uart_port *port)
  418. {
  419. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  420. unsigned long flags;
  421. int retval;
  422. /*
  423. * Clear the FIFO buffers and disable them.
  424. * (they will be reeanbled in set_termios())
  425. */
  426. sio_set(up, TXX9_SIFCR,
  427. TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
  428. /* clear reset */
  429. sio_mask(up, TXX9_SIFCR,
  430. TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
  431. sio_out(up, TXX9_SIDICR, 0);
  432. /*
  433. * Clear the interrupt registers.
  434. */
  435. sio_out(up, TXX9_SIDISR, 0);
  436. retval = request_irq(up->port.irq, serial_txx9_interrupt,
  437. SA_SHIRQ, "serial_txx9", up);
  438. if (retval)
  439. return retval;
  440. /*
  441. * Now, initialize the UART
  442. */
  443. spin_lock_irqsave(&up->port.lock, flags);
  444. serial_txx9_set_mctrl(&up->port, up->port.mctrl);
  445. spin_unlock_irqrestore(&up->port.lock, flags);
  446. /* Enable RX/TX */
  447. sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_RSDE | TXX9_SIFLCR_TSDE);
  448. /*
  449. * Finally, enable interrupts.
  450. */
  451. sio_set(up, TXX9_SIDICR, TXX9_SIDICR_RIE);
  452. return 0;
  453. }
  454. static void serial_txx9_shutdown(struct uart_port *port)
  455. {
  456. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  457. unsigned long flags;
  458. /*
  459. * Disable interrupts from this port
  460. */
  461. sio_out(up, TXX9_SIDICR, 0); /* disable all intrs */
  462. spin_lock_irqsave(&up->port.lock, flags);
  463. serial_txx9_set_mctrl(&up->port, up->port.mctrl);
  464. spin_unlock_irqrestore(&up->port.lock, flags);
  465. /*
  466. * Disable break condition
  467. */
  468. sio_mask(up, TXX9_SIFLCR, TXX9_SIFLCR_TBRK);
  469. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  470. if (up->port.cons && up->port.line == up->port.cons->index) {
  471. free_irq(up->port.irq, up);
  472. return;
  473. }
  474. #endif
  475. /* reset FIFOs */
  476. sio_set(up, TXX9_SIFCR,
  477. TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
  478. /* clear reset */
  479. sio_mask(up, TXX9_SIFCR,
  480. TXX9_SIFCR_TFRST | TXX9_SIFCR_RFRST | TXX9_SIFCR_FRSTE);
  481. /* Disable RX/TX */
  482. sio_set(up, TXX9_SIFLCR, TXX9_SIFLCR_RSDE | TXX9_SIFLCR_TSDE);
  483. free_irq(up->port.irq, up);
  484. }
  485. static void
  486. serial_txx9_set_termios(struct uart_port *port, struct termios *termios,
  487. struct termios *old)
  488. {
  489. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  490. unsigned int cval, fcr = 0;
  491. unsigned long flags;
  492. unsigned int baud, quot;
  493. cval = sio_in(up, TXX9_SILCR);
  494. /* byte size and parity */
  495. cval &= ~TXX9_SILCR_UMODE_MASK;
  496. switch (termios->c_cflag & CSIZE) {
  497. case CS7:
  498. cval |= TXX9_SILCR_UMODE_7BIT;
  499. break;
  500. default:
  501. case CS5: /* not supported */
  502. case CS6: /* not supported */
  503. case CS8:
  504. cval |= TXX9_SILCR_UMODE_8BIT;
  505. break;
  506. }
  507. cval &= ~TXX9_SILCR_USBL_MASK;
  508. if (termios->c_cflag & CSTOPB)
  509. cval |= TXX9_SILCR_USBL_2BIT;
  510. else
  511. cval |= TXX9_SILCR_USBL_1BIT;
  512. cval &= ~(TXX9_SILCR_UPEN | TXX9_SILCR_UEPS);
  513. if (termios->c_cflag & PARENB)
  514. cval |= TXX9_SILCR_UPEN;
  515. if (!(termios->c_cflag & PARODD))
  516. cval |= TXX9_SILCR_UEPS;
  517. /*
  518. * Ask the core to calculate the divisor for us.
  519. */
  520. baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16/2);
  521. quot = uart_get_divisor(port, baud);
  522. /* Set up FIFOs */
  523. /* TX Int by FIFO Empty, RX Int by Receiving 1 char. */
  524. fcr = TXX9_SIFCR_TDIL_MAX | TXX9_SIFCR_RDIL_1;
  525. /*
  526. * Ok, we're now changing the port state. Do it with
  527. * interrupts disabled.
  528. */
  529. spin_lock_irqsave(&up->port.lock, flags);
  530. /*
  531. * Update the per-port timeout.
  532. */
  533. uart_update_timeout(port, termios->c_cflag, baud);
  534. up->port.read_status_mask = TXX9_SIDISR_UOER |
  535. TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS;
  536. if (termios->c_iflag & INPCK)
  537. up->port.read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER;
  538. if (termios->c_iflag & (BRKINT | PARMRK))
  539. up->port.read_status_mask |= TXX9_SIDISR_UBRK;
  540. /*
  541. * Characteres to ignore
  542. */
  543. up->port.ignore_status_mask = 0;
  544. if (termios->c_iflag & IGNPAR)
  545. up->port.ignore_status_mask |= TXX9_SIDISR_UPER | TXX9_SIDISR_UFER;
  546. if (termios->c_iflag & IGNBRK) {
  547. up->port.ignore_status_mask |= TXX9_SIDISR_UBRK;
  548. /*
  549. * If we're ignoring parity and break indicators,
  550. * ignore overruns too (for real raw support).
  551. */
  552. if (termios->c_iflag & IGNPAR)
  553. up->port.ignore_status_mask |= TXX9_SIDISR_UOER;
  554. }
  555. /*
  556. * ignore all characters if CREAD is not set
  557. */
  558. if ((termios->c_cflag & CREAD) == 0)
  559. up->port.ignore_status_mask |= TXX9_SIDISR_RDIS;
  560. /* CTS flow control flag */
  561. if ((termios->c_cflag & CRTSCTS) &&
  562. (up->port.flags & UPF_TXX9_HAVE_CTS_LINE)) {
  563. sio_set(up, TXX9_SIFLCR,
  564. TXX9_SIFLCR_RCS | TXX9_SIFLCR_TES);
  565. } else {
  566. sio_mask(up, TXX9_SIFLCR,
  567. TXX9_SIFLCR_RCS | TXX9_SIFLCR_TES);
  568. }
  569. sio_out(up, TXX9_SILCR, cval);
  570. sio_quot_set(up, quot);
  571. sio_out(up, TXX9_SIFCR, fcr);
  572. serial_txx9_set_mctrl(&up->port, up->port.mctrl);
  573. spin_unlock_irqrestore(&up->port.lock, flags);
  574. }
  575. static void
  576. serial_txx9_pm(struct uart_port *port, unsigned int state,
  577. unsigned int oldstate)
  578. {
  579. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  580. if (up->pm)
  581. up->pm(port, state, oldstate);
  582. }
  583. static int serial_txx9_request_resource(struct uart_txx9_port *up)
  584. {
  585. unsigned int size = TXX9_REGION_SIZE;
  586. int ret = 0;
  587. switch (up->port.iotype) {
  588. default:
  589. if (!up->port.mapbase)
  590. break;
  591. if (!request_mem_region(up->port.mapbase, size, "serial_txx9")) {
  592. ret = -EBUSY;
  593. break;
  594. }
  595. if (up->port.flags & UPF_IOREMAP) {
  596. up->port.membase = ioremap(up->port.mapbase, size);
  597. if (!up->port.membase) {
  598. release_mem_region(up->port.mapbase, size);
  599. ret = -ENOMEM;
  600. }
  601. }
  602. break;
  603. case UPIO_PORT:
  604. if (!request_region(up->port.iobase, size, "serial_txx9"))
  605. ret = -EBUSY;
  606. break;
  607. }
  608. return ret;
  609. }
  610. static void serial_txx9_release_resource(struct uart_txx9_port *up)
  611. {
  612. unsigned int size = TXX9_REGION_SIZE;
  613. switch (up->port.iotype) {
  614. default:
  615. if (!up->port.mapbase)
  616. break;
  617. if (up->port.flags & UPF_IOREMAP) {
  618. iounmap(up->port.membase);
  619. up->port.membase = NULL;
  620. }
  621. release_mem_region(up->port.mapbase, size);
  622. break;
  623. case UPIO_PORT:
  624. release_region(up->port.iobase, size);
  625. break;
  626. }
  627. }
  628. static void serial_txx9_release_port(struct uart_port *port)
  629. {
  630. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  631. serial_txx9_release_resource(up);
  632. }
  633. static int serial_txx9_request_port(struct uart_port *port)
  634. {
  635. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  636. return serial_txx9_request_resource(up);
  637. }
  638. static void serial_txx9_config_port(struct uart_port *port, int uflags)
  639. {
  640. struct uart_txx9_port *up = (struct uart_txx9_port *)port;
  641. unsigned long flags;
  642. int ret;
  643. /*
  644. * Find the region that we can probe for. This in turn
  645. * tells us whether we can probe for the type of port.
  646. */
  647. ret = serial_txx9_request_resource(up);
  648. if (ret < 0)
  649. return;
  650. port->type = PORT_TXX9;
  651. up->port.fifosize = TXX9_SIO_TX_FIFO;
  652. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  653. if (up->port.line == up->port.cons->index)
  654. return;
  655. #endif
  656. spin_lock_irqsave(&up->port.lock, flags);
  657. /*
  658. * Reset the UART.
  659. */
  660. sio_out(up, TXX9_SIFCR, TXX9_SIFCR_SWRST);
  661. #ifdef CONFIG_CPU_TX49XX
  662. /* TX4925 BUG WORKAROUND. Accessing SIOC register
  663. * immediately after soft reset causes bus error. */
  664. iob();
  665. udelay(1);
  666. #endif
  667. while (sio_in(up, TXX9_SIFCR) & TXX9_SIFCR_SWRST)
  668. ;
  669. /* TX Int by FIFO Empty, RX Int by Receiving 1 char. */
  670. sio_set(up, TXX9_SIFCR,
  671. TXX9_SIFCR_TDIL_MAX | TXX9_SIFCR_RDIL_1);
  672. /* initial settings */
  673. sio_out(up, TXX9_SILCR,
  674. TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT |
  675. ((up->port.flags & UPF_TXX9_USE_SCLK) ?
  676. TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG));
  677. sio_quot_set(up, uart_get_divisor(port, 9600));
  678. sio_out(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSTL_MAX /* 15 */);
  679. spin_unlock_irqrestore(&up->port.lock, flags);
  680. }
  681. static int
  682. serial_txx9_verify_port(struct uart_port *port, struct serial_struct *ser)
  683. {
  684. if (ser->irq < 0 ||
  685. ser->baud_base < 9600 || ser->type != PORT_TXX9)
  686. return -EINVAL;
  687. return 0;
  688. }
  689. static const char *
  690. serial_txx9_type(struct uart_port *port)
  691. {
  692. return "txx9";
  693. }
  694. static struct uart_ops serial_txx9_pops = {
  695. .tx_empty = serial_txx9_tx_empty,
  696. .set_mctrl = serial_txx9_set_mctrl,
  697. .get_mctrl = serial_txx9_get_mctrl,
  698. .stop_tx = serial_txx9_stop_tx,
  699. .start_tx = serial_txx9_start_tx,
  700. .stop_rx = serial_txx9_stop_rx,
  701. .enable_ms = serial_txx9_enable_ms,
  702. .break_ctl = serial_txx9_break_ctl,
  703. .startup = serial_txx9_startup,
  704. .shutdown = serial_txx9_shutdown,
  705. .set_termios = serial_txx9_set_termios,
  706. .pm = serial_txx9_pm,
  707. .type = serial_txx9_type,
  708. .release_port = serial_txx9_release_port,
  709. .request_port = serial_txx9_request_port,
  710. .config_port = serial_txx9_config_port,
  711. .verify_port = serial_txx9_verify_port,
  712. };
  713. static struct uart_txx9_port serial_txx9_ports[UART_NR];
  714. static void __init serial_txx9_register_ports(struct uart_driver *drv)
  715. {
  716. int i;
  717. for (i = 0; i < UART_NR; i++) {
  718. struct uart_txx9_port *up = &serial_txx9_ports[i];
  719. up->port.line = i;
  720. up->port.ops = &serial_txx9_pops;
  721. uart_add_one_port(drv, &up->port);
  722. }
  723. }
  724. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  725. /*
  726. * Wait for transmitter & holding register to empty
  727. */
  728. static inline void wait_for_xmitr(struct uart_txx9_port *up)
  729. {
  730. unsigned int tmout = 10000;
  731. /* Wait up to 10ms for the character(s) to be sent. */
  732. while (--tmout &&
  733. !(sio_in(up, TXX9_SICISR) & TXX9_SICISR_TXALS))
  734. udelay(1);
  735. /* Wait up to 1s for flow control if necessary */
  736. if (up->port.flags & UPF_CONS_FLOW) {
  737. tmout = 1000000;
  738. while (--tmout &&
  739. (sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS))
  740. udelay(1);
  741. }
  742. }
  743. /*
  744. * Print a string to the serial port trying not to disturb
  745. * any possible real use of the port...
  746. *
  747. * The console_lock must be held when we get here.
  748. */
  749. static void
  750. serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
  751. {
  752. struct uart_txx9_port *up = &serial_txx9_ports[co->index];
  753. unsigned int ier, flcr;
  754. int i;
  755. /*
  756. * First save the UER then disable the interrupts
  757. */
  758. ier = sio_in(up, TXX9_SIDICR);
  759. sio_out(up, TXX9_SIDICR, 0);
  760. /*
  761. * Disable flow-control if enabled (and unnecessary)
  762. */
  763. flcr = sio_in(up, TXX9_SIFLCR);
  764. if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES))
  765. sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES);
  766. /*
  767. * Now, do each character
  768. */
  769. for (i = 0; i < count; i++, s++) {
  770. wait_for_xmitr(up);
  771. /*
  772. * Send the character out.
  773. * If a LF, also do CR...
  774. */
  775. sio_out(up, TXX9_SITFIFO, *s);
  776. if (*s == 10) {
  777. wait_for_xmitr(up);
  778. sio_out(up, TXX9_SITFIFO, 13);
  779. }
  780. }
  781. /*
  782. * Finally, wait for transmitter to become empty
  783. * and restore the IER
  784. */
  785. wait_for_xmitr(up);
  786. sio_out(up, TXX9_SIFLCR, flcr);
  787. sio_out(up, TXX9_SIDICR, ier);
  788. }
  789. static int serial_txx9_console_setup(struct console *co, char *options)
  790. {
  791. struct uart_port *port;
  792. struct uart_txx9_port *up;
  793. int baud = 9600;
  794. int bits = 8;
  795. int parity = 'n';
  796. int flow = 'n';
  797. /*
  798. * Check whether an invalid uart number has been specified, and
  799. * if so, search for the first available port that does have
  800. * console support.
  801. */
  802. if (co->index >= UART_NR)
  803. co->index = 0;
  804. up = &serial_txx9_ports[co->index];
  805. port = &up->port;
  806. if (!port->ops)
  807. return -ENODEV;
  808. /*
  809. * Temporary fix.
  810. */
  811. spin_lock_init(&port->lock);
  812. /*
  813. * Disable UART interrupts, set DTR and RTS high
  814. * and set speed.
  815. */
  816. sio_out(up, TXX9_SIDICR, 0);
  817. /* initial settings */
  818. sio_out(up, TXX9_SILCR,
  819. TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT |
  820. ((port->flags & UPF_TXX9_USE_SCLK) ?
  821. TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG));
  822. sio_out(up, TXX9_SIFLCR, TXX9_SIFLCR_RTSTL_MAX /* 15 */);
  823. if (options)
  824. uart_parse_options(options, &baud, &parity, &bits, &flow);
  825. return uart_set_options(port, co, baud, parity, bits, flow);
  826. }
  827. static struct uart_driver serial_txx9_reg;
  828. static struct console serial_txx9_console = {
  829. .name = TXX9_TTY_NAME,
  830. .write = serial_txx9_console_write,
  831. .device = uart_console_device,
  832. .setup = serial_txx9_console_setup,
  833. .flags = CON_PRINTBUFFER,
  834. .index = -1,
  835. .data = &serial_txx9_reg,
  836. };
  837. static int __init serial_txx9_console_init(void)
  838. {
  839. register_console(&serial_txx9_console);
  840. return 0;
  841. }
  842. console_initcall(serial_txx9_console_init);
  843. #define SERIAL_TXX9_CONSOLE &serial_txx9_console
  844. #else
  845. #define SERIAL_TXX9_CONSOLE NULL
  846. #endif
  847. static struct uart_driver serial_txx9_reg = {
  848. .owner = THIS_MODULE,
  849. .driver_name = "serial_txx9",
  850. .devfs_name = TXX9_TTY_DEVFS_NAME,
  851. .dev_name = TXX9_TTY_NAME,
  852. .major = TXX9_TTY_MAJOR,
  853. .minor = TXX9_TTY_MINOR_START,
  854. .nr = UART_NR,
  855. .cons = SERIAL_TXX9_CONSOLE,
  856. };
  857. int __init early_serial_txx9_setup(struct uart_port *port)
  858. {
  859. if (port->line >= ARRAY_SIZE(serial_txx9_ports))
  860. return -ENODEV;
  861. serial_txx9_ports[port->line].port = *port;
  862. serial_txx9_ports[port->line].port.ops = &serial_txx9_pops;
  863. serial_txx9_ports[port->line].port.flags |= UPF_BOOT_AUTOCONF;
  864. return 0;
  865. }
  866. #ifdef ENABLE_SERIAL_TXX9_PCI
  867. /**
  868. * serial_txx9_suspend_port - suspend one serial port
  869. * @line: serial line number
  870. * @level: the level of port suspension, as per uart_suspend_port
  871. *
  872. * Suspend one serial port.
  873. */
  874. static void serial_txx9_suspend_port(int line)
  875. {
  876. uart_suspend_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
  877. }
  878. /**
  879. * serial_txx9_resume_port - resume one serial port
  880. * @line: serial line number
  881. * @level: the level of port resumption, as per uart_resume_port
  882. *
  883. * Resume one serial port.
  884. */
  885. static void serial_txx9_resume_port(int line)
  886. {
  887. uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
  888. }
  889. static DEFINE_MUTEX(serial_txx9_mutex);
  890. /**
  891. * serial_txx9_register_port - register a serial port
  892. * @port: serial port template
  893. *
  894. * Configure the serial port specified by the request.
  895. *
  896. * The port is then probed and if necessary the IRQ is autodetected
  897. * If this fails an error is returned.
  898. *
  899. * On success the port is ready to use and the line number is returned.
  900. */
  901. static int __devinit serial_txx9_register_port(struct uart_port *port)
  902. {
  903. int i;
  904. struct uart_txx9_port *uart;
  905. int ret = -ENOSPC;
  906. mutex_lock(&serial_txx9_mutex);
  907. for (i = 0; i < UART_NR; i++) {
  908. uart = &serial_txx9_ports[i];
  909. if (uart->port.type == PORT_UNKNOWN)
  910. break;
  911. }
  912. if (i < UART_NR) {
  913. uart_remove_one_port(&serial_txx9_reg, &uart->port);
  914. uart->port.iobase = port->iobase;
  915. uart->port.membase = port->membase;
  916. uart->port.irq = port->irq;
  917. uart->port.uartclk = port->uartclk;
  918. uart->port.iotype = port->iotype;
  919. uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
  920. uart->port.mapbase = port->mapbase;
  921. if (port->dev)
  922. uart->port.dev = port->dev;
  923. ret = uart_add_one_port(&serial_txx9_reg, &uart->port);
  924. if (ret == 0)
  925. ret = uart->port.line;
  926. }
  927. mutex_unlock(&serial_txx9_mutex);
  928. return ret;
  929. }
  930. /**
  931. * serial_txx9_unregister_port - remove a txx9 serial port at runtime
  932. * @line: serial line number
  933. *
  934. * Remove one serial port. This may not be called from interrupt
  935. * context. We hand the port back to the our control.
  936. */
  937. static void __devexit serial_txx9_unregister_port(int line)
  938. {
  939. struct uart_txx9_port *uart = &serial_txx9_ports[line];
  940. mutex_lock(&serial_txx9_mutex);
  941. uart_remove_one_port(&serial_txx9_reg, &uart->port);
  942. uart->port.flags = 0;
  943. uart->port.type = PORT_UNKNOWN;
  944. uart->port.iobase = 0;
  945. uart->port.mapbase = 0;
  946. uart->port.membase = 0;
  947. uart->port.dev = NULL;
  948. uart_add_one_port(&serial_txx9_reg, &uart->port);
  949. mutex_unlock(&serial_txx9_mutex);
  950. }
  951. /*
  952. * Probe one serial board. Unfortunately, there is no rhyme nor reason
  953. * to the arrangement of serial ports on a PCI card.
  954. */
  955. static int __devinit
  956. pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
  957. {
  958. struct uart_port port;
  959. int line;
  960. int rc;
  961. rc = pci_enable_device(dev);
  962. if (rc)
  963. return rc;
  964. memset(&port, 0, sizeof(port));
  965. port.ops = &serial_txx9_pops;
  966. port.flags |= UPF_TXX9_HAVE_CTS_LINE;
  967. port.uartclk = 66670000;
  968. port.irq = dev->irq;
  969. port.iotype = UPIO_PORT;
  970. port.iobase = pci_resource_start(dev, 1);
  971. port.dev = &dev->dev;
  972. line = serial_txx9_register_port(&port);
  973. if (line < 0) {
  974. printk(KERN_WARNING "Couldn't register serial port %s: %d\n", pci_name(dev), line);
  975. }
  976. pci_set_drvdata(dev, (void *)(long)line);
  977. return 0;
  978. }
  979. static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev)
  980. {
  981. int line = (int)(long)pci_get_drvdata(dev);
  982. pci_set_drvdata(dev, NULL);
  983. if (line) {
  984. serial_txx9_unregister_port(line);
  985. pci_disable_device(dev);
  986. }
  987. }
  988. static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state)
  989. {
  990. int line = (int)(long)pci_get_drvdata(dev);
  991. if (line)
  992. serial_txx9_suspend_port(line);
  993. pci_save_state(dev);
  994. pci_set_power_state(dev, pci_choose_state(dev, state));
  995. return 0;
  996. }
  997. static int pciserial_txx9_resume_one(struct pci_dev *dev)
  998. {
  999. int line = (int)(long)pci_get_drvdata(dev);
  1000. pci_set_power_state(dev, PCI_D0);
  1001. pci_restore_state(dev);
  1002. if (line) {
  1003. pci_enable_device(dev);
  1004. serial_txx9_resume_port(line);
  1005. }
  1006. return 0;
  1007. }
  1008. static struct pci_device_id serial_txx9_pci_tbl[] = {
  1009. { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC,
  1010. PCI_ANY_ID, PCI_ANY_ID,
  1011. 0, 0, 0 },
  1012. { 0, }
  1013. };
  1014. static struct pci_driver serial_txx9_pci_driver = {
  1015. .name = "serial_txx9",
  1016. .probe = pciserial_txx9_init_one,
  1017. .remove = __devexit_p(pciserial_txx9_remove_one),
  1018. .suspend = pciserial_txx9_suspend_one,
  1019. .resume = pciserial_txx9_resume_one,
  1020. .id_table = serial_txx9_pci_tbl,
  1021. };
  1022. MODULE_DEVICE_TABLE(pci, serial_txx9_pci_tbl);
  1023. #endif /* ENABLE_SERIAL_TXX9_PCI */
  1024. static int __init serial_txx9_init(void)
  1025. {
  1026. int ret;
  1027. printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
  1028. ret = uart_register_driver(&serial_txx9_reg);
  1029. if (ret >= 0) {
  1030. serial_txx9_register_ports(&serial_txx9_reg);
  1031. #ifdef ENABLE_SERIAL_TXX9_PCI
  1032. ret = pci_register_driver(&serial_txx9_pci_driver);
  1033. #endif
  1034. }
  1035. return ret;
  1036. }
  1037. static void __exit serial_txx9_exit(void)
  1038. {
  1039. int i;
  1040. #ifdef ENABLE_SERIAL_TXX9_PCI
  1041. pci_unregister_driver(&serial_txx9_pci_driver);
  1042. #endif
  1043. for (i = 0; i < UART_NR; i++)
  1044. uart_remove_one_port(&serial_txx9_reg, &serial_txx9_ports[i].port);
  1045. uart_unregister_driver(&serial_txx9_reg);
  1046. }
  1047. module_init(serial_txx9_init);
  1048. module_exit(serial_txx9_exit);
  1049. MODULE_LICENSE("GPL");
  1050. MODULE_DESCRIPTION("TX39/49 serial driver");
  1051. MODULE_ALIAS_CHARDEV_MAJOR(TXX9_TTY_MAJOR);