serial_txx9.c 31 KB

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