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