Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. |
| 3 | * http://www.samsung.com |
| 4 | * |
| 5 | * Common Codes for EXYNOS |
| 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. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/irq.h> |
Rob Herring | a900e5d | 2013-02-12 16:04:52 -0600 | [diff] [blame] | 15 | #include <linux/irqchip.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 16 | #include <linux/io.h> |
Linus Torvalds | 7affca3 | 2012-01-07 12:03:30 -0800 | [diff] [blame] | 17 | #include <linux/device.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 18 | #include <linux/gpio.h> |
| 19 | #include <linux/sched.h> |
| 20 | #include <linux/serial_core.h> |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 21 | #include <linux/of.h> |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 22 | #include <linux/of_fdt.h> |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 23 | #include <linux/of_irq.h> |
Thomas Abraham | 1e60bc0 | 2012-05-15 16:18:35 +0900 | [diff] [blame] | 24 | #include <linux/export.h> |
| 25 | #include <linux/irqdomain.h> |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 26 | #include <linux/irqchip.h> |
Thomas Abraham | e873a47 | 2012-05-15 16:25:23 +0900 | [diff] [blame] | 27 | #include <linux/of_address.h> |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 28 | #include <linux/clocksource.h> |
| 29 | #include <linux/clk-provider.h> |
Rob Herring | 520f7bd | 2012-12-27 13:10:24 -0600 | [diff] [blame] | 30 | #include <linux/irqchip/arm-gic.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 31 | |
| 32 | #include <asm/proc-fns.h> |
Arnd Bergmann | 40ba95f | 2012-01-07 11:51:28 +0000 | [diff] [blame] | 33 | #include <asm/exception.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 34 | #include <asm/hardware/cache-l2x0.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 35 | #include <asm/mach/map.h> |
| 36 | #include <asm/mach/irq.h> |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 37 | #include <asm/cacheflush.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 38 | |
| 39 | #include <mach/regs-irq.h> |
| 40 | #include <mach/regs-pmu.h> |
| 41 | #include <mach/regs-gpio.h> |
| 42 | |
| 43 | #include <plat/cpu.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 44 | #include <plat/devs.h> |
| 45 | #include <plat/pm.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 46 | #include <plat/sdhci.h> |
| 47 | #include <plat/gpio-cfg.h> |
| 48 | #include <plat/adc-core.h> |
| 49 | #include <plat/fb-core.h> |
| 50 | #include <plat/fimc-core.h> |
| 51 | #include <plat/iic-core.h> |
| 52 | #include <plat/tv-core.h> |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 53 | #include <plat/spi-core.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 54 | #include <plat/regs-serial.h> |
| 55 | |
| 56 | #include "common.h" |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 57 | #define L2_AUX_VAL 0x7C470001 |
| 58 | #define L2_AUX_MASK 0xC200ffff |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 59 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 60 | static const char name_exynos4210[] = "EXYNOS4210"; |
| 61 | static const char name_exynos4212[] = "EXYNOS4212"; |
| 62 | static const char name_exynos4412[] = "EXYNOS4412"; |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 63 | static const char name_exynos5250[] = "EXYNOS5250"; |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 64 | static const char name_exynos5440[] = "EXYNOS5440"; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 65 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 66 | static void exynos4_map_io(void); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 67 | static void exynos5_map_io(void); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 68 | static void exynos5440_map_io(void); |
Thomas Abraham | 55b6ef7 | 2012-10-29 19:46:49 +0900 | [diff] [blame] | 69 | static void exynos4_init_uarts(struct s3c2410_uartcfg *cfg, int no); |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 70 | static int exynos_init(void); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 71 | |
Thomas Abraham | 9274427 | 2013-03-09 17:03:33 +0900 | [diff] [blame] | 72 | unsigned long xxti_f = 0, xusbxti_f = 0; |
| 73 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 74 | static struct cpu_table cpu_ids[] __initdata = { |
| 75 | { |
| 76 | .idcode = EXYNOS4210_CPU_ID, |
| 77 | .idmask = EXYNOS4_CPU_MASK, |
| 78 | .map_io = exynos4_map_io, |
Thomas Abraham | 55b6ef7 | 2012-10-29 19:46:49 +0900 | [diff] [blame] | 79 | .init_uarts = exynos4_init_uarts, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 80 | .init = exynos_init, |
| 81 | .name = name_exynos4210, |
| 82 | }, { |
| 83 | .idcode = EXYNOS4212_CPU_ID, |
| 84 | .idmask = EXYNOS4_CPU_MASK, |
| 85 | .map_io = exynos4_map_io, |
Thomas Abraham | 55b6ef7 | 2012-10-29 19:46:49 +0900 | [diff] [blame] | 86 | .init_uarts = exynos4_init_uarts, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 87 | .init = exynos_init, |
| 88 | .name = name_exynos4212, |
| 89 | }, { |
| 90 | .idcode = EXYNOS4412_CPU_ID, |
| 91 | .idmask = EXYNOS4_CPU_MASK, |
| 92 | .map_io = exynos4_map_io, |
Thomas Abraham | 55b6ef7 | 2012-10-29 19:46:49 +0900 | [diff] [blame] | 93 | .init_uarts = exynos4_init_uarts, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 94 | .init = exynos_init, |
| 95 | .name = name_exynos4412, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 96 | }, { |
| 97 | .idcode = EXYNOS5250_SOC_ID, |
| 98 | .idmask = EXYNOS5_SOC_MASK, |
| 99 | .map_io = exynos5_map_io, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 100 | .init = exynos_init, |
| 101 | .name = name_exynos5250, |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 102 | }, { |
| 103 | .idcode = EXYNOS5440_SOC_ID, |
| 104 | .idmask = EXYNOS5_SOC_MASK, |
| 105 | .map_io = exynos5440_map_io, |
| 106 | .init = exynos_init, |
| 107 | .name = name_exynos5440, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 108 | }, |
| 109 | }; |
| 110 | |
| 111 | /* Initial IO mappings */ |
| 112 | |
| 113 | static struct map_desc exynos_iodesc[] __initdata = { |
| 114 | { |
| 115 | .virtual = (unsigned long)S5P_VA_CHIPID, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 116 | .pfn = __phys_to_pfn(EXYNOS_PA_CHIPID), |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 117 | .length = SZ_4K, |
| 118 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 119 | }, |
| 120 | }; |
| 121 | |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 122 | #ifdef CONFIG_ARCH_EXYNOS5 |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 123 | static struct map_desc exynos5440_iodesc[] __initdata = { |
| 124 | { |
| 125 | .virtual = (unsigned long)S5P_VA_CHIPID, |
| 126 | .pfn = __phys_to_pfn(EXYNOS5440_PA_CHIPID), |
| 127 | .length = SZ_4K, |
| 128 | .type = MT_DEVICE, |
| 129 | }, |
| 130 | }; |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 131 | #endif |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 132 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 133 | static struct map_desc exynos4_iodesc[] __initdata = { |
| 134 | { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 135 | .virtual = (unsigned long)S3C_VA_SYS, |
| 136 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSCON), |
| 137 | .length = SZ_64K, |
| 138 | .type = MT_DEVICE, |
| 139 | }, { |
| 140 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 141 | .pfn = __phys_to_pfn(EXYNOS4_PA_TIMER), |
| 142 | .length = SZ_16K, |
| 143 | .type = MT_DEVICE, |
| 144 | }, { |
| 145 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 146 | .pfn = __phys_to_pfn(EXYNOS4_PA_WATCHDOG), |
| 147 | .length = SZ_4K, |
| 148 | .type = MT_DEVICE, |
| 149 | }, { |
| 150 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 151 | .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC), |
| 152 | .length = SZ_4K, |
| 153 | .type = MT_DEVICE, |
| 154 | }, { |
| 155 | .virtual = (unsigned long)S5P_VA_SYSTIMER, |
| 156 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSTIMER), |
| 157 | .length = SZ_4K, |
| 158 | .type = MT_DEVICE, |
| 159 | }, { |
| 160 | .virtual = (unsigned long)S5P_VA_PMU, |
| 161 | .pfn = __phys_to_pfn(EXYNOS4_PA_PMU), |
| 162 | .length = SZ_64K, |
| 163 | .type = MT_DEVICE, |
| 164 | }, { |
| 165 | .virtual = (unsigned long)S5P_VA_COMBINER_BASE, |
| 166 | .pfn = __phys_to_pfn(EXYNOS4_PA_COMBINER), |
| 167 | .length = SZ_4K, |
| 168 | .type = MT_DEVICE, |
| 169 | }, { |
| 170 | .virtual = (unsigned long)S5P_VA_GIC_CPU, |
| 171 | .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_CPU), |
| 172 | .length = SZ_64K, |
| 173 | .type = MT_DEVICE, |
| 174 | }, { |
| 175 | .virtual = (unsigned long)S5P_VA_GIC_DIST, |
| 176 | .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_DIST), |
| 177 | .length = SZ_64K, |
| 178 | .type = MT_DEVICE, |
| 179 | }, { |
| 180 | .virtual = (unsigned long)S3C_VA_UART, |
| 181 | .pfn = __phys_to_pfn(EXYNOS4_PA_UART), |
| 182 | .length = SZ_512K, |
| 183 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 184 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 185 | .virtual = (unsigned long)S5P_VA_CMU, |
| 186 | .pfn = __phys_to_pfn(EXYNOS4_PA_CMU), |
| 187 | .length = SZ_128K, |
| 188 | .type = MT_DEVICE, |
| 189 | }, { |
| 190 | .virtual = (unsigned long)S5P_VA_COREPERI_BASE, |
| 191 | .pfn = __phys_to_pfn(EXYNOS4_PA_COREPERI), |
| 192 | .length = SZ_8K, |
| 193 | .type = MT_DEVICE, |
| 194 | }, { |
| 195 | .virtual = (unsigned long)S5P_VA_L2CC, |
| 196 | .pfn = __phys_to_pfn(EXYNOS4_PA_L2CC), |
| 197 | .length = SZ_4K, |
| 198 | .type = MT_DEVICE, |
| 199 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 200 | .virtual = (unsigned long)S5P_VA_DMC0, |
| 201 | .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0), |
MyungJoo Ham | 2bde0b0 | 2011-12-01 15:12:30 +0900 | [diff] [blame] | 202 | .length = SZ_64K, |
| 203 | .type = MT_DEVICE, |
| 204 | }, { |
| 205 | .virtual = (unsigned long)S5P_VA_DMC1, |
| 206 | .pfn = __phys_to_pfn(EXYNOS4_PA_DMC1), |
| 207 | .length = SZ_64K, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 208 | .type = MT_DEVICE, |
| 209 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 210 | .virtual = (unsigned long)S3C_VA_USB_HSPHY, |
| 211 | .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY), |
| 212 | .length = SZ_4K, |
| 213 | .type = MT_DEVICE, |
| 214 | }, |
| 215 | }; |
| 216 | |
| 217 | static struct map_desc exynos4_iodesc0[] __initdata = { |
| 218 | { |
| 219 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 220 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM0), |
| 221 | .length = SZ_4K, |
| 222 | .type = MT_DEVICE, |
| 223 | }, |
| 224 | }; |
| 225 | |
| 226 | static struct map_desc exynos4_iodesc1[] __initdata = { |
| 227 | { |
| 228 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 229 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM1), |
| 230 | .length = SZ_4K, |
| 231 | .type = MT_DEVICE, |
| 232 | }, |
| 233 | }; |
| 234 | |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame^] | 235 | static struct map_desc exynos4210_iodesc[] __initdata = { |
| 236 | { |
| 237 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 238 | .pfn = __phys_to_pfn(EXYNOS4210_PA_SYSRAM_NS), |
| 239 | .length = SZ_4K, |
| 240 | .type = MT_DEVICE, |
| 241 | }, |
| 242 | }; |
| 243 | |
| 244 | static struct map_desc exynos4x12_iodesc[] __initdata = { |
| 245 | { |
| 246 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 247 | .pfn = __phys_to_pfn(EXYNOS4x12_PA_SYSRAM_NS), |
| 248 | .length = SZ_4K, |
| 249 | .type = MT_DEVICE, |
| 250 | }, |
| 251 | }; |
| 252 | |
| 253 | static struct map_desc exynos5250_iodesc[] __initdata = { |
| 254 | { |
| 255 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 256 | .pfn = __phys_to_pfn(EXYNOS5250_PA_SYSRAM_NS), |
| 257 | .length = SZ_4K, |
| 258 | .type = MT_DEVICE, |
| 259 | }, |
| 260 | }; |
| 261 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 262 | static struct map_desc exynos5_iodesc[] __initdata = { |
| 263 | { |
| 264 | .virtual = (unsigned long)S3C_VA_SYS, |
| 265 | .pfn = __phys_to_pfn(EXYNOS5_PA_SYSCON), |
| 266 | .length = SZ_64K, |
| 267 | .type = MT_DEVICE, |
| 268 | }, { |
| 269 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 270 | .pfn = __phys_to_pfn(EXYNOS5_PA_TIMER), |
| 271 | .length = SZ_16K, |
| 272 | .type = MT_DEVICE, |
| 273 | }, { |
| 274 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 275 | .pfn = __phys_to_pfn(EXYNOS5_PA_WATCHDOG), |
| 276 | .length = SZ_4K, |
| 277 | .type = MT_DEVICE, |
| 278 | }, { |
| 279 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 280 | .pfn = __phys_to_pfn(EXYNOS5_PA_SROMC), |
| 281 | .length = SZ_4K, |
| 282 | .type = MT_DEVICE, |
| 283 | }, { |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 284 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 285 | .pfn = __phys_to_pfn(EXYNOS5_PA_SYSRAM), |
| 286 | .length = SZ_4K, |
| 287 | .type = MT_DEVICE, |
| 288 | }, { |
| 289 | .virtual = (unsigned long)S5P_VA_CMU, |
| 290 | .pfn = __phys_to_pfn(EXYNOS5_PA_CMU), |
| 291 | .length = 144 * SZ_1K, |
| 292 | .type = MT_DEVICE, |
| 293 | }, { |
| 294 | .virtual = (unsigned long)S5P_VA_PMU, |
| 295 | .pfn = __phys_to_pfn(EXYNOS5_PA_PMU), |
| 296 | .length = SZ_64K, |
| 297 | .type = MT_DEVICE, |
| 298 | }, { |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 299 | .virtual = (unsigned long)S3C_VA_UART, |
| 300 | .pfn = __phys_to_pfn(EXYNOS5_PA_UART), |
| 301 | .length = SZ_512K, |
| 302 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 303 | }, |
| 304 | }; |
| 305 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 306 | static struct map_desc exynos5440_iodesc0[] __initdata = { |
| 307 | { |
| 308 | .virtual = (unsigned long)S3C_VA_UART, |
| 309 | .pfn = __phys_to_pfn(EXYNOS5440_PA_UART0), |
| 310 | .length = SZ_512K, |
| 311 | .type = MT_DEVICE, |
| 312 | }, |
| 313 | }; |
| 314 | |
Russell King | 9eb4859 | 2012-01-03 11:56:53 +0100 | [diff] [blame] | 315 | void exynos4_restart(char mode, const char *cmd) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 316 | { |
| 317 | __raw_writel(0x1, S5P_SWRESET); |
| 318 | } |
| 319 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 320 | void exynos5_restart(char mode, const char *cmd) |
| 321 | { |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 322 | struct device_node *np; |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 323 | u32 val; |
| 324 | void __iomem *addr; |
| 325 | |
| 326 | if (of_machine_is_compatible("samsung,exynos5250")) { |
| 327 | val = 0x1; |
| 328 | addr = EXYNOS_SWRESET; |
| 329 | } else if (of_machine_is_compatible("samsung,exynos5440")) { |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 330 | np = of_find_compatible_node(NULL, NULL, "samsung,exynos5440-clock"); |
| 331 | addr = of_iomap(np, 0) + 0xcc; |
| 332 | val = (0xfff << 20) | (0x1 << 16); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 333 | } else { |
| 334 | pr_err("%s: cannot support non-DT\n", __func__); |
| 335 | return; |
| 336 | } |
| 337 | |
| 338 | __raw_writel(val, addr); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 339 | } |
| 340 | |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 341 | void __init exynos_init_late(void) |
| 342 | { |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 343 | if (of_machine_is_compatible("samsung,exynos5440")) |
| 344 | /* to be supported later */ |
| 345 | return; |
| 346 | |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 347 | exynos_pm_late_initcall(); |
| 348 | } |
| 349 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 350 | /* |
| 351 | * exynos_map_io |
| 352 | * |
| 353 | * register the standard cpu IO areas |
| 354 | */ |
| 355 | |
| 356 | void __init exynos_init_io(struct map_desc *mach_desc, int size) |
| 357 | { |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 358 | struct map_desc *iodesc = exynos_iodesc; |
| 359 | int iodesc_sz = ARRAY_SIZE(exynos_iodesc); |
| 360 | #if defined(CONFIG_OF) && defined(CONFIG_ARCH_EXYNOS5) |
| 361 | unsigned long root = of_get_flat_dt_root(); |
| 362 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 363 | /* initialize the io descriptors we need for initialization */ |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 364 | if (of_flat_dt_is_compatible(root, "samsung,exynos5440")) { |
| 365 | iodesc = exynos5440_iodesc; |
| 366 | iodesc_sz = ARRAY_SIZE(exynos5440_iodesc); |
| 367 | } |
| 368 | #endif |
| 369 | |
| 370 | iotable_init(iodesc, iodesc_sz); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 371 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 372 | if (mach_desc) |
| 373 | iotable_init(mach_desc, size); |
| 374 | |
| 375 | /* detect cpu id and rev. */ |
| 376 | s5p_init_cpu(S5P_VA_CHIPID); |
| 377 | |
| 378 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
| 379 | } |
| 380 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 381 | static void __init exynos4_map_io(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 382 | { |
| 383 | iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc)); |
| 384 | |
| 385 | if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_0) |
| 386 | iotable_init(exynos4_iodesc0, ARRAY_SIZE(exynos4_iodesc0)); |
| 387 | else |
| 388 | iotable_init(exynos4_iodesc1, ARRAY_SIZE(exynos4_iodesc1)); |
| 389 | |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame^] | 390 | if (soc_is_exynos4210()) |
| 391 | iotable_init(exynos4210_iodesc, ARRAY_SIZE(exynos4210_iodesc)); |
| 392 | if (soc_is_exynos4212() || soc_is_exynos4412()) |
| 393 | iotable_init(exynos4x12_iodesc, ARRAY_SIZE(exynos4x12_iodesc)); |
| 394 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 395 | /* initialize device information early */ |
| 396 | exynos4_default_sdhci0(); |
| 397 | exynos4_default_sdhci1(); |
| 398 | exynos4_default_sdhci2(); |
| 399 | exynos4_default_sdhci3(); |
| 400 | |
| 401 | s3c_adc_setname("samsung-adc-v3"); |
| 402 | |
| 403 | s3c_fimc_setname(0, "exynos4-fimc"); |
| 404 | s3c_fimc_setname(1, "exynos4-fimc"); |
| 405 | s3c_fimc_setname(2, "exynos4-fimc"); |
| 406 | s3c_fimc_setname(3, "exynos4-fimc"); |
| 407 | |
Thomas Abraham | 8482c81 | 2012-04-14 08:04:46 -0700 | [diff] [blame] | 408 | s3c_sdhci_setname(0, "exynos4-sdhci"); |
| 409 | s3c_sdhci_setname(1, "exynos4-sdhci"); |
| 410 | s3c_sdhci_setname(2, "exynos4-sdhci"); |
| 411 | s3c_sdhci_setname(3, "exynos4-sdhci"); |
| 412 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 413 | /* The I2C bus controllers are directly compatible with s3c2440 */ |
| 414 | s3c_i2c0_setname("s3c2440-i2c"); |
| 415 | s3c_i2c1_setname("s3c2440-i2c"); |
| 416 | s3c_i2c2_setname("s3c2440-i2c"); |
| 417 | |
| 418 | s5p_fb_setname(0, "exynos4-fb"); |
| 419 | s5p_hdmi_setname("exynos4-hdmi"); |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 420 | |
| 421 | s3c64xx_spi_setname("exynos4210-spi"); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 422 | } |
| 423 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 424 | static void __init exynos5_map_io(void) |
| 425 | { |
| 426 | iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc)); |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame^] | 427 | |
| 428 | if (soc_is_exynos5250()) |
| 429 | iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc)); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 430 | } |
| 431 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 432 | static void __init exynos5440_map_io(void) |
| 433 | { |
| 434 | iotable_init(exynos5440_iodesc0, ARRAY_SIZE(exynos5440_iodesc0)); |
| 435 | } |
| 436 | |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 437 | void __init exynos_init_time(void) |
| 438 | { |
| 439 | if (of_have_populated_dt()) { |
| 440 | #ifdef CONFIG_OF |
| 441 | of_clk_init(NULL); |
| 442 | clocksource_of_init(); |
| 443 | #endif |
| 444 | } else { |
| 445 | /* todo: remove after migrating legacy E4 platforms to dt */ |
Thomas Abraham | 296f3f2 | 2013-04-05 15:17:47 +0900 | [diff] [blame] | 446 | #ifdef CONFIG_ARCH_EXYNOS4 |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 447 | exynos4_clk_init(NULL); |
Thomas Abraham | 9274427 | 2013-03-09 17:03:33 +0900 | [diff] [blame] | 448 | exynos4_clk_register_fixed_ext(xxti_f, xusbxti_f); |
Thomas Abraham | 296f3f2 | 2013-04-05 15:17:47 +0900 | [diff] [blame] | 449 | #endif |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 450 | mct_init(); |
| 451 | } |
| 452 | } |
| 453 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 454 | void __init exynos4_init_irq(void) |
| 455 | { |
Arnd Bergmann | 40ba95f | 2012-01-07 11:51:28 +0000 | [diff] [blame] | 456 | unsigned int gic_bank_offset; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 457 | |
| 458 | gic_bank_offset = soc_is_exynos4412() ? 0x4000 : 0x8000; |
| 459 | |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 460 | if (!of_have_populated_dt()) |
Grant Likely | 7529495 | 2012-02-14 14:06:57 -0700 | [diff] [blame] | 461 | gic_init_bases(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU, gic_bank_offset, NULL); |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 462 | #ifdef CONFIG_OF |
| 463 | else |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 464 | irqchip_init(); |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 465 | #endif |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 466 | |
Thomas Abraham | e873a47 | 2012-05-15 16:25:23 +0900 | [diff] [blame] | 467 | if (!of_have_populated_dt()) |
| 468 | combiner_init(S5P_VA_COMBINER_BASE, NULL); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 469 | |
| 470 | /* |
| 471 | * The parameters of s5p_init_irq() are for VIC init. |
| 472 | * Theses parameters should be NULL and 0 because EXYNOS4 |
| 473 | * uses GIC instead of VIC. |
| 474 | */ |
| 475 | s5p_init_irq(NULL, 0); |
| 476 | } |
| 477 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 478 | void __init exynos5_init_irq(void) |
| 479 | { |
Tushar Behera | 6fff5a1 | 2012-04-24 13:25:01 -0700 | [diff] [blame] | 480 | #ifdef CONFIG_OF |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 481 | irqchip_init(); |
Tushar Behera | 6fff5a1 | 2012-04-24 13:25:01 -0700 | [diff] [blame] | 482 | #endif |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 483 | /* |
| 484 | * The parameters of s5p_init_irq() are for VIC init. |
| 485 | * Theses parameters should be NULL and 0 because EXYNOS4 |
| 486 | * uses GIC instead of VIC. |
| 487 | */ |
Kukjin Kim | 12fee19 | 2012-12-06 15:31:10 +0900 | [diff] [blame] | 488 | if (!of_machine_is_compatible("samsung,exynos5440")) |
| 489 | s5p_init_irq(NULL, 0); |
Inderpal Singh | 3445513 | 2012-11-22 14:46:21 +0900 | [diff] [blame] | 490 | |
| 491 | gic_arch_extn.irq_set_wake = s3c_irq_wake; |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 492 | } |
| 493 | |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 494 | struct bus_type exynos_subsys = { |
| 495 | .name = "exynos-core", |
| 496 | .dev_name = "exynos-core", |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 497 | }; |
| 498 | |
Linus Torvalds | 7affca3 | 2012-01-07 12:03:30 -0800 | [diff] [blame] | 499 | static struct device exynos4_dev = { |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 500 | .bus = &exynos_subsys, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 501 | }; |
| 502 | |
| 503 | static int __init exynos_core_init(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 504 | { |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 505 | return subsys_system_register(&exynos_subsys, NULL); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 506 | } |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 507 | core_initcall(exynos_core_init); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 508 | |
| 509 | #ifdef CONFIG_CACHE_L2X0 |
| 510 | static int __init exynos4_l2x0_cache_init(void) |
| 511 | { |
Il Han | e1b1994 | 2012-04-05 07:59:36 -0700 | [diff] [blame] | 512 | int ret; |
| 513 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 514 | if (soc_is_exynos5250() || soc_is_exynos5440()) |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 515 | return 0; |
| 516 | |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 517 | ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK); |
| 518 | if (!ret) { |
| 519 | l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); |
| 520 | clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); |
| 521 | return 0; |
| 522 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 523 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 524 | if (!(__raw_readl(S5P_VA_L2CC + L2X0_CTRL) & 0x1)) { |
| 525 | l2x0_saved_regs.phy_base = EXYNOS4_PA_L2CC; |
| 526 | /* TAG, Data Latency Control: 2 cycles */ |
| 527 | l2x0_saved_regs.tag_latency = 0x110; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 528 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 529 | if (soc_is_exynos4212() || soc_is_exynos4412()) |
| 530 | l2x0_saved_regs.data_latency = 0x120; |
| 531 | else |
| 532 | l2x0_saved_regs.data_latency = 0x110; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 533 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 534 | l2x0_saved_regs.prefetch_ctrl = 0x30000007; |
| 535 | l2x0_saved_regs.pwr_ctrl = |
| 536 | (L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 537 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 538 | l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 539 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 540 | __raw_writel(l2x0_saved_regs.tag_latency, |
| 541 | S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL); |
| 542 | __raw_writel(l2x0_saved_regs.data_latency, |
| 543 | S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); |
| 544 | |
| 545 | /* L2X0 Prefetch Control */ |
| 546 | __raw_writel(l2x0_saved_regs.prefetch_ctrl, |
| 547 | S5P_VA_L2CC + L2X0_PREFETCH_CTRL); |
| 548 | |
| 549 | /* L2X0 Power Control */ |
| 550 | __raw_writel(l2x0_saved_regs.pwr_ctrl, |
| 551 | S5P_VA_L2CC + L2X0_POWER_CTRL); |
| 552 | |
| 553 | clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); |
| 554 | clean_dcache_area(&l2x0_saved_regs, sizeof(struct l2x0_regs)); |
| 555 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 556 | |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 557 | l2x0_init(S5P_VA_L2CC, L2_AUX_VAL, L2_AUX_MASK); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 558 | return 0; |
| 559 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 560 | early_initcall(exynos4_l2x0_cache_init); |
| 561 | #endif |
| 562 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 563 | static int __init exynos_init(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 564 | { |
| 565 | printk(KERN_INFO "EXYNOS: Initializing architecture\n"); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 566 | |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 567 | return device_register(&exynos4_dev); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 568 | } |
| 569 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 570 | /* uart registration process */ |
| 571 | |
Thomas Abraham | 55b6ef7 | 2012-10-29 19:46:49 +0900 | [diff] [blame] | 572 | static void __init exynos4_init_uarts(struct s3c2410_uartcfg *cfg, int no) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 573 | { |
| 574 | struct s3c2410_uartcfg *tcfg = cfg; |
| 575 | u32 ucnt; |
| 576 | |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 577 | for (ucnt = 0; ucnt < no; ucnt++, tcfg++) |
| 578 | tcfg->has_fracval = 1; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 579 | |
Thomas Abraham | 55b6ef7 | 2012-10-29 19:46:49 +0900 | [diff] [blame] | 580 | s3c24xx_init_uartdevs("exynos4210-uart", exynos4_uart_resources, cfg, no); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 581 | } |
| 582 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 583 | static void __iomem *exynos_eint_base; |
| 584 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 585 | static DEFINE_SPINLOCK(eint_lock); |
| 586 | |
| 587 | static unsigned int eint0_15_data[16]; |
| 588 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 589 | static inline int exynos4_irq_to_gpio(unsigned int irq) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 590 | { |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 591 | if (irq < IRQ_EINT(0)) |
| 592 | return -EINVAL; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 593 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 594 | irq -= IRQ_EINT(0); |
| 595 | if (irq < 8) |
| 596 | return EXYNOS4_GPX0(irq); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 597 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 598 | irq -= 8; |
| 599 | if (irq < 8) |
| 600 | return EXYNOS4_GPX1(irq); |
| 601 | |
| 602 | irq -= 8; |
| 603 | if (irq < 8) |
| 604 | return EXYNOS4_GPX2(irq); |
| 605 | |
| 606 | irq -= 8; |
| 607 | if (irq < 8) |
| 608 | return EXYNOS4_GPX3(irq); |
| 609 | |
| 610 | return -EINVAL; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 611 | } |
| 612 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 613 | static inline int exynos5_irq_to_gpio(unsigned int irq) |
| 614 | { |
| 615 | if (irq < IRQ_EINT(0)) |
| 616 | return -EINVAL; |
| 617 | |
| 618 | irq -= IRQ_EINT(0); |
| 619 | if (irq < 8) |
| 620 | return EXYNOS5_GPX0(irq); |
| 621 | |
| 622 | irq -= 8; |
| 623 | if (irq < 8) |
| 624 | return EXYNOS5_GPX1(irq); |
| 625 | |
| 626 | irq -= 8; |
| 627 | if (irq < 8) |
| 628 | return EXYNOS5_GPX2(irq); |
| 629 | |
| 630 | irq -= 8; |
| 631 | if (irq < 8) |
| 632 | return EXYNOS5_GPX3(irq); |
| 633 | |
| 634 | return -EINVAL; |
| 635 | } |
| 636 | |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 637 | static unsigned int exynos4_eint0_15_src_int[16] = { |
| 638 | EXYNOS4_IRQ_EINT0, |
| 639 | EXYNOS4_IRQ_EINT1, |
| 640 | EXYNOS4_IRQ_EINT2, |
| 641 | EXYNOS4_IRQ_EINT3, |
| 642 | EXYNOS4_IRQ_EINT4, |
| 643 | EXYNOS4_IRQ_EINT5, |
| 644 | EXYNOS4_IRQ_EINT6, |
| 645 | EXYNOS4_IRQ_EINT7, |
| 646 | EXYNOS4_IRQ_EINT8, |
| 647 | EXYNOS4_IRQ_EINT9, |
| 648 | EXYNOS4_IRQ_EINT10, |
| 649 | EXYNOS4_IRQ_EINT11, |
| 650 | EXYNOS4_IRQ_EINT12, |
| 651 | EXYNOS4_IRQ_EINT13, |
| 652 | EXYNOS4_IRQ_EINT14, |
| 653 | EXYNOS4_IRQ_EINT15, |
| 654 | }; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 655 | |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 656 | static unsigned int exynos5_eint0_15_src_int[16] = { |
| 657 | EXYNOS5_IRQ_EINT0, |
| 658 | EXYNOS5_IRQ_EINT1, |
| 659 | EXYNOS5_IRQ_EINT2, |
| 660 | EXYNOS5_IRQ_EINT3, |
| 661 | EXYNOS5_IRQ_EINT4, |
| 662 | EXYNOS5_IRQ_EINT5, |
| 663 | EXYNOS5_IRQ_EINT6, |
| 664 | EXYNOS5_IRQ_EINT7, |
| 665 | EXYNOS5_IRQ_EINT8, |
| 666 | EXYNOS5_IRQ_EINT9, |
| 667 | EXYNOS5_IRQ_EINT10, |
| 668 | EXYNOS5_IRQ_EINT11, |
| 669 | EXYNOS5_IRQ_EINT12, |
| 670 | EXYNOS5_IRQ_EINT13, |
| 671 | EXYNOS5_IRQ_EINT14, |
| 672 | EXYNOS5_IRQ_EINT15, |
| 673 | }; |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 674 | static inline void exynos_irq_eint_mask(struct irq_data *data) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 675 | { |
| 676 | u32 mask; |
| 677 | |
| 678 | spin_lock(&eint_lock); |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 679 | mask = __raw_readl(EINT_MASK(exynos_eint_base, data->irq)); |
| 680 | mask |= EINT_OFFSET_BIT(data->irq); |
| 681 | __raw_writel(mask, EINT_MASK(exynos_eint_base, data->irq)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 682 | spin_unlock(&eint_lock); |
| 683 | } |
| 684 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 685 | static void exynos_irq_eint_unmask(struct irq_data *data) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 686 | { |
| 687 | u32 mask; |
| 688 | |
| 689 | spin_lock(&eint_lock); |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 690 | mask = __raw_readl(EINT_MASK(exynos_eint_base, data->irq)); |
| 691 | mask &= ~(EINT_OFFSET_BIT(data->irq)); |
| 692 | __raw_writel(mask, EINT_MASK(exynos_eint_base, data->irq)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 693 | spin_unlock(&eint_lock); |
| 694 | } |
| 695 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 696 | static inline void exynos_irq_eint_ack(struct irq_data *data) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 697 | { |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 698 | __raw_writel(EINT_OFFSET_BIT(data->irq), |
| 699 | EINT_PEND(exynos_eint_base, data->irq)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 700 | } |
| 701 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 702 | static void exynos_irq_eint_maskack(struct irq_data *data) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 703 | { |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 704 | exynos_irq_eint_mask(data); |
| 705 | exynos_irq_eint_ack(data); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 706 | } |
| 707 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 708 | static int exynos_irq_eint_set_type(struct irq_data *data, unsigned int type) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 709 | { |
| 710 | int offs = EINT_OFFSET(data->irq); |
| 711 | int shift; |
| 712 | u32 ctrl, mask; |
| 713 | u32 newvalue = 0; |
| 714 | |
| 715 | switch (type) { |
| 716 | case IRQ_TYPE_EDGE_RISING: |
| 717 | newvalue = S5P_IRQ_TYPE_EDGE_RISING; |
| 718 | break; |
| 719 | |
| 720 | case IRQ_TYPE_EDGE_FALLING: |
| 721 | newvalue = S5P_IRQ_TYPE_EDGE_FALLING; |
| 722 | break; |
| 723 | |
| 724 | case IRQ_TYPE_EDGE_BOTH: |
| 725 | newvalue = S5P_IRQ_TYPE_EDGE_BOTH; |
| 726 | break; |
| 727 | |
| 728 | case IRQ_TYPE_LEVEL_LOW: |
| 729 | newvalue = S5P_IRQ_TYPE_LEVEL_LOW; |
| 730 | break; |
| 731 | |
| 732 | case IRQ_TYPE_LEVEL_HIGH: |
| 733 | newvalue = S5P_IRQ_TYPE_LEVEL_HIGH; |
| 734 | break; |
| 735 | |
| 736 | default: |
| 737 | printk(KERN_ERR "No such irq type %d", type); |
| 738 | return -EINVAL; |
| 739 | } |
| 740 | |
| 741 | shift = (offs & 0x7) * 4; |
| 742 | mask = 0x7 << shift; |
| 743 | |
| 744 | spin_lock(&eint_lock); |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 745 | ctrl = __raw_readl(EINT_CON(exynos_eint_base, data->irq)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 746 | ctrl &= ~mask; |
| 747 | ctrl |= newvalue << shift; |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 748 | __raw_writel(ctrl, EINT_CON(exynos_eint_base, data->irq)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 749 | spin_unlock(&eint_lock); |
| 750 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 751 | if (soc_is_exynos5250()) |
| 752 | s3c_gpio_cfgpin(exynos5_irq_to_gpio(data->irq), S3C_GPIO_SFN(0xf)); |
| 753 | else |
| 754 | s3c_gpio_cfgpin(exynos4_irq_to_gpio(data->irq), S3C_GPIO_SFN(0xf)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 755 | |
| 756 | return 0; |
| 757 | } |
| 758 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 759 | static struct irq_chip exynos_irq_eint = { |
| 760 | .name = "exynos-eint", |
| 761 | .irq_mask = exynos_irq_eint_mask, |
| 762 | .irq_unmask = exynos_irq_eint_unmask, |
| 763 | .irq_mask_ack = exynos_irq_eint_maskack, |
| 764 | .irq_ack = exynos_irq_eint_ack, |
| 765 | .irq_set_type = exynos_irq_eint_set_type, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 766 | #ifdef CONFIG_PM |
| 767 | .irq_set_wake = s3c_irqext_wake, |
| 768 | #endif |
| 769 | }; |
| 770 | |
| 771 | /* |
| 772 | * exynos4_irq_demux_eint |
| 773 | * |
| 774 | * This function demuxes the IRQ from from EINTs 16 to 31. |
| 775 | * It is designed to be inlined into the specific handler |
| 776 | * s5p_irq_demux_eintX_Y. |
| 777 | * |
| 778 | * Each EINT pend/mask registers handle eight of them. |
| 779 | */ |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 780 | static inline void exynos_irq_demux_eint(unsigned int start) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 781 | { |
| 782 | unsigned int irq; |
| 783 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 784 | u32 status = __raw_readl(EINT_PEND(exynos_eint_base, start)); |
| 785 | u32 mask = __raw_readl(EINT_MASK(exynos_eint_base, start)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 786 | |
| 787 | status &= ~mask; |
| 788 | status &= 0xff; |
| 789 | |
| 790 | while (status) { |
| 791 | irq = fls(status) - 1; |
| 792 | generic_handle_irq(irq + start); |
| 793 | status &= ~(1 << irq); |
| 794 | } |
| 795 | } |
| 796 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 797 | static void exynos_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 798 | { |
| 799 | struct irq_chip *chip = irq_get_chip(irq); |
| 800 | chained_irq_enter(chip, desc); |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 801 | exynos_irq_demux_eint(IRQ_EINT(16)); |
| 802 | exynos_irq_demux_eint(IRQ_EINT(24)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 803 | chained_irq_exit(chip, desc); |
| 804 | } |
| 805 | |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 806 | static void exynos_irq_eint0_15(unsigned int irq, struct irq_desc *desc) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 807 | { |
| 808 | u32 *irq_data = irq_get_handler_data(irq); |
| 809 | struct irq_chip *chip = irq_get_chip(irq); |
| 810 | |
| 811 | chained_irq_enter(chip, desc); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 812 | generic_handle_irq(*irq_data); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 813 | chained_irq_exit(chip, desc); |
| 814 | } |
| 815 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 816 | static int __init exynos_init_irq_eint(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 817 | { |
| 818 | int irq; |
| 819 | |
Thomas Abraham | fef05c2 | 2012-09-07 06:07:40 +0900 | [diff] [blame] | 820 | #ifdef CONFIG_PINCTRL_SAMSUNG |
| 821 | /* |
| 822 | * The Samsung pinctrl driver provides an integrated gpio/pinmux/pinconf |
| 823 | * functionality along with support for external gpio and wakeup |
| 824 | * interrupts. If the samsung pinctrl driver is enabled and includes |
| 825 | * the wakeup interrupt support, then the setting up external wakeup |
| 826 | * interrupts here can be skipped. This check here is temporary to |
| 827 | * allow exynos4 platforms that do not use Samsung pinctrl driver to |
| 828 | * co-exist with platforms that do. When all of the Samsung Exynos4 |
| 829 | * platforms switch over to using the pinctrl driver, the wakeup |
| 830 | * interrupt support code here can be completely removed. |
| 831 | */ |
Tomasz Figa | ab7b51f | 2012-11-07 08:44:51 +0900 | [diff] [blame] | 832 | static const struct of_device_id exynos_pinctrl_ids[] = { |
Kukjin Kim | b533c86 | 2013-01-02 16:05:42 -0800 | [diff] [blame] | 833 | { .compatible = "samsung,exynos4210-pinctrl", }, |
| 834 | { .compatible = "samsung,exynos4x12-pinctrl", }, |
Tomasz Figa | ab7b51f | 2012-11-07 08:44:51 +0900 | [diff] [blame] | 835 | }; |
Thomas Abraham | fef05c2 | 2012-09-07 06:07:40 +0900 | [diff] [blame] | 836 | struct device_node *pctrl_np, *wkup_np; |
Thomas Abraham | fef05c2 | 2012-09-07 06:07:40 +0900 | [diff] [blame] | 837 | const char *wkup_compat = "samsung,exynos4210-wakeup-eint"; |
| 838 | |
Tomasz Figa | ab7b51f | 2012-11-07 08:44:51 +0900 | [diff] [blame] | 839 | for_each_matching_node(pctrl_np, exynos_pinctrl_ids) { |
Thomas Abraham | fef05c2 | 2012-09-07 06:07:40 +0900 | [diff] [blame] | 840 | if (of_device_is_available(pctrl_np)) { |
| 841 | wkup_np = of_find_compatible_node(pctrl_np, NULL, |
| 842 | wkup_compat); |
| 843 | if (wkup_np) |
| 844 | return -ENODEV; |
| 845 | } |
| 846 | } |
| 847 | #endif |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 848 | if (soc_is_exynos5440()) |
| 849 | return 0; |
Thomas Abraham | fef05c2 | 2012-09-07 06:07:40 +0900 | [diff] [blame] | 850 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 851 | if (soc_is_exynos5250()) |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 852 | exynos_eint_base = ioremap(EXYNOS5_PA_GPIO1, SZ_4K); |
| 853 | else |
| 854 | exynos_eint_base = ioremap(EXYNOS4_PA_GPIO2, SZ_4K); |
| 855 | |
| 856 | if (exynos_eint_base == NULL) { |
| 857 | pr_err("unable to ioremap for EINT base address\n"); |
| 858 | return -ENOMEM; |
| 859 | } |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 860 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 861 | for (irq = 0 ; irq <= 31 ; irq++) { |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 862 | irq_set_chip_and_handler(IRQ_EINT(irq), &exynos_irq_eint, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 863 | handle_level_irq); |
| 864 | set_irq_flags(IRQ_EINT(irq), IRQF_VALID); |
| 865 | } |
| 866 | |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 867 | irq_set_chained_handler(EXYNOS_IRQ_EINT16_31, exynos_irq_demux_eint16_31); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 868 | |
| 869 | for (irq = 0 ; irq <= 15 ; irq++) { |
| 870 | eint0_15_data[irq] = IRQ_EINT(irq); |
| 871 | |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 872 | if (soc_is_exynos5250()) { |
| 873 | irq_set_handler_data(exynos5_eint0_15_src_int[irq], |
| 874 | &eint0_15_data[irq]); |
| 875 | irq_set_chained_handler(exynos5_eint0_15_src_int[irq], |
| 876 | exynos_irq_eint0_15); |
| 877 | } else { |
| 878 | irq_set_handler_data(exynos4_eint0_15_src_int[irq], |
| 879 | &eint0_15_data[irq]); |
| 880 | irq_set_chained_handler(exynos4_eint0_15_src_int[irq], |
| 881 | exynos_irq_eint0_15); |
| 882 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | return 0; |
| 886 | } |
Eunki Kim | 330c90a | 2012-03-14 01:43:31 -0700 | [diff] [blame] | 887 | arch_initcall(exynos_init_irq_eint); |