serial.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. * arch/arm/mach-omap2/serial.c
  3. *
  4. * OMAP2 serial support.
  5. *
  6. * Copyright (C) 2005-2008 Nokia Corporation
  7. * Author: Paul Mundt <paul.mundt@nokia.com>
  8. *
  9. * Major rework for PM support by Kevin Hilman
  10. *
  11. * Based off of arch/arm/mach-omap/omap1/serial.c
  12. *
  13. * Copyright (C) 2009 Texas Instruments
  14. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com
  15. *
  16. * This file is subject to the terms and conditions of the GNU General Public
  17. * License. See the file "COPYING" in the main directory of this archive
  18. * for more details.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/serial_8250.h>
  23. #include <linux/serial_reg.h>
  24. #include <linux/clk.h>
  25. #include <linux/io.h>
  26. #include <plat/common.h>
  27. #include <plat/board.h>
  28. #include <plat/clock.h>
  29. #include <plat/control.h>
  30. #include "prm.h"
  31. #include "pm.h"
  32. #include "prm-regbits-34xx.h"
  33. #define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV 0x52
  34. #define UART_OMAP_WER 0x17 /* Wake-up enable register */
  35. #define DEFAULT_TIMEOUT (5 * HZ)
  36. struct omap_uart_state {
  37. int num;
  38. int can_sleep;
  39. struct timer_list timer;
  40. u32 timeout;
  41. void __iomem *wk_st;
  42. void __iomem *wk_en;
  43. u32 wk_mask;
  44. u32 padconf;
  45. struct clk *ick;
  46. struct clk *fck;
  47. int clocked;
  48. struct plat_serial8250_port *p;
  49. struct list_head node;
  50. struct platform_device pdev;
  51. #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
  52. int context_valid;
  53. /* Registers to be saved/restored for OFF-mode */
  54. u16 dll;
  55. u16 dlh;
  56. u16 ier;
  57. u16 sysc;
  58. u16 scr;
  59. u16 wer;
  60. #endif
  61. };
  62. static LIST_HEAD(uart_list);
  63. static struct plat_serial8250_port serial_platform_data0[] = {
  64. {
  65. .mapbase = OMAP_UART1_BASE,
  66. .irq = 72,
  67. .flags = UPF_BOOT_AUTOCONF,
  68. .iotype = UPIO_MEM,
  69. .regshift = 2,
  70. .uartclk = OMAP24XX_BASE_BAUD * 16,
  71. }, {
  72. .flags = 0
  73. }
  74. };
  75. static struct plat_serial8250_port serial_platform_data1[] = {
  76. {
  77. .mapbase = OMAP_UART2_BASE,
  78. .irq = 73,
  79. .flags = UPF_BOOT_AUTOCONF,
  80. .iotype = UPIO_MEM,
  81. .regshift = 2,
  82. .uartclk = OMAP24XX_BASE_BAUD * 16,
  83. }, {
  84. .flags = 0
  85. }
  86. };
  87. static struct plat_serial8250_port serial_platform_data2[] = {
  88. {
  89. .mapbase = OMAP_UART3_BASE,
  90. .irq = 74,
  91. .flags = UPF_BOOT_AUTOCONF,
  92. .iotype = UPIO_MEM,
  93. .regshift = 2,
  94. .uartclk = OMAP24XX_BASE_BAUD * 16,
  95. }, {
  96. .flags = 0
  97. }
  98. };
  99. #ifdef CONFIG_ARCH_OMAP4
  100. static struct plat_serial8250_port serial_platform_data3[] = {
  101. {
  102. .mapbase = OMAP_UART4_BASE,
  103. .irq = 70,
  104. .flags = UPF_BOOT_AUTOCONF,
  105. .iotype = UPIO_MEM,
  106. .regshift = 2,
  107. .uartclk = OMAP24XX_BASE_BAUD * 16,
  108. }, {
  109. .flags = 0
  110. }
  111. };
  112. #endif
  113. static inline unsigned int serial_read_reg(struct plat_serial8250_port *up,
  114. int offset)
  115. {
  116. offset <<= up->regshift;
  117. return (unsigned int)__raw_readb(up->membase + offset);
  118. }
  119. static inline void serial_write_reg(struct plat_serial8250_port *p, int offset,
  120. int value)
  121. {
  122. offset <<= p->regshift;
  123. __raw_writeb(value, p->membase + offset);
  124. }
  125. /*
  126. * Internal UARTs need to be initialized for the 8250 autoconfig to work
  127. * properly. Note that the TX watermark initialization may not be needed
  128. * once the 8250.c watermark handling code is merged.
  129. */
  130. static inline void __init omap_uart_reset(struct omap_uart_state *uart)
  131. {
  132. struct plat_serial8250_port *p = uart->p;
  133. serial_write_reg(p, UART_OMAP_MDR1, 0x07);
  134. serial_write_reg(p, UART_OMAP_SCR, 0x08);
  135. serial_write_reg(p, UART_OMAP_MDR1, 0x00);
  136. serial_write_reg(p, UART_OMAP_SYSC, (0x02 << 3) | (1 << 2) | (1 << 0));
  137. }
  138. #if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3)
  139. static void omap_uart_save_context(struct omap_uart_state *uart)
  140. {
  141. u16 lcr = 0;
  142. struct plat_serial8250_port *p = uart->p;
  143. if (!enable_off_mode)
  144. return;
  145. lcr = serial_read_reg(p, UART_LCR);
  146. serial_write_reg(p, UART_LCR, 0xBF);
  147. uart->dll = serial_read_reg(p, UART_DLL);
  148. uart->dlh = serial_read_reg(p, UART_DLM);
  149. serial_write_reg(p, UART_LCR, lcr);
  150. uart->ier = serial_read_reg(p, UART_IER);
  151. uart->sysc = serial_read_reg(p, UART_OMAP_SYSC);
  152. uart->scr = serial_read_reg(p, UART_OMAP_SCR);
  153. uart->wer = serial_read_reg(p, UART_OMAP_WER);
  154. uart->context_valid = 1;
  155. }
  156. static void omap_uart_restore_context(struct omap_uart_state *uart)
  157. {
  158. u16 efr = 0;
  159. struct plat_serial8250_port *p = uart->p;
  160. if (!enable_off_mode)
  161. return;
  162. if (!uart->context_valid)
  163. return;
  164. uart->context_valid = 0;
  165. serial_write_reg(p, UART_OMAP_MDR1, 0x7);
  166. serial_write_reg(p, UART_LCR, 0xBF); /* Config B mode */
  167. efr = serial_read_reg(p, UART_EFR);
  168. serial_write_reg(p, UART_EFR, UART_EFR_ECB);
  169. serial_write_reg(p, UART_LCR, 0x0); /* Operational mode */
  170. serial_write_reg(p, UART_IER, 0x0);
  171. serial_write_reg(p, UART_LCR, 0xBF); /* Config B mode */
  172. serial_write_reg(p, UART_DLL, uart->dll);
  173. serial_write_reg(p, UART_DLM, uart->dlh);
  174. serial_write_reg(p, UART_LCR, 0x0); /* Operational mode */
  175. serial_write_reg(p, UART_IER, uart->ier);
  176. serial_write_reg(p, UART_FCR, 0xA1);
  177. serial_write_reg(p, UART_LCR, 0xBF); /* Config B mode */
  178. serial_write_reg(p, UART_EFR, efr);
  179. serial_write_reg(p, UART_LCR, UART_LCR_WLEN8);
  180. serial_write_reg(p, UART_OMAP_SCR, uart->scr);
  181. serial_write_reg(p, UART_OMAP_WER, uart->wer);
  182. serial_write_reg(p, UART_OMAP_SYSC, uart->sysc);
  183. serial_write_reg(p, UART_OMAP_MDR1, 0x00); /* UART 16x mode */
  184. }
  185. #else
  186. static inline void omap_uart_save_context(struct omap_uart_state *uart) {}
  187. static inline void omap_uart_restore_context(struct omap_uart_state *uart) {}
  188. #endif /* CONFIG_PM && CONFIG_ARCH_OMAP3 */
  189. static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
  190. {
  191. if (uart->clocked)
  192. return;
  193. clk_enable(uart->ick);
  194. clk_enable(uart->fck);
  195. uart->clocked = 1;
  196. omap_uart_restore_context(uart);
  197. }
  198. #ifdef CONFIG_PM
  199. static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
  200. {
  201. if (!uart->clocked)
  202. return;
  203. omap_uart_save_context(uart);
  204. uart->clocked = 0;
  205. clk_disable(uart->ick);
  206. clk_disable(uart->fck);
  207. }
  208. static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
  209. {
  210. /* Set wake-enable bit */
  211. if (uart->wk_en && uart->wk_mask) {
  212. u32 v = __raw_readl(uart->wk_en);
  213. v |= uart->wk_mask;
  214. __raw_writel(v, uart->wk_en);
  215. }
  216. /* Ensure IOPAD wake-enables are set */
  217. if (cpu_is_omap34xx() && uart->padconf) {
  218. u16 v = omap_ctrl_readw(uart->padconf);
  219. v |= OMAP3_PADCONF_WAKEUPENABLE0;
  220. omap_ctrl_writew(v, uart->padconf);
  221. }
  222. }
  223. static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
  224. {
  225. /* Clear wake-enable bit */
  226. if (uart->wk_en && uart->wk_mask) {
  227. u32 v = __raw_readl(uart->wk_en);
  228. v &= ~uart->wk_mask;
  229. __raw_writel(v, uart->wk_en);
  230. }
  231. /* Ensure IOPAD wake-enables are cleared */
  232. if (cpu_is_omap34xx() && uart->padconf) {
  233. u16 v = omap_ctrl_readw(uart->padconf);
  234. v &= ~OMAP3_PADCONF_WAKEUPENABLE0;
  235. omap_ctrl_writew(v, uart->padconf);
  236. }
  237. }
  238. static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
  239. int enable)
  240. {
  241. struct plat_serial8250_port *p = uart->p;
  242. u16 sysc;
  243. sysc = serial_read_reg(p, UART_OMAP_SYSC) & 0x7;
  244. if (enable)
  245. sysc |= 0x2 << 3;
  246. else
  247. sysc |= 0x1 << 3;
  248. serial_write_reg(p, UART_OMAP_SYSC, sysc);
  249. }
  250. static void omap_uart_block_sleep(struct omap_uart_state *uart)
  251. {
  252. omap_uart_enable_clocks(uart);
  253. omap_uart_smart_idle_enable(uart, 0);
  254. uart->can_sleep = 0;
  255. if (uart->timeout)
  256. mod_timer(&uart->timer, jiffies + uart->timeout);
  257. else
  258. del_timer(&uart->timer);
  259. }
  260. static void omap_uart_allow_sleep(struct omap_uart_state *uart)
  261. {
  262. if (device_may_wakeup(&uart->pdev.dev))
  263. omap_uart_enable_wakeup(uart);
  264. else
  265. omap_uart_disable_wakeup(uart);
  266. if (!uart->clocked)
  267. return;
  268. omap_uart_smart_idle_enable(uart, 1);
  269. uart->can_sleep = 1;
  270. del_timer(&uart->timer);
  271. }
  272. static void omap_uart_idle_timer(unsigned long data)
  273. {
  274. struct omap_uart_state *uart = (struct omap_uart_state *)data;
  275. omap_uart_allow_sleep(uart);
  276. }
  277. void omap_uart_prepare_idle(int num)
  278. {
  279. struct omap_uart_state *uart;
  280. list_for_each_entry(uart, &uart_list, node) {
  281. if (num == uart->num && uart->can_sleep) {
  282. omap_uart_disable_clocks(uart);
  283. return;
  284. }
  285. }
  286. }
  287. void omap_uart_resume_idle(int num)
  288. {
  289. struct omap_uart_state *uart;
  290. list_for_each_entry(uart, &uart_list, node) {
  291. if (num == uart->num) {
  292. omap_uart_enable_clocks(uart);
  293. /* Check for IO pad wakeup */
  294. if (cpu_is_omap34xx() && uart->padconf) {
  295. u16 p = omap_ctrl_readw(uart->padconf);
  296. if (p & OMAP3_PADCONF_WAKEUPEVENT0)
  297. omap_uart_block_sleep(uart);
  298. }
  299. /* Check for normal UART wakeup */
  300. if (__raw_readl(uart->wk_st) & uart->wk_mask)
  301. omap_uart_block_sleep(uart);
  302. return;
  303. }
  304. }
  305. }
  306. void omap_uart_prepare_suspend(void)
  307. {
  308. struct omap_uart_state *uart;
  309. list_for_each_entry(uart, &uart_list, node) {
  310. omap_uart_allow_sleep(uart);
  311. }
  312. }
  313. int omap_uart_can_sleep(void)
  314. {
  315. struct omap_uart_state *uart;
  316. int can_sleep = 1;
  317. list_for_each_entry(uart, &uart_list, node) {
  318. if (!uart->clocked)
  319. continue;
  320. if (!uart->can_sleep) {
  321. can_sleep = 0;
  322. continue;
  323. }
  324. /* This UART can now safely sleep. */
  325. omap_uart_allow_sleep(uart);
  326. }
  327. return can_sleep;
  328. }
  329. /**
  330. * omap_uart_interrupt()
  331. *
  332. * This handler is used only to detect that *any* UART interrupt has
  333. * occurred. It does _nothing_ to handle the interrupt. Rather,
  334. * any UART interrupt will trigger the inactivity timer so the
  335. * UART will not idle or sleep for its timeout period.
  336. *
  337. **/
  338. static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
  339. {
  340. struct omap_uart_state *uart = dev_id;
  341. omap_uart_block_sleep(uart);
  342. return IRQ_NONE;
  343. }
  344. static void omap_uart_idle_init(struct omap_uart_state *uart)
  345. {
  346. struct plat_serial8250_port *p = uart->p;
  347. int ret;
  348. uart->can_sleep = 0;
  349. uart->timeout = DEFAULT_TIMEOUT;
  350. setup_timer(&uart->timer, omap_uart_idle_timer,
  351. (unsigned long) uart);
  352. mod_timer(&uart->timer, jiffies + uart->timeout);
  353. omap_uart_smart_idle_enable(uart, 0);
  354. if (cpu_is_omap34xx()) {
  355. u32 mod = (uart->num == 2) ? OMAP3430_PER_MOD : CORE_MOD;
  356. u32 wk_mask = 0;
  357. u32 padconf = 0;
  358. uart->wk_en = OMAP34XX_PRM_REGADDR(mod, PM_WKEN1);
  359. uart->wk_st = OMAP34XX_PRM_REGADDR(mod, PM_WKST1);
  360. switch (uart->num) {
  361. case 0:
  362. wk_mask = OMAP3430_ST_UART1_MASK;
  363. padconf = 0x182;
  364. break;
  365. case 1:
  366. wk_mask = OMAP3430_ST_UART2_MASK;
  367. padconf = 0x17a;
  368. break;
  369. case 2:
  370. wk_mask = OMAP3430_ST_UART3_MASK;
  371. padconf = 0x19e;
  372. break;
  373. }
  374. uart->wk_mask = wk_mask;
  375. uart->padconf = padconf;
  376. } else if (cpu_is_omap24xx()) {
  377. u32 wk_mask = 0;
  378. if (cpu_is_omap2430()) {
  379. uart->wk_en = OMAP2430_PRM_REGADDR(CORE_MOD, PM_WKEN1);
  380. uart->wk_st = OMAP2430_PRM_REGADDR(CORE_MOD, PM_WKST1);
  381. } else if (cpu_is_omap2420()) {
  382. uart->wk_en = OMAP2420_PRM_REGADDR(CORE_MOD, PM_WKEN1);
  383. uart->wk_st = OMAP2420_PRM_REGADDR(CORE_MOD, PM_WKST1);
  384. }
  385. switch (uart->num) {
  386. case 0:
  387. wk_mask = OMAP24XX_ST_UART1_MASK;
  388. break;
  389. case 1:
  390. wk_mask = OMAP24XX_ST_UART2_MASK;
  391. break;
  392. case 2:
  393. wk_mask = OMAP24XX_ST_UART3_MASK;
  394. break;
  395. }
  396. uart->wk_mask = wk_mask;
  397. } else {
  398. uart->wk_en = 0;
  399. uart->wk_st = 0;
  400. uart->wk_mask = 0;
  401. uart->padconf = 0;
  402. }
  403. p->irqflags |= IRQF_SHARED;
  404. ret = request_irq(p->irq, omap_uart_interrupt, IRQF_SHARED,
  405. "serial idle", (void *)uart);
  406. WARN_ON(ret);
  407. }
  408. void omap_uart_enable_irqs(int enable)
  409. {
  410. int ret;
  411. struct omap_uart_state *uart;
  412. list_for_each_entry(uart, &uart_list, node) {
  413. if (enable)
  414. ret = request_irq(uart->p->irq, omap_uart_interrupt,
  415. IRQF_SHARED, "serial idle", (void *)uart);
  416. else
  417. free_irq(uart->p->irq, (void *)uart);
  418. }
  419. }
  420. static ssize_t sleep_timeout_show(struct device *dev,
  421. struct device_attribute *attr,
  422. char *buf)
  423. {
  424. struct platform_device *pdev = container_of(dev,
  425. struct platform_device, dev);
  426. struct omap_uart_state *uart = container_of(pdev,
  427. struct omap_uart_state, pdev);
  428. return sprintf(buf, "%u\n", uart->timeout / HZ);
  429. }
  430. static ssize_t sleep_timeout_store(struct device *dev,
  431. struct device_attribute *attr,
  432. const char *buf, size_t n)
  433. {
  434. struct platform_device *pdev = container_of(dev,
  435. struct platform_device, dev);
  436. struct omap_uart_state *uart = container_of(pdev,
  437. struct omap_uart_state, pdev);
  438. unsigned int value;
  439. if (sscanf(buf, "%u", &value) != 1) {
  440. printk(KERN_ERR "sleep_timeout_store: Invalid value\n");
  441. return -EINVAL;
  442. }
  443. uart->timeout = value * HZ;
  444. if (uart->timeout)
  445. mod_timer(&uart->timer, jiffies + uart->timeout);
  446. else
  447. /* A zero value means disable timeout feature */
  448. omap_uart_block_sleep(uart);
  449. return n;
  450. }
  451. DEVICE_ATTR(sleep_timeout, 0644, sleep_timeout_show, sleep_timeout_store);
  452. #define DEV_CREATE_FILE(dev, attr) WARN_ON(device_create_file(dev, attr))
  453. #else
  454. static inline void omap_uart_idle_init(struct omap_uart_state *uart) {}
  455. #define DEV_CREATE_FILE(dev, attr)
  456. #endif /* CONFIG_PM */
  457. static struct omap_uart_state omap_uart[] = {
  458. {
  459. .pdev = {
  460. .name = "serial8250",
  461. .id = PLAT8250_DEV_PLATFORM,
  462. .dev = {
  463. .platform_data = serial_platform_data0,
  464. },
  465. },
  466. }, {
  467. .pdev = {
  468. .name = "serial8250",
  469. .id = PLAT8250_DEV_PLATFORM1,
  470. .dev = {
  471. .platform_data = serial_platform_data1,
  472. },
  473. },
  474. }, {
  475. .pdev = {
  476. .name = "serial8250",
  477. .id = PLAT8250_DEV_PLATFORM2,
  478. .dev = {
  479. .platform_data = serial_platform_data2,
  480. },
  481. },
  482. },
  483. #ifdef CONFIG_ARCH_OMAP4
  484. {
  485. .pdev = {
  486. .name = "serial8250",
  487. .id = 3,
  488. .dev = {
  489. .platform_data = serial_platform_data3,
  490. },
  491. },
  492. },
  493. #endif
  494. };
  495. /*
  496. * Override the default 8250 read handler: mem_serial_in()
  497. * Empty RX fifo read causes an abort on omap3630 and omap4
  498. * This function makes sure that an empty rx fifo is not read on these silicons
  499. * (OMAP1/2/3430 are not affected)
  500. */
  501. static unsigned int serial_in_override(struct uart_port *up, int offset)
  502. {
  503. if (UART_RX == offset) {
  504. unsigned int lsr;
  505. lsr = serial_read_reg(omap_uart[up->line].p, UART_LSR);
  506. if (!(lsr & UART_LSR_DR))
  507. return -EPERM;
  508. }
  509. return serial_read_reg(omap_uart[up->line].p, offset);
  510. }
  511. void __init omap_serial_early_init(void)
  512. {
  513. int i;
  514. char name[16];
  515. /*
  516. * Make sure the serial ports are muxed on at this point.
  517. * You have to mux them off in device drivers later on
  518. * if not needed.
  519. */
  520. for (i = 0; i < ARRAY_SIZE(omap_uart); i++) {
  521. struct omap_uart_state *uart = &omap_uart[i];
  522. struct platform_device *pdev = &uart->pdev;
  523. struct device *dev = &pdev->dev;
  524. struct plat_serial8250_port *p = dev->platform_data;
  525. /*
  526. * Module 4KB + L4 interconnect 4KB
  527. * Static mapping, never released
  528. */
  529. p->membase = ioremap(p->mapbase, SZ_8K);
  530. if (!p->membase) {
  531. printk(KERN_ERR "ioremap failed for uart%i\n", i + 1);
  532. continue;
  533. }
  534. sprintf(name, "uart%d_ick", i+1);
  535. uart->ick = clk_get(NULL, name);
  536. if (IS_ERR(uart->ick)) {
  537. printk(KERN_ERR "Could not get uart%d_ick\n", i+1);
  538. uart->ick = NULL;
  539. }
  540. sprintf(name, "uart%d_fck", i+1);
  541. uart->fck = clk_get(NULL, name);
  542. if (IS_ERR(uart->fck)) {
  543. printk(KERN_ERR "Could not get uart%d_fck\n", i+1);
  544. uart->fck = NULL;
  545. }
  546. /* FIXME: Remove this once the clkdev is ready */
  547. if (!cpu_is_omap44xx()) {
  548. if (!uart->ick || !uart->fck)
  549. continue;
  550. }
  551. uart->num = i;
  552. p->private_data = uart;
  553. uart->p = p;
  554. list_add_tail(&uart->node, &uart_list);
  555. if (cpu_is_omap44xx())
  556. p->irq += 32;
  557. omap_uart_enable_clocks(uart);
  558. }
  559. }
  560. /**
  561. * omap_serial_init_port() - initialize single serial port
  562. * @port: serial port number (0-3)
  563. *
  564. * This function initialies serial driver for given @port only.
  565. * Platforms can call this function instead of omap_serial_init()
  566. * if they don't plan to use all available UARTs as serial ports.
  567. *
  568. * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
  569. * use only one of the two.
  570. */
  571. void __init omap_serial_init_port(int port)
  572. {
  573. struct omap_uart_state *uart;
  574. struct platform_device *pdev;
  575. struct device *dev;
  576. BUG_ON(port < 0);
  577. BUG_ON(port >= ARRAY_SIZE(omap_uart));
  578. uart = &omap_uart[port];
  579. pdev = &uart->pdev;
  580. dev = &pdev->dev;
  581. omap_uart_reset(uart);
  582. omap_uart_idle_init(uart);
  583. if (WARN_ON(platform_device_register(pdev)))
  584. return;
  585. if ((cpu_is_omap34xx() && uart->padconf) ||
  586. (uart->wk_en && uart->wk_mask)) {
  587. device_init_wakeup(dev, true);
  588. DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout);
  589. }
  590. /* omap44xx: Never read empty UART fifo
  591. * omap3xxx: Never read empty UART fifo on UARTs
  592. * with IP rev >=0x52
  593. */
  594. if (cpu_is_omap44xx())
  595. uart->p->serial_in = serial_in_override;
  596. else if ((serial_read_reg(uart->p, UART_OMAP_MVER) & 0xFF)
  597. >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
  598. uart->p->serial_in = serial_in_override;
  599. }
  600. /**
  601. * omap_serial_init() - intialize all supported serial ports
  602. *
  603. * Initializes all available UARTs as serial ports. Platforms
  604. * can call this function when they want to have default behaviour
  605. * for serial ports (e.g initialize them all as serial ports).
  606. */
  607. void __init omap_serial_init(void)
  608. {
  609. int i;
  610. for (i = 0; i < ARRAY_SIZE(omap_uart); i++)
  611. omap_serial_init_port(i);
  612. }