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> |
Tomasz Figa | 68a433f | 2013-05-25 06:27:29 +0900 | [diff] [blame] | 13 | #include <linux/bitops.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/irq.h> |
Rob Herring | a900e5d | 2013-02-12 16:04:52 -0600 | [diff] [blame] | 16 | #include <linux/irqchip.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 17 | #include <linux/io.h> |
Linus Torvalds | 7affca3 | 2012-01-07 12:03:30 -0800 | [diff] [blame] | 18 | #include <linux/device.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 19 | #include <linux/gpio.h> |
Tomasz Figa | 68a433f | 2013-05-25 06:27:29 +0900 | [diff] [blame] | 20 | #include <clocksource/samsung_pwm.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 21 | #include <linux/sched.h> |
| 22 | #include <linux/serial_core.h> |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 23 | #include <linux/of.h> |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 24 | #include <linux/of_fdt.h> |
Arnd Bergmann | 237c78b | 2012-01-07 12:30:20 +0000 | [diff] [blame] | 25 | #include <linux/of_irq.h> |
Thomas Abraham | 1e60bc0 | 2012-05-15 16:18:35 +0900 | [diff] [blame] | 26 | #include <linux/export.h> |
| 27 | #include <linux/irqdomain.h> |
Thomas Abraham | e873a47 | 2012-05-15 16:25:23 +0900 | [diff] [blame] | 28 | #include <linux/of_address.h> |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 29 | #include <linux/clocksource.h> |
| 30 | #include <linux/clk-provider.h> |
Rob Herring | 520f7bd | 2012-12-27 13:10:24 -0600 | [diff] [blame] | 31 | #include <linux/irqchip/arm-gic.h> |
Catalin Marinas | de88cbb | 2013-01-18 15:31:37 +0000 | [diff] [blame] | 32 | #include <linux/irqchip/chained_irq.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 33 | |
| 34 | #include <asm/proc-fns.h> |
Arnd Bergmann | 40ba95f | 2012-01-07 11:51:28 +0000 | [diff] [blame] | 35 | #include <asm/exception.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 36 | #include <asm/hardware/cache-l2x0.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 37 | #include <asm/mach/map.h> |
| 38 | #include <asm/mach/irq.h> |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 39 | #include <asm/cacheflush.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 40 | |
| 41 | #include <mach/regs-irq.h> |
| 42 | #include <mach/regs-pmu.h> |
| 43 | #include <mach/regs-gpio.h> |
| 44 | |
| 45 | #include <plat/cpu.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 46 | #include <plat/pm.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 47 | #include <plat/regs-serial.h> |
| 48 | |
| 49 | #include "common.h" |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 50 | #define L2_AUX_VAL 0x7C470001 |
| 51 | #define L2_AUX_MASK 0xC200ffff |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 52 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 53 | static const char name_exynos4210[] = "EXYNOS4210"; |
| 54 | static const char name_exynos4212[] = "EXYNOS4212"; |
| 55 | static const char name_exynos4412[] = "EXYNOS4412"; |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 56 | static const char name_exynos5250[] = "EXYNOS5250"; |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 57 | static const char name_exynos5440[] = "EXYNOS5440"; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 58 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 59 | static void exynos4_map_io(void); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 60 | static void exynos5_map_io(void); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 61 | static void exynos5440_map_io(void); |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 62 | static int exynos_init(void); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 63 | |
Thomas Abraham | 9274427 | 2013-03-09 17:03:33 +0900 | [diff] [blame] | 64 | unsigned long xxti_f = 0, xusbxti_f = 0; |
| 65 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 66 | static struct cpu_table cpu_ids[] __initdata = { |
| 67 | { |
| 68 | .idcode = EXYNOS4210_CPU_ID, |
| 69 | .idmask = EXYNOS4_CPU_MASK, |
| 70 | .map_io = exynos4_map_io, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 71 | .init = exynos_init, |
| 72 | .name = name_exynos4210, |
| 73 | }, { |
| 74 | .idcode = EXYNOS4212_CPU_ID, |
| 75 | .idmask = EXYNOS4_CPU_MASK, |
| 76 | .map_io = exynos4_map_io, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 77 | .init = exynos_init, |
| 78 | .name = name_exynos4212, |
| 79 | }, { |
| 80 | .idcode = EXYNOS4412_CPU_ID, |
| 81 | .idmask = EXYNOS4_CPU_MASK, |
| 82 | .map_io = exynos4_map_io, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 83 | .init = exynos_init, |
| 84 | .name = name_exynos4412, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 85 | }, { |
| 86 | .idcode = EXYNOS5250_SOC_ID, |
| 87 | .idmask = EXYNOS5_SOC_MASK, |
| 88 | .map_io = exynos5_map_io, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 89 | .init = exynos_init, |
| 90 | .name = name_exynos5250, |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 91 | }, { |
| 92 | .idcode = EXYNOS5440_SOC_ID, |
| 93 | .idmask = EXYNOS5_SOC_MASK, |
| 94 | .map_io = exynos5440_map_io, |
| 95 | .init = exynos_init, |
| 96 | .name = name_exynos5440, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 97 | }, |
| 98 | }; |
| 99 | |
| 100 | /* Initial IO mappings */ |
| 101 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 102 | static struct map_desc exynos4_iodesc[] __initdata = { |
| 103 | { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 104 | .virtual = (unsigned long)S3C_VA_SYS, |
| 105 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSCON), |
| 106 | .length = SZ_64K, |
| 107 | .type = MT_DEVICE, |
| 108 | }, { |
| 109 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 110 | .pfn = __phys_to_pfn(EXYNOS4_PA_TIMER), |
| 111 | .length = SZ_16K, |
| 112 | .type = MT_DEVICE, |
| 113 | }, { |
| 114 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 115 | .pfn = __phys_to_pfn(EXYNOS4_PA_WATCHDOG), |
| 116 | .length = SZ_4K, |
| 117 | .type = MT_DEVICE, |
| 118 | }, { |
| 119 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 120 | .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC), |
| 121 | .length = SZ_4K, |
| 122 | .type = MT_DEVICE, |
| 123 | }, { |
| 124 | .virtual = (unsigned long)S5P_VA_SYSTIMER, |
| 125 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSTIMER), |
| 126 | .length = SZ_4K, |
| 127 | .type = MT_DEVICE, |
| 128 | }, { |
| 129 | .virtual = (unsigned long)S5P_VA_PMU, |
| 130 | .pfn = __phys_to_pfn(EXYNOS4_PA_PMU), |
| 131 | .length = SZ_64K, |
| 132 | .type = MT_DEVICE, |
| 133 | }, { |
| 134 | .virtual = (unsigned long)S5P_VA_COMBINER_BASE, |
| 135 | .pfn = __phys_to_pfn(EXYNOS4_PA_COMBINER), |
| 136 | .length = SZ_4K, |
| 137 | .type = MT_DEVICE, |
| 138 | }, { |
| 139 | .virtual = (unsigned long)S5P_VA_GIC_CPU, |
| 140 | .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_CPU), |
| 141 | .length = SZ_64K, |
| 142 | .type = MT_DEVICE, |
| 143 | }, { |
| 144 | .virtual = (unsigned long)S5P_VA_GIC_DIST, |
| 145 | .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_DIST), |
| 146 | .length = SZ_64K, |
| 147 | .type = MT_DEVICE, |
| 148 | }, { |
| 149 | .virtual = (unsigned long)S3C_VA_UART, |
| 150 | .pfn = __phys_to_pfn(EXYNOS4_PA_UART), |
| 151 | .length = SZ_512K, |
| 152 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 153 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 154 | .virtual = (unsigned long)S5P_VA_CMU, |
| 155 | .pfn = __phys_to_pfn(EXYNOS4_PA_CMU), |
| 156 | .length = SZ_128K, |
| 157 | .type = MT_DEVICE, |
| 158 | }, { |
| 159 | .virtual = (unsigned long)S5P_VA_COREPERI_BASE, |
| 160 | .pfn = __phys_to_pfn(EXYNOS4_PA_COREPERI), |
| 161 | .length = SZ_8K, |
| 162 | .type = MT_DEVICE, |
| 163 | }, { |
| 164 | .virtual = (unsigned long)S5P_VA_L2CC, |
| 165 | .pfn = __phys_to_pfn(EXYNOS4_PA_L2CC), |
| 166 | .length = SZ_4K, |
| 167 | .type = MT_DEVICE, |
| 168 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 169 | .virtual = (unsigned long)S5P_VA_DMC0, |
| 170 | .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0), |
MyungJoo Ham | 2bde0b0 | 2011-12-01 15:12:30 +0900 | [diff] [blame] | 171 | .length = SZ_64K, |
| 172 | .type = MT_DEVICE, |
| 173 | }, { |
| 174 | .virtual = (unsigned long)S5P_VA_DMC1, |
| 175 | .pfn = __phys_to_pfn(EXYNOS4_PA_DMC1), |
| 176 | .length = SZ_64K, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 177 | .type = MT_DEVICE, |
| 178 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 179 | .virtual = (unsigned long)S3C_VA_USB_HSPHY, |
| 180 | .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY), |
| 181 | .length = SZ_4K, |
| 182 | .type = MT_DEVICE, |
| 183 | }, |
| 184 | }; |
| 185 | |
| 186 | static struct map_desc exynos4_iodesc0[] __initdata = { |
| 187 | { |
| 188 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 189 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM0), |
| 190 | .length = SZ_4K, |
| 191 | .type = MT_DEVICE, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct map_desc exynos4_iodesc1[] __initdata = { |
| 196 | { |
| 197 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 198 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM1), |
| 199 | .length = SZ_4K, |
| 200 | .type = MT_DEVICE, |
| 201 | }, |
| 202 | }; |
| 203 | |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 204 | static struct map_desc exynos4210_iodesc[] __initdata = { |
| 205 | { |
| 206 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 207 | .pfn = __phys_to_pfn(EXYNOS4210_PA_SYSRAM_NS), |
| 208 | .length = SZ_4K, |
| 209 | .type = MT_DEVICE, |
| 210 | }, |
| 211 | }; |
| 212 | |
| 213 | static struct map_desc exynos4x12_iodesc[] __initdata = { |
| 214 | { |
| 215 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 216 | .pfn = __phys_to_pfn(EXYNOS4x12_PA_SYSRAM_NS), |
| 217 | .length = SZ_4K, |
| 218 | .type = MT_DEVICE, |
| 219 | }, |
| 220 | }; |
| 221 | |
| 222 | static struct map_desc exynos5250_iodesc[] __initdata = { |
| 223 | { |
| 224 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 225 | .pfn = __phys_to_pfn(EXYNOS5250_PA_SYSRAM_NS), |
| 226 | .length = SZ_4K, |
| 227 | .type = MT_DEVICE, |
| 228 | }, |
| 229 | }; |
| 230 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 231 | static struct map_desc exynos5_iodesc[] __initdata = { |
| 232 | { |
| 233 | .virtual = (unsigned long)S3C_VA_SYS, |
| 234 | .pfn = __phys_to_pfn(EXYNOS5_PA_SYSCON), |
| 235 | .length = SZ_64K, |
| 236 | .type = MT_DEVICE, |
| 237 | }, { |
| 238 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 239 | .pfn = __phys_to_pfn(EXYNOS5_PA_TIMER), |
| 240 | .length = SZ_16K, |
| 241 | .type = MT_DEVICE, |
| 242 | }, { |
| 243 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 244 | .pfn = __phys_to_pfn(EXYNOS5_PA_WATCHDOG), |
| 245 | .length = SZ_4K, |
| 246 | .type = MT_DEVICE, |
| 247 | }, { |
| 248 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 249 | .pfn = __phys_to_pfn(EXYNOS5_PA_SROMC), |
| 250 | .length = SZ_4K, |
| 251 | .type = MT_DEVICE, |
| 252 | }, { |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 253 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 254 | .pfn = __phys_to_pfn(EXYNOS5_PA_SYSRAM), |
| 255 | .length = SZ_4K, |
| 256 | .type = MT_DEVICE, |
| 257 | }, { |
| 258 | .virtual = (unsigned long)S5P_VA_CMU, |
| 259 | .pfn = __phys_to_pfn(EXYNOS5_PA_CMU), |
| 260 | .length = 144 * SZ_1K, |
| 261 | .type = MT_DEVICE, |
| 262 | }, { |
| 263 | .virtual = (unsigned long)S5P_VA_PMU, |
| 264 | .pfn = __phys_to_pfn(EXYNOS5_PA_PMU), |
| 265 | .length = SZ_64K, |
| 266 | .type = MT_DEVICE, |
| 267 | }, { |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 268 | .virtual = (unsigned long)S3C_VA_UART, |
| 269 | .pfn = __phys_to_pfn(EXYNOS5_PA_UART), |
| 270 | .length = SZ_512K, |
| 271 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 272 | }, |
| 273 | }; |
| 274 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 275 | static struct map_desc exynos5440_iodesc0[] __initdata = { |
| 276 | { |
| 277 | .virtual = (unsigned long)S3C_VA_UART, |
| 278 | .pfn = __phys_to_pfn(EXYNOS5440_PA_UART0), |
| 279 | .length = SZ_512K, |
| 280 | .type = MT_DEVICE, |
| 281 | }, |
| 282 | }; |
| 283 | |
Russell King | 9eb4859 | 2012-01-03 11:56:53 +0100 | [diff] [blame] | 284 | void exynos4_restart(char mode, const char *cmd) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 285 | { |
| 286 | __raw_writel(0x1, S5P_SWRESET); |
| 287 | } |
| 288 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 289 | void exynos5_restart(char mode, const char *cmd) |
| 290 | { |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 291 | struct device_node *np; |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 292 | u32 val; |
| 293 | void __iomem *addr; |
| 294 | |
| 295 | if (of_machine_is_compatible("samsung,exynos5250")) { |
| 296 | val = 0x1; |
| 297 | addr = EXYNOS_SWRESET; |
| 298 | } else if (of_machine_is_compatible("samsung,exynos5440")) { |
Jungseok Lee | 1ba830c | 2013-05-25 06:33:03 +0900 | [diff] [blame] | 299 | u32 status; |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 300 | np = of_find_compatible_node(NULL, NULL, "samsung,exynos5440-clock"); |
Jungseok Lee | 1ba830c | 2013-05-25 06:33:03 +0900 | [diff] [blame] | 301 | |
| 302 | addr = of_iomap(np, 0) + 0xbc; |
| 303 | status = __raw_readl(addr); |
| 304 | |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 305 | addr = of_iomap(np, 0) + 0xcc; |
Jungseok Lee | 1ba830c | 2013-05-25 06:33:03 +0900 | [diff] [blame] | 306 | val = __raw_readl(addr); |
| 307 | |
| 308 | val = (val & 0xffff0000) | (status & 0xffff); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 309 | } else { |
| 310 | pr_err("%s: cannot support non-DT\n", __func__); |
| 311 | return; |
| 312 | } |
| 313 | |
| 314 | __raw_writel(val, addr); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 315 | } |
| 316 | |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 317 | void __init exynos_init_late(void) |
| 318 | { |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 319 | if (of_machine_is_compatible("samsung,exynos5440")) |
| 320 | /* to be supported later */ |
| 321 | return; |
| 322 | |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 323 | exynos_pm_late_initcall(); |
| 324 | } |
| 325 | |
Thomas Abraham | f5f83c7 | 2013-04-23 22:46:53 +0900 | [diff] [blame] | 326 | int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, |
| 327 | int depth, void *data) |
| 328 | { |
| 329 | struct map_desc iodesc; |
| 330 | __be32 *reg; |
| 331 | unsigned long len; |
| 332 | |
| 333 | if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") && |
| 334 | !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock")) |
| 335 | return 0; |
| 336 | |
| 337 | reg = of_get_flat_dt_prop(node, "reg", &len); |
| 338 | if (reg == NULL || len != (sizeof(unsigned long) * 2)) |
| 339 | return 0; |
| 340 | |
| 341 | iodesc.pfn = __phys_to_pfn(be32_to_cpu(reg[0])); |
| 342 | iodesc.length = be32_to_cpu(reg[1]) - 1; |
| 343 | iodesc.virtual = (unsigned long)S5P_VA_CHIPID; |
| 344 | iodesc.type = MT_DEVICE; |
| 345 | iotable_init(&iodesc, 1); |
| 346 | return 1; |
| 347 | } |
Thomas Abraham | f5f83c7 | 2013-04-23 22:46:53 +0900 | [diff] [blame] | 348 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 349 | /* |
| 350 | * exynos_map_io |
| 351 | * |
| 352 | * register the standard cpu IO areas |
| 353 | */ |
| 354 | |
| 355 | void __init exynos_init_io(struct map_desc *mach_desc, int size) |
| 356 | { |
Doug Anderson | 9c1fcdc | 2013-06-05 13:56:33 -0700 | [diff] [blame] | 357 | debug_ll_io_init(); |
| 358 | |
Tomasz Figa | 04fae59 | 2013-06-15 09:13:25 +0900 | [diff] [blame^] | 359 | of_scan_flat_dt(exynos_fdt_map_chipid, NULL); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 360 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 361 | if (mach_desc) |
| 362 | iotable_init(mach_desc, size); |
| 363 | |
| 364 | /* detect cpu id and rev. */ |
| 365 | s5p_init_cpu(S5P_VA_CHIPID); |
| 366 | |
| 367 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
| 368 | } |
| 369 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 370 | static void __init exynos4_map_io(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 371 | { |
| 372 | iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc)); |
| 373 | |
| 374 | if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_0) |
| 375 | iotable_init(exynos4_iodesc0, ARRAY_SIZE(exynos4_iodesc0)); |
| 376 | else |
| 377 | iotable_init(exynos4_iodesc1, ARRAY_SIZE(exynos4_iodesc1)); |
| 378 | |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 379 | if (soc_is_exynos4210()) |
| 380 | iotable_init(exynos4210_iodesc, ARRAY_SIZE(exynos4210_iodesc)); |
| 381 | if (soc_is_exynos4212() || soc_is_exynos4412()) |
| 382 | iotable_init(exynos4x12_iodesc, ARRAY_SIZE(exynos4x12_iodesc)); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 383 | } |
| 384 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 385 | static void __init exynos5_map_io(void) |
| 386 | { |
| 387 | iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc)); |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 388 | |
| 389 | if (soc_is_exynos5250()) |
| 390 | iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc)); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 391 | } |
| 392 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 393 | static void __init exynos5440_map_io(void) |
| 394 | { |
| 395 | iotable_init(exynos5440_iodesc0, ARRAY_SIZE(exynos5440_iodesc0)); |
| 396 | } |
| 397 | |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 398 | void __init exynos_init_time(void) |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 399 | { |
Tomasz Figa | 3c70348 | 2013-06-15 09:04:58 +0900 | [diff] [blame] | 400 | of_clk_init(NULL); |
| 401 | clocksource_of_init(); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 402 | } |
| 403 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 404 | void __init exynos4_init_irq(void) |
| 405 | { |
Tomasz Figa | d243997 | 2013-06-15 09:04:55 +0900 | [diff] [blame] | 406 | irqchip_init(); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 407 | } |
| 408 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 409 | void __init exynos5_init_irq(void) |
| 410 | { |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 411 | irqchip_init(); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 412 | } |
| 413 | |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 414 | struct bus_type exynos_subsys = { |
| 415 | .name = "exynos-core", |
| 416 | .dev_name = "exynos-core", |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 417 | }; |
| 418 | |
Linus Torvalds | 7affca3 | 2012-01-07 12:03:30 -0800 | [diff] [blame] | 419 | static struct device exynos4_dev = { |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 420 | .bus = &exynos_subsys, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 421 | }; |
| 422 | |
| 423 | static int __init exynos_core_init(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 424 | { |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 425 | return subsys_system_register(&exynos_subsys, NULL); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 426 | } |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 427 | core_initcall(exynos_core_init); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 428 | |
| 429 | #ifdef CONFIG_CACHE_L2X0 |
| 430 | static int __init exynos4_l2x0_cache_init(void) |
| 431 | { |
Il Han | e1b1994 | 2012-04-05 07:59:36 -0700 | [diff] [blame] | 432 | int ret; |
| 433 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 434 | if (soc_is_exynos5250() || soc_is_exynos5440()) |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 435 | return 0; |
| 436 | |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 437 | ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK); |
| 438 | if (!ret) { |
| 439 | l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); |
| 440 | clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); |
| 441 | return 0; |
| 442 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 443 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 444 | if (!(__raw_readl(S5P_VA_L2CC + L2X0_CTRL) & 0x1)) { |
| 445 | l2x0_saved_regs.phy_base = EXYNOS4_PA_L2CC; |
| 446 | /* TAG, Data Latency Control: 2 cycles */ |
| 447 | l2x0_saved_regs.tag_latency = 0x110; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 448 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 449 | if (soc_is_exynos4212() || soc_is_exynos4412()) |
| 450 | l2x0_saved_regs.data_latency = 0x120; |
| 451 | else |
| 452 | l2x0_saved_regs.data_latency = 0x110; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 453 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 454 | l2x0_saved_regs.prefetch_ctrl = 0x30000007; |
| 455 | l2x0_saved_regs.pwr_ctrl = |
| 456 | (L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 457 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 458 | l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 459 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 460 | __raw_writel(l2x0_saved_regs.tag_latency, |
| 461 | S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL); |
| 462 | __raw_writel(l2x0_saved_regs.data_latency, |
| 463 | S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); |
| 464 | |
| 465 | /* L2X0 Prefetch Control */ |
| 466 | __raw_writel(l2x0_saved_regs.prefetch_ctrl, |
| 467 | S5P_VA_L2CC + L2X0_PREFETCH_CTRL); |
| 468 | |
| 469 | /* L2X0 Power Control */ |
| 470 | __raw_writel(l2x0_saved_regs.pwr_ctrl, |
| 471 | S5P_VA_L2CC + L2X0_POWER_CTRL); |
| 472 | |
| 473 | clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); |
| 474 | clean_dcache_area(&l2x0_saved_regs, sizeof(struct l2x0_regs)); |
| 475 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 476 | |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 477 | l2x0_init(S5P_VA_L2CC, L2_AUX_VAL, L2_AUX_MASK); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 478 | return 0; |
| 479 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 480 | early_initcall(exynos4_l2x0_cache_init); |
| 481 | #endif |
| 482 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 483 | static int __init exynos_init(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 484 | { |
| 485 | printk(KERN_INFO "EXYNOS: Initializing architecture\n"); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 486 | |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 487 | return device_register(&exynos4_dev); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 488 | } |