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