bfin_5xx.c 30 KB

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