2 * linux/arch/arm/mach-omap1/id.c
4 * OMAP1 CPU identification code
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/delay.h>
16 #include <linux/serial.h>
17 #include <linux/tty.h>
18 #include <linux/serial_8250.h>
19 #include <linux/serial_reg.h>
22 #include <asm/mach-types.h>
23 #include <asm/hardware/clock.h>
25 #include <asm/arch/board.h>
26 #include <asm/arch/mux.h>
27 #include <asm/arch/fpga.h>
29 static struct clk
* uart1_ck
= NULL
;
30 static struct clk
* uart2_ck
= NULL
;
31 static struct clk
* uart3_ck
= NULL
;
33 static inline unsigned int omap_serial_in(struct plat_serial8250_port
*up
,
36 offset
<<= up
->regshift
;
37 return (unsigned int)__raw_readb(up
->membase
+ offset
);
40 static inline void omap_serial_outp(struct plat_serial8250_port
*p
, int offset
,
43 offset
<<= p
->regshift
;
44 __raw_writeb(value
, p
->membase
+ offset
);
48 * Internal UARTs need to be initialized for the 8250 autoconfig to work
49 * properly. Note that the TX watermark initialization may not be needed
50 * once the 8250.c watermark handling code is merged.
52 static void __init
omap_serial_reset(struct plat_serial8250_port
*p
)
54 omap_serial_outp(p
, UART_OMAP_MDR1
, 0x07); /* disable UART */
55 omap_serial_outp(p
, UART_OMAP_SCR
, 0x08); /* TX watermark */
56 omap_serial_outp(p
, UART_OMAP_MDR1
, 0x00); /* enable UART */
58 if (!cpu_is_omap1510()) {
59 omap_serial_outp(p
, UART_OMAP_SYSC
, 0x01);
60 while (!(omap_serial_in(p
, UART_OMAP_SYSC
) & 0x01));
64 static struct plat_serial8250_port serial_platform_data
[] = {
66 .membase
= (char*)IO_ADDRESS(OMAP_UART1_BASE
),
67 .mapbase
= (unsigned long)OMAP_UART1_BASE
,
69 .flags
= UPF_BOOT_AUTOCONF
,
72 .uartclk
= OMAP16XX_BASE_BAUD
* 16,
75 .membase
= (char*)IO_ADDRESS(OMAP_UART2_BASE
),
76 .mapbase
= (unsigned long)OMAP_UART2_BASE
,
78 .flags
= UPF_BOOT_AUTOCONF
,
81 .uartclk
= OMAP16XX_BASE_BAUD
* 16,
84 .membase
= (char*)IO_ADDRESS(OMAP_UART3_BASE
),
85 .mapbase
= (unsigned long)OMAP_UART3_BASE
,
87 .flags
= UPF_BOOT_AUTOCONF
,
90 .uartclk
= OMAP16XX_BASE_BAUD
* 16,
95 static struct platform_device serial_device
= {
99 .platform_data
= serial_platform_data
,
104 * Note that on Innovator-1510 UART2 pins conflict with USB2.
105 * By default UART2 does not work on Innovator-1510 if you have
106 * USB OHCI enabled. To use UART2, you must disable USB2 first.
108 void __init
omap_serial_init(int ports
[OMAP_MAX_NR_PORTS
])
112 if (cpu_is_omap730()) {
113 serial_platform_data
[0].regshift
= 0;
114 serial_platform_data
[1].regshift
= 0;
115 serial_platform_data
[0].irq
= INT_730_UART_MODEM_1
;
116 serial_platform_data
[1].irq
= INT_730_UART_MODEM_IRDA_2
;
119 if (cpu_is_omap1510()) {
120 serial_platform_data
[0].uartclk
= OMAP1510_BASE_BAUD
* 16;
121 serial_platform_data
[1].uartclk
= OMAP1510_BASE_BAUD
* 16;
122 serial_platform_data
[2].uartclk
= OMAP1510_BASE_BAUD
* 16;
125 for (i
= 0; i
< OMAP_MAX_NR_PORTS
; i
++) {
129 serial_platform_data
[i
].membase
= NULL
;
130 serial_platform_data
[i
].mapbase
= 0;
136 uart1_ck
= clk_get(NULL
, "uart1_ck");
137 if (IS_ERR(uart1_ck
))
138 printk("Could not get uart1_ck\n");
141 if (cpu_is_omap1510())
142 clk_set_rate(uart1_ck
, 12000000);
144 if (cpu_is_omap1510()) {
145 omap_cfg_reg(UART1_TX
);
146 omap_cfg_reg(UART1_RTS
);
147 if (machine_is_omap_innovator()) {
148 reg
= fpga_read(OMAP1510_FPGA_POWER
);
149 reg
|= OMAP1510_FPGA_PCR_COM1_EN
;
150 fpga_write(reg
, OMAP1510_FPGA_POWER
);
156 uart2_ck
= clk_get(NULL
, "uart2_ck");
157 if (IS_ERR(uart2_ck
))
158 printk("Could not get uart2_ck\n");
161 if (cpu_is_omap1510())
162 clk_set_rate(uart2_ck
, 12000000);
164 clk_set_rate(uart2_ck
, 48000000);
166 if (cpu_is_omap1510()) {
167 omap_cfg_reg(UART2_TX
);
168 omap_cfg_reg(UART2_RTS
);
169 if (machine_is_omap_innovator()) {
170 reg
= fpga_read(OMAP1510_FPGA_POWER
);
171 reg
|= OMAP1510_FPGA_PCR_COM2_EN
;
172 fpga_write(reg
, OMAP1510_FPGA_POWER
);
178 uart3_ck
= clk_get(NULL
, "uart3_ck");
179 if (IS_ERR(uart3_ck
))
180 printk("Could not get uart3_ck\n");
183 if (cpu_is_omap1510())
184 clk_set_rate(uart3_ck
, 12000000);
186 if (cpu_is_omap1510()) {
187 omap_cfg_reg(UART3_TX
);
188 omap_cfg_reg(UART3_RX
);
192 omap_serial_reset(&serial_platform_data
[i
]);
196 static int __init
omap_init(void)
198 return platform_device_register(&serial_device
);
200 arch_initcall(omap_init
);