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/devs.h> |
| 47 | #include <plat/pm.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 48 | #include <plat/sdhci.h> |
| 49 | #include <plat/gpio-cfg.h> |
| 50 | #include <plat/adc-core.h> |
| 51 | #include <plat/fb-core.h> |
| 52 | #include <plat/fimc-core.h> |
| 53 | #include <plat/iic-core.h> |
| 54 | #include <plat/tv-core.h> |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 55 | #include <plat/spi-core.h> |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 56 | #include <plat/regs-serial.h> |
| 57 | |
| 58 | #include "common.h" |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 59 | #define L2_AUX_VAL 0x7C470001 |
| 60 | #define L2_AUX_MASK 0xC200ffff |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 61 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 62 | static const char name_exynos4210[] = "EXYNOS4210"; |
| 63 | static const char name_exynos4212[] = "EXYNOS4212"; |
| 64 | static const char name_exynos4412[] = "EXYNOS4412"; |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 65 | static const char name_exynos5250[] = "EXYNOS5250"; |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 66 | static const char name_exynos5440[] = "EXYNOS5440"; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 67 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 68 | static void exynos4_map_io(void); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 69 | static void exynos5_map_io(void); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 70 | static void exynos5440_map_io(void); |
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, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 80 | .init = exynos_init, |
| 81 | .name = name_exynos4210, |
| 82 | }, { |
| 83 | .idcode = EXYNOS4212_CPU_ID, |
| 84 | .idmask = EXYNOS4_CPU_MASK, |
| 85 | .map_io = exynos4_map_io, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 86 | .init = exynos_init, |
| 87 | .name = name_exynos4212, |
| 88 | }, { |
| 89 | .idcode = EXYNOS4412_CPU_ID, |
| 90 | .idmask = EXYNOS4_CPU_MASK, |
| 91 | .map_io = exynos4_map_io, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 92 | .init = exynos_init, |
| 93 | .name = name_exynos4412, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 94 | }, { |
| 95 | .idcode = EXYNOS5250_SOC_ID, |
| 96 | .idmask = EXYNOS5_SOC_MASK, |
| 97 | .map_io = exynos5_map_io, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 98 | .init = exynos_init, |
| 99 | .name = name_exynos5250, |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 100 | }, { |
| 101 | .idcode = EXYNOS5440_SOC_ID, |
| 102 | .idmask = EXYNOS5_SOC_MASK, |
| 103 | .map_io = exynos5440_map_io, |
| 104 | .init = exynos_init, |
| 105 | .name = name_exynos5440, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 106 | }, |
| 107 | }; |
| 108 | |
| 109 | /* Initial IO mappings */ |
| 110 | |
| 111 | static struct map_desc exynos_iodesc[] __initdata = { |
| 112 | { |
| 113 | .virtual = (unsigned long)S5P_VA_CHIPID, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 114 | .pfn = __phys_to_pfn(EXYNOS_PA_CHIPID), |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 115 | .length = SZ_4K, |
| 116 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 117 | }, |
| 118 | }; |
| 119 | |
| 120 | static struct map_desc exynos4_iodesc[] __initdata = { |
| 121 | { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 122 | .virtual = (unsigned long)S3C_VA_SYS, |
| 123 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSCON), |
| 124 | .length = SZ_64K, |
| 125 | .type = MT_DEVICE, |
| 126 | }, { |
| 127 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 128 | .pfn = __phys_to_pfn(EXYNOS4_PA_TIMER), |
| 129 | .length = SZ_16K, |
| 130 | .type = MT_DEVICE, |
| 131 | }, { |
| 132 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 133 | .pfn = __phys_to_pfn(EXYNOS4_PA_WATCHDOG), |
| 134 | .length = SZ_4K, |
| 135 | .type = MT_DEVICE, |
| 136 | }, { |
| 137 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 138 | .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC), |
| 139 | .length = SZ_4K, |
| 140 | .type = MT_DEVICE, |
| 141 | }, { |
| 142 | .virtual = (unsigned long)S5P_VA_SYSTIMER, |
| 143 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSTIMER), |
| 144 | .length = SZ_4K, |
| 145 | .type = MT_DEVICE, |
| 146 | }, { |
| 147 | .virtual = (unsigned long)S5P_VA_PMU, |
| 148 | .pfn = __phys_to_pfn(EXYNOS4_PA_PMU), |
| 149 | .length = SZ_64K, |
| 150 | .type = MT_DEVICE, |
| 151 | }, { |
| 152 | .virtual = (unsigned long)S5P_VA_COMBINER_BASE, |
| 153 | .pfn = __phys_to_pfn(EXYNOS4_PA_COMBINER), |
| 154 | .length = SZ_4K, |
| 155 | .type = MT_DEVICE, |
| 156 | }, { |
| 157 | .virtual = (unsigned long)S5P_VA_GIC_CPU, |
| 158 | .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_CPU), |
| 159 | .length = SZ_64K, |
| 160 | .type = MT_DEVICE, |
| 161 | }, { |
| 162 | .virtual = (unsigned long)S5P_VA_GIC_DIST, |
| 163 | .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_DIST), |
| 164 | .length = SZ_64K, |
| 165 | .type = MT_DEVICE, |
| 166 | }, { |
| 167 | .virtual = (unsigned long)S3C_VA_UART, |
| 168 | .pfn = __phys_to_pfn(EXYNOS4_PA_UART), |
| 169 | .length = SZ_512K, |
| 170 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 171 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 172 | .virtual = (unsigned long)S5P_VA_CMU, |
| 173 | .pfn = __phys_to_pfn(EXYNOS4_PA_CMU), |
| 174 | .length = SZ_128K, |
| 175 | .type = MT_DEVICE, |
| 176 | }, { |
| 177 | .virtual = (unsigned long)S5P_VA_COREPERI_BASE, |
| 178 | .pfn = __phys_to_pfn(EXYNOS4_PA_COREPERI), |
| 179 | .length = SZ_8K, |
| 180 | .type = MT_DEVICE, |
| 181 | }, { |
| 182 | .virtual = (unsigned long)S5P_VA_L2CC, |
| 183 | .pfn = __phys_to_pfn(EXYNOS4_PA_L2CC), |
| 184 | .length = SZ_4K, |
| 185 | .type = MT_DEVICE, |
| 186 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 187 | .virtual = (unsigned long)S5P_VA_DMC0, |
| 188 | .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0), |
MyungJoo Ham | 2bde0b0 | 2011-12-01 15:12:30 +0900 | [diff] [blame] | 189 | .length = SZ_64K, |
| 190 | .type = MT_DEVICE, |
| 191 | }, { |
| 192 | .virtual = (unsigned long)S5P_VA_DMC1, |
| 193 | .pfn = __phys_to_pfn(EXYNOS4_PA_DMC1), |
| 194 | .length = SZ_64K, |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 195 | .type = MT_DEVICE, |
| 196 | }, { |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 197 | .virtual = (unsigned long)S3C_VA_USB_HSPHY, |
| 198 | .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY), |
| 199 | .length = SZ_4K, |
| 200 | .type = MT_DEVICE, |
| 201 | }, |
| 202 | }; |
| 203 | |
| 204 | static struct map_desc exynos4_iodesc0[] __initdata = { |
| 205 | { |
| 206 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 207 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM0), |
| 208 | .length = SZ_4K, |
| 209 | .type = MT_DEVICE, |
| 210 | }, |
| 211 | }; |
| 212 | |
| 213 | static struct map_desc exynos4_iodesc1[] __initdata = { |
| 214 | { |
| 215 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 216 | .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM1), |
| 217 | .length = SZ_4K, |
| 218 | .type = MT_DEVICE, |
| 219 | }, |
| 220 | }; |
| 221 | |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 222 | static struct map_desc exynos4210_iodesc[] __initdata = { |
| 223 | { |
| 224 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 225 | .pfn = __phys_to_pfn(EXYNOS4210_PA_SYSRAM_NS), |
| 226 | .length = SZ_4K, |
| 227 | .type = MT_DEVICE, |
| 228 | }, |
| 229 | }; |
| 230 | |
| 231 | static struct map_desc exynos4x12_iodesc[] __initdata = { |
| 232 | { |
| 233 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 234 | .pfn = __phys_to_pfn(EXYNOS4x12_PA_SYSRAM_NS), |
| 235 | .length = SZ_4K, |
| 236 | .type = MT_DEVICE, |
| 237 | }, |
| 238 | }; |
| 239 | |
| 240 | static struct map_desc exynos5250_iodesc[] __initdata = { |
| 241 | { |
| 242 | .virtual = (unsigned long)S5P_VA_SYSRAM_NS, |
| 243 | .pfn = __phys_to_pfn(EXYNOS5250_PA_SYSRAM_NS), |
| 244 | .length = SZ_4K, |
| 245 | .type = MT_DEVICE, |
| 246 | }, |
| 247 | }; |
| 248 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 249 | static struct map_desc exynos5_iodesc[] __initdata = { |
| 250 | { |
| 251 | .virtual = (unsigned long)S3C_VA_SYS, |
| 252 | .pfn = __phys_to_pfn(EXYNOS5_PA_SYSCON), |
| 253 | .length = SZ_64K, |
| 254 | .type = MT_DEVICE, |
| 255 | }, { |
| 256 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 257 | .pfn = __phys_to_pfn(EXYNOS5_PA_TIMER), |
| 258 | .length = SZ_16K, |
| 259 | .type = MT_DEVICE, |
| 260 | }, { |
| 261 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 262 | .pfn = __phys_to_pfn(EXYNOS5_PA_WATCHDOG), |
| 263 | .length = SZ_4K, |
| 264 | .type = MT_DEVICE, |
| 265 | }, { |
| 266 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 267 | .pfn = __phys_to_pfn(EXYNOS5_PA_SROMC), |
| 268 | .length = SZ_4K, |
| 269 | .type = MT_DEVICE, |
| 270 | }, { |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 271 | .virtual = (unsigned long)S5P_VA_SYSRAM, |
| 272 | .pfn = __phys_to_pfn(EXYNOS5_PA_SYSRAM), |
| 273 | .length = SZ_4K, |
| 274 | .type = MT_DEVICE, |
| 275 | }, { |
| 276 | .virtual = (unsigned long)S5P_VA_CMU, |
| 277 | .pfn = __phys_to_pfn(EXYNOS5_PA_CMU), |
| 278 | .length = 144 * SZ_1K, |
| 279 | .type = MT_DEVICE, |
| 280 | }, { |
| 281 | .virtual = (unsigned long)S5P_VA_PMU, |
| 282 | .pfn = __phys_to_pfn(EXYNOS5_PA_PMU), |
| 283 | .length = SZ_64K, |
| 284 | .type = MT_DEVICE, |
| 285 | }, { |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 286 | .virtual = (unsigned long)S3C_VA_UART, |
| 287 | .pfn = __phys_to_pfn(EXYNOS5_PA_UART), |
| 288 | .length = SZ_512K, |
| 289 | .type = MT_DEVICE, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 290 | }, |
| 291 | }; |
| 292 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 293 | static struct map_desc exynos5440_iodesc0[] __initdata = { |
| 294 | { |
| 295 | .virtual = (unsigned long)S3C_VA_UART, |
| 296 | .pfn = __phys_to_pfn(EXYNOS5440_PA_UART0), |
| 297 | .length = SZ_512K, |
| 298 | .type = MT_DEVICE, |
| 299 | }, |
| 300 | }; |
| 301 | |
Tomasz Figa | 68a433f | 2013-05-25 06:27:29 +0900 | [diff] [blame] | 302 | static struct samsung_pwm_variant exynos4_pwm_variant = { |
| 303 | .bits = 32, |
| 304 | .div_base = 0, |
| 305 | .has_tint_cstat = true, |
| 306 | .tclk_mask = 0, |
| 307 | }; |
| 308 | |
Russell King | 9eb4859 | 2012-01-03 11:56:53 +0100 | [diff] [blame] | 309 | void exynos4_restart(char mode, const char *cmd) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 310 | { |
| 311 | __raw_writel(0x1, S5P_SWRESET); |
| 312 | } |
| 313 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 314 | void exynos5_restart(char mode, const char *cmd) |
| 315 | { |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 316 | struct device_node *np; |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 317 | u32 val; |
| 318 | void __iomem *addr; |
| 319 | |
| 320 | if (of_machine_is_compatible("samsung,exynos5250")) { |
| 321 | val = 0x1; |
| 322 | addr = EXYNOS_SWRESET; |
| 323 | } else if (of_machine_is_compatible("samsung,exynos5440")) { |
Jungseok Lee | 1ba830c | 2013-05-25 06:33:03 +0900 | [diff] [blame] | 324 | u32 status; |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 325 | np = of_find_compatible_node(NULL, NULL, "samsung,exynos5440-clock"); |
Jungseok Lee | 1ba830c | 2013-05-25 06:33:03 +0900 | [diff] [blame] | 326 | |
| 327 | addr = of_iomap(np, 0) + 0xbc; |
| 328 | status = __raw_readl(addr); |
| 329 | |
Thomas Abraham | 60db7e5 | 2013-01-24 10:09:13 -0800 | [diff] [blame] | 330 | addr = of_iomap(np, 0) + 0xcc; |
Jungseok Lee | 1ba830c | 2013-05-25 06:33:03 +0900 | [diff] [blame] | 331 | val = __raw_readl(addr); |
| 332 | |
| 333 | val = (val & 0xffff0000) | (status & 0xffff); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 334 | } else { |
| 335 | pr_err("%s: cannot support non-DT\n", __func__); |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | __raw_writel(val, addr); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 340 | } |
| 341 | |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 342 | void __init exynos_init_late(void) |
| 343 | { |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 344 | if (of_machine_is_compatible("samsung,exynos5440")) |
| 345 | /* to be supported later */ |
| 346 | return; |
| 347 | |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 348 | exynos_pm_late_initcall(); |
| 349 | } |
| 350 | |
Thomas Abraham | f5f83c7 | 2013-04-23 22:46:53 +0900 | [diff] [blame] | 351 | int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, |
| 352 | int depth, void *data) |
| 353 | { |
| 354 | struct map_desc iodesc; |
| 355 | __be32 *reg; |
| 356 | unsigned long len; |
| 357 | |
| 358 | if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") && |
| 359 | !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock")) |
| 360 | return 0; |
| 361 | |
| 362 | reg = of_get_flat_dt_prop(node, "reg", &len); |
| 363 | if (reg == NULL || len != (sizeof(unsigned long) * 2)) |
| 364 | return 0; |
| 365 | |
| 366 | iodesc.pfn = __phys_to_pfn(be32_to_cpu(reg[0])); |
| 367 | iodesc.length = be32_to_cpu(reg[1]) - 1; |
| 368 | iodesc.virtual = (unsigned long)S5P_VA_CHIPID; |
| 369 | iodesc.type = MT_DEVICE; |
| 370 | iotable_init(&iodesc, 1); |
| 371 | return 1; |
| 372 | } |
Thomas Abraham | f5f83c7 | 2013-04-23 22:46:53 +0900 | [diff] [blame] | 373 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 374 | /* |
| 375 | * exynos_map_io |
| 376 | * |
| 377 | * register the standard cpu IO areas |
| 378 | */ |
| 379 | |
| 380 | void __init exynos_init_io(struct map_desc *mach_desc, int size) |
| 381 | { |
Doug Anderson | 9c1fcdc | 2013-06-05 13:56:33 -0700 | [diff] [blame] | 382 | debug_ll_io_init(); |
| 383 | |
Thomas Abraham | f5f83c7 | 2013-04-23 22:46:53 +0900 | [diff] [blame] | 384 | if (initial_boot_params) |
| 385 | of_scan_flat_dt(exynos_fdt_map_chipid, NULL); |
| 386 | else |
Thomas Abraham | f5f83c7 | 2013-04-23 22:46:53 +0900 | [diff] [blame] | 387 | iotable_init(exynos_iodesc, ARRAY_SIZE(exynos_iodesc)); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 388 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 389 | if (mach_desc) |
| 390 | iotable_init(mach_desc, size); |
| 391 | |
| 392 | /* detect cpu id and rev. */ |
| 393 | s5p_init_cpu(S5P_VA_CHIPID); |
| 394 | |
| 395 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
| 396 | } |
| 397 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 398 | static void __init exynos4_map_io(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 399 | { |
| 400 | iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc)); |
| 401 | |
| 402 | if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_0) |
| 403 | iotable_init(exynos4_iodesc0, ARRAY_SIZE(exynos4_iodesc0)); |
| 404 | else |
| 405 | iotable_init(exynos4_iodesc1, ARRAY_SIZE(exynos4_iodesc1)); |
| 406 | |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 407 | if (soc_is_exynos4210()) |
| 408 | iotable_init(exynos4210_iodesc, ARRAY_SIZE(exynos4210_iodesc)); |
| 409 | if (soc_is_exynos4212() || soc_is_exynos4412()) |
| 410 | iotable_init(exynos4x12_iodesc, ARRAY_SIZE(exynos4x12_iodesc)); |
| 411 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 412 | /* initialize device information early */ |
| 413 | exynos4_default_sdhci0(); |
| 414 | exynos4_default_sdhci1(); |
| 415 | exynos4_default_sdhci2(); |
| 416 | exynos4_default_sdhci3(); |
| 417 | |
| 418 | s3c_adc_setname("samsung-adc-v3"); |
| 419 | |
| 420 | s3c_fimc_setname(0, "exynos4-fimc"); |
| 421 | s3c_fimc_setname(1, "exynos4-fimc"); |
| 422 | s3c_fimc_setname(2, "exynos4-fimc"); |
| 423 | s3c_fimc_setname(3, "exynos4-fimc"); |
| 424 | |
Thomas Abraham | 8482c81 | 2012-04-14 08:04:46 -0700 | [diff] [blame] | 425 | s3c_sdhci_setname(0, "exynos4-sdhci"); |
| 426 | s3c_sdhci_setname(1, "exynos4-sdhci"); |
| 427 | s3c_sdhci_setname(2, "exynos4-sdhci"); |
| 428 | s3c_sdhci_setname(3, "exynos4-sdhci"); |
| 429 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 430 | /* The I2C bus controllers are directly compatible with s3c2440 */ |
| 431 | s3c_i2c0_setname("s3c2440-i2c"); |
| 432 | s3c_i2c1_setname("s3c2440-i2c"); |
| 433 | s3c_i2c2_setname("s3c2440-i2c"); |
| 434 | |
| 435 | s5p_fb_setname(0, "exynos4-fb"); |
| 436 | s5p_hdmi_setname("exynos4-hdmi"); |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 437 | |
| 438 | s3c64xx_spi_setname("exynos4210-spi"); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 439 | } |
| 440 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 441 | static void __init exynos5_map_io(void) |
| 442 | { |
| 443 | iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc)); |
Tomasz Figa | 41de898 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 444 | |
| 445 | if (soc_is_exynos5250()) |
| 446 | iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc)); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 447 | } |
| 448 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 449 | static void __init exynos5440_map_io(void) |
| 450 | { |
| 451 | iotable_init(exynos5440_iodesc0, ARRAY_SIZE(exynos5440_iodesc0)); |
| 452 | } |
| 453 | |
Tomasz Figa | 68a433f | 2013-05-25 06:27:29 +0900 | [diff] [blame] | 454 | void __init exynos_set_timer_source(u8 channels) |
| 455 | { |
| 456 | exynos4_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1; |
| 457 | exynos4_pwm_variant.output_mask &= ~channels; |
| 458 | } |
| 459 | |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 460 | void __init exynos_init_time(void) |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 461 | { |
Tomasz Figa | 68a433f | 2013-05-25 06:27:29 +0900 | [diff] [blame] | 462 | unsigned int timer_irqs[SAMSUNG_PWM_NUM] = { |
| 463 | EXYNOS4_IRQ_TIMER0_VIC, EXYNOS4_IRQ_TIMER1_VIC, |
| 464 | EXYNOS4_IRQ_TIMER2_VIC, EXYNOS4_IRQ_TIMER3_VIC, |
| 465 | EXYNOS4_IRQ_TIMER4_VIC, |
| 466 | }; |
| 467 | |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 468 | if (of_have_populated_dt()) { |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 469 | of_clk_init(NULL); |
| 470 | clocksource_of_init(); |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 471 | } else { |
| 472 | /* todo: remove after migrating legacy E4 platforms to dt */ |
Thomas Abraham | 296f3f2 | 2013-04-05 15:17:47 +0900 | [diff] [blame] | 473 | #ifdef CONFIG_ARCH_EXYNOS4 |
Arnd Bergmann | 25e56eb | 2013-04-10 11:31:44 +0200 | [diff] [blame] | 474 | 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] | 475 | exynos4_clk_register_fixed_ext(xxti_f, xusbxti_f); |
Thomas Abraham | 296f3f2 | 2013-04-05 15:17:47 +0900 | [diff] [blame] | 476 | #endif |
Tomasz Figa | 68a433f | 2013-05-25 06:27:29 +0900 | [diff] [blame] | 477 | #ifdef CONFIG_CLKSRC_SAMSUNG_PWM |
| 478 | if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_0) |
| 479 | samsung_pwm_clocksource_init(S3C_VA_TIMER, |
| 480 | timer_irqs, &exynos4_pwm_variant); |
| 481 | else |
| 482 | #endif |
| 483 | mct_init(S5P_VA_SYSTIMER, EXYNOS4_IRQ_MCT_G0, |
| 484 | EXYNOS4_IRQ_MCT_L0, EXYNOS4_IRQ_MCT_L1); |
Thomas Abraham | 6923ae4 | 2013-03-09 17:03:29 +0900 | [diff] [blame] | 485 | } |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 486 | } |
| 487 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 488 | void __init exynos4_init_irq(void) |
| 489 | { |
Tomasz Figa | d243997 | 2013-06-15 09:04:55 +0900 | [diff] [blame^] | 490 | irqchip_init(); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 491 | } |
| 492 | |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 493 | void __init exynos5_init_irq(void) |
| 494 | { |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 495 | irqchip_init(); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 496 | } |
| 497 | |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 498 | struct bus_type exynos_subsys = { |
| 499 | .name = "exynos-core", |
| 500 | .dev_name = "exynos-core", |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 501 | }; |
| 502 | |
Linus Torvalds | 7affca3 | 2012-01-07 12:03:30 -0800 | [diff] [blame] | 503 | static struct device exynos4_dev = { |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 504 | .bus = &exynos_subsys, |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 505 | }; |
| 506 | |
| 507 | static int __init exynos_core_init(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 508 | { |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 509 | return subsys_system_register(&exynos_subsys, NULL); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 510 | } |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 511 | core_initcall(exynos_core_init); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 512 | |
| 513 | #ifdef CONFIG_CACHE_L2X0 |
| 514 | static int __init exynos4_l2x0_cache_init(void) |
| 515 | { |
Il Han | e1b1994 | 2012-04-05 07:59:36 -0700 | [diff] [blame] | 516 | int ret; |
| 517 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 518 | if (soc_is_exynos5250() || soc_is_exynos5440()) |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 519 | return 0; |
| 520 | |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 521 | ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK); |
| 522 | if (!ret) { |
| 523 | l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); |
| 524 | clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); |
| 525 | return 0; |
| 526 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 527 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 528 | if (!(__raw_readl(S5P_VA_L2CC + L2X0_CTRL) & 0x1)) { |
| 529 | l2x0_saved_regs.phy_base = EXYNOS4_PA_L2CC; |
| 530 | /* TAG, Data Latency Control: 2 cycles */ |
| 531 | l2x0_saved_regs.tag_latency = 0x110; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 532 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 533 | if (soc_is_exynos4212() || soc_is_exynos4412()) |
| 534 | l2x0_saved_regs.data_latency = 0x120; |
| 535 | else |
| 536 | l2x0_saved_regs.data_latency = 0x110; |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 537 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 538 | l2x0_saved_regs.prefetch_ctrl = 0x30000007; |
| 539 | l2x0_saved_regs.pwr_ctrl = |
| 540 | (L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 541 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 542 | l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 543 | |
Amit Daniel Kachhap | b756a50 | 2012-03-08 02:07:41 -0800 | [diff] [blame] | 544 | __raw_writel(l2x0_saved_regs.tag_latency, |
| 545 | S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL); |
| 546 | __raw_writel(l2x0_saved_regs.data_latency, |
| 547 | S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); |
| 548 | |
| 549 | /* L2X0 Prefetch Control */ |
| 550 | __raw_writel(l2x0_saved_regs.prefetch_ctrl, |
| 551 | S5P_VA_L2CC + L2X0_PREFETCH_CTRL); |
| 552 | |
| 553 | /* L2X0 Power Control */ |
| 554 | __raw_writel(l2x0_saved_regs.pwr_ctrl, |
| 555 | S5P_VA_L2CC + L2X0_POWER_CTRL); |
| 556 | |
| 557 | clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); |
| 558 | clean_dcache_area(&l2x0_saved_regs, sizeof(struct l2x0_regs)); |
| 559 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 560 | |
Amit Daniel Kachhap | 6cdeddc | 2012-03-08 02:09:12 -0800 | [diff] [blame] | 561 | l2x0_init(S5P_VA_L2CC, L2_AUX_VAL, L2_AUX_MASK); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 562 | return 0; |
| 563 | } |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 564 | early_initcall(exynos4_l2x0_cache_init); |
| 565 | #endif |
| 566 | |
Kukjin Kim | 906c789 | 2012-02-11 21:27:08 +0900 | [diff] [blame] | 567 | static int __init exynos_init(void) |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 568 | { |
| 569 | printk(KERN_INFO "EXYNOS: Initializing architecture\n"); |
Kukjin Kim | 94c7ca7 | 2012-02-11 22:15:45 +0900 | [diff] [blame] | 570 | |
Thomas Abraham | 9ee6af9 | 2012-05-15 15:47:40 +0900 | [diff] [blame] | 571 | return device_register(&exynos4_dev); |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 572 | } |