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