blob: 04b58cb4988860bbd46d18e277679930d8674d78 [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>
Kay Sievers4a858cf2011-12-21 16:01:38 -080021#include <linux/device.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020022#include <linux/syscore_ops.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010023#include <linux/serial_core.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090024#include <linux/serial_s3c.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010025#include <linux/platform_device.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070026#include <linux/reboot.h>
Russell Kingfced80c2008-09-06 12:10:45 +010027#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/irq.h>
32
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/hardware.h>
Linus Walleijb0161ca2014-01-14 14:24:24 +010034#include <mach/gpio-samsung.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/irq.h>
David Howells9f97da72012-03-28 18:30:01 +010036#include <asm/system_misc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Ben Dookse4253822008-10-21 14:06:38 +010038#include <plat/cpu-freq.h>
39
Russell Kinga09e64f2008-08-05 16:14:15 +010040#include <mach/regs-clock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Ben Dooksa2b7ba92008-10-07 22:26:09 +010042#include <plat/cpu.h>
43#include <plat/devs.h>
Ben Dooksd5120ae2008-10-07 23:09:51 +010044#include <plat/clock.h>
Ben Dookse24b8642008-10-21 14:06:34 +010045#include <plat/pll.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020046#include <plat/pm.h>
Kukjin Kimb27b0722012-01-03 14:02:03 +010047#include <plat/watchdog-reset.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Ben Dooks1ec72692010-05-03 14:39:45 +090049#include <plat/gpio-core.h>
50#include <plat/gpio-cfg.h>
51#include <plat/gpio-cfg-helpers.h>
52
Heiko Stuebnerd8fdec12013-01-29 10:25:22 -080053#include "common.h"
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055/* Initial IO mappings */
56
57static struct map_desc s3c2410_iodesc[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 IODESC_ENT(CLKPWR),
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 IODESC_ENT(TIMER),
Dimitry Andric62ee9142005-08-17 13:01:19 +010060 IODESC_ENT(WATCHDOG),
Linus Torvalds1da177e2005-04-16 15:20:36 -070061};
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063/* our uart devices */
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065/* uart registration process */
66
67void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
68{
Ben Dooks66a9b492006-06-18 23:04:05 +010069 s3c24xx_init_uartdevs("s3c2410-uart", s3c2410_uart_resources, cfg, no);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
72/* s3c2410_map_io
73 *
74 * register the standard cpu IO areas, and any passed in from the
75 * machine specific initialisation.
76*/
77
Ben Dooks74b265d2008-10-21 14:06:31 +010078void __init s3c2410_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
Kukjin Kim782d8a32011-08-30 20:47:32 +090080 s3c24xx_gpiocfg_default.set_pull = s3c24xx_gpio_setpull_1up;
81 s3c24xx_gpiocfg_default.get_pull = s3c24xx_gpio_getpull_1up;
Ben Dooks1ec72692010-05-03 14:39:45 +090082
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
85
Ben Dookse4253822008-10-21 14:06:38 +010086void __init_or_cpufreq s3c2410_setup_clocks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Ben Dookse4253822008-10-21 14:06:38 +010088 struct clk *xtal_clk;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 unsigned long tmp;
Ben Dookse4253822008-10-21 14:06:38 +010090 unsigned long xtal;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 unsigned long fclk;
92 unsigned long hclk;
93 unsigned long pclk;
94
Ben Dookse4253822008-10-21 14:06:38 +010095 xtal_clk = clk_get(NULL, "xtal");
96 xtal = clk_get_rate(xtal_clk);
97 clk_put(xtal_clk);
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 /* now we've got our machine bits initialised, work out what
100 * clocks we've got */
101
Ben Dookse24b8642008-10-21 14:06:34 +0100102 fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104 tmp = __raw_readl(S3C2410_CLKDIVN);
105
106 /* work out clock scalings */
107
108 hclk = fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
109 pclk = hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
110
111 /* print brieft summary of clocks, etc */
112
113 printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
114 print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
115
116 /* initialise the clocks here, to allow other things like the
117 * console to use them
118 */
119
Ben Dookse4253822008-10-21 14:06:38 +0100120 s3c24xx_setup_clocks(fclk, hclk, pclk);
121}
122
Ben Dooksad787592009-07-30 23:23:40 +0100123/* fake ARMCLK for use with cpufreq, etc. */
124
125static struct clk s3c2410_armclk = {
126 .name = "armclk",
127 .parent = &clk_f,
128 .id = -1,
129};
130
Thomas Abraham0cfb26e2011-10-24 12:08:42 +0200131static struct clk_lookup s3c2410_clk_lookup[] = {
132 CLKDEV_INIT(NULL, "clk_uart_baud0", &clk_p),
133 CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk),
134};
135
Ben Dookse4253822008-10-21 14:06:38 +0100136void __init s3c2410_init_clocks(int xtal)
137{
138 s3c24xx_register_baseclocks(xtal);
139 s3c2410_setup_clocks();
Ben Dooks99c13852006-06-22 22:18:20 +0100140 s3c2410_baseclk_add();
Ben Dooksad787592009-07-30 23:23:40 +0100141 s3c24xx_register_clock(&s3c2410_armclk);
Thomas Abraham0cfb26e2011-10-24 12:08:42 +0200142 clkdev_add_table(s3c2410_clk_lookup, ARRAY_SIZE(s3c2410_clk_lookup));
Tomasz Figa88f59732013-06-17 23:45:37 +0900143 samsung_wdt_reset_init(S3C24XX_VA_WATCHDOG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Kay Sievers4a858cf2011-12-21 16:01:38 -0800146struct bus_type s3c2410_subsys = {
Kay Sieversaf5ca3f42007-12-20 02:09:39 +0100147 .name = "s3c2410-core",
Kay Sievers4a858cf2011-12-21 16:01:38 -0800148 .dev_name = "s3c2410-core",
Ben Dooksa3413052006-06-22 22:18:13 +0100149};
150
Ben Dooksf0176792009-07-30 23:23:38 +0100151/* Note, we would have liked to name this s3c2410-core, but we cannot
Kay Sievers4a858cf2011-12-21 16:01:38 -0800152 * register two subsystems with the same name.
Ben Dooksf0176792009-07-30 23:23:38 +0100153 */
Kay Sievers4a858cf2011-12-21 16:01:38 -0800154struct bus_type s3c2410a_subsys = {
Ben Dooksf0176792009-07-30 23:23:38 +0100155 .name = "s3c2410a-core",
Kay Sievers4a858cf2011-12-21 16:01:38 -0800156 .dev_name = "s3c2410a-core",
Ben Dooksf0176792009-07-30 23:23:38 +0100157};
158
Kay Sievers4a858cf2011-12-21 16:01:38 -0800159static struct device s3c2410_dev = {
160 .bus = &s3c2410_subsys,
Ben Dooksa3413052006-06-22 22:18:13 +0100161};
162
Kay Sievers4a858cf2011-12-21 16:01:38 -0800163/* need to register the subsystem before we actually register the device, and
Ben Dooksa3413052006-06-22 22:18:13 +0100164 * we also need to ensure that it has been initialised before any of the
Ben Dooks6db3eee2007-02-12 16:03:22 +0100165 * drivers even try to use it (even if not on an s3c2410 based system)
Ben Dooksa3413052006-06-22 22:18:13 +0100166 * as a driver which may support both 2410 and 2440 may try and use it.
167*/
168
169static int __init s3c2410_core_init(void)
170{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800171 return subsys_system_register(&s3c2410_subsys, NULL);
Ben Dooksa3413052006-06-22 22:18:13 +0100172}
173
174core_initcall(s3c2410_core_init);
175
Ben Dooksf0176792009-07-30 23:23:38 +0100176static int __init s3c2410a_core_init(void)
177{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800178 return subsys_system_register(&s3c2410a_subsys, NULL);
Ben Dooksf0176792009-07-30 23:23:38 +0100179}
180
181core_initcall(s3c2410a_core_init);
182
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183int __init s3c2410_init(void)
184{
185 printk("S3C2410: Initialising architecture\n");
186
Domenico Andreolifb630b92011-10-22 04:00:53 +0900187#ifdef CONFIG_PM
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200188 register_syscore_ops(&s3c2410_pm_syscore_ops);
189 register_syscore_ops(&s3c24xx_irq_syscore_ops);
Heiko Stuebnerd8fdec12013-01-29 10:25:22 -0800190#endif
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200191
Kay Sievers4a858cf2011-12-21 16:01:38 -0800192 return device_register(&s3c2410_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193}
Ben Dooksf0176792009-07-30 23:23:38 +0100194
195int __init s3c2410a_init(void)
196{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800197 s3c2410_dev.bus = &s3c2410a_subsys;
Ben Dooksf0176792009-07-30 23:23:38 +0100198 return s3c2410_init();
199}
Kukjin Kimb27b0722012-01-03 14:02:03 +0100200
Robin Holt7b6d8642013-07-08 16:01:40 -0700201void s3c2410_restart(enum reboot_mode mode, const char *cmd)
Kukjin Kimb27b0722012-01-03 14:02:03 +0100202{
Robin Holt7b6d8642013-07-08 16:01:40 -0700203 if (mode == REBOOT_SOFT) {
Kukjin Kimb27b0722012-01-03 14:02:03 +0100204 soft_restart(0);
205 }
206
Tomasz Figa88f59732013-06-17 23:45:37 +0900207 samsung_wdt_reset();
Kukjin Kimb27b0722012-01-03 14:02:03 +0100208
209 /* we'll take a jump through zero as a poor second */
210 soft_restart(0);
211}