1 /* 2 * Copyright (c) 2011 Samsung Electronics Co., Ltd. 3 * http://www.samsung.com 4 * 5 * Common Header for EXYNOS machines 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 */ 11 12 #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H 13 #define __ARCH_ARM_MACH_EXYNOS_COMMON_H 14 15 #include <linux/platform_data/cpuidle-exynos.h> 16 17 #define EXYNOS3250_SOC_ID 0xE3472000 18 #define EXYNOS3_SOC_MASK 0xFFFFF000 19 20 #define EXYNOS4210_CPU_ID 0x43210000 21 #define EXYNOS4412_CPU_ID 0xE4412200 22 #define EXYNOS4_CPU_MASK 0xFFFE0000 23 24 #define EXYNOS5250_SOC_ID 0x43520000 25 #define EXYNOS5410_SOC_ID 0xE5410000 26 #define EXYNOS5420_SOC_ID 0xE5420000 27 #define EXYNOS5440_SOC_ID 0xE5440000 28 #define EXYNOS5800_SOC_ID 0xE5422000 29 #define EXYNOS5_SOC_MASK 0xFFFFF000 30 31 extern unsigned long samsung_cpu_id; 32 33 #define IS_SAMSUNG_CPU(name, id, mask) \ 34 static inline int is_samsung_##name(void) \ 35 { \ 36 return ((samsung_cpu_id & mask) == (id & mask)); \ 37 } 38 39 IS_SAMSUNG_CPU(exynos3250, EXYNOS3250_SOC_ID, EXYNOS3_SOC_MASK) 40 IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK) 41 IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK) 42 IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK) 43 IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK) 44 IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK) 45 IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK) 46 IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK) 47 48 #if defined(CONFIG_SOC_EXYNOS3250) 49 # define soc_is_exynos3250() is_samsung_exynos3250() 50 #else 51 # define soc_is_exynos3250() 0 52 #endif 53 54 #if defined(CONFIG_CPU_EXYNOS4210) 55 # define soc_is_exynos4210() is_samsung_exynos4210() 56 #else 57 # define soc_is_exynos4210() 0 58 #endif 59 60 #if defined(CONFIG_SOC_EXYNOS4412) 61 # define soc_is_exynos4412() is_samsung_exynos4412() 62 #else 63 # define soc_is_exynos4412() 0 64 #endif 65 66 #define EXYNOS4210_REV_0 (0x0) 67 #define EXYNOS4210_REV_1_0 (0x10) 68 #define EXYNOS4210_REV_1_1 (0x11) 69 70 #if defined(CONFIG_SOC_EXYNOS5250) 71 # define soc_is_exynos5250() is_samsung_exynos5250() 72 #else 73 # define soc_is_exynos5250() 0 74 #endif 75 76 #if defined(CONFIG_SOC_EXYNOS5410) 77 # define soc_is_exynos5410() is_samsung_exynos5410() 78 #else 79 # define soc_is_exynos5410() 0 80 #endif 81 82 #if defined(CONFIG_SOC_EXYNOS5420) 83 # define soc_is_exynos5420() is_samsung_exynos5420() 84 #else 85 # define soc_is_exynos5420() 0 86 #endif 87 88 #if defined(CONFIG_SOC_EXYNOS5440) 89 # define soc_is_exynos5440() is_samsung_exynos5440() 90 #else 91 # define soc_is_exynos5440() 0 92 #endif 93 94 #if defined(CONFIG_SOC_EXYNOS5800) 95 # define soc_is_exynos5800() is_samsung_exynos5800() 96 #else 97 # define soc_is_exynos5800() 0 98 #endif 99 100 #define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4412()) 101 #define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5410() || \ 102 soc_is_exynos5420() || soc_is_exynos5800()) 103 104 extern u32 cp15_save_diag; 105 extern u32 cp15_save_power; 106 107 extern void __iomem *sysram_ns_base_addr; 108 extern void __iomem *sysram_base_addr; 109 extern void __iomem *pmu_base_addr; 110 void exynos_sysram_init(void); 111 112 enum { 113 FW_DO_IDLE_SLEEP, 114 FW_DO_IDLE_AFTR, 115 }; 116 117 void exynos_firmware_init(void); 118 119 /* CPU BOOT mode flag for Exynos3250 SoC bootloader */ 120 #define C2_STATE (1 << 3) 121 /* 122 * Magic values for bootloader indicating chosen low power mode. 123 * See also Documentation/arm/Samsung/Bootloader-interface.txt 124 */ 125 #define EXYNOS_SLEEP_MAGIC 0x00000bad 126 #define EXYNOS_AFTR_MAGIC 0xfcba0d10 127 128 void exynos_set_boot_flag(unsigned int cpu, unsigned int mode); 129 void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode); 130 131 extern u32 exynos_get_eint_wake_mask(void); 132 133 #ifdef CONFIG_PM_SLEEP 134 extern void __init exynos_pm_init(void); 135 #else 136 static inline void exynos_pm_init(void) {} 137 #endif 138 139 extern void exynos_cpu_resume(void); 140 extern void exynos_cpu_resume_ns(void); 141 142 extern const struct smp_operations exynos_smp_ops; 143 144 extern void exynos_cpu_power_down(int cpu); 145 extern void exynos_cpu_power_up(int cpu); 146 extern int exynos_cpu_power_state(int cpu); 147 extern void exynos_cluster_power_down(int cluster); 148 extern void exynos_cluster_power_up(int cluster); 149 extern int exynos_cluster_power_state(int cluster); 150 extern void exynos_cpu_save_register(void); 151 extern void exynos_cpu_restore_register(void); 152 extern void exynos_pm_central_suspend(void); 153 extern int exynos_pm_central_resume(void); 154 extern void exynos_enter_aftr(void); 155 156 extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data; 157 158 extern void exynos_set_delayed_reset_assertion(bool enable); 159 160 extern unsigned int samsung_rev(void); 161 extern void exynos_core_restart(u32 core_id); 162 extern int exynos_set_boot_addr(u32 core_id, unsigned long boot_addr); 163 extern int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr); 164 165 static inline void pmu_raw_writel(u32 val, u32 offset) 166 { 167 writel_relaxed(val, pmu_base_addr + offset); 168 } 169 170 static inline u32 pmu_raw_readl(u32 offset) 171 { 172 return readl_relaxed(pmu_base_addr + offset); 173 } 174 175 #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ 176