Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009-2011 Samsung Electronics Co., Ltd. |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 3 | * http://www.samsung.com |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 4 | * |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 5 | * Common Codes for S5PV210 |
| 6 | * |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 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. |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 10 | */ |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/list.h> |
| 16 | #include <linux/timer.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/clk.h> |
| 20 | #include <linux/io.h> |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 21 | #include <linux/device.h> |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 22 | #include <clocksource/samsung_pwm.h> |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
SeungChull Suh | 4341f9b | 2010-10-02 12:48:12 +0900 | [diff] [blame] | 24 | #include <linux/sched.h> |
Jon Medhurst | a06a58a | 2011-08-04 14:39:20 +0100 | [diff] [blame] | 25 | #include <linux/dma-mapping.h> |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 26 | #include <linux/serial_core.h> |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 27 | |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 28 | #include <asm/proc-fns.h> |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 29 | #include <asm/mach/arch.h> |
| 30 | #include <asm/mach/map.h> |
| 31 | #include <asm/mach/irq.h> |
| 32 | |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 33 | #include <mach/map.h> |
| 34 | #include <mach/regs-clock.h> |
| 35 | |
| 36 | #include <plat/cpu.h> |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 37 | #include <plat/clock.h> |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 38 | #include <plat/devs.h> |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 39 | #include <plat/sdhci.h> |
Naveen Krishna Ch | 50e9769 | 2010-06-09 15:25:19 +0530 | [diff] [blame] | 40 | #include <plat/adc-core.h> |
Abhilash Kesavan | 4b9a5ad | 2010-06-08 17:11:43 +0900 | [diff] [blame] | 41 | #include <plat/ata-core.h> |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 42 | #include <plat/fb-core.h> |
Sylwester Nawrocki | 33c14ff | 2010-08-05 18:16:31 +0900 | [diff] [blame] | 43 | #include <plat/fimc-core.h> |
Marek Szyprowski | c8d833b | 2010-05-20 08:13:06 +0200 | [diff] [blame] | 44 | #include <plat/iic-core.h> |
Joonyoung Shim | e7d0628 | 2010-06-21 16:28:28 +0900 | [diff] [blame] | 45 | #include <plat/keypad-core.h> |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 46 | #include <plat/pwm-core.h> |
Tomasz Stanislawski | fbf0556 | 2011-09-19 16:44:42 +0900 | [diff] [blame] | 47 | #include <plat/tv-core.h> |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 48 | #include <plat/spi-core.h> |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 49 | #include <plat/regs-serial.h> |
| 50 | |
| 51 | #include "common.h" |
| 52 | |
| 53 | static const char name_s5pv210[] = "S5PV210/S5PC110"; |
| 54 | |
| 55 | static struct cpu_table cpu_ids[] __initdata = { |
| 56 | { |
| 57 | .idcode = S5PV210_CPU_ID, |
| 58 | .idmask = S5PV210_CPU_MASK, |
| 59 | .map_io = s5pv210_map_io, |
| 60 | .init_clocks = s5pv210_init_clocks, |
| 61 | .init_uarts = s5pv210_init_uarts, |
| 62 | .init = s5pv210_init, |
| 63 | .name = name_s5pv210, |
| 64 | }, |
| 65 | }; |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 66 | |
| 67 | /* Initial IO mappings */ |
| 68 | |
| 69 | static struct map_desc s5pv210_iodesc[] __initdata = { |
| 70 | { |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 71 | .virtual = (unsigned long)S5P_VA_CHIPID, |
| 72 | .pfn = __phys_to_pfn(S5PV210_PA_CHIPID), |
| 73 | .length = SZ_4K, |
| 74 | .type = MT_DEVICE, |
| 75 | }, { |
| 76 | .virtual = (unsigned long)S3C_VA_SYS, |
| 77 | .pfn = __phys_to_pfn(S5PV210_PA_SYSCON), |
| 78 | .length = SZ_64K, |
| 79 | .type = MT_DEVICE, |
| 80 | }, { |
| 81 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 82 | .pfn = __phys_to_pfn(S5PV210_PA_TIMER), |
| 83 | .length = SZ_16K, |
| 84 | .type = MT_DEVICE, |
| 85 | }, { |
| 86 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 87 | .pfn = __phys_to_pfn(S5PV210_PA_WATCHDOG), |
| 88 | .length = SZ_4K, |
| 89 | .type = MT_DEVICE, |
| 90 | }, { |
| 91 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 92 | .pfn = __phys_to_pfn(S5PV210_PA_SROMC), |
| 93 | .length = SZ_4K, |
| 94 | .type = MT_DEVICE, |
| 95 | }, { |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 96 | .virtual = (unsigned long)S5P_VA_SYSTIMER, |
| 97 | .pfn = __phys_to_pfn(S5PV210_PA_SYSTIMER), |
Kyungmin Park | a203a13 | 2010-08-21 11:48:45 +0900 | [diff] [blame] | 98 | .length = SZ_4K, |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 99 | .type = MT_DEVICE, |
| 100 | }, { |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 101 | .virtual = (unsigned long)S5P_VA_GPIO, |
| 102 | .pfn = __phys_to_pfn(S5PV210_PA_GPIO), |
| 103 | .length = SZ_4K, |
| 104 | .type = MT_DEVICE, |
| 105 | }, { |
| 106 | .virtual = (unsigned long)VA_VIC0, |
| 107 | .pfn = __phys_to_pfn(S5PV210_PA_VIC0), |
| 108 | .length = SZ_16K, |
| 109 | .type = MT_DEVICE, |
| 110 | }, { |
| 111 | .virtual = (unsigned long)VA_VIC1, |
| 112 | .pfn = __phys_to_pfn(S5PV210_PA_VIC1), |
| 113 | .length = SZ_16K, |
| 114 | .type = MT_DEVICE, |
| 115 | }, { |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 116 | .virtual = (unsigned long)VA_VIC2, |
| 117 | .pfn = __phys_to_pfn(S5PV210_PA_VIC2), |
| 118 | .length = SZ_16K, |
| 119 | .type = MT_DEVICE, |
| 120 | }, { |
| 121 | .virtual = (unsigned long)VA_VIC3, |
| 122 | .pfn = __phys_to_pfn(S5PV210_PA_VIC3), |
| 123 | .length = SZ_16K, |
| 124 | .type = MT_DEVICE, |
| 125 | }, { |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 126 | .virtual = (unsigned long)S3C_VA_UART, |
| 127 | .pfn = __phys_to_pfn(S3C_PA_UART), |
| 128 | .length = SZ_512K, |
| 129 | .type = MT_DEVICE, |
| 130 | }, { |
Jaecheol Lee | 1d826d1 | 2010-09-15 15:57:37 +0900 | [diff] [blame] | 131 | .virtual = (unsigned long)S5P_VA_DMC0, |
| 132 | .pfn = __phys_to_pfn(S5PV210_PA_DMC0), |
| 133 | .length = SZ_4K, |
| 134 | .type = MT_DEVICE, |
| 135 | }, { |
| 136 | .virtual = (unsigned long)S5P_VA_DMC1, |
| 137 | .pfn = __phys_to_pfn(S5PV210_PA_DMC1), |
| 138 | .length = SZ_4K, |
| 139 | .type = MT_DEVICE, |
Marek Szyprowski | ca1931c | 2010-09-29 22:10:51 +0900 | [diff] [blame] | 140 | }, { |
| 141 | .virtual = (unsigned long)S3C_VA_USB_HSPHY, |
| 142 | .pfn =__phys_to_pfn(S5PV210_PA_HSPHY), |
| 143 | .length = SZ_4K, |
| 144 | .type = MT_DEVICE, |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 145 | } |
| 146 | }; |
| 147 | |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 148 | void s5pv210_restart(enum reboot_mode mode, const char *cmd) |
Jongpill Lee | 4550ee2 | 2010-07-23 21:39:15 +0900 | [diff] [blame] | 149 | { |
| 150 | __raw_writel(0x1, S5P_SWRESET); |
| 151 | } |
| 152 | |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 153 | static struct samsung_pwm_variant s5pv210_pwm_variant = { |
| 154 | .bits = 32, |
| 155 | .div_base = 0, |
| 156 | .has_tint_cstat = true, |
| 157 | .tclk_mask = (1 << 5), |
| 158 | }; |
| 159 | |
Tomasz Figa | 4280506 | 2013-04-28 02:25:01 +0200 | [diff] [blame] | 160 | void __init samsung_set_timer_source(unsigned int event, unsigned int source) |
| 161 | { |
| 162 | s5pv210_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1; |
| 163 | s5pv210_pwm_variant.output_mask &= ~(BIT(event) | BIT(source)); |
| 164 | } |
| 165 | |
| 166 | void __init samsung_timer_init(void) |
| 167 | { |
| 168 | unsigned int timer_irqs[SAMSUNG_PWM_NUM] = { |
| 169 | IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC, |
| 170 | IRQ_TIMER3_VIC, IRQ_TIMER4_VIC, |
| 171 | }; |
| 172 | |
| 173 | samsung_pwm_clocksource_init(S3C_VA_TIMER, |
| 174 | timer_irqs, &s5pv210_pwm_variant); |
| 175 | } |
| 176 | |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 177 | /* |
| 178 | * s5pv210_map_io |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 179 | * |
| 180 | * register the standard cpu IO areas |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 181 | */ |
| 182 | |
| 183 | void __init s5pv210_init_io(struct map_desc *mach_desc, int size) |
| 184 | { |
| 185 | /* initialize the io descriptors we need for initialization */ |
| 186 | iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc)); |
| 187 | if (mach_desc) |
| 188 | iotable_init(mach_desc, size); |
| 189 | |
| 190 | /* detect cpu id and rev. */ |
| 191 | s5p_init_cpu(S5P_VA_CHIPID); |
| 192 | |
| 193 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 194 | |
| 195 | samsung_pwm_set_platdata(&s5pv210_pwm_variant); |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 196 | } |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 197 | |
| 198 | void __init s5pv210_map_io(void) |
| 199 | { |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 200 | /* initialise device information early */ |
| 201 | s5pv210_default_sdhci0(); |
| 202 | s5pv210_default_sdhci1(); |
| 203 | s5pv210_default_sdhci2(); |
Hyuk Lee | 976a62f | 2010-06-14 10:18:56 +0900 | [diff] [blame] | 204 | s5pv210_default_sdhci3(); |
Marek Szyprowski | e6f66a9 | 2010-05-20 08:13:07 +0200 | [diff] [blame] | 205 | |
MyungJoo Ham | a0428f3 | 2011-07-20 21:08:18 +0900 | [diff] [blame] | 206 | s3c_adc_setname("samsung-adc-v3"); |
Naveen Krishna Ch | 50e9769 | 2010-06-09 15:25:19 +0530 | [diff] [blame] | 207 | |
Abhilash Kesavan | 4b9a5ad | 2010-06-08 17:11:43 +0900 | [diff] [blame] | 208 | s3c_cfcon_setname("s5pv210-pata"); |
| 209 | |
Kukjin Kim | d61bd77 | 2010-08-06 21:49:18 +0900 | [diff] [blame] | 210 | s3c_fimc_setname(0, "s5pv210-fimc"); |
| 211 | s3c_fimc_setname(1, "s5pv210-fimc"); |
| 212 | s3c_fimc_setname(2, "s5pv210-fimc"); |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 213 | |
| 214 | /* the i2c devices are directly compatible with s3c2440 */ |
| 215 | s3c_i2c0_setname("s3c2440-i2c"); |
| 216 | s3c_i2c1_setname("s3c2440-i2c"); |
| 217 | s3c_i2c2_setname("s3c2440-i2c"); |
Pawel Osciak | eb42b04 | 2010-08-10 18:02:37 -0700 | [diff] [blame] | 218 | |
| 219 | s3c_fb_setname("s5pv210-fb"); |
Linus Torvalds | 636d174 | 2010-08-11 09:13:19 -0700 | [diff] [blame] | 220 | |
Joonyoung Shim | e7d0628 | 2010-06-21 16:28:28 +0900 | [diff] [blame] | 221 | /* Use s5pv210-keypad instead of samsung-keypad */ |
| 222 | samsung_keypad_setname("s5pv210-keypad"); |
Tomasz Stanislawski | fbf0556 | 2011-09-19 16:44:42 +0900 | [diff] [blame] | 223 | |
| 224 | /* setup TV devices */ |
| 225 | s5p_hdmi_setname("s5pv210-hdmi"); |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 226 | |
| 227 | s3c64xx_spi_setname("s5pv210-spi"); |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void __init s5pv210_init_clocks(int xtal) |
| 231 | { |
| 232 | printk(KERN_DEBUG "%s: initializing clocks\n", __func__); |
| 233 | |
| 234 | s3c24xx_register_baseclocks(xtal); |
| 235 | s5p_register_clocks(xtal); |
| 236 | s5pv210_register_clocks(); |
| 237 | s5pv210_setup_clocks(); |
| 238 | } |
| 239 | |
| 240 | void __init s5pv210_init_irq(void) |
| 241 | { |
| 242 | u32 vic[4]; /* S5PV210 supports 4 VIC */ |
| 243 | |
| 244 | /* All the VICs are fully populated. */ |
| 245 | vic[0] = ~0; |
| 246 | vic[1] = ~0; |
| 247 | vic[2] = ~0; |
| 248 | vic[3] = ~0; |
| 249 | |
| 250 | s5p_init_irq(vic, ARRAY_SIZE(vic)); |
| 251 | } |
| 252 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 253 | struct bus_type s5pv210_subsys = { |
| 254 | .name = "s5pv210-core", |
| 255 | .dev_name = "s5pv210-core", |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 256 | }; |
| 257 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 258 | static struct device s5pv210_dev = { |
| 259 | .bus = &s5pv210_subsys, |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | static int __init s5pv210_core_init(void) |
| 263 | { |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 264 | return subsys_system_register(&s5pv210_subsys, NULL); |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 265 | } |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 266 | core_initcall(s5pv210_core_init); |
| 267 | |
| 268 | int __init s5pv210_init(void) |
| 269 | { |
| 270 | printk(KERN_INFO "S5PV210: Initializing architecture\n"); |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 271 | return device_register(&s5pv210_dev); |
Kukjin Kim | 939d28a | 2010-02-24 16:40:29 +0900 | [diff] [blame] | 272 | } |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 273 | |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 274 | /* uart registration process */ |
| 275 | |
| 276 | void __init s5pv210_init_uarts(struct s3c2410_uartcfg *cfg, int no) |
| 277 | { |
Kukjin Kim | 3fa754c | 2011-12-22 23:32:07 +0100 | [diff] [blame] | 278 | s3c24xx_init_uartdevs("s5pv210-uart", s5p_uart_resources, cfg, no); |
| 279 | } |