2 * arch/arm/mach-omap/omap2/serial.c
4 * OMAP2 serial support.
6 * Copyright (C) 2005 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>
22 #include <asm/arch/common.h>
23 #include <asm/arch/board.h>
25 static struct plat_serial8250_port serial_platform_data[] = {
27 .membase = (char *)IO_ADDRESS(OMAP_UART1_BASE),
28 .mapbase = (unsigned long)OMAP_UART1_BASE,
30 .flags = UPF_BOOT_AUTOCONF,
33 .uartclk = OMAP16XX_BASE_BAUD * 16,
35 .membase = (char *)IO_ADDRESS(OMAP_UART2_BASE),
36 .mapbase = (unsigned long)OMAP_UART2_BASE,
38 .flags = UPF_BOOT_AUTOCONF,
41 .uartclk = OMAP16XX_BASE_BAUD * 16,
43 .membase = (char *)IO_ADDRESS(OMAP_UART3_BASE),
44 .mapbase = (unsigned long)OMAP_UART3_BASE,
46 .flags = UPF_BOOT_AUTOCONF,
49 .uartclk = OMAP16XX_BASE_BAUD * 16,
55 static inline unsigned int serial_read_reg(struct plat_serial8250_port *up,
58 offset <<= up->regshift;
59 return (unsigned int)__raw_readb(up->membase + offset);
62 static inline void serial_write_reg(struct plat_serial8250_port *p, int offset,
65 offset <<= p->regshift;
66 __raw_writeb(value, (unsigned long)(p->membase + offset));
70 * Internal UARTs need to be initialized for the 8250 autoconfig to work
71 * properly. Note that the TX watermark initialization may not be needed
72 * once the 8250.c watermark handling code is merged.
74 static inline void __init omap_serial_reset(struct plat_serial8250_port *p)
76 serial_write_reg(p, UART_OMAP_MDR1, 0x07);
77 serial_write_reg(p, UART_OMAP_SCR, 0x08);
78 serial_write_reg(p, UART_OMAP_MDR1, 0x00);
79 serial_write_reg(p, UART_OMAP_SYSC, 0x01);
82 void __init omap_serial_init()
85 const struct omap_uart_config *info;
88 * Make sure the serial ports are muxed on at this point.
89 * You have to mux them off in device drivers later on
93 info = omap_get_config(OMAP_TAG_UART,
94 struct omap_uart_config);
99 for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
100 struct plat_serial8250_port *p = serial_platform_data + i;
102 if (!(info->enabled_uarts & (1 << i))) {
108 omap_serial_reset(p);
112 static struct platform_device serial_device = {
113 .name = "serial8250",
116 .platform_data = serial_platform_data,
120 static int __init omap_init(void)
122 return platform_device_register(&serial_device);
124 arch_initcall(omap_init);