Krzysztof Kozlowski | 4490e3c | 2017-12-25 20:54:35 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com/ |
| 5 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Copyright (c) 2004-2005 Simtec Electronics |
| 7 | * Ben Dooks <ben@simtec.co.uk> |
| 8 | * |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 9 | * Header file for Samsung CPU support |
Krzysztof Kozlowski | 4490e3c | 2017-12-25 20:54:35 +0100 | [diff] [blame] | 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
| 12 | /* todo - fix when rmk changes iodescs to use `void __iomem *` */ |
| 13 | |
Kyungmin Park | c3fcf5d | 2009-11-17 08:41:17 +0100 | [diff] [blame] | 14 | #ifndef __SAMSUNG_PLAT_CPU_H |
| 15 | #define __SAMSUNG_PLAT_CPU_H |
| 16 | |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 17 | extern unsigned long samsung_cpu_id; |
| 18 | |
Tomasz Figa | 0424106 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 19 | #define S3C2410_CPU_ID 0x32410000 |
| 20 | #define S3C2410_CPU_MASK 0xFFFFFFFF |
| 21 | |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 22 | #define S3C24XX_CPU_ID 0x32400000 |
| 23 | #define S3C24XX_CPU_MASK 0xFFF00000 |
| 24 | |
Heiko Stuebner | 9eecbe5 | 2013-02-12 10:12:06 -0800 | [diff] [blame] | 25 | #define S3C2412_CPU_ID 0x32412000 |
| 26 | #define S3C2412_CPU_MASK 0xFFFFF000 |
| 27 | |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 28 | #define S3C6400_CPU_ID 0x36400000 |
| 29 | #define S3C6410_CPU_ID 0x36410000 |
Mark Brown | 2747f5e56 | 2011-09-05 19:11:40 +0900 | [diff] [blame] | 30 | #define S3C64XX_CPU_MASK 0xFFFFF000 |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 31 | |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 32 | #define S5PV210_CPU_ID 0x43110000 |
| 33 | #define S5PV210_CPU_MASK 0xFFFFF000 |
| 34 | |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 35 | #define IS_SAMSUNG_CPU(name, id, mask) \ |
| 36 | static inline int is_samsung_##name(void) \ |
| 37 | { \ |
| 38 | return ((samsung_cpu_id & mask) == (id & mask)); \ |
| 39 | } |
| 40 | |
Tomasz Figa | 0424106 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 41 | IS_SAMSUNG_CPU(s3c2410, S3C2410_CPU_ID, S3C2410_CPU_MASK) |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 42 | IS_SAMSUNG_CPU(s3c24xx, S3C24XX_CPU_ID, S3C24XX_CPU_MASK) |
Heiko Stuebner | 9eecbe5 | 2013-02-12 10:12:06 -0800 | [diff] [blame] | 43 | IS_SAMSUNG_CPU(s3c2412, S3C2412_CPU_ID, S3C2412_CPU_MASK) |
Mark Brown | 0f4e54c | 2011-10-18 08:39:57 +0900 | [diff] [blame] | 44 | IS_SAMSUNG_CPU(s3c6400, S3C6400_CPU_ID, S3C64XX_CPU_MASK) |
| 45 | IS_SAMSUNG_CPU(s3c6410, S3C6410_CPU_ID, S3C64XX_CPU_MASK) |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 46 | |
| 47 | #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \ |
| 48 | defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2440) || \ |
| 49 | defined(CONFIG_CPU_S3C2442) || defined(CONFIG_CPU_S3C244X) || \ |
| 50 | defined(CONFIG_CPU_S3C2443) |
| 51 | # define soc_is_s3c24xx() is_samsung_s3c24xx() |
Tomasz Figa | 0424106 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 52 | # define soc_is_s3c2410() is_samsung_s3c2410() |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 53 | #else |
| 54 | # define soc_is_s3c24xx() 0 |
Tomasz Figa | 0424106 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 55 | # define soc_is_s3c2410() 0 |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 56 | #endif |
| 57 | |
Heiko Stuebner | 9eecbe5 | 2013-02-12 10:12:06 -0800 | [diff] [blame] | 58 | #if defined(CONFIG_CPU_S3C2412) |
| 59 | # define soc_is_s3c2412() is_samsung_s3c2412() |
| 60 | #else |
| 61 | # define soc_is_s3c2412() 0 |
| 62 | #endif |
| 63 | |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 64 | #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410) |
Tomasz Figa | 57a2312 | 2013-08-26 02:00:37 +0900 | [diff] [blame] | 65 | # define soc_is_s3c6400() is_samsung_s3c6400() |
| 66 | # define soc_is_s3c6410() is_samsung_s3c6410() |
Mark Brown | 0f4e54c | 2011-10-18 08:39:57 +0900 | [diff] [blame] | 67 | # define soc_is_s3c64xx() (is_samsung_s3c6400() || is_samsung_s3c6410()) |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 68 | #else |
Tomasz Figa | 57a2312 | 2013-08-26 02:00:37 +0900 | [diff] [blame] | 69 | # define soc_is_s3c6400() 0 |
| 70 | # define soc_is_s3c6410() 0 |
Kukjin Kim | c06af3c | 2011-08-20 02:18:18 +0900 | [diff] [blame] | 71 | # define soc_is_s3c64xx() 0 |
| 72 | #endif |
| 73 | |
Lucas Correia Villa Real | 0367a8d | 2006-01-26 15:20:50 +0000 | [diff] [blame] | 74 | #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Sachin Kamat | c4c7135 | 2012-06-20 16:34:25 +0900 | [diff] [blame] | 76 | #ifndef KHZ |
| 77 | #define KHZ (1000) |
| 78 | #endif |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #ifndef MHZ |
| 81 | #define MHZ (1000*1000) |
| 82 | #endif |
| 83 | |
Ben Dooks | a503059 | 2008-10-21 14:06:43 +0100 | [diff] [blame] | 84 | #define print_mhz(m) ((m) / MHZ), (((m) / 1000) % 1000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | /* forward declaration */ |
Ben Dooks | 66a9b49 | 2006-06-18 23:04:05 +0100 | [diff] [blame] | 87 | struct s3c24xx_uart_resources; |
| 88 | struct platform_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | struct s3c2410_uartcfg; |
| 90 | struct map_desc; |
| 91 | |
Ben Dooks | 74b265d | 2008-10-21 14:06:31 +0100 | [diff] [blame] | 92 | /* per-cpu initialisation function table. */ |
| 93 | |
| 94 | struct cpu_table { |
| 95 | unsigned long idcode; |
| 96 | unsigned long idmask; |
| 97 | void (*map_io)(void); |
| 98 | void (*init_uarts)(struct s3c2410_uartcfg *cfg, int no); |
| 99 | void (*init_clocks)(int xtal); |
| 100 | int (*init)(void); |
| 101 | const char *name; |
| 102 | }; |
| 103 | |
| 104 | extern void s3c_init_cpu(unsigned long idcode, |
| 105 | struct cpu_table *cpus, unsigned int cputab_size); |
| 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | /* core initialisation functions */ |
| 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | extern void s3c24xx_init_io(struct map_desc *mach_desc, int size); |
| 110 | |
Kukjin Kim | e6d1cb9 | 2011-08-20 12:18:07 +0900 | [diff] [blame] | 111 | extern void s3c64xx_init_cpu(void); |
Kukjin Kim | 56b2092 | 2011-08-20 13:41:21 +0900 | [diff] [blame] | 112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | extern void s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no); |
| 114 | |
| 115 | extern void s3c24xx_init_clocks(int xtal); |
| 116 | |
Ben Dooks | 66a9b49 | 2006-06-18 23:04:05 +0100 | [diff] [blame] | 117 | extern void s3c24xx_init_uartdevs(char *name, |
| 118 | struct s3c24xx_uart_resources *res, |
| 119 | struct s3c2410_uartcfg *cfg, int no); |
| 120 | |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 121 | extern struct syscore_ops s3c2410_pm_syscore_ops; |
| 122 | extern struct syscore_ops s3c2412_pm_syscore_ops; |
| 123 | extern struct syscore_ops s3c2416_pm_syscore_ops; |
| 124 | extern struct syscore_ops s3c244x_pm_syscore_ops; |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 125 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 126 | extern struct bus_type s3c6410_subsys; |
Ben Dooks | 1deb507 | 2008-12-12 00:24:31 +0000 | [diff] [blame] | 127 | |
Kyungmin Park | c3fcf5d | 2009-11-17 08:41:17 +0100 | [diff] [blame] | 128 | #endif |