# BRCM_VERSION=3
[bcm963xx.git] / kernel / linux / arch / arm / mach-s3c2410 / s3c2410.c
1 /* linux/arch/arm/mach-s3c2410/s3c2410.c
2  *
3  * Copyright (c) 2003 Simtec Electronics
4  * Ben Dooks <ben@simtec.co.uk>
5  *
6  * http://www.simtec.co.uk/products/EB2410ITX/
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  *
12  * Modifications:
13  *     16-May-2003 BJD  Created initial version
14  *     16-Aug-2003 BJD  Fixed header files and copyright, added URL
15  *     05-Sep-2003 BJD  Moved to kernel v2.6
16  *     18-Jan-2003 BJD  Added serial port configuration
17 */
18
19 #include <linux/kernel.h>
20 #include <linux/types.h>
21 #include <linux/interrupt.h>
22 #include <linux/list.h>
23 #include <linux/timer.h>
24 #include <linux/init.h>
25 #include <linux/device.h>
26
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
30
31 #include <asm/hardware.h>
32 #include <asm/io.h>
33 #include <asm/irq.h>
34
35 #include <asm/arch/regs-clock.h>
36 #include <asm/arch/regs-serial.h>
37
38 int s3c2410_clock_tick_rate = 12*1000*1000;  /* current timers at 12MHz */
39
40 /* serial port setup */
41
42 struct s3c2410_uartcfg *s3c2410_uartcfgs;
43
44 /* clock info */
45
46 unsigned long s3c2410_fclk;
47 unsigned long s3c2410_hclk;
48 unsigned long s3c2410_pclk;
49
50 #ifndef MHZ
51 #define MHZ (1000*1000)
52 #endif
53
54 #define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
55
56 #define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
57
58 static struct map_desc s3c2410_iodesc[] __initdata = {
59   IODESC_ENT(IRQ),
60   IODESC_ENT(MEMCTRL),
61   IODESC_ENT(USBHOST),
62   IODESC_ENT(DMA),
63   IODESC_ENT(CLKPWR),
64   IODESC_ENT(LCD),
65   IODESC_ENT(NAND),
66   IODESC_ENT(UART),
67   IODESC_ENT(TIMER),
68   IODESC_ENT(USBDEV),
69   IODESC_ENT(WATCHDOG),
70   IODESC_ENT(IIC),
71   IODESC_ENT(IIS),
72   IODESC_ENT(GPIO),
73   IODESC_ENT(RTC),
74   IODESC_ENT(ADC),
75   IODESC_ENT(SPI),
76   IODESC_ENT(SDI)
77 };
78
79 static struct resource s3c_uart0_resource[] = {
80         [0] = {
81                 .start = S3C2410_PA_UART0,
82                 .end   = S3C2410_PA_UART0 + 0x3fff,
83                 .flags = IORESOURCE_MEM,
84         },
85         [1] = {
86                 .start = IRQ_S3CUART_RX0,
87                 .end   = IRQ_S3CUART_ERR0,
88                 .flags = IORESOURCE_IRQ,
89         }
90
91 };
92
93 static struct resource s3c_uart1_resource[] = {
94         [0] = {
95                 .start = S3C2410_PA_UART1,
96                 .end   = S3C2410_PA_UART1 + 0x3fff,
97                 .flags = IORESOURCE_MEM,
98         },
99         [1] = {
100                 .start = IRQ_S3CUART_RX1,
101                 .end   = IRQ_S3CUART_ERR1,
102                 .flags = IORESOURCE_IRQ,
103         }
104 };
105
106 static struct resource s3c_uart2_resource[] = {
107         [0] = {
108                 .start = S3C2410_PA_UART2,
109                 .end   = S3C2410_PA_UART2 + 0x3fff,
110                 .flags = IORESOURCE_MEM,
111         },
112         [1] = {
113                 .start = IRQ_S3CUART_RX2,
114                 .end   = IRQ_S3CUART_ERR2,
115                 .flags = IORESOURCE_IRQ,
116         }
117 };
118
119 /* our uart devices */
120
121 static struct platform_device s3c_uart0 = {
122         .name             = "s3c2410-uart",
123         .id               = 0,
124         .num_resources    = ARRAY_SIZE(s3c_uart0_resource),
125         .resource         = s3c_uart0_resource,
126 };
127
128
129 static struct platform_device s3c_uart1 = {
130         .name             = "s3c2410-uart",
131         .id               = 1,
132         .num_resources    = ARRAY_SIZE(s3c_uart1_resource),
133         .resource         = s3c_uart1_resource,
134 };
135
136 static struct platform_device s3c_uart2 = {
137         .name             = "s3c2410-uart",
138         .id               = 2,
139         .num_resources    = ARRAY_SIZE(s3c_uart2_resource),
140         .resource         = s3c_uart2_resource,
141 };
142
143 static struct platform_device *uart_devices[] __initdata = {
144         &s3c_uart0,
145         &s3c_uart1,
146         &s3c_uart2
147 };
148
149 void __init s3c2410_map_io(struct map_desc *mach_desc, int size)
150 {
151         unsigned long tmp;
152
153         /* register our io-tables */
154
155         iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
156         iotable_init(mach_desc, size);
157
158         /* now we've got our machine bits initialised, work out what
159          * clocks we've got */
160
161         s3c2410_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), 12*MHZ);
162
163         tmp = __raw_readl(S3C2410_CLKDIVN);
164         //printk("tmp=%08x, fclk=%d\n", tmp, s3c2410_fclk);
165
166         /* work out clock scalings */
167
168         s3c2410_hclk = s3c2410_fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
169         s3c2410_pclk = s3c2410_hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
170
171         /* print brieft summary of clocks, etc */
172
173         printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
174                print_mhz(s3c2410_fclk), print_mhz(s3c2410_hclk),
175                print_mhz(s3c2410_pclk));
176 }
177
178
179 static int __init s3c2410_init(void)
180 {
181         int ret;
182
183         printk("S3C2410: Initialising architecture\n");
184
185         ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
186
187         return ret;
188 }
189
190 arch_initcall(s3c2410_init);