bfin_5xx.c 30 KB

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