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