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> |
| 25 | #include <linux/platform_device.h> |
SeungChull Suh | 4341f9b | 2010-10-02 12:48:12 +0900 | [diff] [blame] | 26 | #include <linux/sched.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 27 | |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 28 | #include <asm/irq.h> |
| 29 | #include <asm/proc-fns.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame^] | 30 | #include <asm/system_misc.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 31 | #include <asm/mach/arch.h> |
| 32 | #include <asm/mach/map.h> |
| 33 | #include <asm/mach/irq.h> |
| 34 | |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 35 | #include <mach/map.h> |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 36 | #include <mach/hardware.h> |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 37 | #include <mach/regs-clock.h> |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 38 | |
| 39 | #include <plat/cpu.h> |
| 40 | #include <plat/devs.h> |
| 41 | #include <plat/clock.h> |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 42 | #include <plat/sdhci.h> |
Naveen Krishna Ch | 327b903 | 2010-06-30 21:50:24 +0900 | [diff] [blame] | 43 | #include <plat/adc-core.h> |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 44 | #include <plat/ata-core.h> |
Pawel Osciak | eb42b04 | 2010-08-10 18:02:37 -0700 | [diff] [blame] | 45 | #include <plat/fb-core.h> |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 46 | #include <plat/iic-core.h> |
| 47 | #include <plat/onenand-core.h> |
| 48 | #include <plat/regs-serial.h> |
Kukjin Kim | 5497d2e | 2011-12-22 23:35:21 +0100 | [diff] [blame] | 49 | #include <plat/watchdog-reset.h> |
Marek Szyprowski | 999304b | 2010-05-20 08:59:05 +0200 | [diff] [blame] | 50 | |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 51 | #include "common.h" |
| 52 | |
| 53 | static const char name_s5pc100[] = "S5PC100"; |
| 54 | |
| 55 | static struct cpu_table cpu_ids[] __initdata = { |
| 56 | { |
| 57 | .idcode = S5PC100_CPU_ID, |
| 58 | .idmask = S5PC100_CPU_MASK, |
| 59 | .map_io = s5pc100_map_io, |
| 60 | .init_clocks = s5pc100_init_clocks, |
| 61 | .init_uarts = s5pc100_init_uarts, |
| 62 | .init = s5pc100_init, |
| 63 | .name = name_s5pc100, |
| 64 | }, |
| 65 | }; |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 66 | |
| 67 | /* Initial IO mappings */ |
| 68 | |
| 69 | static struct map_desc s5pc100_iodesc[] __initdata = { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 70 | { |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 71 | .virtual = (unsigned long)S5P_VA_CHIPID, |
| 72 | .pfn = __phys_to_pfn(S5PC100_PA_CHIPID), |
| 73 | .length = SZ_4K, |
| 74 | .type = MT_DEVICE, |
| 75 | }, { |
| 76 | .virtual = (unsigned long)S3C_VA_SYS, |
| 77 | .pfn = __phys_to_pfn(S5PC100_PA_SYSCON), |
| 78 | .length = SZ_64K, |
| 79 | .type = MT_DEVICE, |
| 80 | }, { |
| 81 | .virtual = (unsigned long)S3C_VA_TIMER, |
| 82 | .pfn = __phys_to_pfn(S5PC100_PA_TIMER), |
| 83 | .length = SZ_16K, |
| 84 | .type = MT_DEVICE, |
| 85 | }, { |
| 86 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 87 | .pfn = __phys_to_pfn(S5PC100_PA_WATCHDOG), |
| 88 | .length = SZ_4K, |
| 89 | .type = MT_DEVICE, |
| 90 | }, { |
| 91 | .virtual = (unsigned long)S5P_VA_SROMC, |
| 92 | .pfn = __phys_to_pfn(S5PC100_PA_SROMC), |
| 93 | .length = SZ_4K, |
| 94 | .type = MT_DEVICE, |
| 95 | }, { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 96 | .virtual = (unsigned long)S5P_VA_SYSTIMER, |
| 97 | .pfn = __phys_to_pfn(S5PC100_PA_SYSTIMER), |
| 98 | .length = SZ_16K, |
| 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(S5PC100_PA_GPIO), |
| 103 | .length = SZ_4K, |
| 104 | .type = MT_DEVICE, |
| 105 | }, { |
| 106 | .virtual = (unsigned long)VA_VIC0, |
| 107 | .pfn = __phys_to_pfn(S5PC100_PA_VIC0), |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 108 | .length = SZ_16K, |
| 109 | .type = MT_DEVICE, |
| 110 | }, { |
Kukjin Kim | 19a2c06 | 2010-08-31 16:30:51 +0900 | [diff] [blame] | 111 | .virtual = (unsigned long)VA_VIC1, |
| 112 | .pfn = __phys_to_pfn(S5PC100_PA_VIC1), |
| 113 | .length = SZ_16K, |
| 114 | .type = MT_DEVICE, |
| 115 | }, { |
| 116 | .virtual = (unsigned long)VA_VIC2, |
| 117 | .pfn = __phys_to_pfn(S5PC100_PA_VIC2), |
| 118 | .length = SZ_16K, |
| 119 | .type = MT_DEVICE, |
| 120 | }, { |
| 121 | .virtual = (unsigned long)S3C_VA_UART, |
| 122 | .pfn = __phys_to_pfn(S3C_PA_UART), |
| 123 | .length = SZ_512K, |
| 124 | .type = MT_DEVICE, |
| 125 | }, { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 126 | .virtual = (unsigned long)S5PC100_VA_OTHERS, |
| 127 | .pfn = __phys_to_pfn(S5PC100_PA_OTHERS), |
| 128 | .length = SZ_4K, |
| 129 | .type = MT_DEVICE, |
| 130 | } |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 131 | }; |
| 132 | |
Kyungmin Park | c3fcf5d | 2009-11-17 08:41:17 +0100 | [diff] [blame] | 133 | static void s5pc100_idle(void) |
| 134 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 135 | if (!need_resched()) |
| 136 | cpu_do_idle(); |
Kyungmin Park | c3fcf5d | 2009-11-17 08:41:17 +0100 | [diff] [blame] | 137 | |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 138 | local_irq_enable(); |
Kyungmin Park | c3fcf5d | 2009-11-17 08:41:17 +0100 | [diff] [blame] | 139 | } |
| 140 | |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 141 | /* |
| 142 | * s5pc100_map_io |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 143 | * |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 144 | * register the standard CPU IO areas |
| 145 | */ |
| 146 | |
| 147 | void __init s5pc100_init_io(struct map_desc *mach_desc, int size) |
| 148 | { |
| 149 | /* initialize the io descriptors we need for initialization */ |
| 150 | iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc)); |
| 151 | if (mach_desc) |
| 152 | iotable_init(mach_desc, size); |
| 153 | |
| 154 | /* detect cpu id and rev. */ |
| 155 | s5p_init_cpu(S5P_VA_CHIPID); |
| 156 | |
| 157 | s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); |
| 158 | } |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 159 | |
| 160 | void __init s5pc100_map_io(void) |
| 161 | { |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 162 | /* initialise device information early */ |
Kyungmin Park | 86cd4f5 | 2009-11-17 08:41:23 +0100 | [diff] [blame] | 163 | s5pc100_default_sdhci0(); |
| 164 | s5pc100_default_sdhci1(); |
| 165 | s5pc100_default_sdhci2(); |
Kyungmin Park | 5eda288 | 2009-11-17 08:41:21 +0100 | [diff] [blame] | 166 | |
Naveen Krishna Ch | 327b903 | 2010-06-30 21:50:24 +0900 | [diff] [blame] | 167 | s3c_adc_setname("s3c64xx-adc"); |
| 168 | |
Kyungmin Park | 5eda288 | 2009-11-17 08:41:21 +0100 | [diff] [blame] | 169 | /* the i2c devices are directly compatible with s3c2440 */ |
| 170 | s3c_i2c0_setname("s3c2440-i2c"); |
| 171 | s3c_i2c1_setname("s3c2440-i2c"); |
Marek Szyprowski | 999304b | 2010-05-20 08:59:05 +0200 | [diff] [blame] | 172 | |
| 173 | s3c_onenand_setname("s5pc100-onenand"); |
Pawel Osciak | eb42b04 | 2010-08-10 18:02:37 -0700 | [diff] [blame] | 174 | s3c_fb_setname("s5pc100-fb"); |
Abhilash Kesavan | 66194a7 | 2010-06-08 17:02:08 +0900 | [diff] [blame] | 175 | s3c_cfcon_setname("s5pc100-pata"); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void __init s5pc100_init_clocks(int xtal) |
| 179 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 180 | printk(KERN_DEBUG "%s: initializing clocks\n", __func__); |
| 181 | |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 182 | s3c24xx_register_baseclocks(xtal); |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 183 | s5p_register_clocks(xtal); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 184 | s5pc100_register_clocks(); |
| 185 | s5pc100_setup_clocks(); |
| 186 | } |
| 187 | |
| 188 | void __init s5pc100_init_irq(void) |
| 189 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 190 | u32 vic[] = {~0, ~0, ~0}; |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 191 | |
| 192 | /* VIC0, VIC1, and VIC2 are fully populated. */ |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 193 | s5p_init_irq(vic, ARRAY_SIZE(vic)); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 194 | } |
| 195 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 196 | static struct bus_type s5pc100_subsys = { |
| 197 | .name = "s5pc100-core", |
| 198 | .dev_name = "s5pc100-core", |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 199 | }; |
| 200 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 201 | static struct device s5pc100_dev = { |
| 202 | .bus = &s5pc100_subsys, |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | static int __init s5pc100_core_init(void) |
| 206 | { |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 207 | return subsys_system_register(&s5pc100_subsys, NULL); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 208 | } |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 209 | core_initcall(s5pc100_core_init); |
| 210 | |
| 211 | int __init s5pc100_init(void) |
| 212 | { |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 213 | printk(KERN_INFO "S5PC100: Initializing architecture\n"); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 214 | |
Marek Szyprowski | acc8470 | 2010-05-20 07:51:08 +0200 | [diff] [blame] | 215 | /* set idle function */ |
| 216 | pm_idle = s5pc100_idle; |
Kyungmin Park | c3fcf5d | 2009-11-17 08:41:17 +0100 | [diff] [blame] | 217 | |
Kukjin Kim | ea04018 | 2012-01-06 16:08:09 +0900 | [diff] [blame] | 218 | return device_register(&s5pc100_dev); |
Byungho Min | 8acd1ad | 2009-06-23 21:40:15 +0900 | [diff] [blame] | 219 | } |
Kukjin Kim | dd4153d | 2011-12-22 23:31:28 +0100 | [diff] [blame] | 220 | |
| 221 | /* uart registration process */ |
| 222 | |
| 223 | void __init s5pc100_init_uarts(struct s3c2410_uartcfg *cfg, int no) |
| 224 | { |
| 225 | s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no); |
| 226 | } |
Kukjin Kim | 5497d2e | 2011-12-22 23:35:21 +0100 | [diff] [blame] | 227 | |
| 228 | void s5pc100_restart(char mode, const char *cmd) |
| 229 | { |
| 230 | if (mode != 's') |
| 231 | arch_wdt_reset(); |
| 232 | |
| 233 | soft_restart(0); |
| 234 | } |