Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 1 | /* |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 2 | * Copyright (c) 2006 Simtec Electronics |
| 3 | * Ben Dooks <ben@simtec.co.uk> |
| 4 | * |
| 5 | * http://armlinux.simtec.co.uk/. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/list.h> |
| 16 | #include <linux/timer.h> |
| 17 | #include <linux/init.h> |
Ben Dooks | e425382 | 2008-10-21 14:06:38 +0100 | [diff] [blame] | 18 | #include <linux/clk.h> |
Ben Dooks | eca8c24 | 2007-05-28 18:19:16 +0100 | [diff] [blame] | 19 | #include <linux/delay.h> |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 20 | #include <linux/device.h> |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 21 | #include <linux/syscore_ops.h> |
Ben Dooks | b6d1f54 | 2006-12-17 23:22:26 +0100 | [diff] [blame] | 22 | #include <linux/serial_core.h> |
Tushar Behera | 334a1c7 | 2014-02-14 10:32:45 +0900 | [diff] [blame] | 23 | #include <linux/serial_s3c.h> |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 25 | #include <linux/io.h> |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 26 | #include <linux/reboot.h> |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 27 | |
| 28 | #include <asm/mach/arch.h> |
| 29 | #include <asm/mach/map.h> |
| 30 | #include <asm/mach/irq.h> |
| 31 | |
Ben Dooks | c84cbb2 | 2006-09-14 13:29:15 +0100 | [diff] [blame] | 32 | #include <asm/proc-fns.h> |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 33 | #include <asm/irq.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 34 | #include <asm/system_misc.h> |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 35 | |
Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 36 | #include <mach/hardware.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 37 | #include <mach/regs-clock.h> |
Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 38 | #include <mach/regs-gpio.h> |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 39 | |
Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 40 | #include <plat/cpu.h> |
| 41 | #include <plat/cpu-freq.h> |
| 42 | #include <plat/devs.h> |
Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 43 | #include <plat/pm.h> |
Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 44 | #include <plat/regs-spi.h> |
Kukjin Kim | fd4e5a5 | 2013-01-02 11:04:57 -0800 | [diff] [blame] | 45 | |
Heiko Stuebner | d8fdec1 | 2013-01-29 10:25:22 -0800 | [diff] [blame] | 46 | #include "common.h" |
Kukjin Kim | f8eed6c | 2015-07-30 02:00:35 +0900 | [diff] [blame] | 47 | #include "nand-core.h" |
Kukjin Kim | b435378 | 2013-01-02 14:01:09 -0800 | [diff] [blame] | 48 | #include "regs-dsc.h" |
Kukjin Kim | 14cce0e | 2013-02-01 21:49:35 -0800 | [diff] [blame] | 49 | #include "s3c2412-power.h" |
Kukjin Kim | b435378 | 2013-01-02 14:01:09 -0800 | [diff] [blame] | 50 | |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 51 | #ifndef CONFIG_CPU_S3C2412_ONLY |
| 52 | void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; |
Ben Dooks | 50dedf1 | 2006-09-18 10:19:06 +0100 | [diff] [blame] | 53 | |
| 54 | static inline void s3c2412_init_gpio2(void) |
| 55 | { |
| 56 | s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10; |
| 57 | } |
| 58 | #else |
| 59 | #define s3c2412_init_gpio2() do { } while(0) |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 60 | #endif |
| 61 | |
| 62 | /* Initial IO mappings */ |
| 63 | |
| 64 | static struct map_desc s3c2412_iodesc[] __initdata = { |
| 65 | IODESC_ENT(CLKPWR), |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 66 | IODESC_ENT(TIMER), |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 67 | IODESC_ENT(WATCHDOG), |
Ben Dooks | 2540003 | 2009-07-30 23:23:36 +0100 | [diff] [blame] | 68 | { |
| 69 | .virtual = (unsigned long)S3C2412_VA_SSMC, |
| 70 | .pfn = __phys_to_pfn(S3C2412_PA_SSMC), |
| 71 | .length = SZ_1M, |
| 72 | .type = MT_DEVICE, |
| 73 | }, |
| 74 | { |
| 75 | .virtual = (unsigned long)S3C2412_VA_EBI, |
| 76 | .pfn = __phys_to_pfn(S3C2412_PA_EBI), |
| 77 | .length = SZ_1M, |
| 78 | .type = MT_DEVICE, |
| 79 | }, |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | /* uart registration process */ |
| 83 | |
| 84 | void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no) |
| 85 | { |
| 86 | s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no); |
| 87 | |
| 88 | /* rename devices that are s3c2412/s3c2413 specific */ |
| 89 | s3c_device_sdi.name = "s3c2412-sdi"; |
Ben Dooks | 72d70d0 | 2006-09-20 20:46:09 +0100 | [diff] [blame] | 90 | s3c_device_lcd.name = "s3c2412-lcd"; |
Atul Dahiya | ef3f2dd | 2010-10-18 19:56:45 +0900 | [diff] [blame] | 91 | s3c_nand_setname("s3c2412-nand"); |
Sandeep Sanjay Patil | e903382 | 2007-05-16 10:51:45 +0100 | [diff] [blame] | 92 | |
Ben Dooks | f3fb5a5 | 2007-10-04 21:41:20 +0100 | [diff] [blame] | 93 | /* alter IRQ of SDI controller */ |
| 94 | |
| 95 | s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI; |
| 96 | s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI; |
| 97 | |
Sandeep Sanjay Patil | e903382 | 2007-05-16 10:51:45 +0100 | [diff] [blame] | 98 | /* spi channel related changes, s3c2412/13 specific */ |
| 99 | s3c_device_spi0.name = "s3c2412-spi"; |
| 100 | s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24; |
| 101 | s3c_device_spi1.name = "s3c2412-spi"; |
| 102 | s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1; |
| 103 | s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24; |
| 104 | |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 105 | } |
| 106 | |
Ben Dooks | c84cbb2 | 2006-09-14 13:29:15 +0100 | [diff] [blame] | 107 | /* s3c2412_idle |
| 108 | * |
| 109 | * use the standard idle call by ensuring the idle mode |
| 110 | * in power config, then issuing the idle co-processor |
| 111 | * instruction |
| 112 | */ |
| 113 | |
| 114 | static void s3c2412_idle(void) |
| 115 | { |
| 116 | unsigned long tmp; |
| 117 | |
| 118 | /* ensure our idle mode is to go to idle */ |
| 119 | |
| 120 | tmp = __raw_readl(S3C2412_PWRCFG); |
| 121 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; |
| 122 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; |
| 123 | __raw_writel(tmp, S3C2412_PWRCFG); |
| 124 | |
| 125 | cpu_do_idle(); |
| 126 | } |
| 127 | |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 128 | /* s3c2412_map_io |
| 129 | * |
| 130 | * register the standard cpu IO areas, and any passed in from the |
| 131 | * machine specific initialisation. |
| 132 | */ |
| 133 | |
Ben Dooks | 74b265d | 2008-10-21 14:06:31 +0100 | [diff] [blame] | 134 | void __init s3c2412_map_io(void) |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 135 | { |
| 136 | /* move base of IO */ |
| 137 | |
Ben Dooks | 50dedf1 | 2006-09-18 10:19:06 +0100 | [diff] [blame] | 138 | s3c2412_init_gpio2(); |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 139 | |
Ben Dooks | c84cbb2 | 2006-09-14 13:29:15 +0100 | [diff] [blame] | 140 | /* set our idle function */ |
| 141 | |
Nicolas Pitre | 9231127 | 2011-08-03 11:34:59 -0400 | [diff] [blame] | 142 | arm_pm_idle = s3c2412_idle; |
Ben Dooks | c84cbb2 | 2006-09-14 13:29:15 +0100 | [diff] [blame] | 143 | |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 144 | /* register our io-tables */ |
| 145 | |
| 146 | iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc)); |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 147 | } |
| 148 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 149 | /* need to register the subsystem before we actually register the device, and |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 150 | * we also need to ensure that it has been initialised before any of the |
| 151 | * drivers even try to use it (even if not on an s3c2412 based system) |
| 152 | * as a driver which may support both 2410 and 2440 may try and use it. |
| 153 | */ |
| 154 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 155 | struct bus_type s3c2412_subsys = { |
Kay Sievers | af5ca3f | 2007-12-20 02:09:39 +0100 | [diff] [blame] | 156 | .name = "s3c2412-core", |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 157 | .dev_name = "s3c2412-core", |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | static int __init s3c2412_core_init(void) |
| 161 | { |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 162 | return subsys_system_register(&s3c2412_subsys, NULL); |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | core_initcall(s3c2412_core_init); |
| 166 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 167 | static struct device s3c2412_dev = { |
| 168 | .bus = &s3c2412_subsys, |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | int __init s3c2412_init(void) |
| 172 | { |
| 173 | printk("S3C2412: Initialising architecture\n"); |
| 174 | |
Arnd Bergmann | 4f506da | 2015-02-27 05:50:22 +0900 | [diff] [blame] | 175 | #ifdef CONFIG_PM_SLEEP |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 176 | register_syscore_ops(&s3c2412_pm_syscore_ops); |
| 177 | register_syscore_ops(&s3c24xx_irq_syscore_ops); |
Heiko Stuebner | d8fdec1 | 2013-01-29 10:25:22 -0800 | [diff] [blame] | 178 | #endif |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 179 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 180 | return device_register(&s3c2412_dev); |
Ben Dooks | 68d9ab3 | 2006-06-24 21:21:27 +0100 | [diff] [blame] | 181 | } |