2 * arch/arm/mach-omap2/serial.c
4 * OMAP2 serial support.
6 * Copyright (C) 2005-2008 Nokia Corporation
7 * Author: Paul Mundt <paul.mundt@nokia.com>
9 * Based off of arch/arm/mach-omap/omap1/serial.c
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/serial_8250.h>
18 #include <linux/serial_reg.h>
19 #include <linux/clk.h>
23 #include <asm/arch/common.h>
24 #include <asm/arch/board.h>
26 static struct clk
*uart_ick
[OMAP_MAX_NR_PORTS
];
27 static struct clk
*uart_fck
[OMAP_MAX_NR_PORTS
];
29 static struct plat_serial8250_port serial_platform_data
[] = {
31 .membase
= (char *)IO_ADDRESS(OMAP_UART1_BASE
),
32 .mapbase
= (unsigned long)OMAP_UART1_BASE
,
34 .flags
= UPF_BOOT_AUTOCONF
,
37 .uartclk
= OMAP24XX_BASE_BAUD
* 16,
39 .membase
= (char *)IO_ADDRESS(OMAP_UART2_BASE
),
40 .mapbase
= (unsigned long)OMAP_UART2_BASE
,
42 .flags
= UPF_BOOT_AUTOCONF
,
45 .uartclk
= OMAP24XX_BASE_BAUD
* 16,
47 .membase
= (char *)IO_ADDRESS(OMAP_UART3_BASE
),
48 .mapbase
= (unsigned long)OMAP_UART3_BASE
,
50 .flags
= UPF_BOOT_AUTOCONF
,
53 .uartclk
= OMAP24XX_BASE_BAUD
* 16,
59 static inline unsigned int serial_read_reg(struct plat_serial8250_port
*up
,
62 offset
<<= up
->regshift
;
63 return (unsigned int)__raw_readb(up
->membase
+ offset
);
66 static inline void serial_write_reg(struct plat_serial8250_port
*p
, int offset
,
69 offset
<<= p
->regshift
;
70 __raw_writeb(value
, (unsigned long)(p
->membase
+ offset
));
74 * Internal UARTs need to be initialized for the 8250 autoconfig to work
75 * properly. Note that the TX watermark initialization may not be needed
76 * once the 8250.c watermark handling code is merged.
78 static inline void __init
omap_serial_reset(struct plat_serial8250_port
*p
)
80 serial_write_reg(p
, UART_OMAP_MDR1
, 0x07);
81 serial_write_reg(p
, UART_OMAP_SCR
, 0x08);
82 serial_write_reg(p
, UART_OMAP_MDR1
, 0x00);
83 serial_write_reg(p
, UART_OMAP_SYSC
, (0x02 << 3) | (1 << 2) | (1 << 0));
86 void omap_serial_enable_clocks(int enable
)
89 for (i
= 0; i
< OMAP_MAX_NR_PORTS
; i
++) {
91 enable
? clk_enable(uart_ick
[i
]) :
92 clk_disable(uart_ick
[i
]);
94 enable
? clk_enable(uart_fck
[i
]) :
95 clk_disable(uart_fck
[i
]);
99 void __init
omap_serial_init(void)
102 const struct omap_uart_config
*info
;
106 * Make sure the serial ports are muxed on at this point.
107 * You have to mux them off in device drivers later on
111 info
= omap_get_config(OMAP_TAG_UART
, struct omap_uart_config
);
116 for (i
= 0; i
< OMAP_MAX_NR_PORTS
; i
++) {
117 struct plat_serial8250_port
*p
= serial_platform_data
+ i
;
119 if (!(info
->enabled_uarts
& (1 << i
))) {
125 sprintf(name
, "uart%d_ick", i
+1);
126 uart_ick
[i
] = clk_get(NULL
, name
);
127 if (IS_ERR(uart_ick
[i
])) {
128 printk(KERN_ERR
"Could not get uart%d_ick\n", i
+1);
132 clk_enable(uart_ick
[i
]);
133 sprintf(name
, "uart%d_fck", i
+1);
134 uart_fck
[i
] = clk_get(NULL
, name
);
135 if (IS_ERR(uart_fck
[i
])) {
136 printk(KERN_ERR
"Could not get uart%d_fck\n", i
+1);
140 clk_enable(uart_fck
[i
]);
142 omap_serial_reset(p
);
146 static struct platform_device serial_device
= {
147 .name
= "serial8250",
148 .id
= PLAT8250_DEV_PLATFORM
,
150 .platform_data
= serial_platform_data
,
154 static int __init
omap_init(void)
156 return platform_device_register(&serial_device
);
158 arch_initcall(omap_init
);