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