1 /* linux/arch/arm/mach-s3c2410/s3c2410.c
3 * Copyright (c) 2003 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://www.simtec.co.uk/products/EB2410ITX/
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.
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
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>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
31 #include <asm/hardware.h>
35 #include <asm/arch/regs-clock.h>
36 #include <asm/arch/regs-serial.h>
38 int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */
40 /* serial port setup */
42 struct s3c2410_uartcfg *s3c2410_uartcfgs;
46 unsigned long s3c2410_fclk;
47 unsigned long s3c2410_hclk;
48 unsigned long s3c2410_pclk;
51 #define MHZ (1000*1000)
54 #define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
56 #define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
58 static struct map_desc s3c2410_iodesc[] __initdata = {
79 static struct resource s3c_uart0_resource[] = {
81 .start = S3C2410_PA_UART0,
82 .end = S3C2410_PA_UART0 + 0x3fff,
83 .flags = IORESOURCE_MEM,
86 .start = IRQ_S3CUART_RX0,
87 .end = IRQ_S3CUART_ERR0,
88 .flags = IORESOURCE_IRQ,
93 static struct resource s3c_uart1_resource[] = {
95 .start = S3C2410_PA_UART1,
96 .end = S3C2410_PA_UART1 + 0x3fff,
97 .flags = IORESOURCE_MEM,
100 .start = IRQ_S3CUART_RX1,
101 .end = IRQ_S3CUART_ERR1,
102 .flags = IORESOURCE_IRQ,
106 static struct resource s3c_uart2_resource[] = {
108 .start = S3C2410_PA_UART2,
109 .end = S3C2410_PA_UART2 + 0x3fff,
110 .flags = IORESOURCE_MEM,
113 .start = IRQ_S3CUART_RX2,
114 .end = IRQ_S3CUART_ERR2,
115 .flags = IORESOURCE_IRQ,
119 /* our uart devices */
121 static struct platform_device s3c_uart0 = {
122 .name = "s3c2410-uart",
124 .num_resources = ARRAY_SIZE(s3c_uart0_resource),
125 .resource = s3c_uart0_resource,
129 static struct platform_device s3c_uart1 = {
130 .name = "s3c2410-uart",
132 .num_resources = ARRAY_SIZE(s3c_uart1_resource),
133 .resource = s3c_uart1_resource,
136 static struct platform_device s3c_uart2 = {
137 .name = "s3c2410-uart",
139 .num_resources = ARRAY_SIZE(s3c_uart2_resource),
140 .resource = s3c_uart2_resource,
143 static struct platform_device *uart_devices[] __initdata = {
149 void __init s3c2410_map_io(struct map_desc *mach_desc, int size)
153 /* register our io-tables */
155 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
156 iotable_init(mach_desc, size);
158 /* now we've got our machine bits initialised, work out what
159 * clocks we've got */
161 s3c2410_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), 12*MHZ);
163 tmp = __raw_readl(S3C2410_CLKDIVN);
164 //printk("tmp=%08x, fclk=%d\n", tmp, s3c2410_fclk);
166 /* work out clock scalings */
168 s3c2410_hclk = s3c2410_fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
169 s3c2410_pclk = s3c2410_hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
171 /* print brieft summary of clocks, etc */
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));
179 static int __init s3c2410_init(void)
183 printk("S3C2410: Initialising architecture\n");
185 ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
190 arch_initcall(s3c2410_init);