blob: adc90a3c5890574856fbdd3d5ccd3ab559f71a08 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* linux/arch/arm/mach-s3c2410/s3c2410.c
2 *
3 * Copyright (c) 2003-2005 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070011*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/list.h>
17#include <linux/timer.h>
18#include <linux/init.h>
Ben Dooks1ec72692010-05-03 14:39:45 +090019#include <linux/gpio.h>
Ben Dookse4253822008-10-21 14:06:38 +010020#include <linux/clk.h>
Ben Dooksa3413052006-06-22 22:18:13 +010021#include <linux/sysdev.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010022#include <linux/serial_core.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010023#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010024#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/irq.h>
29
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/irq.h>
32
Ben Dookse4253822008-10-21 14:06:38 +010033#include <plat/cpu-freq.h>
34
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/regs-clock.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010036#include <plat/regs-serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Ben Dooksa2b7ba92008-10-07 22:26:09 +010038#include <plat/s3c2410.h>
39#include <plat/cpu.h>
40#include <plat/devs.h>
Ben Dooksd5120ae2008-10-07 23:09:51 +010041#include <plat/clock.h>
Ben Dookse24b8642008-10-21 14:06:34 +010042#include <plat/pll.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Ben Dooks1ec72692010-05-03 14:39:45 +090044#include <plat/gpio-core.h>
45#include <plat/gpio-cfg.h>
46#include <plat/gpio-cfg-helpers.h>
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048/* Initial IO mappings */
49
50static struct map_desc s3c2410_iodesc[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 IODESC_ENT(CLKPWR),
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 IODESC_ENT(TIMER),
Dimitry Andric62ee9142005-08-17 13:01:19 +010053 IODESC_ENT(WATCHDOG),
Linus Torvalds1da177e2005-04-16 15:20:36 -070054};
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056/* our uart devices */
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/* uart registration process */
59
60void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
61{
Ben Dooks66a9b492006-06-18 23:04:05 +010062 s3c24xx_init_uartdevs("s3c2410-uart", s3c2410_uart_resources, cfg, no);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
64
65/* s3c2410_map_io
66 *
67 * register the standard cpu IO areas, and any passed in from the
68 * machine specific initialisation.
69*/
70
Ben Dooks74b265d2008-10-21 14:06:31 +010071void __init s3c2410_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
Ben Dooks1ec72692010-05-03 14:39:45 +090073 s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_1up;
74 s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_1up;
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
Ben Dookse4253822008-10-21 14:06:38 +010079void __init_or_cpufreq s3c2410_setup_clocks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
Ben Dookse4253822008-10-21 14:06:38 +010081 struct clk *xtal_clk;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 unsigned long tmp;
Ben Dookse4253822008-10-21 14:06:38 +010083 unsigned long xtal;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 unsigned long fclk;
85 unsigned long hclk;
86 unsigned long pclk;
87
Ben Dookse4253822008-10-21 14:06:38 +010088 xtal_clk = clk_get(NULL, "xtal");
89 xtal = clk_get_rate(xtal_clk);
90 clk_put(xtal_clk);
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 /* now we've got our machine bits initialised, work out what
93 * clocks we've got */
94
Ben Dookse24b8642008-10-21 14:06:34 +010095 fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 tmp = __raw_readl(S3C2410_CLKDIVN);
98
99 /* work out clock scalings */
100
101 hclk = fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
102 pclk = hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
103
104 /* print brieft summary of clocks, etc */
105
106 printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
107 print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
108
109 /* initialise the clocks here, to allow other things like the
110 * console to use them
111 */
112
Ben Dookse4253822008-10-21 14:06:38 +0100113 s3c24xx_setup_clocks(fclk, hclk, pclk);
114}
115
Ben Dooksad787592009-07-30 23:23:40 +0100116/* fake ARMCLK for use with cpufreq, etc. */
117
118static struct clk s3c2410_armclk = {
119 .name = "armclk",
120 .parent = &clk_f,
121 .id = -1,
122};
123
Ben Dookse4253822008-10-21 14:06:38 +0100124void __init s3c2410_init_clocks(int xtal)
125{
126 s3c24xx_register_baseclocks(xtal);
127 s3c2410_setup_clocks();
Ben Dooks99c13852006-06-22 22:18:20 +0100128 s3c2410_baseclk_add();
Ben Dooksad787592009-07-30 23:23:40 +0100129 s3c24xx_register_clock(&s3c2410_armclk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130}
131
Ben Dooksa3413052006-06-22 22:18:13 +0100132struct sysdev_class s3c2410_sysclass = {
Kay Sieversaf5ca3f2007-12-20 02:09:39 +0100133 .name = "s3c2410-core",
Ben Dooksa3413052006-06-22 22:18:13 +0100134};
135
Ben Dooksf0176792009-07-30 23:23:38 +0100136/* Note, we would have liked to name this s3c2410-core, but we cannot
137 * register two sysdev_class with the same name.
138 */
139struct sysdev_class s3c2410a_sysclass = {
140 .name = "s3c2410a-core",
141};
142
Ben Dooksa3413052006-06-22 22:18:13 +0100143static struct sys_device s3c2410_sysdev = {
144 .cls = &s3c2410_sysclass,
145};
146
147/* need to register class before we actually register the device, and
148 * we also need to ensure that it has been initialised before any of the
Ben Dooks6db3eee2007-02-12 16:03:22 +0100149 * drivers even try to use it (even if not on an s3c2410 based system)
Ben Dooksa3413052006-06-22 22:18:13 +0100150 * as a driver which may support both 2410 and 2440 may try and use it.
151*/
152
153static int __init s3c2410_core_init(void)
154{
155 return sysdev_class_register(&s3c2410_sysclass);
156}
157
158core_initcall(s3c2410_core_init);
159
Ben Dooksf0176792009-07-30 23:23:38 +0100160static int __init s3c2410a_core_init(void)
161{
162 return sysdev_class_register(&s3c2410a_sysclass);
163}
164
165core_initcall(s3c2410a_core_init);
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167int __init s3c2410_init(void)
168{
169 printk("S3C2410: Initialising architecture\n");
170
Ben Dooksa3413052006-06-22 22:18:13 +0100171 return sysdev_register(&s3c2410_sysdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172}
Ben Dooksf0176792009-07-30 23:23:38 +0100173
174int __init s3c2410a_init(void)
175{
176 s3c2410_sysdev.cls = &s3c2410a_sysclass;
177 return s3c2410_init();
178}