xref: /linux/arch/arm/mach-exynos/common.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
1347863d4SKrzysztof Kozlowski /* SPDX-License-Identifier: GPL-2.0 */
2cc511b8dSKukjin Kim /*
3cc511b8dSKukjin Kim  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4cc511b8dSKukjin Kim  *		http://www.samsung.com
5cc511b8dSKukjin Kim  *
645984f0cSKrzysztof Kozlowski  * Common Header for Exynos machines
7cc511b8dSKukjin Kim  */
8cc511b8dSKukjin Kim 
9cc511b8dSKukjin Kim #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
10cc511b8dSKukjin Kim #define __ARCH_ARM_MACH_EXYNOS_COMMON_H
11cc511b8dSKukjin Kim 
12712eddf7SBartlomiej Zolnierkiewicz #include <linux/platform_data/cpuidle-exynos.h>
136e6aac75SThomas Abraham 
14940bc58dSChanwoo Choi #define EXYNOS3250_SOC_ID	0xE3472000
15940bc58dSChanwoo Choi #define EXYNOS3_SOC_MASK	0xFFFFF000
16940bc58dSChanwoo Choi 
177cb2ded1SSachin Kamat #define EXYNOS4210_CPU_ID	0x43210000
184e486a65SArtur Weber #define EXYNOS4212_CPU_ID	0x43220000
197cb2ded1SSachin Kamat #define EXYNOS4412_CPU_ID	0xE4412200
207cb2ded1SSachin Kamat #define EXYNOS4_CPU_MASK	0xFFFE0000
217cb2ded1SSachin Kamat 
227cb2ded1SSachin Kamat #define EXYNOS5250_SOC_ID	0x43520000
23723c9c7eSTarek Dakhran #define EXYNOS5410_SOC_ID	0xE5410000
247cb2ded1SSachin Kamat #define EXYNOS5420_SOC_ID	0xE5420000
2586c6f148SArun Kumar K #define EXYNOS5800_SOC_ID	0xE5422000
267cb2ded1SSachin Kamat #define EXYNOS5_SOC_MASK	0xFFFFF000
277cb2ded1SSachin Kamat 
28edaff7e1SArnd Bergmann extern unsigned long exynos_cpu_id;
297cb2ded1SSachin Kamat 
307cb2ded1SSachin Kamat #define IS_SAMSUNG_CPU(name, id, mask)		\
317cb2ded1SSachin Kamat static inline int is_samsung_##name(void)	\
327cb2ded1SSachin Kamat {						\
33edaff7e1SArnd Bergmann 	return ((exynos_cpu_id & mask) == (id & mask));	\
347cb2ded1SSachin Kamat }
357cb2ded1SSachin Kamat 
36940bc58dSChanwoo Choi IS_SAMSUNG_CPU(exynos3250, EXYNOS3250_SOC_ID, EXYNOS3_SOC_MASK)
377cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
384e486a65SArtur Weber IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK)
397cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
407cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
41723c9c7eSTarek Dakhran IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK)
427cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
4386c6f148SArun Kumar K IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
447cb2ded1SSachin Kamat 
45940bc58dSChanwoo Choi #if defined(CONFIG_SOC_EXYNOS3250)
46940bc58dSChanwoo Choi # define soc_is_exynos3250()	is_samsung_exynos3250()
47940bc58dSChanwoo Choi #else
48940bc58dSChanwoo Choi # define soc_is_exynos3250()	0
49940bc58dSChanwoo Choi #endif
50940bc58dSChanwoo Choi 
517cb2ded1SSachin Kamat #if defined(CONFIG_CPU_EXYNOS4210)
527cb2ded1SSachin Kamat # define soc_is_exynos4210()	is_samsung_exynos4210()
537cb2ded1SSachin Kamat #else
547cb2ded1SSachin Kamat # define soc_is_exynos4210()	0
557cb2ded1SSachin Kamat #endif
567cb2ded1SSachin Kamat 
574e486a65SArtur Weber #if defined(CONFIG_SOC_EXYNOS4212)
584e486a65SArtur Weber # define soc_is_exynos4212()	is_samsung_exynos4212()
594e486a65SArtur Weber #else
604e486a65SArtur Weber # define soc_is_exynos4212()	0
614e486a65SArtur Weber #endif
624e486a65SArtur Weber 
637cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS4412)
647cb2ded1SSachin Kamat # define soc_is_exynos4412()	is_samsung_exynos4412()
657cb2ded1SSachin Kamat #else
667cb2ded1SSachin Kamat # define soc_is_exynos4412()	0
677cb2ded1SSachin Kamat #endif
687cb2ded1SSachin Kamat 
697cb2ded1SSachin Kamat #define EXYNOS4210_REV_0	(0x0)
707cb2ded1SSachin Kamat #define EXYNOS4210_REV_1_0	(0x10)
717cb2ded1SSachin Kamat #define EXYNOS4210_REV_1_1	(0x11)
727cb2ded1SSachin Kamat 
737cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS5250)
747cb2ded1SSachin Kamat # define soc_is_exynos5250()	is_samsung_exynos5250()
757cb2ded1SSachin Kamat #else
767cb2ded1SSachin Kamat # define soc_is_exynos5250()	0
777cb2ded1SSachin Kamat #endif
787cb2ded1SSachin Kamat 
79723c9c7eSTarek Dakhran #if defined(CONFIG_SOC_EXYNOS5410)
80723c9c7eSTarek Dakhran # define soc_is_exynos5410()	is_samsung_exynos5410()
81723c9c7eSTarek Dakhran #else
82723c9c7eSTarek Dakhran # define soc_is_exynos5410()	0
83723c9c7eSTarek Dakhran #endif
84723c9c7eSTarek Dakhran 
857cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS5420)
867cb2ded1SSachin Kamat # define soc_is_exynos5420()	is_samsung_exynos5420()
877cb2ded1SSachin Kamat #else
887cb2ded1SSachin Kamat # define soc_is_exynos5420()	0
897cb2ded1SSachin Kamat #endif
907cb2ded1SSachin Kamat 
9186c6f148SArun Kumar K #if defined(CONFIG_SOC_EXYNOS5800)
9286c6f148SArun Kumar K # define soc_is_exynos5800()	is_samsung_exynos5800()
9386c6f148SArun Kumar K #else
9486c6f148SArun Kumar K # define soc_is_exynos5800()	0
9586c6f148SArun Kumar K #endif
9686c6f148SArun Kumar K 
972b9d9c32STomasz Figa extern u32 cp15_save_diag;
982b9d9c32STomasz Figa extern u32 cp15_save_power;
992b9d9c32STomasz Figa 
100b3205deaSSachin Kamat extern void __iomem *sysram_ns_base_addr;
101cd245f59SDaniel Lezcano extern void __iomem *sysram_base_addr;
1023a1f2f38SJoonyoung Shim extern phys_addr_t sysram_base_phys;
103fce9e5bbSPankaj Dubey extern void __iomem *pmu_base_addr;
1041754c42eSOlof Johansson void exynos_sysram_init(void);
105bb13fabcSShawn Guo 
1060b7778a8SBartlomiej Zolnierkiewicz enum {
1070b7778a8SBartlomiej Zolnierkiewicz 	FW_DO_IDLE_SLEEP,
1080b7778a8SBartlomiej Zolnierkiewicz 	FW_DO_IDLE_AFTR,
1090b7778a8SBartlomiej Zolnierkiewicz };
1100b7778a8SBartlomiej Zolnierkiewicz 
111bca28f8fSTomasz Figa void exynos_firmware_init(void);
112bca28f8fSTomasz Figa 
113dc1b9448SBartlomiej Zolnierkiewicz /* CPU BOOT mode flag for Exynos3250 SoC bootloader */
114dc1b9448SBartlomiej Zolnierkiewicz #define C2_STATE	(1 << 3)
115054e6aa1SKrzysztof Kozlowski /*
116054e6aa1SKrzysztof Kozlowski  * Magic values for bootloader indicating chosen low power mode.
117*e318b36eSJonathan Corbet  * See also Documentation/arch/arm/samsung/bootloader-interface.rst
118054e6aa1SKrzysztof Kozlowski  */
119054e6aa1SKrzysztof Kozlowski #define EXYNOS_SLEEP_MAGIC	0x00000bad
120054e6aa1SKrzysztof Kozlowski #define EXYNOS_AFTR_MAGIC	0xfcba0d10
121dc1b9448SBartlomiej Zolnierkiewicz 
122e0b35c1aSKrzysztof Kozlowski bool __init exynos_secure_firmware_available(void);
123dc1b9448SBartlomiej Zolnierkiewicz void exynos_set_boot_flag(unsigned int cpu, unsigned int mode);
124dc1b9448SBartlomiej Zolnierkiewicz void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode);
125dc1b9448SBartlomiej Zolnierkiewicz 
126559ba237STomasz Figa #ifdef CONFIG_PM_SLEEP
127559ba237STomasz Figa extern void __init exynos_pm_init(void);
128559ba237STomasz Figa #else
exynos_pm_init(void)129559ba237STomasz Figa static inline void exynos_pm_init(void) {}
130559ba237STomasz Figa #endif
131559ba237STomasz Figa 
132d710aa31STomasz Figa extern void exynos_cpu_resume(void);
1332b9d9c32STomasz Figa extern void exynos_cpu_resume_ns(void);
134d710aa31STomasz Figa 
13575305275SMasahiro Yamada extern const struct smp_operations exynos_smp_ops;
13606853ae4SMarc Zyngier 
137d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_down(int cpu);
138d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_up(int cpu);
139d3af6976SLeela Krishna Amudala extern int  exynos_cpu_power_state(int cpu);
140096d21c6SAbhilash Kesavan extern void exynos_cluster_power_down(int cluster);
141096d21c6SAbhilash Kesavan extern void exynos_cluster_power_up(int cluster);
142096d21c6SAbhilash Kesavan extern int  exynos_cluster_power_state(int cluster);
1430d713cf1SBartlomiej Zolnierkiewicz extern void exynos_cpu_save_register(void);
1440d713cf1SBartlomiej Zolnierkiewicz extern void exynos_cpu_restore_register(void);
1450d713cf1SBartlomiej Zolnierkiewicz extern void exynos_pm_central_suspend(void);
1460d713cf1SBartlomiej Zolnierkiewicz extern int exynos_pm_central_resume(void);
1473681bafeSDaniel Lezcano extern void exynos_enter_aftr(void);
1483c33710bSPankaj Dubey #ifdef CONFIG_SMP
1493c33710bSPankaj Dubey extern void exynos_scu_enable(void);
1503c33710bSPankaj Dubey #else
exynos_scu_enable(void)1513c33710bSPankaj Dubey static inline void exynos_scu_enable(void) { }
1523c33710bSPankaj Dubey #endif
153ccd458c1SKukjin Kim 
154712eddf7SBartlomiej Zolnierkiewicz extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data;
155712eddf7SBartlomiej Zolnierkiewicz 
1566f024978SKrzysztof Kozlowski extern void exynos_set_delayed_reset_assertion(bool enable);
1576f024978SKrzysztof Kozlowski 
158edaff7e1SArnd Bergmann extern unsigned int exynos_rev(void);
159af997114SBartlomiej Zolnierkiewicz extern void exynos_core_restart(u32 core_id);
160af997114SBartlomiej Zolnierkiewicz extern int exynos_set_boot_addr(u32 core_id, unsigned long boot_addr);
161af997114SBartlomiej Zolnierkiewicz extern int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr);
1627cb2ded1SSachin Kamat 
pmu_raw_writel(u32 val,u32 offset)1632e94ac42SPankaj Dubey static inline void pmu_raw_writel(u32 val, u32 offset)
1642e94ac42SPankaj Dubey {
165d0ceee0bSBen Dooks 	writel_relaxed(val, pmu_base_addr + offset);
1662e94ac42SPankaj Dubey }
1672e94ac42SPankaj Dubey 
pmu_raw_readl(u32 offset)1682e94ac42SPankaj Dubey static inline u32 pmu_raw_readl(u32 offset)
1692e94ac42SPankaj Dubey {
170d0ceee0bSBen Dooks 	return readl_relaxed(pmu_base_addr + offset);
1712e94ac42SPankaj Dubey }
1722e94ac42SPankaj Dubey 
173cc511b8dSKukjin Kim #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
174