Krzysztof Kozlowski | 347863d | 2017-12-25 20:54:31 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com |
| 5 | * |
Krzysztof Kozlowski | 45984f0 | 2020-01-04 16:20:51 +0100 | [diff] [blame] | 6 | * Common Header for Exynos machines |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H |
| 10 | #define __ARCH_ARM_MACH_EXYNOS_COMMON_H |
| 11 | |
Bartlomiej Zolnierkiewicz | 712eddf7 | 2015-01-24 14:05:50 +0900 | [diff] [blame] | 12 | #include <linux/platform_data/cpuidle-exynos.h> |
Thomas Abraham | 6e6aac7 | 2013-03-09 17:03:05 +0900 | [diff] [blame] | 13 | |
Chanwoo Choi | 940bc58 | 2014-05-26 04:12:26 +0900 | [diff] [blame] | 14 | #define EXYNOS3250_SOC_ID 0xE3472000 |
| 15 | #define EXYNOS3_SOC_MASK 0xFFFFF000 |
| 16 | |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 17 | #define EXYNOS4210_CPU_ID 0x43210000 |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 18 | #define EXYNOS4412_CPU_ID 0xE4412200 |
| 19 | #define EXYNOS4_CPU_MASK 0xFFFE0000 |
| 20 | |
| 21 | #define EXYNOS5250_SOC_ID 0x43520000 |
Tarek Dakhran | 723c9c7 | 2014-05-27 06:54:12 +0900 | [diff] [blame] | 22 | #define EXYNOS5410_SOC_ID 0xE5410000 |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 23 | #define EXYNOS5420_SOC_ID 0xE5420000 |
Arun Kumar K | 86c6f14 | 2014-05-26 04:16:11 +0900 | [diff] [blame] | 24 | #define EXYNOS5800_SOC_ID 0xE5422000 |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 25 | #define EXYNOS5_SOC_MASK 0xFFFFF000 |
| 26 | |
| 27 | extern unsigned long samsung_cpu_id; |
| 28 | |
| 29 | #define IS_SAMSUNG_CPU(name, id, mask) \ |
| 30 | static inline int is_samsung_##name(void) \ |
| 31 | { \ |
| 32 | return ((samsung_cpu_id & mask) == (id & mask)); \ |
| 33 | } |
| 34 | |
Chanwoo Choi | 940bc58 | 2014-05-26 04:12:26 +0900 | [diff] [blame] | 35 | IS_SAMSUNG_CPU(exynos3250, EXYNOS3250_SOC_ID, EXYNOS3_SOC_MASK) |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 36 | IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK) |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 37 | IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK) |
| 38 | IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK) |
Tarek Dakhran | 723c9c7 | 2014-05-27 06:54:12 +0900 | [diff] [blame] | 39 | IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK) |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 40 | IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK) |
Arun Kumar K | 86c6f14 | 2014-05-26 04:16:11 +0900 | [diff] [blame] | 41 | IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK) |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 42 | |
Chanwoo Choi | 940bc58 | 2014-05-26 04:12:26 +0900 | [diff] [blame] | 43 | #if defined(CONFIG_SOC_EXYNOS3250) |
| 44 | # define soc_is_exynos3250() is_samsung_exynos3250() |
| 45 | #else |
| 46 | # define soc_is_exynos3250() 0 |
| 47 | #endif |
| 48 | |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 49 | #if defined(CONFIG_CPU_EXYNOS4210) |
| 50 | # define soc_is_exynos4210() is_samsung_exynos4210() |
| 51 | #else |
| 52 | # define soc_is_exynos4210() 0 |
| 53 | #endif |
| 54 | |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 55 | #if defined(CONFIG_SOC_EXYNOS4412) |
| 56 | # define soc_is_exynos4412() is_samsung_exynos4412() |
| 57 | #else |
| 58 | # define soc_is_exynos4412() 0 |
| 59 | #endif |
| 60 | |
| 61 | #define EXYNOS4210_REV_0 (0x0) |
| 62 | #define EXYNOS4210_REV_1_0 (0x10) |
| 63 | #define EXYNOS4210_REV_1_1 (0x11) |
| 64 | |
| 65 | #if defined(CONFIG_SOC_EXYNOS5250) |
| 66 | # define soc_is_exynos5250() is_samsung_exynos5250() |
| 67 | #else |
| 68 | # define soc_is_exynos5250() 0 |
| 69 | #endif |
| 70 | |
Tarek Dakhran | 723c9c7 | 2014-05-27 06:54:12 +0900 | [diff] [blame] | 71 | #if defined(CONFIG_SOC_EXYNOS5410) |
| 72 | # define soc_is_exynos5410() is_samsung_exynos5410() |
| 73 | #else |
| 74 | # define soc_is_exynos5410() 0 |
| 75 | #endif |
| 76 | |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 77 | #if defined(CONFIG_SOC_EXYNOS5420) |
| 78 | # define soc_is_exynos5420() is_samsung_exynos5420() |
| 79 | #else |
| 80 | # define soc_is_exynos5420() 0 |
| 81 | #endif |
| 82 | |
Arun Kumar K | 86c6f14 | 2014-05-26 04:16:11 +0900 | [diff] [blame] | 83 | #if defined(CONFIG_SOC_EXYNOS5800) |
| 84 | # define soc_is_exynos5800() is_samsung_exynos5800() |
| 85 | #else |
| 86 | # define soc_is_exynos5800() 0 |
| 87 | #endif |
| 88 | |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 89 | extern u32 cp15_save_diag; |
| 90 | extern u32 cp15_save_power; |
| 91 | |
Sachin Kamat | b3205de | 2014-05-13 07:13:44 +0900 | [diff] [blame] | 92 | extern void __iomem *sysram_ns_base_addr; |
Daniel Lezcano | cd245f5 | 2014-05-26 04:50:34 +0900 | [diff] [blame] | 93 | extern void __iomem *sysram_base_addr; |
Joonyoung Shim | 3a1f2f3 | 2019-02-18 15:34:11 +0100 | [diff] [blame] | 94 | extern phys_addr_t sysram_base_phys; |
Pankaj Dubey | fce9e5b | 2014-07-11 08:08:29 +0900 | [diff] [blame] | 95 | extern void __iomem *pmu_base_addr; |
Olof Johansson | 1754c42 | 2014-06-02 21:47:46 -0700 | [diff] [blame] | 96 | void exynos_sysram_init(void); |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 97 | |
Bartlomiej Zolnierkiewicz | 0b7778a | 2014-09-25 17:59:41 +0900 | [diff] [blame] | 98 | enum { |
| 99 | FW_DO_IDLE_SLEEP, |
| 100 | FW_DO_IDLE_AFTR, |
| 101 | }; |
| 102 | |
Tomasz Figa | bca28f8 | 2012-12-11 13:58:43 +0900 | [diff] [blame] | 103 | void exynos_firmware_init(void); |
| 104 | |
Bartlomiej Zolnierkiewicz | dc1b944 | 2015-03-27 02:32:56 +0900 | [diff] [blame] | 105 | /* CPU BOOT mode flag for Exynos3250 SoC bootloader */ |
| 106 | #define C2_STATE (1 << 3) |
Krzysztof Kozlowski | 054e6aa | 2015-06-14 13:38:23 +0900 | [diff] [blame] | 107 | /* |
| 108 | * Magic values for bootloader indicating chosen low power mode. |
Mauro Carvalho Chehab | dc7a12b | 2019-04-14 15:51:10 -0300 | [diff] [blame] | 109 | * See also Documentation/arm/samsung/bootloader-interface.rst |
Krzysztof Kozlowski | 054e6aa | 2015-06-14 13:38:23 +0900 | [diff] [blame] | 110 | */ |
| 111 | #define EXYNOS_SLEEP_MAGIC 0x00000bad |
| 112 | #define EXYNOS_AFTR_MAGIC 0xfcba0d10 |
Bartlomiej Zolnierkiewicz | dc1b944 | 2015-03-27 02:32:56 +0900 | [diff] [blame] | 113 | |
Krzysztof Kozlowski | e0b35c1 | 2018-07-24 18:49:46 +0200 | [diff] [blame] | 114 | bool __init exynos_secure_firmware_available(void); |
Bartlomiej Zolnierkiewicz | dc1b944 | 2015-03-27 02:32:56 +0900 | [diff] [blame] | 115 | void exynos_set_boot_flag(unsigned int cpu, unsigned int mode); |
| 116 | void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode); |
| 117 | |
Tomasz Figa | 559ba23 | 2014-03-18 07:28:22 +0900 | [diff] [blame] | 118 | #ifdef CONFIG_PM_SLEEP |
| 119 | extern void __init exynos_pm_init(void); |
| 120 | #else |
| 121 | static inline void exynos_pm_init(void) {} |
| 122 | #endif |
| 123 | |
Tomasz Figa | d710aa3 | 2014-03-18 07:28:27 +0900 | [diff] [blame] | 124 | extern void exynos_cpu_resume(void); |
Tomasz Figa | 2b9d9c3 | 2014-09-24 01:24:39 +0900 | [diff] [blame] | 125 | extern void exynos_cpu_resume_ns(void); |
Tomasz Figa | d710aa3 | 2014-03-18 07:28:27 +0900 | [diff] [blame] | 126 | |
Masahiro Yamada | 7530527 | 2015-11-15 10:39:53 +0900 | [diff] [blame] | 127 | extern const struct smp_operations exynos_smp_ops; |
Marc Zyngier | 06853ae | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 128 | |
Leela Krishna Amudala | d3af697 | 2014-05-16 04:23:24 +0900 | [diff] [blame] | 129 | extern void exynos_cpu_power_down(int cpu); |
| 130 | extern void exynos_cpu_power_up(int cpu); |
| 131 | extern int exynos_cpu_power_state(int cpu); |
Abhilash Kesavan | 096d21c | 2014-05-16 04:23:26 +0900 | [diff] [blame] | 132 | extern void exynos_cluster_power_down(int cluster); |
| 133 | extern void exynos_cluster_power_up(int cluster); |
| 134 | extern int exynos_cluster_power_state(int cluster); |
Bartlomiej Zolnierkiewicz | 0d713cf | 2014-09-25 18:02:45 +0900 | [diff] [blame] | 135 | extern void exynos_cpu_save_register(void); |
| 136 | extern void exynos_cpu_restore_register(void); |
| 137 | extern void exynos_pm_central_suspend(void); |
| 138 | extern int exynos_pm_central_resume(void); |
Daniel Lezcano | 3681baf | 2014-05-09 06:53:00 +0900 | [diff] [blame] | 139 | extern void exynos_enter_aftr(void); |
Pankaj Dubey | 3c33710 | 2018-05-10 13:02:54 +0200 | [diff] [blame] | 140 | #ifdef CONFIG_SMP |
| 141 | extern void exynos_scu_enable(void); |
| 142 | #else |
| 143 | static inline void exynos_scu_enable(void) { } |
| 144 | #endif |
Kukjin Kim | ccd458c | 2012-12-31 10:06:48 -0800 | [diff] [blame] | 145 | |
Bartlomiej Zolnierkiewicz | 712eddf7 | 2015-01-24 14:05:50 +0900 | [diff] [blame] | 146 | extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data; |
| 147 | |
Krzysztof Kozlowski | 6f02497 | 2015-03-11 11:13:57 +0100 | [diff] [blame] | 148 | extern void exynos_set_delayed_reset_assertion(bool enable); |
| 149 | |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 150 | extern unsigned int samsung_rev(void); |
Bartlomiej Zolnierkiewicz | af99711 | 2015-03-18 14:09:57 +0100 | [diff] [blame] | 151 | extern void exynos_core_restart(u32 core_id); |
| 152 | extern int exynos_set_boot_addr(u32 core_id, unsigned long boot_addr); |
| 153 | extern int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr); |
Sachin Kamat | 7cb2ded | 2014-05-13 07:11:57 +0900 | [diff] [blame] | 154 | |
Pankaj Dubey | 2e94ac4 | 2014-07-19 03:43:22 +0900 | [diff] [blame] | 155 | static inline void pmu_raw_writel(u32 val, u32 offset) |
| 156 | { |
Ben Dooks | d0ceee0 | 2016-06-21 11:20:25 +0100 | [diff] [blame] | 157 | writel_relaxed(val, pmu_base_addr + offset); |
Pankaj Dubey | 2e94ac4 | 2014-07-19 03:43:22 +0900 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | static inline u32 pmu_raw_readl(u32 offset) |
| 161 | { |
Ben Dooks | d0ceee0 | 2016-06-21 11:20:25 +0100 | [diff] [blame] | 162 | return readl_relaxed(pmu_base_addr + offset); |
Pankaj Dubey | 2e94ac4 | 2014-07-19 03:43:22 +0900 | [diff] [blame] | 163 | } |
| 164 | |
Kukjin Kim | cc511b8 | 2011-12-27 08:18:36 +0100 | [diff] [blame] | 165 | #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ |