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>
34 #include <asm/mach-types.h>
36 #include <asm/arch/regs-clock.h>
37 #include <asm/arch/regs-serial.h>
39 int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */
41 /* serial port setup */
43 struct s3c2410_uartcfg *s3c2410_uartcfgs;
47 unsigned long s3c2410_fclk;
48 unsigned long s3c2410_hclk;
49 unsigned long s3c2410_pclk;
52 #define MHZ (1000*1000)
55 #define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
57 #define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
59 static struct map_desc s3c2410_iodesc[] __initdata = {
80 static struct resource s3c_uart0_resource[] = {
82 .start = S3C2410_PA_UART0,
83 .end = S3C2410_PA_UART0 + 0x3fff,
84 .flags = IORESOURCE_MEM,
87 .start = IRQ_S3CUART_RX0,
88 .end = IRQ_S3CUART_ERR0,
89 .flags = IORESOURCE_IRQ,
94 static struct resource s3c_uart1_resource[] = {
96 .start = S3C2410_PA_UART1,
97 .end = S3C2410_PA_UART1 + 0x3fff,
98 .flags = IORESOURCE_MEM,
101 .start = IRQ_S3CUART_RX1,
102 .end = IRQ_S3CUART_ERR1,
103 .flags = IORESOURCE_IRQ,
107 static struct resource s3c_uart2_resource[] = {
109 .start = S3C2410_PA_UART2,
110 .end = S3C2410_PA_UART2 + 0x3fff,
111 .flags = IORESOURCE_MEM,
114 .start = IRQ_S3CUART_RX2,
115 .end = IRQ_S3CUART_ERR2,
116 .flags = IORESOURCE_IRQ,
120 /* our uart devices */
122 static struct platform_device s3c_uart0 = {
123 .name = "s3c2410-uart",
125 .num_resources = ARRAY_SIZE(s3c_uart0_resource),
126 .resource = s3c_uart0_resource,
130 static struct platform_device s3c_uart1 = {
131 .name = "s3c2410-uart",
133 .num_resources = ARRAY_SIZE(s3c_uart1_resource),
134 .resource = s3c_uart1_resource,
137 static struct platform_device s3c_uart2 = {
138 .name = "s3c2410-uart",
140 .num_resources = ARRAY_SIZE(s3c_uart2_resource),
141 .resource = s3c_uart2_resource,
144 static struct platform_device *uart_devices[] __initdata = {
150 void __init s3c2410_map_io(struct map_desc *mach_desc, int size)
154 /* register our io-tables */
156 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
157 iotable_init(mach_desc, size);
159 /* now we've got our machine bits initialised, work out what
160 * clocks we've got */
162 s3c2410_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), 12*MHZ);
164 tmp = __raw_readl(S3C2410_CLKDIVN);
165 //printk("tmp=%08x, fclk=%d\n", tmp, s3c2410_fclk);
167 /* work out clock scalings */
169 s3c2410_hclk = s3c2410_fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
170 s3c2410_pclk = s3c2410_hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
172 /* print brieft summary of clocks, etc */
174 printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
175 print_mhz(s3c2410_fclk), print_mhz(s3c2410_hclk),
176 print_mhz(s3c2410_pclk));
180 static int __init s3c2410_init(void)
184 printk("S3C2410: Initialising architecture\n");
186 ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
191 arch_initcall(s3c2410_init);