bfin_5xx.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  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. bfin_serial_stop_tx(&uart->port);
  256. return;
  257. }
  258. if (uart->port.x_char) {
  259. UART_PUT_CHAR(uart, uart->port.x_char);
  260. uart->port.icount.tx++;
  261. uart->port.x_char = 0;
  262. }
  263. while ((UART_GET_LSR(uart) & THRE) && xmit->tail != xmit->head) {
  264. UART_PUT_CHAR(uart, xmit->buf[xmit->tail]);
  265. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  266. uart->port.icount.tx++;
  267. SSYNC();
  268. }
  269. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  270. uart_write_wakeup(&uart->port);
  271. if (uart_circ_empty(xmit))
  272. bfin_serial_stop_tx(&uart->port);
  273. }
  274. static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id)
  275. {
  276. struct bfin_serial_port *uart = dev_id;
  277. spin_lock(&uart->port.lock);
  278. while (UART_GET_LSR(uart) & DR)
  279. bfin_serial_rx_chars(uart);
  280. spin_unlock(&uart->port.lock);
  281. return IRQ_HANDLED;
  282. }
  283. static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
  284. {
  285. struct bfin_serial_port *uart = dev_id;
  286. spin_lock(&uart->port.lock);
  287. if (UART_GET_LSR(uart) & THRE)
  288. bfin_serial_tx_chars(uart);
  289. spin_unlock(&uart->port.lock);
  290. return IRQ_HANDLED;
  291. }
  292. #endif
  293. #ifdef CONFIG_SERIAL_BFIN_DMA
  294. static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
  295. {
  296. struct circ_buf *xmit = &uart->port.info->xmit;
  297. uart->tx_done = 0;
  298. /*
  299. * Check the modem control lines before
  300. * transmitting anything.
  301. */
  302. bfin_serial_mctrl_check(uart);
  303. if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
  304. uart->tx_count = 0;
  305. uart->tx_done = 1;
  306. return;
  307. }
  308. if (uart->port.x_char) {
  309. UART_PUT_CHAR(uart, uart->port.x_char);
  310. uart->port.icount.tx++;
  311. uart->port.x_char = 0;
  312. }
  313. uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE);
  314. if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail))
  315. uart->tx_count = UART_XMIT_SIZE - xmit->tail;
  316. blackfin_dcache_flush_range((unsigned long)(xmit->buf+xmit->tail),
  317. (unsigned long)(xmit->buf+xmit->tail+uart->tx_count));
  318. set_dma_config(uart->tx_dma_channel,
  319. set_bfin_dma_config(DIR_READ, DMA_FLOW_STOP,
  320. INTR_ON_BUF,
  321. DIMENSION_LINEAR,
  322. DATA_SIZE_8,
  323. DMA_SYNC_RESTART));
  324. set_dma_start_addr(uart->tx_dma_channel, (unsigned long)(xmit->buf+xmit->tail));
  325. set_dma_x_count(uart->tx_dma_channel, uart->tx_count);
  326. set_dma_x_modify(uart->tx_dma_channel, 1);
  327. enable_dma(uart->tx_dma_channel);
  328. UART_SET_IER(uart, ETBEI);
  329. }
  330. static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
  331. {
  332. struct tty_struct *tty = uart->port.info->port.tty;
  333. int i, flg, status;
  334. status = UART_GET_LSR(uart);
  335. UART_CLEAR_LSR(uart);
  336. uart->port.icount.rx +=
  337. CIRC_CNT(uart->rx_dma_buf.head, uart->rx_dma_buf.tail,
  338. UART_XMIT_SIZE);
  339. if (status & BI) {
  340. uart->port.icount.brk++;
  341. if (uart_handle_break(&uart->port))
  342. goto dma_ignore_char;
  343. status &= ~(PE | FE);
  344. }
  345. if (status & PE)
  346. uart->port.icount.parity++;
  347. if (status & OE)
  348. uart->port.icount.overrun++;
  349. if (status & FE)
  350. uart->port.icount.frame++;
  351. status &= uart->port.read_status_mask;
  352. if (status & BI)
  353. flg = TTY_BREAK;
  354. else if (status & PE)
  355. flg = TTY_PARITY;
  356. else if (status & FE)
  357. flg = TTY_FRAME;
  358. else
  359. flg = TTY_NORMAL;
  360. for (i = uart->rx_dma_buf.tail; i != uart->rx_dma_buf.head; i++) {
  361. if (i >= UART_XMIT_SIZE)
  362. i = 0;
  363. if (!uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i]))
  364. uart_insert_char(&uart->port, status, OE,
  365. uart->rx_dma_buf.buf[i], flg);
  366. }
  367. dma_ignore_char:
  368. tty_flip_buffer_push(tty);
  369. }
  370. void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
  371. {
  372. int x_pos, pos;
  373. uart->rx_dma_nrows = get_dma_curr_ycount(uart->rx_dma_channel);
  374. x_pos = get_dma_curr_xcount(uart->rx_dma_channel);
  375. uart->rx_dma_nrows = DMA_RX_YCOUNT - uart->rx_dma_nrows;
  376. if (uart->rx_dma_nrows == DMA_RX_YCOUNT)
  377. uart->rx_dma_nrows = 0;
  378. x_pos = DMA_RX_XCOUNT - x_pos;
  379. if (x_pos == DMA_RX_XCOUNT)
  380. x_pos = 0;
  381. pos = uart->rx_dma_nrows * DMA_RX_XCOUNT + x_pos;
  382. if (pos != uart->rx_dma_buf.tail) {
  383. uart->rx_dma_buf.head = pos;
  384. bfin_serial_dma_rx_chars(uart);
  385. uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
  386. }
  387. mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES);
  388. }
  389. static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
  390. {
  391. struct bfin_serial_port *uart = dev_id;
  392. struct circ_buf *xmit = &uart->port.info->xmit;
  393. spin_lock(&uart->port.lock);
  394. if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) {
  395. disable_dma(uart->tx_dma_channel);
  396. clear_dma_irqstat(uart->tx_dma_channel);
  397. UART_CLEAR_IER(uart, ETBEI);
  398. xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
  399. uart->port.icount.tx += uart->tx_count;
  400. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  401. uart_write_wakeup(&uart->port);
  402. bfin_serial_dma_tx_chars(uart);
  403. }
  404. spin_unlock(&uart->port.lock);
  405. return IRQ_HANDLED;
  406. }
  407. static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id)
  408. {
  409. struct bfin_serial_port *uart = dev_id;
  410. unsigned short irqstat;
  411. spin_lock(&uart->port.lock);
  412. irqstat = get_dma_curr_irqstat(uart->rx_dma_channel);
  413. clear_dma_irqstat(uart->rx_dma_channel);
  414. spin_unlock(&uart->port.lock);
  415. mod_timer(&(uart->rx_dma_timer), jiffies);
  416. return IRQ_HANDLED;
  417. }
  418. #endif
  419. /*
  420. * Return TIOCSER_TEMT when transmitter is not busy.
  421. */
  422. static unsigned int bfin_serial_tx_empty(struct uart_port *port)
  423. {
  424. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  425. unsigned short lsr;
  426. lsr = UART_GET_LSR(uart);
  427. if (lsr & TEMT)
  428. return TIOCSER_TEMT;
  429. else
  430. return 0;
  431. }
  432. static unsigned int bfin_serial_get_mctrl(struct uart_port *port)
  433. {
  434. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  435. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  436. if (uart->cts_pin < 0)
  437. return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
  438. if (UART_GET_CTS(uart))
  439. return TIOCM_DSR | TIOCM_CAR;
  440. else
  441. #endif
  442. return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
  443. }
  444. static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
  445. {
  446. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  447. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  448. if (uart->rts_pin < 0)
  449. return;
  450. if (mctrl & TIOCM_RTS)
  451. UART_CLEAR_RTS(uart);
  452. else
  453. UART_SET_RTS(uart);
  454. #endif
  455. }
  456. /*
  457. * Handle any change of modem status signal since we were last called.
  458. */
  459. static void bfin_serial_mctrl_check(struct bfin_serial_port *uart)
  460. {
  461. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  462. unsigned int status;
  463. struct uart_info *info = uart->port.info;
  464. struct tty_struct *tty = info->port.tty;
  465. status = bfin_serial_get_mctrl(&uart->port);
  466. uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
  467. if (!(status & TIOCM_CTS)) {
  468. tty->hw_stopped = 1;
  469. uart->cts_timer.data = (unsigned long)(uart);
  470. uart->cts_timer.function = (void *)bfin_serial_mctrl_check;
  471. uart->cts_timer.expires = jiffies + CTS_CHECK_JIFFIES;
  472. add_timer(&(uart->cts_timer));
  473. } else {
  474. tty->hw_stopped = 0;
  475. }
  476. #endif
  477. }
  478. /*
  479. * Interrupts are always disabled.
  480. */
  481. static void bfin_serial_break_ctl(struct uart_port *port, int break_state)
  482. {
  483. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  484. u16 lcr = UART_GET_LCR(uart);
  485. if (break_state)
  486. lcr |= SB;
  487. else
  488. lcr &= ~SB;
  489. UART_PUT_LCR(uart, lcr);
  490. SSYNC();
  491. }
  492. static int bfin_serial_startup(struct uart_port *port)
  493. {
  494. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  495. #ifdef CONFIG_SERIAL_BFIN_DMA
  496. dma_addr_t dma_handle;
  497. if (request_dma(uart->rx_dma_channel, "BFIN_UART_RX") < 0) {
  498. printk(KERN_NOTICE "Unable to attach Blackfin UART RX DMA channel\n");
  499. return -EBUSY;
  500. }
  501. if (request_dma(uart->tx_dma_channel, "BFIN_UART_TX") < 0) {
  502. printk(KERN_NOTICE "Unable to attach Blackfin UART TX DMA channel\n");
  503. free_dma(uart->rx_dma_channel);
  504. return -EBUSY;
  505. }
  506. set_dma_callback(uart->rx_dma_channel, bfin_serial_dma_rx_int, uart);
  507. set_dma_callback(uart->tx_dma_channel, bfin_serial_dma_tx_int, uart);
  508. uart->rx_dma_buf.buf = (unsigned char *)dma_alloc_coherent(NULL, PAGE_SIZE, &dma_handle, GFP_DMA);
  509. uart->rx_dma_buf.head = 0;
  510. uart->rx_dma_buf.tail = 0;
  511. uart->rx_dma_nrows = 0;
  512. set_dma_config(uart->rx_dma_channel,
  513. set_bfin_dma_config(DIR_WRITE, DMA_FLOW_AUTO,
  514. INTR_ON_ROW, DIMENSION_2D,
  515. DATA_SIZE_8,
  516. DMA_SYNC_RESTART));
  517. set_dma_x_count(uart->rx_dma_channel, DMA_RX_XCOUNT);
  518. set_dma_x_modify(uart->rx_dma_channel, 1);
  519. set_dma_y_count(uart->rx_dma_channel, DMA_RX_YCOUNT);
  520. set_dma_y_modify(uart->rx_dma_channel, 1);
  521. set_dma_start_addr(uart->rx_dma_channel, (unsigned long)uart->rx_dma_buf.buf);
  522. enable_dma(uart->rx_dma_channel);
  523. uart->rx_dma_timer.data = (unsigned long)(uart);
  524. uart->rx_dma_timer.function = (void *)bfin_serial_rx_dma_timeout;
  525. uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES;
  526. add_timer(&(uart->rx_dma_timer));
  527. #else
  528. if (request_irq(uart->port.irq, bfin_serial_rx_int, IRQF_DISABLED,
  529. "BFIN_UART_RX", uart)) {
  530. # ifdef CONFIG_KGDB_UART
  531. if (uart->port.line != CONFIG_KGDB_UART_PORT) {
  532. # endif
  533. printk(KERN_NOTICE "Unable to attach BlackFin UART RX interrupt\n");
  534. return -EBUSY;
  535. # ifdef CONFIG_KGDB_UART
  536. }
  537. # endif
  538. }
  539. if (request_irq
  540. (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED,
  541. "BFIN_UART_TX", uart)) {
  542. printk(KERN_NOTICE "Unable to attach BlackFin UART TX interrupt\n");
  543. free_irq(uart->port.irq, uart);
  544. return -EBUSY;
  545. }
  546. #endif
  547. UART_SET_IER(uart, ERBFI);
  548. return 0;
  549. }
  550. static void bfin_serial_shutdown(struct uart_port *port)
  551. {
  552. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  553. #ifdef CONFIG_SERIAL_BFIN_DMA
  554. disable_dma(uart->tx_dma_channel);
  555. free_dma(uart->tx_dma_channel);
  556. disable_dma(uart->rx_dma_channel);
  557. free_dma(uart->rx_dma_channel);
  558. del_timer(&(uart->rx_dma_timer));
  559. dma_free_coherent(NULL, PAGE_SIZE, uart->rx_dma_buf.buf, 0);
  560. #else
  561. #ifdef CONFIG_KGDB_UART
  562. if (uart->port.line != CONFIG_KGDB_UART_PORT)
  563. #endif
  564. free_irq(uart->port.irq, uart);
  565. free_irq(uart->port.irq+1, uart);
  566. #endif
  567. }
  568. static void
  569. bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
  570. struct ktermios *old)
  571. {
  572. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  573. unsigned long flags;
  574. unsigned int baud, quot;
  575. unsigned short val, ier, lcr = 0;
  576. switch (termios->c_cflag & CSIZE) {
  577. case CS8:
  578. lcr = WLS(8);
  579. break;
  580. case CS7:
  581. lcr = WLS(7);
  582. break;
  583. case CS6:
  584. lcr = WLS(6);
  585. break;
  586. case CS5:
  587. lcr = WLS(5);
  588. break;
  589. default:
  590. printk(KERN_ERR "%s: word lengh not supported\n",
  591. __func__);
  592. }
  593. if (termios->c_cflag & CSTOPB)
  594. lcr |= STB;
  595. if (termios->c_cflag & PARENB)
  596. lcr |= PEN;
  597. if (!(termios->c_cflag & PARODD))
  598. lcr |= EPS;
  599. if (termios->c_cflag & CMSPAR)
  600. lcr |= STP;
  601. port->read_status_mask = OE;
  602. if (termios->c_iflag & INPCK)
  603. port->read_status_mask |= (FE | PE);
  604. if (termios->c_iflag & (BRKINT | PARMRK))
  605. port->read_status_mask |= BI;
  606. /*
  607. * Characters to ignore
  608. */
  609. port->ignore_status_mask = 0;
  610. if (termios->c_iflag & IGNPAR)
  611. port->ignore_status_mask |= FE | PE;
  612. if (termios->c_iflag & IGNBRK) {
  613. port->ignore_status_mask |= BI;
  614. /*
  615. * If we're ignoring parity and break indicators,
  616. * ignore overruns too (for real raw support).
  617. */
  618. if (termios->c_iflag & IGNPAR)
  619. port->ignore_status_mask |= OE;
  620. }
  621. baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
  622. quot = uart_get_divisor(port, baud);
  623. spin_lock_irqsave(&uart->port.lock, flags);
  624. UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
  625. /* Disable UART */
  626. ier = UART_GET_IER(uart);
  627. UART_DISABLE_INTS(uart);
  628. /* Set DLAB in LCR to Access DLL and DLH */
  629. UART_SET_DLAB(uart);
  630. UART_PUT_DLL(uart, quot & 0xFF);
  631. UART_PUT_DLH(uart, (quot >> 8) & 0xFF);
  632. SSYNC();
  633. /* Clear DLAB in LCR to Access THR RBR IER */
  634. UART_CLEAR_DLAB(uart);
  635. UART_PUT_LCR(uart, lcr);
  636. /* Enable UART */
  637. UART_ENABLE_INTS(uart, ier);
  638. val = UART_GET_GCTL(uart);
  639. val |= UCEN;
  640. UART_PUT_GCTL(uart, val);
  641. spin_unlock_irqrestore(&uart->port.lock, flags);
  642. }
  643. static const char *bfin_serial_type(struct uart_port *port)
  644. {
  645. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  646. return uart->port.type == PORT_BFIN ? "BFIN-UART" : NULL;
  647. }
  648. /*
  649. * Release the memory region(s) being used by 'port'.
  650. */
  651. static void bfin_serial_release_port(struct uart_port *port)
  652. {
  653. }
  654. /*
  655. * Request the memory region(s) being used by 'port'.
  656. */
  657. static int bfin_serial_request_port(struct uart_port *port)
  658. {
  659. return 0;
  660. }
  661. /*
  662. * Configure/autoconfigure the port.
  663. */
  664. static void bfin_serial_config_port(struct uart_port *port, int flags)
  665. {
  666. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  667. if (flags & UART_CONFIG_TYPE &&
  668. bfin_serial_request_port(&uart->port) == 0)
  669. uart->port.type = PORT_BFIN;
  670. }
  671. /*
  672. * Verify the new serial_struct (for TIOCSSERIAL).
  673. * The only change we allow are to the flags and type, and
  674. * even then only between PORT_BFIN and PORT_UNKNOWN
  675. */
  676. static int
  677. bfin_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
  678. {
  679. return 0;
  680. }
  681. /*
  682. * Enable the IrDA function if tty->ldisc.num is N_IRDA.
  683. * In other cases, disable IrDA function.
  684. */
  685. static void bfin_serial_set_ldisc(struct uart_port *port)
  686. {
  687. int line = port->line;
  688. unsigned short val;
  689. if (line >= port->info->port.tty->driver->num)
  690. return;
  691. switch (port->info->port.tty->termios->c_line) {
  692. case N_IRDA:
  693. val = UART_GET_GCTL(&bfin_serial_ports[line]);
  694. val |= (IREN | RPOLC);
  695. UART_PUT_GCTL(&bfin_serial_ports[line], val);
  696. break;
  697. default:
  698. val = UART_GET_GCTL(&bfin_serial_ports[line]);
  699. val &= ~(IREN | RPOLC);
  700. UART_PUT_GCTL(&bfin_serial_ports[line], val);
  701. }
  702. }
  703. static struct uart_ops bfin_serial_pops = {
  704. .tx_empty = bfin_serial_tx_empty,
  705. .set_mctrl = bfin_serial_set_mctrl,
  706. .get_mctrl = bfin_serial_get_mctrl,
  707. .stop_tx = bfin_serial_stop_tx,
  708. .start_tx = bfin_serial_start_tx,
  709. .stop_rx = bfin_serial_stop_rx,
  710. .enable_ms = bfin_serial_enable_ms,
  711. .break_ctl = bfin_serial_break_ctl,
  712. .startup = bfin_serial_startup,
  713. .shutdown = bfin_serial_shutdown,
  714. .set_termios = bfin_serial_set_termios,
  715. .set_ldisc = bfin_serial_set_ldisc,
  716. .type = bfin_serial_type,
  717. .release_port = bfin_serial_release_port,
  718. .request_port = bfin_serial_request_port,
  719. .config_port = bfin_serial_config_port,
  720. .verify_port = bfin_serial_verify_port,
  721. };
  722. static void __init bfin_serial_init_ports(void)
  723. {
  724. static int first = 1;
  725. int i;
  726. if (!first)
  727. return;
  728. first = 0;
  729. for (i = 0; i < nr_active_ports; i++) {
  730. bfin_serial_ports[i].port.uartclk = get_sclk();
  731. bfin_serial_ports[i].port.ops = &bfin_serial_pops;
  732. bfin_serial_ports[i].port.line = i;
  733. bfin_serial_ports[i].port.iotype = UPIO_MEM;
  734. bfin_serial_ports[i].port.membase =
  735. (void __iomem *)bfin_serial_resource[i].uart_base_addr;
  736. bfin_serial_ports[i].port.mapbase =
  737. bfin_serial_resource[i].uart_base_addr;
  738. bfin_serial_ports[i].port.irq =
  739. bfin_serial_resource[i].uart_irq;
  740. bfin_serial_ports[i].port.flags = UPF_BOOT_AUTOCONF;
  741. #ifdef CONFIG_SERIAL_BFIN_DMA
  742. bfin_serial_ports[i].tx_done = 1;
  743. bfin_serial_ports[i].tx_count = 0;
  744. bfin_serial_ports[i].tx_dma_channel =
  745. bfin_serial_resource[i].uart_tx_dma_channel;
  746. bfin_serial_ports[i].rx_dma_channel =
  747. bfin_serial_resource[i].uart_rx_dma_channel;
  748. init_timer(&(bfin_serial_ports[i].rx_dma_timer));
  749. #endif
  750. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  751. init_timer(&(bfin_serial_ports[i].cts_timer));
  752. bfin_serial_ports[i].cts_pin =
  753. bfin_serial_resource[i].uart_cts_pin;
  754. bfin_serial_ports[i].rts_pin =
  755. bfin_serial_resource[i].uart_rts_pin;
  756. #endif
  757. bfin_serial_hw_init(&bfin_serial_ports[i]);
  758. }
  759. }
  760. #ifdef CONFIG_SERIAL_BFIN_CONSOLE
  761. /*
  762. * If the port was already initialised (eg, by a boot loader),
  763. * try to determine the current setup.
  764. */
  765. static void __init
  766. bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
  767. int *parity, int *bits)
  768. {
  769. unsigned short status;
  770. status = UART_GET_IER(uart) & (ERBFI | ETBEI);
  771. if (status == (ERBFI | ETBEI)) {
  772. /* ok, the port was enabled */
  773. u16 lcr, dlh, dll;
  774. lcr = UART_GET_LCR(uart);
  775. *parity = 'n';
  776. if (lcr & PEN) {
  777. if (lcr & EPS)
  778. *parity = 'e';
  779. else
  780. *parity = 'o';
  781. }
  782. switch (lcr & 0x03) {
  783. case 0: *bits = 5; break;
  784. case 1: *bits = 6; break;
  785. case 2: *bits = 7; break;
  786. case 3: *bits = 8; break;
  787. }
  788. /* Set DLAB in LCR to Access DLL and DLH */
  789. UART_SET_DLAB(uart);
  790. dll = UART_GET_DLL(uart);
  791. dlh = UART_GET_DLH(uart);
  792. /* Clear DLAB in LCR to Access THR RBR IER */
  793. UART_CLEAR_DLAB(uart);
  794. *baud = get_sclk() / (16*(dll | dlh << 8));
  795. }
  796. pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits);
  797. }
  798. #endif
  799. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  800. static struct uart_driver bfin_serial_reg;
  801. static int __init
  802. bfin_serial_console_setup(struct console *co, char *options)
  803. {
  804. struct bfin_serial_port *uart;
  805. # ifdef CONFIG_SERIAL_BFIN_CONSOLE
  806. int baud = 57600;
  807. int bits = 8;
  808. int parity = 'n';
  809. # ifdef CONFIG_SERIAL_BFIN_CTSRTS
  810. int flow = 'r';
  811. # else
  812. int flow = 'n';
  813. # endif
  814. # endif
  815. /*
  816. * Check whether an invalid uart number has been specified, and
  817. * if so, search for the first available port that does have
  818. * console support.
  819. */
  820. if (co->index == -1 || co->index >= nr_active_ports)
  821. co->index = 0;
  822. uart = &bfin_serial_ports[co->index];
  823. # ifdef CONFIG_SERIAL_BFIN_CONSOLE
  824. if (options)
  825. uart_parse_options(options, &baud, &parity, &bits, &flow);
  826. else
  827. bfin_serial_console_get_options(uart, &baud, &parity, &bits);
  828. return uart_set_options(&uart->port, co, baud, parity, bits, flow);
  829. # else
  830. return 0;
  831. # endif
  832. }
  833. #endif /* defined (CONFIG_SERIAL_BFIN_CONSOLE) ||
  834. defined (CONFIG_EARLY_PRINTK) */
  835. #ifdef CONFIG_SERIAL_BFIN_CONSOLE
  836. static void bfin_serial_console_putchar(struct uart_port *port, int ch)
  837. {
  838. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  839. while (!(UART_GET_LSR(uart) & THRE))
  840. barrier();
  841. UART_PUT_CHAR(uart, ch);
  842. SSYNC();
  843. }
  844. /*
  845. * Interrupts are disabled on entering
  846. */
  847. static void
  848. bfin_serial_console_write(struct console *co, const char *s, unsigned int count)
  849. {
  850. struct bfin_serial_port *uart = &bfin_serial_ports[co->index];
  851. int flags = 0;
  852. spin_lock_irqsave(&uart->port.lock, flags);
  853. uart_console_write(&uart->port, s, count, bfin_serial_console_putchar);
  854. spin_unlock_irqrestore(&uart->port.lock, flags);
  855. }
  856. static struct console bfin_serial_console = {
  857. .name = BFIN_SERIAL_NAME,
  858. .write = bfin_serial_console_write,
  859. .device = uart_console_device,
  860. .setup = bfin_serial_console_setup,
  861. .flags = CON_PRINTBUFFER,
  862. .index = -1,
  863. .data = &bfin_serial_reg,
  864. };
  865. static int __init bfin_serial_rs_console_init(void)
  866. {
  867. bfin_serial_init_ports();
  868. register_console(&bfin_serial_console);
  869. #ifdef CONFIG_KGDB_UART
  870. kgdb_entry_state = 0;
  871. init_kgdb_uart();
  872. #endif
  873. return 0;
  874. }
  875. console_initcall(bfin_serial_rs_console_init);
  876. #define BFIN_SERIAL_CONSOLE &bfin_serial_console
  877. #else
  878. #define BFIN_SERIAL_CONSOLE NULL
  879. #endif /* CONFIG_SERIAL_BFIN_CONSOLE */
  880. #ifdef CONFIG_EARLY_PRINTK
  881. static __init void early_serial_putc(struct uart_port *port, int ch)
  882. {
  883. unsigned timeout = 0xffff;
  884. struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
  885. while ((!(UART_GET_LSR(uart) & THRE)) && --timeout)
  886. cpu_relax();
  887. UART_PUT_CHAR(uart, ch);
  888. }
  889. static __init void early_serial_write(struct console *con, const char *s,
  890. unsigned int n)
  891. {
  892. struct bfin_serial_port *uart = &bfin_serial_ports[con->index];
  893. unsigned int i;
  894. for (i = 0; i < n; i++, s++) {
  895. if (*s == '\n')
  896. early_serial_putc(&uart->port, '\r');
  897. early_serial_putc(&uart->port, *s);
  898. }
  899. }
  900. static struct __initdata console bfin_early_serial_console = {
  901. .name = "early_BFuart",
  902. .write = early_serial_write,
  903. .device = uart_console_device,
  904. .flags = CON_PRINTBUFFER,
  905. .setup = bfin_serial_console_setup,
  906. .index = -1,
  907. .data = &bfin_serial_reg,
  908. };
  909. struct console __init *bfin_earlyserial_init(unsigned int port,
  910. unsigned int cflag)
  911. {
  912. struct bfin_serial_port *uart;
  913. struct ktermios t;
  914. if (port == -1 || port >= nr_active_ports)
  915. port = 0;
  916. bfin_serial_init_ports();
  917. bfin_early_serial_console.index = port;
  918. uart = &bfin_serial_ports[port];
  919. t.c_cflag = cflag;
  920. t.c_iflag = 0;
  921. t.c_oflag = 0;
  922. t.c_lflag = ICANON;
  923. t.c_line = port;
  924. bfin_serial_set_termios(&uart->port, &t, &t);
  925. return &bfin_early_serial_console;
  926. }
  927. #endif /* CONFIG_SERIAL_BFIN_CONSOLE */
  928. static struct uart_driver bfin_serial_reg = {
  929. .owner = THIS_MODULE,
  930. .driver_name = "bfin-uart",
  931. .dev_name = BFIN_SERIAL_NAME,
  932. .major = BFIN_SERIAL_MAJOR,
  933. .minor = BFIN_SERIAL_MINOR,
  934. .nr = BFIN_UART_NR_PORTS,
  935. .cons = BFIN_SERIAL_CONSOLE,
  936. };
  937. static int bfin_serial_suspend(struct platform_device *dev, pm_message_t state)
  938. {
  939. int i;
  940. for (i = 0; i < nr_active_ports; i++) {
  941. if (bfin_serial_ports[i].port.dev != &dev->dev)
  942. continue;
  943. uart_suspend_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  944. }
  945. return 0;
  946. }
  947. static int bfin_serial_resume(struct platform_device *dev)
  948. {
  949. int i;
  950. for (i = 0; i < nr_active_ports; i++) {
  951. if (bfin_serial_ports[i].port.dev != &dev->dev)
  952. continue;
  953. uart_resume_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  954. }
  955. return 0;
  956. }
  957. static int bfin_serial_probe(struct platform_device *dev)
  958. {
  959. struct resource *res = dev->resource;
  960. int i;
  961. for (i = 0; i < dev->num_resources; i++, res++)
  962. if (res->flags & IORESOURCE_MEM)
  963. break;
  964. if (i < dev->num_resources) {
  965. for (i = 0; i < nr_active_ports; i++, res++) {
  966. if (bfin_serial_ports[i].port.mapbase != res->start)
  967. continue;
  968. bfin_serial_ports[i].port.dev = &dev->dev;
  969. uart_add_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  970. }
  971. }
  972. return 0;
  973. }
  974. static int bfin_serial_remove(struct platform_device *dev)
  975. {
  976. int i;
  977. for (i = 0; i < nr_active_ports; i++) {
  978. if (bfin_serial_ports[i].port.dev != &dev->dev)
  979. continue;
  980. uart_remove_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
  981. bfin_serial_ports[i].port.dev = NULL;
  982. #ifdef CONFIG_SERIAL_BFIN_CTSRTS
  983. gpio_free(bfin_serial_ports[i].cts_pin);
  984. gpio_free(bfin_serial_ports[i].rts_pin);
  985. #endif
  986. }
  987. return 0;
  988. }
  989. static struct platform_driver bfin_serial_driver = {
  990. .probe = bfin_serial_probe,
  991. .remove = bfin_serial_remove,
  992. .suspend = bfin_serial_suspend,
  993. .resume = bfin_serial_resume,
  994. .driver = {
  995. .name = "bfin-uart",
  996. .owner = THIS_MODULE,
  997. },
  998. };
  999. static int __init bfin_serial_init(void)
  1000. {
  1001. int ret;
  1002. #ifdef CONFIG_KGDB_UART
  1003. struct bfin_serial_port *uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT];
  1004. struct ktermios t;
  1005. #endif
  1006. pr_info("Serial: Blackfin serial driver\n");
  1007. bfin_serial_init_ports();
  1008. ret = uart_register_driver(&bfin_serial_reg);
  1009. if (ret == 0) {
  1010. ret = platform_driver_register(&bfin_serial_driver);
  1011. if (ret) {
  1012. pr_debug("uart register failed\n");
  1013. uart_unregister_driver(&bfin_serial_reg);
  1014. }
  1015. }
  1016. #ifdef CONFIG_KGDB_UART
  1017. if (uart->port.cons->index != CONFIG_KGDB_UART_PORT) {
  1018. request_irq(uart->port.irq, bfin_serial_rx_int,
  1019. IRQF_DISABLED, "BFIN_UART_RX", uart);
  1020. pr_info("Request irq for kgdb uart port\n");
  1021. UART_SET_IER(uart, ERBFI);
  1022. SSYNC();
  1023. t.c_cflag = CS8|B57600;
  1024. t.c_iflag = 0;
  1025. t.c_oflag = 0;
  1026. t.c_lflag = ICANON;
  1027. t.c_line = CONFIG_KGDB_UART_PORT;
  1028. bfin_serial_set_termios(&uart->port, &t, &t);
  1029. }
  1030. #endif
  1031. return ret;
  1032. }
  1033. static void __exit bfin_serial_exit(void)
  1034. {
  1035. platform_driver_unregister(&bfin_serial_driver);
  1036. uart_unregister_driver(&bfin_serial_reg);
  1037. }
  1038. module_init(bfin_serial_init);
  1039. module_exit(bfin_serial_exit);
  1040. MODULE_AUTHOR("Aubrey.Li <aubrey.li@analog.com>");
  1041. MODULE_DESCRIPTION("Blackfin generic serial port driver");
  1042. MODULE_LICENSE("GPL");
  1043. MODULE_ALIAS_CHARDEV_MAJOR(BFIN_SERIAL_MAJOR);
  1044. MODULE_ALIAS("platform:bfin-uart");