MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / arch / arm / mach-s3c2410 / s3c2410.c
blob7709e8dde3dc4e4fd5aff3050892c5e774fb000d
1 /* linux/arch/arm/mach-s3c2410/s3c2410.c
3 * Copyright (c) 2003,2004 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.
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-2004 BJD Added serial port configuration
17 * 21-Aug-2004 BJD Added new struct s3c2410_board handler
20 #include <linux/kernel.h>
21 #include <linux/types.h>
22 #include <linux/interrupt.h>
23 #include <linux/list.h>
24 #include <linux/timer.h>
25 #include <linux/init.h>
26 #include <linux/device.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/irq.h>
32 #include <asm/hardware.h>
33 #include <asm/io.h>
34 #include <asm/irq.h>
36 #include <asm/arch/regs-clock.h>
37 #include <asm/arch/regs-serial.h>
39 #include "s3c2410.h"
40 #include "cpu.h"
42 int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */
44 /* serial port setup */
46 struct s3c2410_uartcfg *s3c2410_uartcfgs;
48 /* clock info */
50 unsigned long s3c2410_fclk;
51 unsigned long s3c2410_hclk;
52 unsigned long s3c2410_pclk;
54 static struct map_desc s3c2410_iodesc[] __initdata = {
55 IODESC_ENT(USBHOST),
56 IODESC_ENT(CLKPWR),
57 IODESC_ENT(LCD),
58 IODESC_ENT(UART),
59 IODESC_ENT(TIMER),
60 IODESC_ENT(ADC),
61 IODESC_ENT(WATCHDOG)
64 static struct resource s3c_uart0_resource[] = {
65 [0] = {
66 .start = S3C2410_PA_UART0,
67 .end = S3C2410_PA_UART0 + 0x3fff,
68 .flags = IORESOURCE_MEM,
70 [1] = {
71 .start = IRQ_S3CUART_RX0,
72 .end = IRQ_S3CUART_ERR0,
73 .flags = IORESOURCE_IRQ,
78 static struct resource s3c_uart1_resource[] = {
79 [0] = {
80 .start = S3C2410_PA_UART1,
81 .end = S3C2410_PA_UART1 + 0x3fff,
82 .flags = IORESOURCE_MEM,
84 [1] = {
85 .start = IRQ_S3CUART_RX1,
86 .end = IRQ_S3CUART_ERR1,
87 .flags = IORESOURCE_IRQ,
91 static struct resource s3c_uart2_resource[] = {
92 [0] = {
93 .start = S3C2410_PA_UART2,
94 .end = S3C2410_PA_UART2 + 0x3fff,
95 .flags = IORESOURCE_MEM,
97 [1] = {
98 .start = IRQ_S3CUART_RX2,
99 .end = IRQ_S3CUART_ERR2,
100 .flags = IORESOURCE_IRQ,
104 /* our uart devices */
106 static struct platform_device s3c_uart0 = {
107 .name = "s3c2410-uart",
108 .id = 0,
109 .num_resources = ARRAY_SIZE(s3c_uart0_resource),
110 .resource = s3c_uart0_resource,
114 static struct platform_device s3c_uart1 = {
115 .name = "s3c2410-uart",
116 .id = 1,
117 .num_resources = ARRAY_SIZE(s3c_uart1_resource),
118 .resource = s3c_uart1_resource,
121 static struct platform_device s3c_uart2 = {
122 .name = "s3c2410-uart",
123 .id = 2,
124 .num_resources = ARRAY_SIZE(s3c_uart2_resource),
125 .resource = s3c_uart2_resource,
128 static struct platform_device *uart_devices[] __initdata = {
129 &s3c_uart0,
130 &s3c_uart1,
131 &s3c_uart2
134 void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
136 unsigned long tmp;
138 /* register our io-tables */
140 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
141 iotable_init(mach_desc, mach_size);
143 printk("machine_initted %p,%d\n", mach_desc, mach_size);
145 /* now we've got our machine bits initialised, work out what
146 * clocks we've got */
148 s3c2410_fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), 12*MHZ);
150 tmp = __raw_readl(S3C2410_CLKDIVN);
151 //printk("tmp=%08x, fclk=%d\n", tmp, s3c2410_fclk);
153 /* work out clock scalings */
155 s3c2410_hclk = s3c2410_fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
156 s3c2410_pclk = s3c2410_hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
158 /* print brieft summary of clocks, etc */
160 printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
161 print_mhz(s3c2410_fclk), print_mhz(s3c2410_hclk),
162 print_mhz(s3c2410_pclk));
165 static struct s3c2410_board *board;
167 void s3c2410_set_board(struct s3c2410_board *b)
169 board = b;
172 void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
174 s3c2410_uartcfgs = cfg;
177 int __init s3c2410_init(void)
179 int ret;
181 printk("S3C2410: Initialising architecture\n");
183 ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
184 if (ret)
185 return ret;
187 if (board != NULL) {
188 if (board->devices != NULL) {
189 ret = platform_add_devices(board->devices,
190 board->devices_count);
192 if (ret) {
193 printk(KERN_ERR "s3c2410: failed to add board devices (%d)\n", ret);
197 /* not adding board devices may not be fatal */
198 ret = 0;
201 return ret;