Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/plat-s3c64xx/cpu.c |
| 2 | * |
| 3 | * Copyright 2008 Openmoko, Inc. |
| 4 | * Copyright 2008 Simtec Electronics |
| 5 | * Ben Dooks <ben@simtec.co.uk> |
| 6 | * http://armlinux.simtec.co.uk/ |
| 7 | * |
| 8 | * S3C64XX CPU Support |
| 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. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/ioport.h> |
Ben Dooks | 1deb507 | 2008-12-12 00:24:31 +0000 | [diff] [blame] | 19 | #include <linux/sysdev.h> |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 20 | #include <linux/serial_core.h> |
| 21 | #include <linux/platform_device.h> |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Jon Medhurst | 284dc06 | 2011-08-04 16:41:43 +0100 | [diff] [blame] | 23 | #include <linux/dma-mapping.h> |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 24 | |
| 25 | #include <mach/hardware.h> |
| 26 | #include <mach/map.h> |
| 27 | |
| 28 | #include <asm/mach/arch.h> |
| 29 | #include <asm/mach/map.h> |
| 30 | |
| 31 | #include <plat/regs-serial.h> |
| 32 | |
| 33 | #include <plat/cpu.h> |
| 34 | #include <plat/devs.h> |
| 35 | #include <plat/clock.h> |
| 36 | |
Ben Dooks | f7be9ab | 2010-01-26 13:41:30 +0900 | [diff] [blame] | 37 | #include <mach/s3c6400.h> |
| 38 | #include <mach/s3c6410.h> |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 39 | |
| 40 | /* table of supported CPUs */ |
| 41 | |
| 42 | static const char name_s3c6400[] = "S3C6400"; |
| 43 | static const char name_s3c6410[] = "S3C6410"; |
| 44 | |
| 45 | static struct cpu_table cpu_ids[] __initdata = { |
| 46 | { |
| 47 | .idcode = 0x36400000, |
| 48 | .idmask = 0xfffff000, |
| 49 | .map_io = s3c6400_map_io, |
| 50 | .init_clocks = s3c6400_init_clocks, |
| 51 | .init_uarts = s3c6400_init_uarts, |
| 52 | .init = s3c6400_init, |
| 53 | .name = name_s3c6400, |
| 54 | }, { |
| 55 | .idcode = 0x36410100, |
| 56 | .idmask = 0xffffff00, |
| 57 | .map_io = s3c6410_map_io, |
| 58 | .init_clocks = s3c6410_init_clocks, |
| 59 | .init_uarts = s3c6410_init_uarts, |
| 60 | .init = s3c6410_init, |
| 61 | .name = name_s3c6410, |
| 62 | }, |
| 63 | }; |
| 64 | |
| 65 | /* minimal IO mapping */ |
| 66 | |
| 67 | /* see notes on uart map in arch/arm/mach-s3c6400/include/mach/debug-macro.S */ |
| 68 | #define UART_OFFS (S3C_PA_UART & 0xfffff) |
| 69 | |
| 70 | static struct map_desc s3c_iodesc[] __initdata = { |
| 71 | { |
Ben Dooks | f945ee1 | 2008-10-21 14:07:13 +0100 | [diff] [blame] | 72 | .virtual = (unsigned long)S3C_VA_SYS, |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 73 | .pfn = __phys_to_pfn(S3C64XX_PA_SYSCON), |
| 74 | .length = SZ_4K, |
| 75 | .type = MT_DEVICE, |
| 76 | }, { |
Andy Green | 810f613 | 2009-12-29 14:40:30 +0000 | [diff] [blame] | 77 | .virtual = (unsigned long)S3C_VA_MEM, |
| 78 | .pfn = __phys_to_pfn(S3C64XX_PA_SROM), |
| 79 | .length = SZ_4K, |
| 80 | .type = MT_DEVICE, |
| 81 | }, { |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 82 | .virtual = (unsigned long)(S3C_VA_UART + UART_OFFS), |
| 83 | .pfn = __phys_to_pfn(S3C_PA_UART), |
| 84 | .length = SZ_4K, |
| 85 | .type = MT_DEVICE, |
| 86 | }, { |
Ben Dooks | 5b39be4 | 2010-01-07 08:59:26 +0900 | [diff] [blame] | 87 | .virtual = (unsigned long)VA_VIC0, |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 88 | .pfn = __phys_to_pfn(S3C64XX_PA_VIC0), |
| 89 | .length = SZ_16K, |
| 90 | .type = MT_DEVICE, |
| 91 | }, { |
Ben Dooks | 5b39be4 | 2010-01-07 08:59:26 +0900 | [diff] [blame] | 92 | .virtual = (unsigned long)VA_VIC1, |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 93 | .pfn = __phys_to_pfn(S3C64XX_PA_VIC1), |
| 94 | .length = SZ_16K, |
| 95 | .type = MT_DEVICE, |
Ben Dooks | f982dc5 | 2008-10-21 14:06:57 +0100 | [diff] [blame] | 96 | }, { |
Ben Dooks | f945ee1 | 2008-10-21 14:07:13 +0100 | [diff] [blame] | 97 | .virtual = (unsigned long)S3C_VA_TIMER, |
Ben Dooks | f982dc5 | 2008-10-21 14:06:57 +0100 | [diff] [blame] | 98 | .pfn = __phys_to_pfn(S3C_PA_TIMER), |
| 99 | .length = SZ_16K, |
| 100 | .type = MT_DEVICE, |
Ben Dooks | 94df868 | 2008-10-21 14:07:07 +0100 | [diff] [blame] | 101 | }, { |
Ben Dooks | f945ee1 | 2008-10-21 14:07:13 +0100 | [diff] [blame] | 102 | .virtual = (unsigned long)S3C64XX_VA_GPIO, |
Ben Dooks | 94df868 | 2008-10-21 14:07:07 +0100 | [diff] [blame] | 103 | .pfn = __phys_to_pfn(S3C64XX_PA_GPIO), |
| 104 | .length = SZ_4K, |
| 105 | .type = MT_DEVICE, |
Ben Dooks | 5b3d515 | 2008-12-12 00:24:38 +0000 | [diff] [blame] | 106 | }, { |
| 107 | .virtual = (unsigned long)S3C64XX_VA_MODEM, |
| 108 | .pfn = __phys_to_pfn(S3C64XX_PA_MODEM), |
| 109 | .length = SZ_4K, |
| 110 | .type = MT_DEVICE, |
Ben Dooks | 543899f | 2009-05-17 23:40:30 +0100 | [diff] [blame] | 111 | }, { |
| 112 | .virtual = (unsigned long)S3C_VA_WATCHDOG, |
| 113 | .pfn = __phys_to_pfn(S3C64XX_PA_WATCHDOG), |
| 114 | .length = SZ_4K, |
| 115 | .type = MT_DEVICE, |
Maurus Cuelenaere | 23196a4 | 2009-11-20 13:04:08 +0100 | [diff] [blame] | 116 | }, { |
| 117 | .virtual = (unsigned long)S3C_VA_USB_HSPHY, |
| 118 | .pfn = __phys_to_pfn(S3C64XX_PA_USB_HSPHY), |
| 119 | .length = SZ_1K, |
| 120 | .type = MT_DEVICE, |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 121 | }, |
| 122 | }; |
| 123 | |
Ben Dooks | 1deb507 | 2008-12-12 00:24:31 +0000 | [diff] [blame] | 124 | |
| 125 | struct sysdev_class s3c64xx_sysclass = { |
| 126 | .name = "s3c64xx-core", |
| 127 | }; |
| 128 | |
| 129 | static struct sys_device s3c64xx_sysdev = { |
| 130 | .cls = &s3c64xx_sysclass, |
| 131 | }; |
| 132 | |
Ben Dooks | 6ce8fde | 2010-01-26 14:32:09 +0900 | [diff] [blame] | 133 | /* uart registration process */ |
| 134 | |
| 135 | void __init s3c6400_common_init_uarts(struct s3c2410_uartcfg *cfg, int no) |
| 136 | { |
| 137 | s3c24xx_init_uartdevs("s3c6400-uart", s3c64xx_uart_resources, cfg, no); |
| 138 | } |
Ben Dooks | 1deb507 | 2008-12-12 00:24:31 +0000 | [diff] [blame] | 139 | |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 140 | /* read cpu identification code */ |
| 141 | |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 142 | void __init s3c64xx_init_io(struct map_desc *mach_desc, int size) |
| 143 | { |
| 144 | unsigned long idcode; |
| 145 | |
| 146 | /* initialise the io descriptors we need for initialisation */ |
| 147 | iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); |
| 148 | iotable_init(mach_desc, size); |
Jon Medhurst | 284dc06 | 2011-08-04 16:41:43 +0100 | [diff] [blame] | 149 | init_consistent_dma_size(SZ_8M); |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 150 | |
| 151 | idcode = __raw_readl(S3C_VA_SYS + 0x118); |
Ben Dooks | e074f98 | 2009-03-24 17:31:42 +0000 | [diff] [blame] | 152 | if (!idcode) { |
| 153 | /* S3C6400 has the ID register in a different place, |
| 154 | * and needs a write before it can be read. */ |
| 155 | |
| 156 | __raw_writel(0x0, S3C_VA_SYS + 0xA1C); |
| 157 | idcode = __raw_readl(S3C_VA_SYS + 0xA1C); |
| 158 | } |
| 159 | |
Ben Dooks | beda30f | 2008-10-21 14:06:49 +0100 | [diff] [blame] | 160 | s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids)); |
| 161 | } |
Ben Dooks | 1deb507 | 2008-12-12 00:24:31 +0000 | [diff] [blame] | 162 | |
| 163 | static __init int s3c64xx_sysdev_init(void) |
| 164 | { |
| 165 | sysdev_class_register(&s3c64xx_sysclass); |
| 166 | return sysdev_register(&s3c64xx_sysdev); |
| 167 | } |
| 168 | |
| 169 | core_initcall(s3c64xx_sysdev_init); |