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