Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 3 | * http://www.samsung.com |
| 4 | * |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 5 | * Copyright 2009 Samsung Electronics Co. |
| 6 | * Byungho Min <bhmin@samsung.com> |
| 7 | * |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 8 | * Common Codes for S5PC100 |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 13 | */ |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 14 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/list.h> |
| 19 | #include <linux/timer.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/clk.h> |
| 22 | #include <linux/io.h> |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 23 | #include <linux/device.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 24 | #include <linux/serial_core.h> |
Tushar Behera | 334a1c7 | 2014-02-14 10:32:45 +0900 | [diff] [blame] | 25 | #include <linux/serial_s3c.h> |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 26 | #include <clocksource/samsung_pwm.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 27 | #include <linux/platform_device.h> |
SeungChull Suh | 4341f9b | 2010-10-02 12:48:12 +0900 | [diff] [blame] | 28 | #include <linux/sched.h> |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 29 | #include <linux/reboot.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 30 | |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 31 | #include <asm/irq.h> |
| 32 | #include <asm/proc-fns.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 33 | #include <asm/system_misc.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/map.h> |
| 36 | #include <asm/mach/irq.h> |
| 37 | |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 38 | #include <mach/map.h> |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 39 | #include <mach/hardware.h> |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 40 | #include <mach/regs-clock.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 41 | |
| 42 | #include <plat/cpu.h> |
| 43 | #include <plat/devs.h> |
| 44 | #include <plat/clock.h> |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 45 | #include <plat/sdhci.h> |
Naveen Krishna Ch | 327b903 | 2010-06-30 21:50:24 +0900 | [diff] [blame] | 46 | #include <plat/adc-core.h> |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 47 | #include <plat/ata-core.h> |
Pawel Osciak | eb42b04 | 2010-08-10 18:02:37 -0700 | [diff] [blame] | 48 | #include <plat/fb-core.h> |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 49 | #include <plat/iic-core.h> |
| 50 | #include <plat/onenand-core.h> |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 51 | #include <plat/pwm-core.h> |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 52 | #include <plat/spi-core.h> |
Kukjin Kim | 5497d2e | 2011-12-22 23:35:21 +0100 | [diff] [blame] | 53 | #include <plat/watchdog-reset.h> |
Marek Szyprowski | 999304b | 2010-05-20 08:59:05 +0200 | [diff] [blame] | 54 | |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 55 | #include "common.h" |
| 56 | |
| 57 | static const char name_s5pc100[] = "S5PC100"; |
| 58 | |
| 59 | static struct cpu_table cpu_ids[] __initdata = { |
| 60 | { |
| 61 | .idcode = S5PC100_CPU_ID, |
| 62 | .idmask = S5PC100_CPU_MASK, |
| 63 | .map_io = s5pc100_map_io, |
| 64 | .init_clocks = s5pc100_init_clocks, |
| 65 | .init_uarts = s5pc100_init_uarts, |
| 66 | .init = s5pc100_init, |
| 67 | .name = name_s5pc100, |
| 68 | }, |
| 69 | }; |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 70 | |
| 71 | /* Initial IO mappings */ |
| 72 | |
| 73 | static struct map_desc s5pc100_iodesc[] __initdata = { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 74 | { |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 75 | .virtual = (unsigned long)S5P_VA_CHIPID, |
| 76 | .pfn = __phys_to_pfn(S5PC100_PA_CHIPID), |
| 77 | .length = SZ_4K, |
| 78 | .type = MT_DEVICE, |
| 79 | }, { |
| 80 | .virtual = (unsigned long)S3C_VA_SYS, |
| 81 | .pfn = __phys_to_pfn(S5PC100_PA_SYSCON), |
| 82 | .length = SZ_64K, |
| 83 | .type = MT_DEVICE, |
| 84 | }, { |
| 85 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 86 | .pfn = __phys_to_pfn(S5PC100_PA_TIMER), |
| 87 | .length = SZ_16K, |
| 88 | .type = MT_DEVICE, |
| 89 | }, { |
| 90 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 91 | .pfn = __phys_to_pfn(S5PC100_PA_WATCHDOG), |
| 92 | .length = SZ_4K, |
| 93 | .type = MT_DEVICE, |
| 94 | }, { |
| 95 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 96 | .pfn = __phys_to_pfn(S5PC100_PA_SROMC), |
| 97 | .length = SZ_4K, |
| 98 | .type = MT_DEVICE, |
| 99 | }, { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 100 | .virtual = (unsigned long)S5P_VA_SYSTIMER, |
| 101 | .pfn = __phys_to_pfn(S5PC100_PA_SYSTIMER), |
| 102 | .length = SZ_16K, |
| 103 | .type = MT_DEVICE, |
| 104 | }, { |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 105 | .virtual = (unsigned long)S5P_VA_GPIO, |
| 106 | .pfn = __phys_to_pfn(S5PC100_PA_GPIO), |
| 107 | .length = SZ_4K, |
| 108 | .type = MT_DEVICE, |
| 109 | }, { |
| 110 | .virtual = (unsigned long)VA_VIC0, |
| 111 | .pfn = __phys_to_pfn(S5PC100_PA_VIC0), |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 112 | .length = SZ_16K, |
| 113 | .type = MT_DEVICE, |
| 114 | }, { |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 115 | .virtual = (unsigned long)VA_VIC1, |
| 116 | .pfn = __phys_to_pfn(S5PC100_PA_VIC1), |
| 117 | .length = SZ_16K, |
| 118 | .type = MT_DEVICE, |
| 119 | }, { |
| 120 | .virtual = (unsigned long)VA_VIC2, |
| 121 | .pfn = __phys_to_pfn(S5PC100_PA_VIC2), |
| 122 | .length = SZ_16K, |
| 123 | .type = MT_DEVICE, |
| 124 | }, { |
| 125 | .virtual = (unsigned long)S3C_VA_UART, |
| 126 | .pfn = __phys_to_pfn(S3C_PA_UART), |
| 127 | .length = SZ_512K, |
| 128 | .type = MT_DEVICE, |
| 129 | }, { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 130 | .virtual = (unsigned long)S5PC100_VA_OTHERS, |
| 131 | .pfn = __phys_to_pfn(S5PC100_PA_OTHERS), |
| 132 | .length = SZ_4K, |
| 133 | .type = MT_DEVICE, |
| 134 | } |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 135 | }; |
| 136 | |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 137 | static struct samsung_pwm_variant s5pc100_pwm_variant = { |
| 138 | .bits = 32, |
| 139 | .div_base = 0, |
| 140 | .has_tint_cstat = true, |
| 141 | .tclk_mask = (1 << 5), |
| 142 | }; |
| 143 | |
Tomasz Figa | 4280506 | 2013-04-28 02:25:01 +0200 | [diff] [blame] | 144 | void __init samsung_set_timer_source(unsigned int event, unsigned int source) |
| 145 | { |
| 146 | s5pc100_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1; |
| 147 | s5pc100_pwm_variant.output_mask &= ~(BIT(event) | BIT(source)); |
| 148 | } |
| 149 | |
| 150 | void __init samsung_timer_init(void) |
| 151 | { |
| 152 | unsigned int timer_irqs[SAMSUNG_PWM_NUM] = { |
| 153 | IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC, |
| 154 | IRQ_TIMER3_VIC, IRQ_TIMER4_VIC, |
| 155 | }; |
| 156 | |
| 157 | samsung_pwm_clocksource_init(S3C_VA_TIMER, |
| 158 | timer_irqs, &s5pc100_pwm_variant); |
| 159 | } |
| 160 | |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 161 | /* |
| 162 | * s5pc100_map_io |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 163 | * |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 164 | * register the standard CPU IO areas |
| 165 | */ |
| 166 | |
| 167 | void __init s5pc100_init_io(struct map_desc *mach_desc, int size) |
| 168 | { |
| 169 | /* initialize the io descriptors we need for initialization */ |
| 170 | iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc)); |
| 171 | if (mach_desc) |
| 172 | iotable_init(mach_desc, size); |
| 173 | |
| 174 | /* detect cpu id and rev. */ |
| 175 | s5p_init_cpu(S5P_VA_CHIPID); |
| 176 | |
| 177 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
Tomasz Figa | 1c161fd | 2013-04-12 21:17:22 +0200 | [diff] [blame] | 178 | |
| 179 | samsung_pwm_set_platdata(&s5pc100_pwm_variant); |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 180 | } |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 181 | |
| 182 | void __init s5pc100_map_io(void) |
| 183 | { |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 184 | /* initialise device information early */ |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 185 | s5pc100_default_sdhci0(); |
| 186 | s5pc100_default_sdhci1(); |
| 187 | s5pc100_default_sdhci2(); |
Kyungmin Park | 5eda288 | 2009-11-17 08:41:21 +0100 | [diff] [blame] | 188 | |
Naveen Krishna Ch | 327b903 | 2010-06-30 21:50:24 +0900 | [diff] [blame] | 189 | s3c_adc_setname("s3c64xx-adc"); |
| 190 | |
Kyungmin Park | 5eda288 | 2009-11-17 08:41:21 +0100 | [diff] [blame] | 191 | /* the i2c devices are directly compatible with s3c2440 */ |
| 192 | s3c_i2c0_setname("s3c2440-i2c"); |
| 193 | s3c_i2c1_setname("s3c2440-i2c"); |
Marek Szyprowski | 999304b | 2010-05-20 08:59:05 +0200 | [diff] [blame] | 194 | |
| 195 | s3c_onenand_setname("s5pc100-onenand"); |
Pawel Osciak | eb42b04 | 2010-08-10 18:02:37 -0700 | [diff] [blame] | 196 | s3c_fb_setname("s5pc100-fb"); |
Abhilash Kesavan | 66194a7 | 2010-06-08 17:02:08 +0900 | [diff] [blame] | 197 | s3c_cfcon_setname("s5pc100-pata"); |
Heiko Stuebner | 308b3af | 2012-10-17 16:47:11 +0900 | [diff] [blame] | 198 | |
| 199 | s3c64xx_spi_setname("s5pc100-spi"); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void __init s5pc100_init_clocks(int xtal) |
| 203 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 204 | printk(KERN_DEBUG "%s: initializing clocks\n", __func__); |
| 205 | |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 206 | s3c24xx_register_baseclocks(xtal); |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 207 | s5p_register_clocks(xtal); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 208 | s5pc100_register_clocks(); |
| 209 | s5pc100_setup_clocks(); |
Tomasz Figa | 88f5973 | 2013-06-17 23:45:37 +0900 | [diff] [blame] | 210 | samsung_wdt_reset_init(S3C_VA_WATCHDOG); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | void __init s5pc100_init_irq(void) |
| 214 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 215 | u32 vic[] = {~0, ~0, ~0}; |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 216 | |
| 217 | /* VIC0, VIC1, and VIC2 are fully populated. */ |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 218 | s5p_init_irq(vic, ARRAY_SIZE(vic)); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 219 | } |
| 220 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 221 | static struct bus_type s5pc100_subsys = { |
| 222 | .name = "s5pc100-core", |
| 223 | .dev_name = "s5pc100-core", |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 224 | }; |
| 225 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 226 | static struct device s5pc100_dev = { |
| 227 | .bus = &s5pc100_subsys, |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | static int __init s5pc100_core_init(void) |
| 231 | { |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 232 | return subsys_system_register(&s5pc100_subsys, NULL); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 233 | } |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 234 | core_initcall(s5pc100_core_init); |
| 235 | |
| 236 | int __init s5pc100_init(void) |
| 237 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 238 | printk(KERN_INFO "S5PC100: Initializing architecture\n"); |
Kukjin Kim | ea04018 | 2012-01-06 16:08:09 +0900 | [diff] [blame] | 239 | return device_register(&s5pc100_dev); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 240 | } |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 241 | |
| 242 | /* uart registration process */ |
| 243 | |
| 244 | void __init s5pc100_init_uarts(struct s3c2410_uartcfg *cfg, int no) |
| 245 | { |
| 246 | s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no); |
| 247 | } |
Kukjin Kim | 5497d2e | 2011-12-22 23:35:21 +0100 | [diff] [blame] | 248 | |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 249 | void s5pc100_restart(enum reboot_mode mode, const char *cmd) |
Kukjin Kim | 5497d2e | 2011-12-22 23:35:21 +0100 | [diff] [blame] | 250 | { |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 251 | if (mode != REBOOT_SOFT) |
Tomasz Figa | 88f5973 | 2013-06-17 23:45:37 +0900 | [diff] [blame] | 252 | samsung_wdt_reset(); |
Kukjin Kim | 5497d2e | 2011-12-22 23:35:21 +0100 | [diff] [blame] | 253 | |
| 254 | soft_restart(0); |
| 255 | } |