bfin_5xx.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. /*
  2. * Blackfin On-Chip Serial Driver
  3. *
  4. * Copyright 2006-2008 Analog Devices Inc.
  5. *
  6. * Enter bugs at http://blackfin.uclinux.org/
  7. *
  8. * Licensed under the GPL-2 or later.
  9. */
  10. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  11. #define SUPPORT_SYSRQ
  12. #endif
  13. #include <linux/module.h>
  14. #include <linux/ioport.h>
  15. #include <linux/init.h>
  16. #include <linux/console.h>
  17. #include <linux/sysrq.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/tty.h>
  20. #include <linux/tty_flip.h>
  21. #include <linux/serial_core.h>
  22. #ifdef CONFIG_KGDB_UART
  23. #include <linux/kgdb.h>
  24. #include <asm/irq_regs.h>
  25. #endif
  26. #include <asm/gpio.h>
  27. #include <mach/bfin_serial_5xx.h>
  28. #ifdef CONFIG_SERIAL_BFIN_DMA
  29. #include <linux/dma-mapping.h>
  30. #include <asm/io.h>
  31. #include <asm/irq.h>
  32. #include <asm/cacheflush.h>
  33. #endif
  34. /* UART name and device definitions */
  35. #define BFIN_SERIAL_NAME "ttyBF"
  36. #define BFIN_SERIAL_MAJOR 204
  37. #define BFIN_SERIAL_MINOR 64
  38. static struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS];
  39. static int nr_active_ports = ARRAY_SIZE(bfin_serial_resource);
  40. /*
  41. * Setup for console. Argument comes from the menuconfig
  42. */
  43. #define DMA_RX_XCOUNT 512
  44. #define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT)
  45. #define DMA_RX_FLUSH_JIFFIES (HZ / 50)
  46. #define CTS_CHECK_JIFFIES (HZ / 50)
  47. #ifdef CONFIG_SERIAL_BFIN_DMA
  48. static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart);
  49. #else
  50. static void bfin_serial_tx_chars(struct bfin_serial_port *uart);
  51. #endif
  52. static void bfin_serial_mctrl_check(struct bfin_serial_port *uart);
  53. /*
  54. * interrupts are disabled on entry
  55. */
  56. static void bfin_serial_stop_tx(struct uart_port *port)
  57. {
  58. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  59. struct circ_buf *xmit = &uart->port.info->xmit;
  60. while (!(UART_GET_LSR(uart) & TEMT))
  61. cpu_relax();
  62. #ifdef CONFIG_SERIAL_BFIN_DMA
  63. disable_dma(uart->tx_dma_channel);
  64. xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
  65. uart->port.icount.tx += uart->tx_count;
  66. uart->tx_count = 0;
  67. uart->tx_done = 1;
  68. #else
  69. #ifdef CONFIG_BF54x
  70. /* Clear TFI bit */
  71. UART_PUT_LSR(uart, TFI);
  72. #endif
  73. UART_CLEAR_IER(uart, ETBEI);
  74. #endif
  75. }
  76. /*
  77. * port is locked and interrupts are disabled
  78. */
  79. static void bfin_serial_start_tx(struct uart_port *port)
  80. {
  81. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  82. #ifdef CONFIG_SERIAL_BFIN_DMA
  83. if (uart->tx_done)
  84. bfin_serial_dma_tx_chars(uart);
  85. #else
  86. UART_SET_IER(uart, ETBEI);
  87. bfin_serial_tx_chars(uart);
  88. #endif
  89. }
  90. /*
  91. * Interrupts are enabled
  92. */
  93. static void bfin_serial_stop_rx(struct uart_port *port)
  94. {
  95. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  96. #ifdef CONFIG_KGDB_UART
  97. if (uart->port.line != CONFIG_KGDB_UART_PORT)
  98. #endif
  99. UART_CLEAR_IER(uart, ERBFI);
  100. }
  101. /*
  102. * Set the modem control timer to fire immediately.
  103. */
  104. static void bfin_serial_enable_ms(struct uart_port *port)
  105. {
  106. }
  107. #ifdef CONFIG_KGDB_UART
  108. static int kgdb_entry_state;
  109. void kgdb_put_debug_char(int chr)
  110. {
  111. struct bfin_serial_port *uart;
  112. if (CONFIG_KGDB_UART_PORT < 0
  113. || CONFIG_KGDB_UART_PORT >= BFIN_UART_NR_PORTS)
  114. uart = &bfin_serial_ports[0];
  115. else
  116. uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT];
  117. while (!(UART_GET_LSR(uart) & THRE)) {
  118. SSYNC();
  119. }
  120. UART_CLEAR_DLAB(uart);
  121. UART_PUT_CHAR(uart, (unsigned char)chr);
  122. SSYNC();
  123. }
  124. int kgdb_get_debug_char(void)
  125. {
  126. struct bfin_serial_port *uart;
  127. unsigned char chr;
  128. if (CONFIG_KGDB_UART_PORT < 0
  129. || CONFIG_KGDB_UART_PORT >= BFIN_UART_NR_PORTS)
  130. uart = &bfin_serial_ports[0];
  131. else
  132. uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT];
  133. while(!(UART_GET_LSR(uart) & DR)) {
  134. SSYNC();
  135. }
  136. UART_CLEAR_DLAB(uart);
  137. chr = UART_GET_CHAR(uart);
  138. SSYNC();
  139. return chr;
  140. }
  141. #endif
  142. #if ANOMALY_05000363 && defined(CONFIG_SERIAL_BFIN_PIO)
  143. # define UART_GET_ANOMALY_THRESHOLD(uart) ((uart)->anomaly_threshold)
  144. # define UART_SET_ANOMALY_THRESHOLD(uart, v) ((uart)->anomaly_threshold = (v))
  145. #else
  146. # define UART_GET_ANOMALY_THRESHOLD(uart) 0
  147. # define UART_SET_ANOMALY_THRESHOLD(uart, v)
  148. #endif
  149. #ifdef CONFIG_SERIAL_BFIN_PIO
  150. static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
  151. {
  152. struct tty_struct *tty = uart->port.info->port.tty;
  153. unsigned int status, ch, flg;
  154. static struct timeval anomaly_start = { .tv_sec = 0 };
  155. status = UART_GET_LSR(uart);
  156. UART_CLEAR_LSR(uart);
  157. ch = UART_GET_CHAR(uart);
  158. uart->port.icount.rx++;
  159. #ifdef CONFIG_KGDB_UART
  160. if (uart->port.line == CONFIG_KGDB_UART_PORT) {
  161. struct pt_regs *regs = get_irq_regs();
  162. if (uart->port.cons->index == CONFIG_KGDB_UART_PORT && ch == 0x1) { /* Ctrl + A */
  163. kgdb_breakkey_pressed(regs);
  164. return;
  165. } else if (kgdb_entry_state == 0 && ch == '$') {/* connection from KGDB */
  166. kgdb_entry_state = 1;
  167. } else if (kgdb_entry_state == 1 && ch == 'q') {
  168. kgdb_entry_state = 0;
  169. kgdb_breakkey_pressed(regs);
  170. return;
  171. } else if (ch == 0x3) {/* Ctrl + C */
  172. kgdb_entry_state = 0;
  173. kgdb_breakkey_pressed(regs);
  174. return;
  175. } else {
  176. kgdb_entry_state = 0;
  177. }
  178. }
  179. #endif
  180. if (ANOMALY_05000363) {
  181. /* The BF533 (and BF561) family of processors have a nice anomaly
  182. * where they continuously generate characters for a "single" break.
  183. * We have to basically ignore this flood until the "next" valid
  184. * character comes across. Due to the nature of the flood, it is
  185. * not possible to reliably catch bytes that are sent too quickly
  186. * after this break. So application code talking to the Blackfin
  187. * which sends a break signal must allow at least 1.5 character
  188. * times after the end of the break for things to stabilize. This
  189. * timeout was picked as it must absolutely be larger than 1
  190. * character time +/- some percent. So 1.5 sounds good. All other
  191. * Blackfin families operate properly. Woo.
  192. */
  193. if (anomaly_start.tv_sec) {
  194. struct timeval curr;
  195. suseconds_t usecs;
  196. if ((~ch & (~ch + 1)) & 0xff)
  197. goto known_good_char;
  198. do_gettimeofday(&curr);
  199. if (curr.tv_sec - anomaly_start.tv_sec > 1)
  200. goto known_good_char;
  201. usecs = 0;
  202. if (curr.tv_sec != anomaly_start.tv_sec)
  203. usecs += USEC_PER_SEC;
  204. usecs += curr.tv_usec - anomaly_start.tv_usec;
  205. if (usecs > UART_GET_ANOMALY_THRESHOLD(uart))
  206. goto known_good_char;
  207. if (ch)
  208. anomaly_start.tv_sec = 0;
  209. else
  210. anomaly_start = curr;
  211. return;
  212. known_good_char:
  213. anomaly_start.tv_sec = 0;
  214. }
  215. }
  216. if (status & BI) {
  217. if (ANOMALY_05000363)
  218. if (bfin_revid() < 5)
  219. do_gettimeofday(&anomaly_start);
  220. uart->port.icount.brk++;
  221. if (uart_handle_break(&uart->port))
  222. goto ignore_char;
  223. status &= ~(PE | FE);
  224. }
  225. if (status & PE)
  226. uart->port.icount.parity++;
  227. if (status & OE)
  228. uart->port.icount.overrun++;
  229. if (status & FE)
  230. uart->port.icount.frame++;
  231. status &= uart->port.read_status_mask;
  232. if (status & BI)
  233. flg = TTY_BREAK;
  234. else if (status & PE)
  235. flg = TTY_PARITY;
  236. else if (status & FE)
  237. flg = TTY_FRAME;
  238. else
  239. flg = TTY_NORMAL;
  240. if (uart_handle_sysrq_char(&uart->port, ch))
  241. goto ignore_char;
  242. uart_insert_char(&uart->port, status, OE, ch, flg);
  243. ignore_char:
  244. tty_flip_buffer_push(tty);
  245. }
  246. static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
  247. {
  248. struct circ_buf *xmit = &uart->port.info->xmit;
  249. /*
  250. * Check the modem control lines before
  251. * transmitting anything.
  252. */
  253. bfin_serial_mctrl_check(uart);
  254. if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
  255. #ifdef CONFIG_BF54x
  256. /* Clear TFI bit */
  257. UART_PUT_LSR(uart, TFI);
  258. #endif
  259. UART_CLEAR_IER(uart, ETBEI);
  260. return;
  261. }
  262. if (uart->port.x_char) {
  263. UART_PUT_CHAR(uart, uart->port.x_char);
  264. uart->port.icount.tx++;
  265. uart->port.x_char = 0;
  266. }
  267. while ((UART_GET_LSR(uart) & THRE) && xmit->tail != xmit->head) {
  268. UART_PUT_CHAR(uart, xmit->buf[xmit->tail]);
  269. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  270. uart->port.icount.tx++;
  271. SSYNC();
  272. }
  273. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  274. uart_write_wakeup(&uart->port);
  275. }
  276. static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id)
  277. {
  278. struct bfin_serial_port *uart = dev_id;
  279. spin_lock(&uart->port.lock);
  280. while (UART_GET_LSR(uart) & DR)
  281. bfin_serial_rx_chars(uart);
  282. spin_unlock(&uart->port.lock);
  283. return IRQ_HANDLED;
  284. }
  285. static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
  286. {
  287. struct bfin_serial_port *uart = dev_id;
  288. spin_lock(&uart->port.lock);
  289. if (UART_GET_LSR(uart) & THRE)
  290. bfin_serial_tx_chars(uart);
  291. spin_unlock(&uart->port.lock);
  292. return IRQ_HANDLED;
  293. }
  294. #endif
  295. #ifdef CONFIG_SERIAL_BFIN_DMA
  296. static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
  297. {
  298. struct circ_buf *xmit = &uart->port.info->xmit;
  299. uart->tx_done = 0;
  300. /*
  301. * Check the modem control lines before
  302. * transmitting anything.
  303. */
  304. bfin_serial_mctrl_check(uart);
  305. if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
  306. uart->tx_count = 0;
  307. uart->tx_done = 1;
  308. return;
  309. }
  310. if (uart->port.x_char) {
  311. UART_PUT_CHAR(uart, uart->port.x_char);
  312. uart->port.icount.tx++;
  313. uart->port.x_char = 0;
  314. }
  315. uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE);
  316. if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail))
  317. uart->tx_count = UART_XMIT_SIZE - xmit->tail;
  318. blackfin_dcache_flush_range((unsigned long)(xmit->buf+xmit->tail),
  319. (unsigned long)(xmit->buf+xmit->tail+uart->tx_count));
  320. set_dma_config(uart->tx_dma_channel,
  321. set_bfin_dma_config(DIR_READ, DMA_FLOW_STOP,
  322. INTR_ON_BUF,
  323. DIMENSION_LINEAR,
  324. DATA_SIZE_8,
  325. DMA_SYNC_RESTART));
  326. set_dma_start_addr(uart->tx_dma_channel, (unsigned long)(xmit->buf+xmit->tail));
  327. set_dma_x_count(uart->tx_dma_channel, uart->tx_count);
  328. set_dma_x_modify(uart->tx_dma_channel, 1);
  329. enable_dma(uart->tx_dma_channel);
  330. UART_SET_IER(uart, ETBEI);
  331. }
  332. static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
  333. {
  334. struct tty_struct *tty = uart->port.info->port.tty;
  335. int i, flg, status;
  336. status = UART_GET_LSR(uart);
  337. UART_CLEAR_LSR(uart);
  338. uart->port.icount.rx +=
  339. CIRC_CNT(uart->rx_dma_buf.head, uart->rx_dma_buf.tail,
  340. UART_XMIT_SIZE);
  341. if (status & BI) {
  342. uart->port.icount.brk++;
  343. if (uart_handle_break(&uart->port))
  344. goto dma_ignore_char;
  345. status &= ~(PE | FE);
  346. }
  347. if (status & PE)
  348. uart->port.icount.parity++;
  349. if (status & OE)
  350. uart->port.icount.overrun++;
  351. if (status & FE)
  352. uart->port.icount.frame++;
  353. status &= uart->port.read_status_mask;
  354. if (status & BI)
  355. flg = TTY_BREAK;
  356. else if (status & PE)
  357. flg = TTY_PARITY;
  358. else if (status & FE)
  359. flg = TTY_FRAME;
  360. else
  361. flg = TTY_NORMAL;
  362. for (i = uart->rx_dma_buf.tail; i != uart->rx_dma_buf.head; i++) {
  363. if (i >= UART_XMIT_SIZE)
  364. i = 0;
  365. if (!uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i]))
  366. uart_insert_char(&uart->port, status, OE,
  367. uart->rx_dma_buf.buf[i], flg);
  368. }
  369. dma_ignore_char:
  370. tty_flip_buffer_push(tty);
  371. }
  372. void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
  373. {
  374. int x_pos, pos;
  375. uart->rx_dma_nrows = get_dma_curr_ycount(uart->rx_dma_channel);
  376. x_pos = get_dma_curr_xcount(uart->rx_dma_channel);
  377. uart->rx_dma_nrows = DMA_RX_YCOUNT - uart->rx_dma_nrows;
  378. if (uart->rx_dma_nrows == DMA_RX_YCOUNT)
  379. uart->rx_dma_nrows = 0;
  380. x_pos = DMA_RX_XCOUNT - x_pos;
  381. if (x_pos == DMA_RX_XCOUNT)
  382. x_pos = 0;
  383. pos = uart->rx_dma_nrows * DMA_RX_XCOUNT + x_pos;
  384. if (pos != uart->rx_dma_buf.tail) {
  385. uart->rx_dma_buf.head = pos;
  386. bfin_serial_dma_rx_chars(uart);
  387. uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
  388. }
  389. mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES);
  390. }
  391. static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
  392. {
  393. struct bfin_serial_port *uart = dev_id;
  394. struct circ_buf *xmit = &uart->port.info->xmit;
  395. spin_lock(&uart->port.lock);
  396. if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) {
  397. disable_dma(uart->tx_dma_channel);
  398. clear_dma_irqstat(uart->tx_dma_channel);
  399. UART_CLEAR_IER(uart, ETBEI);
  400. xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
  401. uart->port.icount.tx += uart->tx_count;
  402. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  403. uart_write_wakeup(&uart->port);
  404. bfin_serial_dma_tx_chars(uart);
  405. }
  406. spin_unlock(&uart->port.lock);
  407. return IRQ_HANDLED;
  408. }
  409. static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id)
  410. {
  411. struct bfin_serial_port *uart = dev_id;
  412. unsigned short irqstat;
  413. spin_lock(&uart->port.lock);
  414. irqstat = get_dma_curr_irqstat(uart->rx_dma_channel);
  415. clear_dma_irqstat(uart->rx_dma_channel);
  416. spin_unlock(&uart->port.lock);
  417. mod_timer(&(uart->rx_dma_timer), jiffies);
  418. return IRQ_HANDLED;
  419. }
  420. #endif
  421. /*
  422. * Return TIOCSER_TEMT when transmitter is not busy.
  423. */
  424. static unsigned int bfin_serial_tx_empty(struct uart_port *port)
  425. {
  426. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  427. unsigned short lsr;
  428. lsr = UART_GET_LSR(uart);
  429. if (lsr & TEMT)
  430. return TIOCSER_TEMT;
  431. else
  432. return 0;
  433. }
  434. static unsigned int bfin_serial_get_mctrl(struct uart_port *port)
  435. {
  436. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  437. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  438. if (uart->cts_pin < 0)
  439. return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
  440. if (UART_GET_CTS(uart))
  441. return TIOCM_DSR | TIOCM_CAR;
  442. else
  443. #endif
  444. return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
  445. }
  446. static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
  447. {
  448. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  449. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  450. if (uart->rts_pin < 0)
  451. return;
  452. if (mctrl & TIOCM_RTS)
  453. UART_CLEAR_RTS(uart);
  454. else
  455. UART_SET_RTS(uart);
  456. #endif
  457. }
  458. /*
  459. * Handle any change of modem status signal since we were last called.
  460. */
  461. static void bfin_serial_mctrl_check(struct bfin_serial_port *uart)
  462. {
  463. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  464. unsigned int status;
  465. struct uart_info *info = uart->port.info;
  466. struct tty_struct *tty = info->port.tty;
  467. status = bfin_serial_get_mctrl(&uart->port);
  468. uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
  469. if (!(status & TIOCM_CTS)) {
  470. tty->hw_stopped = 1;
  471. uart->cts_timer.data = (unsigned long)(uart);
  472. uart->cts_timer.function = (void *)bfin_serial_mctrl_check;
  473. uart->cts_timer.expires = jiffies + CTS_CHECK_JIFFIES;
  474. add_timer(&(uart->cts_timer));
  475. } else {
  476. tty->hw_stopped = 0;
  477. }
  478. #endif
  479. }
  480. /*
  481. * Interrupts are always disabled.
  482. */
  483. static void bfin_serial_break_ctl(struct uart_port *port, int break_state)
  484. {
  485. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  486. u16 lcr = UART_GET_LCR(uart);
  487. if (break_state)
  488. lcr |= SB;
  489. else
  490. lcr &= ~SB;
  491. UART_PUT_LCR(uart, lcr);
  492. SSYNC();
  493. }
  494. static int bfin_serial_startup(struct uart_port *port)
  495. {
  496. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  497. #ifdef CONFIG_SERIAL_BFIN_DMA
  498. dma_addr_t dma_handle;
  499. if (request_dma(uart->rx_dma_channel, "BFIN_UART_RX") < 0) {
  500. printk(KERN_NOTICE "Unable to attach Blackfin UART RX DMA channel\n");
  501. return -EBUSY;
  502. }
  503. if (request_dma(uart->tx_dma_channel, "BFIN_UART_TX") < 0) {
  504. printk(KERN_NOTICE "Unable to attach Blackfin UART TX DMA channel\n");
  505. free_dma(uart->rx_dma_channel);
  506. return -EBUSY;
  507. }
  508. set_dma_callback(uart->rx_dma_channel, bfin_serial_dma_rx_int, uart);
  509. set_dma_callback(uart->tx_dma_channel, bfin_serial_dma_tx_int, uart);
  510. uart->rx_dma_buf.buf = (unsigned char *)dma_alloc_coherent(NULL, PAGE_SIZE, &dma_handle, GFP_DMA);
  511. uart->rx_dma_buf.head = 0;
  512. uart->rx_dma_buf.tail = 0;
  513. uart->rx_dma_nrows = 0;
  514. set_dma_config(uart->rx_dma_channel,
  515. set_bfin_dma_config(DIR_WRITE, DMA_FLOW_AUTO,
  516. INTR_ON_ROW, DIMENSION_2D,
  517. DATA_SIZE_8,
  518. DMA_SYNC_RESTART));
  519. set_dma_x_count(uart->rx_dma_channel, DMA_RX_XCOUNT);
  520. set_dma_x_modify(uart->rx_dma_channel, 1);
  521. set_dma_y_count(uart->rx_dma_channel, DMA_RX_YCOUNT);
  522. set_dma_y_modify(uart->rx_dma_channel, 1);
  523. set_dma_start_addr(uart->rx_dma_channel, (unsigned long)uart->rx_dma_buf.buf);
  524. enable_dma(uart->rx_dma_channel);
  525. uart->rx_dma_timer.data = (unsigned long)(uart);
  526. uart->rx_dma_timer.function = (void *)bfin_serial_rx_dma_timeout;
  527. uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES;
  528. add_timer(&(uart->rx_dma_timer));
  529. #else
  530. if (request_irq(uart->port.irq, bfin_serial_rx_int, IRQF_DISABLED,
  531. "BFIN_UART_RX", uart)) {
  532. # ifdef CONFIG_KGDB_UART
  533. if (uart->port.line != CONFIG_KGDB_UART_PORT) {
  534. # endif
  535. printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n");
  536. return -EBUSY;
  537. # ifdef CONFIG_KGDB_UART
  538. }
  539. # endif
  540. }
  541. if (request_irq
  542. (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED,
  543. "BFIN_UART_TX", uart)) {
  544. printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n");
  545. free_irq(uart->port.irq, uart);
  546. return -EBUSY;
  547. }
  548. #endif
  549. UART_SET_IER(uart, ERBFI);
  550. return 0;
  551. }
  552. static void bfin_serial_shutdown(struct uart_port *port)
  553. {
  554. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  555. #ifdef CONFIG_SERIAL_BFIN_DMA
  556. disable_dma(uart->tx_dma_channel);
  557. free_dma(uart->tx_dma_channel);
  558. disable_dma(uart->rx_dma_channel);
  559. free_dma(uart->rx_dma_channel);
  560. del_timer(&(uart->rx_dma_timer));
  561. dma_free_coherent(NULL, PAGE_SIZE, uart->rx_dma_buf.buf, 0);
  562. #else
  563. #ifdef CONFIG_KGDB_UART
  564. if (uart->port.line != CONFIG_KGDB_UART_PORT)
  565. #endif
  566. free_irq(uart->port.irq, uart);
  567. free_irq(uart->port.irq+1, uart);
  568. #endif
  569. }
  570. static void
  571. bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
  572. struct ktermios *old)
  573. {
  574. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  575. unsigned long flags;
  576. unsigned int baud, quot;
  577. unsigned short val, ier, lcr = 0;
  578. switch (termios->c_cflag & CSIZE) {
  579. case CS8:
  580. lcr = WLS(8);
  581. break;
  582. case CS7:
  583. lcr = WLS(7);
  584. break;
  585. case CS6:
  586. lcr = WLS(6);
  587. break;
  588. case CS5:
  589. lcr = WLS(5);
  590. break;
  591. default:
  592. printk(KERN_ERR "%s: word lengh not supported\n",
  593. __func__);
  594. }
  595. if (termios->c_cflag & CSTOPB)
  596. lcr |= STB;
  597. if (termios->c_cflag & PARENB)
  598. lcr |= PEN;
  599. if (!(termios->c_cflag & PARODD))
  600. lcr |= EPS;
  601. if (termios->c_cflag & CMSPAR)
  602. lcr |= STP;
  603. port->read_status_mask = OE;
  604. if (termios->c_iflag & INPCK)
  605. port->read_status_mask |= (FE | PE);
  606. if (termios->c_iflag & (BRKINT | PARMRK))
  607. port->read_status_mask |= BI;
  608. /*
  609. * Characters to ignore
  610. */
  611. port->ignore_status_mask = 0;
  612. if (termios->c_iflag & IGNPAR)
  613. port->ignore_status_mask |= FE | PE;
  614. if (termios->c_iflag & IGNBRK) {
  615. port->ignore_status_mask |= BI;
  616. /*
  617. * If we're ignoring parity and break indicators,
  618. * ignore overruns too (for real raw support).
  619. */
  620. if (termios->c_iflag & IGNPAR)
  621. port->ignore_status_mask |= OE;
  622. }
  623. baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
  624. quot = uart_get_divisor(port, baud);
  625. spin_lock_irqsave(&uart->port.lock, flags);
  626. UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
  627. /* Disable UART */
  628. ier = UART_GET_IER(uart);
  629. UART_DISABLE_INTS(uart);
  630. /* Set DLAB in LCR to Access DLL and DLH */
  631. UART_SET_DLAB(uart);
  632. UART_PUT_DLL(uart, quot & 0xFF);
  633. UART_PUT_DLH(uart, (quot >> 8) & 0xFF);
  634. SSYNC();
  635. /* Clear DLAB in LCR to Access THR RBR IER */
  636. UART_CLEAR_DLAB(uart);
  637. UART_PUT_LCR(uart, lcr);
  638. /* Enable UART */
  639. UART_ENABLE_INTS(uart, ier);
  640. val = UART_GET_GCTL(uart);
  641. val |= UCEN;
  642. UART_PUT_GCTL(uart, val);
  643. /* Port speed changed, update the per-port timeout. */
  644. uart_update_timeout(port, termios->c_cflag, baud);
  645. spin_unlock_irqrestore(&uart->port.lock, flags);
  646. }
  647. static const char *bfin_serial_type(struct uart_port *port)
  648. {
  649. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  650. return uart->port.type == PORT_BFIN ? "BFIN-UART" : NULL;
  651. }
  652. /*
  653. * Release the memory region(s) being used by 'port'.
  654. */
  655. static void bfin_serial_release_port(struct uart_port *port)
  656. {
  657. }
  658. /*
  659. * Request the memory region(s) being used by 'port'.
  660. */
  661. static int bfin_serial_request_port(struct uart_port *port)
  662. {
  663. return 0;
  664. }
  665. /*
  666. * Configure/autoconfigure the port.
  667. */
  668. static void bfin_serial_config_port(struct uart_port *port, int flags)
  669. {
  670. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  671. if (flags & UART_CONFIG_TYPE &&
  672. bfin_serial_request_port(&uart->port) == 0)
  673. uart->port.type = PORT_BFIN;
  674. }
  675. /*
  676. * Verify the new serial_struct (for TIOCSSERIAL).
  677. * The only change we allow are to the flags and type, and
  678. * even then only between PORT_BFIN and PORT_UNKNOWN
  679. */
  680. static int
  681. bfin_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
  682. {
  683. return 0;
  684. }
  685. /*
  686. * Enable the IrDA function if tty->ldisc.num is N_IRDA.
  687. * In other cases, disable IrDA function.
  688. */
  689. static void bfin_serial_set_ldisc(struct uart_port *port)
  690. {
  691. int line = port->line;
  692. unsigned short val;
  693. if (line >= port->info->port.tty->driver->num)
  694. return;
  695. switch (port->info->port.tty->termios->c_line) {
  696. case N_IRDA:
  697. val = UART_GET_GCTL(&bfin_serial_ports[line]);
  698. val |= (IREN | RPOLC);
  699. UART_PUT_GCTL(&bfin_serial_ports[line], val);
  700. break;
  701. default:
  702. val = UART_GET_GCTL(&bfin_serial_ports[line]);
  703. val &= ~(IREN | RPOLC);
  704. UART_PUT_GCTL(&bfin_serial_ports[line], val);
  705. }
  706. }
  707. static struct uart_ops bfin_serial_pops = {
  708. .tx_empty = bfin_serial_tx_empty,
  709. .set_mctrl = bfin_serial_set_mctrl,
  710. .get_mctrl = bfin_serial_get_mctrl,
  711. .stop_tx = bfin_serial_stop_tx,
  712. .start_tx = bfin_serial_start_tx,
  713. .stop_rx = bfin_serial_stop_rx,
  714. .enable_ms = bfin_serial_enable_ms,
  715. .break_ctl = bfin_serial_break_ctl,
  716. .startup = bfin_serial_startup,
  717. .shutdown = bfin_serial_shutdown,
  718. .set_termios = bfin_serial_set_termios,
  719. .set_ldisc = bfin_serial_set_ldisc,
  720. .type = bfin_serial_type,
  721. .release_port = bfin_serial_release_port,
  722. .request_port = bfin_serial_request_port,
  723. .config_port = bfin_serial_config_port,
  724. .verify_port = bfin_serial_verify_port,
  725. };
  726. static void __init bfin_serial_init_ports(void)
  727. {
  728. static int first = 1;
  729. int i;
  730. if (!first)
  731. return;
  732. first = 0;
  733. for (i = 0; i < nr_active_ports; i++) {
  734. bfin_serial_ports[i].port.uartclk = get_sclk();
  735. bfin_serial_ports[i].port.fifosize = BFIN_UART_TX_FIFO_SIZE;
  736. bfin_serial_ports[i].port.ops = &bfin_serial_pops;
  737. bfin_serial_ports[i].port.line = i;
  738. bfin_serial_ports[i].port.iotype = UPIO_MEM;
  739. bfin_serial_ports[i].port.membase =
  740. (void __iomem *)bfin_serial_resource[i].uart_base_addr;
  741. bfin_serial_ports[i].port.mapbase =
  742. bfin_serial_resource[i].uart_base_addr;
  743. bfin_serial_ports[i].port.irq =
  744. bfin_serial_resource[i].uart_irq;
  745. bfin_serial_ports[i].port.flags = UPF_BOOT_AUTOCONF;
  746. #ifdef CONFIG_SERIAL_BFIN_DMA
  747. bfin_serial_ports[i].tx_done = 1;
  748. bfin_serial_ports[i].tx_count = 0;
  749. bfin_serial_ports[i].tx_dma_channel =
  750. bfin_serial_resource[i].uart_tx_dma_channel;
  751. bfin_serial_ports[i].rx_dma_channel =
  752. bfin_serial_resource[i].uart_rx_dma_channel;
  753. init_timer(&(bfin_serial_ports[i].rx_dma_timer));
  754. #endif
  755. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  756. init_timer(&(bfin_serial_ports[i].cts_timer));
  757. bfin_serial_ports[i].cts_pin =
  758. bfin_serial_resource[i].uart_cts_pin;
  759. bfin_serial_ports[i].rts_pin =
  760. bfin_serial_resource[i].uart_rts_pin;
  761. #endif
  762. bfin_serial_hw_init(&bfin_serial_ports[i]);
  763. }
  764. }
  765. #ifdef CONFIG_SERIAL_BFIN_CONSOLE
  766. /*
  767. * If the port was already initialised (eg, by a boot loader),
  768. * try to determine the current setup.
  769. */
  770. static void __init
  771. bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
  772. int *parity, int *bits)
  773. {
  774. unsigned short status;
  775. status = UART_GET_IER(uart) & (ERBFI | ETBEI);
  776. if (status == (ERBFI | ETBEI)) {
  777. /* ok, the port was enabled */
  778. u16 lcr, dlh, dll;
  779. lcr = UART_GET_LCR(uart);
  780. *parity = 'n';
  781. if (lcr & PEN) {
  782. if (lcr & EPS)
  783. *parity = 'e';
  784. else
  785. *parity = 'o';
  786. }
  787. switch (lcr & 0x03) {
  788. case 0: *bits = 5; break;
  789. case 1: *bits = 6; break;
  790. case 2: *bits = 7; break;
  791. case 3: *bits = 8; break;
  792. }
  793. /* Set DLAB in LCR to Access DLL and DLH */
  794. UART_SET_DLAB(uart);
  795. dll = UART_GET_DLL(uart);
  796. dlh = UART_GET_DLH(uart);
  797. /* Clear DLAB in LCR to Access THR RBR IER */
  798. UART_CLEAR_DLAB(uart);
  799. *baud = get_sclk() / (16*(dll | dlh << 8));
  800. }
  801. pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits);
  802. }
  803. #endif
  804. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  805. static struct uart_driver bfin_serial_reg;
  806. static int __init
  807. bfin_serial_console_setup(struct console *co, char *options)
  808. {
  809. struct bfin_serial_port *uart;
  810. # ifdef CONFIG_SERIAL_BFIN_CONSOLE
  811. int baud = 57600;
  812. int bits = 8;
  813. int parity = 'n';
  814. # ifdef CONFIG_SERIAL_BFIN_CTSRTS
  815. int flow = 'r';
  816. # else
  817. int flow = 'n';
  818. # endif
  819. # endif
  820. /*
  821. * Check whether an invalid uart number has been specified, and
  822. * if so, search for the first available port that does have
  823. * console support.
  824. */
  825. if (co->index == -1 || co->index >= nr_active_ports)
  826. co->index = 0;
  827. uart = &bfin_serial_ports[co->index];
  828. # ifdef CONFIG_SERIAL_BFIN_CONSOLE
  829. if (options)
  830. uart_parse_options(options, &baud, &parity, &bits, &flow);
  831. else
  832. bfin_serial_console_get_options(uart, &baud, &parity, &bits);
  833. return uart_set_options(&uart->port, co, baud, parity, bits, flow);
  834. # else
  835. return 0;
  836. # endif
  837. }
  838. #endif /* defined (CONFIG_SERIAL_BFIN_CONSOLE) ||
  839. defined (CONFIG_EARLY_PRINTK) */
  840. #ifdef CONFIG_SERIAL_BFIN_CONSOLE
  841. static void bfin_serial_console_putchar(struct uart_port *port, int ch)
  842. {
  843. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  844. while (!(UART_GET_LSR(uart) & THRE))
  845. barrier();
  846. UART_PUT_CHAR(uart, ch);
  847. SSYNC();
  848. }
  849. /*
  850. * Interrupts are disabled on entering
  851. */
  852. static void
  853. bfin_serial_console_write(struct console *co, const char *s, unsigned int count)
  854. {
  855. struct bfin_serial_port *uart = &bfin_serial_ports[co->index];
  856. int flags = 0;
  857. spin_lock_irqsave(&uart->port.lock, flags);
  858. uart_console_write(&uart->port, s, count, bfin_serial_console_putchar);
  859. spin_unlock_irqrestore(&uart->port.lock, flags);
  860. }
  861. static struct console bfin_serial_console = {
  862. .name = BFIN_SERIAL_NAME,
  863. .write = bfin_serial_console_write,
  864. .device = uart_console_device,
  865. .setup = bfin_serial_console_setup,
  866. .flags = CON_PRINTBUFFER,
  867. .index = -1,
  868. .data = &bfin_serial_reg,
  869. };
  870. static int __init bfin_serial_rs_console_init(void)
  871. {
  872. bfin_serial_init_ports();
  873. register_console(&bfin_serial_console);
  874. #ifdef CONFIG_KGDB_UART
  875. kgdb_entry_state = 0;
  876. init_kgdb_uart();
  877. #endif
  878. return 0;
  879. }
  880. console_initcall(bfin_serial_rs_console_init);
  881. #define BFIN_SERIAL_CONSOLE &bfin_serial_console
  882. #else
  883. #define BFIN_SERIAL_CONSOLE NULL
  884. #endif /* CONFIG_SERIAL_BFIN_CONSOLE */
  885. #ifdef CONFIG_EARLY_PRINTK
  886. static __init void early_serial_putc(struct uart_port *port, int ch)
  887. {
  888. unsigned timeout = 0xffff;
  889. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  890. while ((!(UART_GET_LSR(uart) & THRE)) && --timeout)
  891. cpu_relax();
  892. UART_PUT_CHAR(uart, ch);
  893. }
  894. static __init void early_serial_write(struct console *con, const char *s,
  895. unsigned int n)
  896. {
  897. struct bfin_serial_port *uart = &bfin_serial_ports[con->index];
  898. unsigned int i;
  899. for (i = 0; i < n; i++, s++) {
  900. if (*s == '\n')
  901. early_serial_putc(&uart->port, '\r');
  902. early_serial_putc(&uart->port, *s);
  903. }
  904. }
  905. static struct __initdata console bfin_early_serial_console = {
  906. .name = "early_BFuart",
  907. .write = early_serial_write,
  908. .device = uart_console_device,
  909. .flags = CON_PRINTBUFFER,
  910. .setup = bfin_serial_console_setup,
  911. .index = -1,
  912. .data = &bfin_serial_reg,
  913. };
  914. struct console __init *bfin_earlyserial_init(unsigned int port,
  915. unsigned int cflag)
  916. {
  917. struct bfin_serial_port *uart;
  918. struct ktermios t;
  919. if (port == -1 || port >= nr_active_ports)
  920. port = 0;
  921. bfin_serial_init_ports();
  922. bfin_early_serial_console.index = port;
  923. uart = &bfin_serial_ports[port];
  924. t.c_cflag = cflag;
  925. t.c_iflag = 0;
  926. t.c_oflag = 0;
  927. t.c_lflag = ICANON;
  928. t.c_line = port;
  929. bfin_serial_set_termios(&uart->port, &t, &t);
  930. return &bfin_early_serial_console;
  931. }
  932. #endif /* CONFIG_SERIAL_BFIN_CONSOLE */
  933. static struct uart_driver bfin_serial_reg = {
  934. .owner = THIS_MODULE,
  935. .driver_name = "bfin-uart",
  936. .dev_name = BFIN_SERIAL_NAME,
  937. .major = BFIN_SERIAL_MAJOR,
  938. .minor = BFIN_SERIAL_MINOR,
  939. .nr = BFIN_UART_NR_PORTS,
  940. .cons = BFIN_SERIAL_CONSOLE,
  941. };
  942. static int bfin_serial_suspend(struct platform_device *dev, pm_message_t state)
  943. {
  944. int i;
  945. for (i = 0; i < nr_active_ports; i++) {
  946. if (bfin_serial_ports[i].port.dev != &dev->dev)
  947. continue;
  948. uart_suspend_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  949. }
  950. return 0;
  951. }
  952. static int bfin_serial_resume(struct platform_device *dev)
  953. {
  954. int i;
  955. for (i = 0; i < nr_active_ports; i++) {
  956. if (bfin_serial_ports[i].port.dev != &dev->dev)
  957. continue;
  958. uart_resume_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  959. }
  960. return 0;
  961. }
  962. static int bfin_serial_probe(struct platform_device *dev)
  963. {
  964. struct resource *res = dev->resource;
  965. int i;
  966. for (i = 0; i < dev->num_resources; i++, res++)
  967. if (res->flags & IORESOURCE_MEM)
  968. break;
  969. if (i < dev->num_resources) {
  970. for (i = 0; i < nr_active_ports; i++, res++) {
  971. if (bfin_serial_ports[i].port.mapbase != res->start)
  972. continue;
  973. bfin_serial_ports[i].port.dev = &dev->dev;
  974. uart_add_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  975. }
  976. }
  977. return 0;
  978. }
  979. static int bfin_serial_remove(struct platform_device *dev)
  980. {
  981. int i;
  982. for (i = 0; i < nr_active_ports; i++) {
  983. if (bfin_serial_ports[i].port.dev != &dev->dev)
  984. continue;
  985. uart_remove_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  986. bfin_serial_ports[i].port.dev = NULL;
  987. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  988. gpio_free(bfin_serial_ports[i].cts_pin);
  989. gpio_free(bfin_serial_ports[i].rts_pin);
  990. #endif
  991. }
  992. return 0;
  993. }
  994. static struct platform_driver bfin_serial_driver = {
  995. .probe = bfin_serial_probe,
  996. .remove = bfin_serial_remove,
  997. .suspend = bfin_serial_suspend,
  998. .resume = bfin_serial_resume,
  999. .driver = {
  1000. .name = "bfin-uart",
  1001. .owner = THIS_MODULE,
  1002. },
  1003. };
  1004. static int __init bfin_serial_init(void)
  1005. {
  1006. int ret;
  1007. #ifdef CONFIG_KGDB_UART
  1008. struct bfin_serial_port *uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT];
  1009. struct ktermios t;
  1010. #endif
  1011. pr_info("Serial: Blackfin serial driver\n");
  1012. bfin_serial_init_ports();
  1013. ret = uart_register_driver(&bfin_serial_reg);
  1014. if (ret == 0) {
  1015. ret = platform_driver_register(&bfin_serial_driver);
  1016. if (ret) {
  1017. pr_debug("uart register failed\n");
  1018. uart_unregister_driver(&bfin_serial_reg);
  1019. }
  1020. }
  1021. #ifdef CONFIG_KGDB_UART
  1022. if (uart->port.cons->index != CONFIG_KGDB_UART_PORT) {
  1023. request_irq(uart->port.irq, bfin_serial_rx_int,
  1024. IRQF_DISABLED, "BFIN_UART_RX", uart);
  1025. pr_info("Request irq for kgdb uart port\n");
  1026. UART_SET_IER(uart, ERBFI);
  1027. SSYNC();
  1028. t.c_cflag = CS8|B57600;
  1029. t.c_iflag = 0;
  1030. t.c_oflag = 0;
  1031. t.c_lflag = ICANON;
  1032. t.c_line = CONFIG_KGDB_UART_PORT;
  1033. bfin_serial_set_termios(&uart->port, &t, &t);
  1034. }
  1035. #endif
  1036. return ret;
  1037. }
  1038. static void __exit bfin_serial_exit(void)
  1039. {
  1040. platform_driver_unregister(&bfin_serial_driver);
  1041. uart_unregister_driver(&bfin_serial_reg);
  1042. }
  1043. module_init(bfin_serial_init);
  1044. module_exit(bfin_serial_exit);
  1045. MODULE_AUTHOR("Aubrey.Li <aubrey.li@analog.com>");
  1046. MODULE_DESCRIPTION("Blackfin generic serial port driver");
  1047. MODULE_LICENSE("GPL");
  1048. MODULE_ALIAS_CHARDEV_MAJOR(BFIN_SERIAL_MAJOR);
  1049. MODULE_ALIAS("platform:bfin-uart");