bfin_5xx.c 30 KB

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