blob: 77a25cb1dccaf56270e1af25256e681099c0c277 [file] [log] [blame]
Tony Lindgren1dbae812005-11-10 14:26:51 +00001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * arch/arm/mach-omap2/serial.c
Tony Lindgren1dbae812005-11-10 14:26:51 +00003 *
4 * OMAP2 serial support.
5 *
Jouni Hogander6e811762008-10-06 15:49:15 +03006 * Copyright (C) 2005-2008 Nokia Corporation
Tony Lindgren1dbae812005-11-10 14:26:51 +00007 * Author: Paul Mundt <paul.mundt@nokia.com>
8 *
Kevin Hilman4af40162009-02-04 10:51:40 -08009 * Major rework for PM support by Kevin Hilman
10 *
Tony Lindgren1dbae812005-11-10 14:26:51 +000011 * Based off of arch/arm/mach-omap/omap1/serial.c
12 *
Santosh Shilimkar44169072009-05-28 14:16:04 -070013 * Copyright (C) 2009 Texas Instruments
14 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com
15 *
Tony Lindgren1dbae812005-11-10 14:26:51 +000016 * 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>
Russell Kingf8ce2542006-01-07 16:15:52 +000022#include <linux/clk.h>
Russell Kingfced80c2008-09-06 12:10:45 +010023#include <linux/io.h>
Santosh Shilimkare03d37d2010-02-18 08:59:06 +000024#include <linux/delay.h>
Kevin Hilman6f251e92010-09-27 20:19:38 +053025#include <linux/platform_device.h>
26#include <linux/slab.h>
Kevin Hilman3244fcd2010-09-27 20:19:53 +053027#include <linux/pm_runtime.h>
Paul Walmsley0d8e2d02010-11-24 16:49:05 -070028#include <linux/console.h>
Kevin Hilman6f251e92010-09-27 20:19:38 +053029
Kevin Hilman6f251e92010-09-27 20:19:38 +053030#include <plat/omap-serial.h>
Tony Lindgren4e653312011-11-10 22:45:17 +010031#include "common.h"
Tony Lindgrence491cf2009-10-20 09:40:47 -070032#include <plat/board.h>
Kevin Hilman6f251e92010-09-27 20:19:38 +053033#include <plat/dma.h>
34#include <plat/omap_hwmod.h>
35#include <plat/omap_device.h>
Govindraj.Rec3bebc2011-10-11 19:11:27 +053036#include <plat/omap-pm.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000037
Paul Walmsley59fb6592010-12-21 15:30:55 -070038#include "prm2xxx_3xxx.h"
Kevin Hilman4af40162009-02-04 10:51:40 -080039#include "pm.h"
Paul Walmsley59fb6592010-12-21 15:30:55 -070040#include "cm2xxx_3xxx.h"
Kevin Hilman4af40162009-02-04 10:51:40 -080041#include "prm-regbits-34xx.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060042#include "control.h"
Tony Lindgren40e44392010-12-22 18:42:35 -080043#include "mux.h"
Kevin Hilman4af40162009-02-04 10:51:40 -080044
Tony Lindgren301fe8e2010-02-01 12:34:31 -080045/*
46 * NOTE: By default the serial timeout is disabled as it causes lost characters
47 * over the serial ports. This means that the UART clocks will stay on until
48 * disabled via sysfs. This also causes that any deeper omap sleep states are
49 * blocked.
50 */
51#define DEFAULT_TIMEOUT 0
Kevin Hilman4af40162009-02-04 10:51:40 -080052
Kevin Hilman6f251e92010-09-27 20:19:38 +053053#define MAX_UART_HWMOD_NAME_LEN 16
54
Kevin Hilman4af40162009-02-04 10:51:40 -080055struct omap_uart_state {
56 int num;
57 int can_sleep;
Kevin Hilman4af40162009-02-04 10:51:40 -080058
59 void __iomem *wk_st;
60 void __iomem *wk_en;
61 u32 wk_mask;
Kevin Hilman4af40162009-02-04 10:51:40 -080062
Kevin Hilman4af40162009-02-04 10:51:40 -080063 int clocked;
64
Kevin Hilman4af40162009-02-04 10:51:40 -080065 struct list_head node;
Kevin Hilman6f251e92010-09-27 20:19:38 +053066 struct omap_hwmod *oh;
67 struct platform_device *pdev;
Kevin Hilman4af40162009-02-04 10:51:40 -080068};
69
Kevin Hilman4af40162009-02-04 10:51:40 -080070static LIST_HEAD(uart_list);
Kevin Hilman6f251e92010-09-27 20:19:38 +053071static u8 num_uarts;
Tony Lindgren1dbae812005-11-10 14:26:51 +000072
Kevin Hilman4af40162009-02-04 10:51:40 -080073static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
74{
75 if (uart->clocked)
76 return;
77
Kevin Hilman6f251e92010-09-27 20:19:38 +053078 omap_device_enable(uart->pdev);
Kevin Hilman4af40162009-02-04 10:51:40 -080079 uart->clocked = 1;
80 omap_uart_restore_context(uart);
81}
82
83#ifdef CONFIG_PM
84
85static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
86{
87 if (!uart->clocked)
88 return;
89
90 omap_uart_save_context(uart);
91 uart->clocked = 0;
Kevin Hilman6f251e92010-09-27 20:19:38 +053092 omap_device_idle(uart->pdev);
Kevin Hilman4af40162009-02-04 10:51:40 -080093}
94
Kevin Hilmanfd455ea2009-04-27 12:27:36 -070095static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
96{
97 /* Set wake-enable bit */
98 if (uart->wk_en && uart->wk_mask) {
99 u32 v = __raw_readl(uart->wk_en);
100 v |= uart->wk_mask;
101 __raw_writel(v, uart->wk_en);
102 }
Kevin Hilmanfd455ea2009-04-27 12:27:36 -0700103}
104
105static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
106{
107 /* Clear wake-enable bit */
108 if (uart->wk_en && uart->wk_mask) {
109 u32 v = __raw_readl(uart->wk_en);
110 v &= ~uart->wk_mask;
111 __raw_writel(v, uart->wk_en);
112 }
Kevin Hilmanfd455ea2009-04-27 12:27:36 -0700113}
114
Kevin Hilman4af40162009-02-04 10:51:40 -0800115static void omap_uart_block_sleep(struct omap_uart_state *uart)
116{
117 omap_uart_enable_clocks(uart);
118
119 omap_uart_smart_idle_enable(uart, 0);
120 uart->can_sleep = 0;
Kevin Hilman4af40162009-02-04 10:51:40 -0800121}
122
Kevin Hilman4af40162009-02-04 10:51:40 -0800123int omap_uart_can_sleep(void)
124{
125 struct omap_uart_state *uart;
126 int can_sleep = 1;
127
128 list_for_each_entry(uart, &uart_list, node) {
129 if (!uart->clocked)
130 continue;
131
132 if (!uart->can_sleep) {
133 can_sleep = 0;
134 continue;
135 }
136
137 /* This UART can now safely sleep. */
138 omap_uart_allow_sleep(uart);
139 }
140
141 return can_sleep;
142}
143
Kevin Hilman4af40162009-02-04 10:51:40 -0800144static void omap_uart_idle_init(struct omap_uart_state *uart)
145{
Kevin Hilman4af40162009-02-04 10:51:40 -0800146 int ret;
147
148 uart->can_sleep = 0;
Kevin Hilman4af40162009-02-04 10:51:40 -0800149 omap_uart_smart_idle_enable(uart, 0);
150
Hemant Pedanekara9203602011-12-13 10:46:44 -0800151 if (cpu_is_omap34xx() && !(cpu_is_ti81xx() || cpu_is_am33xx())) {
Govindraj.R52663ae2010-09-27 20:20:41 +0530152 u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
Kevin Hilman4af40162009-02-04 10:51:40 -0800153 u32 wk_mask = 0;
Kevin Hilman4af40162009-02-04 10:51:40 -0800154
Paul Walmsleyc4d7e582010-12-21 21:05:14 -0700155 /* XXX These PRM accesses do not belong here */
Kevin Hilman4af40162009-02-04 10:51:40 -0800156 uart->wk_en = OMAP34XX_PRM_REGADDR(mod, PM_WKEN1);
157 uart->wk_st = OMAP34XX_PRM_REGADDR(mod, PM_WKST1);
158 switch (uart->num) {
159 case 0:
160 wk_mask = OMAP3430_ST_UART1_MASK;
Kevin Hilman4af40162009-02-04 10:51:40 -0800161 break;
162 case 1:
163 wk_mask = OMAP3430_ST_UART2_MASK;
Kevin Hilman4af40162009-02-04 10:51:40 -0800164 break;
165 case 2:
166 wk_mask = OMAP3430_ST_UART3_MASK;
Kevin Hilman4af40162009-02-04 10:51:40 -0800167 break;
Govindraj.R52663ae2010-09-27 20:20:41 +0530168 case 3:
169 wk_mask = OMAP3630_ST_UART4_MASK;
Govindraj.R52663ae2010-09-27 20:20:41 +0530170 break;
Kevin Hilman4af40162009-02-04 10:51:40 -0800171 }
172 uart->wk_mask = wk_mask;
Kevin Hilman4af40162009-02-04 10:51:40 -0800173 } else if (cpu_is_omap24xx()) {
174 u32 wk_mask = 0;
Kevin Hilmancb74f022010-10-20 23:19:03 +0000175 u32 wk_en = PM_WKEN1, wk_st = PM_WKST1;
Kevin Hilman4af40162009-02-04 10:51:40 -0800176
Kevin Hilman4af40162009-02-04 10:51:40 -0800177 switch (uart->num) {
178 case 0:
179 wk_mask = OMAP24XX_ST_UART1_MASK;
180 break;
181 case 1:
182 wk_mask = OMAP24XX_ST_UART2_MASK;
183 break;
184 case 2:
Kevin Hilmancb74f022010-10-20 23:19:03 +0000185 wk_en = OMAP24XX_PM_WKEN2;
186 wk_st = OMAP24XX_PM_WKST2;
Kevin Hilman4af40162009-02-04 10:51:40 -0800187 wk_mask = OMAP24XX_ST_UART3_MASK;
188 break;
189 }
190 uart->wk_mask = wk_mask;
Kevin Hilmancb74f022010-10-20 23:19:03 +0000191 if (cpu_is_omap2430()) {
192 uart->wk_en = OMAP2430_PRM_REGADDR(CORE_MOD, wk_en);
193 uart->wk_st = OMAP2430_PRM_REGADDR(CORE_MOD, wk_st);
194 } else if (cpu_is_omap2420()) {
195 uart->wk_en = OMAP2420_PRM_REGADDR(CORE_MOD, wk_en);
196 uart->wk_st = OMAP2420_PRM_REGADDR(CORE_MOD, wk_st);
197 }
Kevin Hilman4af40162009-02-04 10:51:40 -0800198 } else {
Nishanth Menonc54bae12010-08-02 13:18:11 +0300199 uart->wk_en = NULL;
200 uart->wk_st = NULL;
Kevin Hilman4af40162009-02-04 10:51:40 -0800201 uart->wk_mask = 0;
Kevin Hilman4af40162009-02-04 10:51:40 -0800202 }
Kevin Hilman4af40162009-02-04 10:51:40 -0800203}
204
Govindraj.R94734742011-11-07 19:00:33 +0530205/*
206 * Errata i291: [UART]:Cannot Acknowledge Idle Requests
207 * in Smartidle Mode When Configured for DMA Operations.
208 * WA: configure uart in force idle mode.
209 */
210static void omap_uart_set_noidle(struct platform_device *pdev)
211{
212 struct omap_device *od = to_omap_device(pdev);
213
214 omap_hwmod_set_slave_idlemode(od->hwmods[0], HWMOD_IDLEMODE_NO);
215}
216
217static void omap_uart_set_forceidle(struct platform_device *pdev)
218{
219 struct omap_device *od = to_omap_device(pdev);
220
221 omap_hwmod_set_slave_idlemode(od->hwmods[0], HWMOD_IDLEMODE_FORCE);
222}
223
Kevin Hilman4af40162009-02-04 10:51:40 -0800224#else
Govindraj.R94734742011-11-07 19:00:33 +0530225static void omap_uart_set_noidle(struct platform_device *pdev) {}
226static void omap_uart_set_forceidle(struct platform_device *pdev) {}
Santosh Shilimkara1b04cc2010-10-11 11:05:18 +0000227static void omap_uart_block_sleep(struct omap_uart_state *uart)
228{
229 /* Needed to enable UART clocks when built without CONFIG_PM */
230 omap_uart_enable_clocks(uart);
231}
Kevin Hilman4af40162009-02-04 10:51:40 -0800232#endif /* CONFIG_PM */
233
Govindraj.R7496ba32011-11-07 18:55:05 +0530234#ifdef CONFIG_OMAP_MUX
235static struct omap_device_pad default_uart1_pads[] __initdata = {
236 {
237 .name = "uart1_cts.uart1_cts",
238 .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
239 },
240 {
241 .name = "uart1_rts.uart1_rts",
242 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
243 },
244 {
245 .name = "uart1_tx.uart1_tx",
246 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
247 },
248 {
249 .name = "uart1_rx.uart1_rx",
250 .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
251 .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
252 .idle = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
253 },
254};
255
256static struct omap_device_pad default_uart2_pads[] __initdata = {
257 {
258 .name = "uart2_cts.uart2_cts",
259 .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
260 },
261 {
262 .name = "uart2_rts.uart2_rts",
263 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
264 },
265 {
266 .name = "uart2_tx.uart2_tx",
267 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
268 },
269 {
270 .name = "uart2_rx.uart2_rx",
271 .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
272 .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
273 .idle = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
274 },
275};
276
277static struct omap_device_pad default_uart3_pads[] __initdata = {
278 {
279 .name = "uart3_cts_rctx.uart3_cts_rctx",
280 .enable = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
281 },
282 {
283 .name = "uart3_rts_sd.uart3_rts_sd",
284 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
285 },
286 {
287 .name = "uart3_tx_irtx.uart3_tx_irtx",
288 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
289 },
290 {
291 .name = "uart3_rx_irrx.uart3_rx_irrx",
292 .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
293 .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
294 .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
295 },
296};
297
298static struct omap_device_pad default_omap36xx_uart4_pads[] __initdata = {
299 {
300 .name = "gpmc_wait2.uart4_tx",
301 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
302 },
303 {
304 .name = "gpmc_wait3.uart4_rx",
305 .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
306 .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
307 .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE2,
308 },
309};
310
311static struct omap_device_pad default_omap4_uart4_pads[] __initdata = {
312 {
313 .name = "uart4_tx.uart4_tx",
314 .enable = OMAP_PIN_OUTPUT | OMAP_MUX_MODE0,
315 },
316 {
317 .name = "uart4_rx.uart4_rx",
318 .flags = OMAP_DEVICE_PAD_REMUX | OMAP_DEVICE_PAD_WAKEUP,
319 .enable = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
320 .idle = OMAP_PIN_INPUT | OMAP_MUX_MODE0,
321 },
322};
323
324static void omap_serial_fill_default_pads(struct omap_board_data *bdata)
325{
326 switch (bdata->id) {
327 case 0:
328 bdata->pads = default_uart1_pads;
329 bdata->pads_cnt = ARRAY_SIZE(default_uart1_pads);
330 break;
331 case 1:
332 bdata->pads = default_uart2_pads;
333 bdata->pads_cnt = ARRAY_SIZE(default_uart2_pads);
334 break;
335 case 2:
336 bdata->pads = default_uart3_pads;
337 bdata->pads_cnt = ARRAY_SIZE(default_uart3_pads);
338 break;
339 case 3:
340 if (cpu_is_omap44xx()) {
341 bdata->pads = default_omap4_uart4_pads;
342 bdata->pads_cnt =
343 ARRAY_SIZE(default_omap4_uart4_pads);
344 } else if (cpu_is_omap3630()) {
345 bdata->pads = default_omap36xx_uart4_pads;
346 bdata->pads_cnt =
347 ARRAY_SIZE(default_omap36xx_uart4_pads);
348 }
349 break;
350 default:
351 break;
352 }
353}
354#else
355static void omap_serial_fill_default_pads(struct omap_board_data *bdata) {}
356#endif
357
Tony Lindgren3e16f922011-02-14 15:40:20 -0800358static int __init omap_serial_early_init(void)
Tony Lindgren1dbae812005-11-10 14:26:51 +0000359{
Kevin Hilman6f251e92010-09-27 20:19:38 +0530360 int i = 0;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000361
Kevin Hilman6f251e92010-09-27 20:19:38 +0530362 do {
363 char oh_name[MAX_UART_HWMOD_NAME_LEN];
364 struct omap_hwmod *oh;
365 struct omap_uart_state *uart;
Thomas Weber21b90342010-02-25 09:40:19 +0000366
Kevin Hilman6f251e92010-09-27 20:19:38 +0530367 snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
368 "uart%d", i + 1);
369 oh = omap_hwmod_lookup(oh_name);
370 if (!oh)
371 break;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000372
Kevin Hilman6f251e92010-09-27 20:19:38 +0530373 uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL);
374 if (WARN_ON(!uart))
Tony Lindgren3e16f922011-02-14 15:40:20 -0800375 return -ENODEV;
Tony Lindgren1dbae812005-11-10 14:26:51 +0000376
Kevin Hilman6f251e92010-09-27 20:19:38 +0530377 uart->oh = oh;
378 uart->num = i++;
379 list_add_tail(&uart->node, &uart_list);
380 num_uarts++;
381
Tony Lindgren84f90c92009-10-16 09:53:00 -0700382 /*
Paul Walmsley550c8092011-02-28 11:58:14 -0700383 * NOTE: omap_hwmod_setup*() has not yet been called,
Kevin Hilman6f251e92010-09-27 20:19:38 +0530384 * so no hwmod functions will work yet.
Tony Lindgren84f90c92009-10-16 09:53:00 -0700385 */
Tony Lindgren84f90c92009-10-16 09:53:00 -0700386
Kevin Hilman6f251e92010-09-27 20:19:38 +0530387 /*
388 * During UART early init, device need to be probed
389 * to determine SoC specific init before omap_device
390 * is ready. Therefore, don't allow idle here
391 */
392 uart->oh->flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
393 } while (1);
Tony Lindgren3e16f922011-02-14 15:40:20 -0800394
395 return 0;
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300396}
Tony Lindgren3e16f922011-02-14 15:40:20 -0800397core_initcall(omap_serial_early_init);
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300398
Mika Westerbergf62349e2009-12-11 16:16:35 -0800399/**
400 * omap_serial_init_port() - initialize single serial port
Tony Lindgren40e44392010-12-22 18:42:35 -0800401 * @bdata: port specific board data pointer
Mika Westerbergf62349e2009-12-11 16:16:35 -0800402 *
Tony Lindgren40e44392010-12-22 18:42:35 -0800403 * This function initialies serial driver for given port only.
Mika Westerbergf62349e2009-12-11 16:16:35 -0800404 * Platforms can call this function instead of omap_serial_init()
405 * if they don't plan to use all available UARTs as serial ports.
406 *
407 * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
408 * use only one of the two.
409 */
Tony Lindgren40e44392010-12-22 18:42:35 -0800410void __init omap_serial_init_port(struct omap_board_data *bdata)
Mika Westerbergf62349e2009-12-11 16:16:35 -0800411{
412 struct omap_uart_state *uart;
Kevin Hilman6f251e92010-09-27 20:19:38 +0530413 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700414 struct platform_device *pdev;
Kevin Hilman6f251e92010-09-27 20:19:38 +0530415 void *pdata = NULL;
416 u32 pdata_size = 0;
417 char *name;
Kevin Hilman6f251e92010-09-27 20:19:38 +0530418 struct omap_uart_port_info omap_up;
Mika Westerbergf62349e2009-12-11 16:16:35 -0800419
Tony Lindgren40e44392010-12-22 18:42:35 -0800420 if (WARN_ON(!bdata))
Sergio Aguirree88d5562010-02-27 14:13:43 -0600421 return;
Tony Lindgren40e44392010-12-22 18:42:35 -0800422 if (WARN_ON(bdata->id < 0))
423 return;
424 if (WARN_ON(bdata->id >= num_uarts))
Mika Westerbergf62349e2009-12-11 16:16:35 -0800425 return;
426
Kevin Hilman6f251e92010-09-27 20:19:38 +0530427 list_for_each_entry(uart, &uart_list, node)
Tony Lindgren40e44392010-12-22 18:42:35 -0800428 if (bdata->id == uart->num)
Kevin Hilman6f251e92010-09-27 20:19:38 +0530429 break;
430
431 oh = uart->oh;
Kevin Hilman6f251e92010-09-27 20:19:38 +0530432 name = DRIVER_NAME;
433
434 omap_up.dma_enabled = uart->dma_enabled;
435 omap_up.uartclk = OMAP24XX_BASE_BAUD * 16;
Govindraj.R273558b2011-09-13 14:01:01 +0530436 omap_up.flags = UPF_BOOT_AUTOCONF;
Govindraj.Rec3bebc2011-10-11 19:11:27 +0530437 omap_up.get_context_loss_count = omap_pm_get_dev_context_loss_count;
Govindraj.R94734742011-11-07 19:00:33 +0530438 omap_up.set_forceidle = omap_uart_set_forceidle;
439 omap_up.set_noidle = omap_uart_set_noidle;
440
441 /* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */
442 if (!cpu_is_omap2420() && !cpu_is_ti816x())
443 omap_up.errata |= UART_ERRATA_i202_MDR1_ACCESS;
444
445 /* Enable DMA Mode Force Idle Errata i291 for omap34xx/3630 */
446 if (cpu_is_omap34xx() || cpu_is_omap3630())
447 omap_up.errata |= UART_ERRATA_i291_DMA_FORCEIDLE;
Kevin Hilman6f251e92010-09-27 20:19:38 +0530448
449 pdata = &omap_up;
450 pdata_size = sizeof(struct omap_uart_port_info);
Kevin Hilman6f251e92010-09-27 20:19:38 +0530451
452 if (WARN_ON(!oh))
453 return;
454
Kevin Hilman3528c582011-07-21 13:48:45 -0700455 pdev = omap_device_build(name, uart->num, oh, pdata, pdata_size,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200456 NULL, 0, false);
Kevin Hilman3528c582011-07-21 13:48:45 -0700457 WARN(IS_ERR(pdev), "Could not build omap_device for %s: %s.\n",
Kevin Hilman6f251e92010-09-27 20:19:38 +0530458 name, oh->name);
459
Kevin Hilman9f8b6942011-08-01 09:33:13 -0700460 omap_device_disable_idle_on_suspend(pdev);
Tony Lindgren40e44392010-12-22 18:42:35 -0800461 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
462
Kevin Hilman3528c582011-07-21 13:48:45 -0700463 uart->pdev = pdev;
Kevin Hilman6f251e92010-09-27 20:19:38 +0530464
465 oh->dev_attr = uart;
466
Torben Hohnac751ef2011-01-25 15:07:35 -0800467 console_lock(); /* in case the earlycon is on the UART */
Paul Walmsley0d8e2d02010-11-24 16:49:05 -0700468
Kevin Hilman6f251e92010-09-27 20:19:38 +0530469 /*
470 * Because of early UART probing, UART did not get idled
471 * on init. Now that omap_device is ready, ensure full idle
472 * before doing omap_device_enable().
473 */
474 omap_hwmod_idle(uart->oh);
475
476 omap_device_enable(uart->pdev);
477 omap_uart_idle_init(uart);
Kevin Hilman6f251e92010-09-27 20:19:38 +0530478 omap_hwmod_enable_wakeup(uart->oh);
479 omap_device_idle(uart->pdev);
480
Kevin Hilman6f251e92010-09-27 20:19:38 +0530481 omap_uart_block_sleep(uart);
Torben Hohnac751ef2011-01-25 15:07:35 -0800482 console_unlock();
Paul Walmsley0d8e2d02010-11-24 16:49:05 -0700483
Govindraj.R7496ba32011-11-07 18:55:05 +0530484 if (((cpu_is_omap34xx() || cpu_is_omap44xx()) && bdata->pads) ||
485 (pdata->wk_en && pdata->wk_mask))
Kevin Hilman3528c582011-07-21 13:48:45 -0700486 device_init_wakeup(&pdev->dev, true);
Mika Westerbergf62349e2009-12-11 16:16:35 -0800487}
488
489/**
Uwe Kleine-Königb5950762010-11-01 15:38:34 -0400490 * omap_serial_init() - initialize all supported serial ports
Mika Westerbergf62349e2009-12-11 16:16:35 -0800491 *
492 * Initializes all available UARTs as serial ports. Platforms
493 * can call this function when they want to have default behaviour
494 * for serial ports (e.g initialize them all as serial ports).
495 */
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300496void __init omap_serial_init(void)
497{
Kevin Hilman6f251e92010-09-27 20:19:38 +0530498 struct omap_uart_state *uart;
Tony Lindgren40e44392010-12-22 18:42:35 -0800499 struct omap_board_data bdata;
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300500
Tony Lindgren40e44392010-12-22 18:42:35 -0800501 list_for_each_entry(uart, &uart_list, node) {
502 bdata.id = uart->num;
503 bdata.flags = 0;
504 bdata.pads = NULL;
505 bdata.pads_cnt = 0;
Govindraj.R7496ba32011-11-07 18:55:05 +0530506
507 if (cpu_is_omap44xx() || cpu_is_omap34xx())
508 omap_serial_fill_default_pads(&bdata);
509
Tony Lindgren40e44392010-12-22 18:42:35 -0800510 omap_serial_init_port(&bdata);
511
512 }
Tony Lindgren1dbae812005-11-10 14:26:51 +0000513}