xref: /linux/arch/arm/mach-exynos/common.h (revision 75305275a721d33ae9abfaeed2817cec8b2fee9a)
1cc511b8dSKukjin Kim /*
2cc511b8dSKukjin Kim  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
3cc511b8dSKukjin Kim  *		http://www.samsung.com
4cc511b8dSKukjin Kim  *
5cc511b8dSKukjin Kim  * Common Header for EXYNOS machines
6cc511b8dSKukjin Kim  *
7cc511b8dSKukjin Kim  * This program is free software; you can redistribute it and/or modify
8cc511b8dSKukjin Kim  * it under the terms of the GNU General Public License version 2 as
9cc511b8dSKukjin Kim  * published by the Free Software Foundation.
10cc511b8dSKukjin Kim  */
11cc511b8dSKukjin Kim 
12cc511b8dSKukjin Kim #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
13cc511b8dSKukjin Kim #define __ARCH_ARM_MACH_EXYNOS_COMMON_H
14cc511b8dSKukjin Kim 
156e6aac75SThomas Abraham #include <linux/of.h>
16712eddf7SBartlomiej Zolnierkiewicz #include <linux/platform_data/cpuidle-exynos.h>
176e6aac75SThomas Abraham 
18940bc58dSChanwoo Choi #define EXYNOS3250_SOC_ID	0xE3472000
19940bc58dSChanwoo Choi #define EXYNOS3_SOC_MASK	0xFFFFF000
20940bc58dSChanwoo Choi 
217cb2ded1SSachin Kamat #define EXYNOS4210_CPU_ID	0x43210000
227cb2ded1SSachin Kamat #define EXYNOS4212_CPU_ID	0x43220000
237cb2ded1SSachin Kamat #define EXYNOS4412_CPU_ID	0xE4412200
247cb2ded1SSachin Kamat #define EXYNOS4_CPU_MASK	0xFFFE0000
257cb2ded1SSachin Kamat 
267cb2ded1SSachin Kamat #define EXYNOS5250_SOC_ID	0x43520000
27723c9c7eSTarek Dakhran #define EXYNOS5410_SOC_ID	0xE5410000
287cb2ded1SSachin Kamat #define EXYNOS5420_SOC_ID	0xE5420000
297cb2ded1SSachin Kamat #define EXYNOS5440_SOC_ID	0xE5440000
3086c6f148SArun Kumar K #define EXYNOS5800_SOC_ID	0xE5422000
317cb2ded1SSachin Kamat #define EXYNOS5_SOC_MASK	0xFFFFF000
327cb2ded1SSachin Kamat 
337cb2ded1SSachin Kamat extern unsigned long samsung_cpu_id;
347cb2ded1SSachin Kamat 
357cb2ded1SSachin Kamat #define IS_SAMSUNG_CPU(name, id, mask)		\
367cb2ded1SSachin Kamat static inline int is_samsung_##name(void)	\
377cb2ded1SSachin Kamat {						\
387cb2ded1SSachin Kamat 	return ((samsung_cpu_id & mask) == (id & mask));	\
397cb2ded1SSachin Kamat }
407cb2ded1SSachin Kamat 
41940bc58dSChanwoo Choi IS_SAMSUNG_CPU(exynos3250, EXYNOS3250_SOC_ID, EXYNOS3_SOC_MASK)
427cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
437cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK)
447cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
457cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
46723c9c7eSTarek Dakhran IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK)
477cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
487cb2ded1SSachin Kamat IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
4986c6f148SArun Kumar K IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
507cb2ded1SSachin Kamat 
51940bc58dSChanwoo Choi #if defined(CONFIG_SOC_EXYNOS3250)
52940bc58dSChanwoo Choi # define soc_is_exynos3250()	is_samsung_exynos3250()
53940bc58dSChanwoo Choi #else
54940bc58dSChanwoo Choi # define soc_is_exynos3250()	0
55940bc58dSChanwoo Choi #endif
56940bc58dSChanwoo Choi 
577cb2ded1SSachin Kamat #if defined(CONFIG_CPU_EXYNOS4210)
587cb2ded1SSachin Kamat # define soc_is_exynos4210()	is_samsung_exynos4210()
597cb2ded1SSachin Kamat #else
607cb2ded1SSachin Kamat # define soc_is_exynos4210()	0
617cb2ded1SSachin Kamat #endif
627cb2ded1SSachin Kamat 
637cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS4212)
647cb2ded1SSachin Kamat # define soc_is_exynos4212()	is_samsung_exynos4212()
657cb2ded1SSachin Kamat #else
667cb2ded1SSachin Kamat # define soc_is_exynos4212()	0
677cb2ded1SSachin Kamat #endif
687cb2ded1SSachin Kamat 
697cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS4412)
707cb2ded1SSachin Kamat # define soc_is_exynos4412()	is_samsung_exynos4412()
717cb2ded1SSachin Kamat #else
727cb2ded1SSachin Kamat # define soc_is_exynos4412()	0
737cb2ded1SSachin Kamat #endif
747cb2ded1SSachin Kamat 
757cb2ded1SSachin Kamat #define EXYNOS4210_REV_0	(0x0)
767cb2ded1SSachin Kamat #define EXYNOS4210_REV_1_0	(0x10)
777cb2ded1SSachin Kamat #define EXYNOS4210_REV_1_1	(0x11)
787cb2ded1SSachin Kamat 
797cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS5250)
807cb2ded1SSachin Kamat # define soc_is_exynos5250()	is_samsung_exynos5250()
817cb2ded1SSachin Kamat #else
827cb2ded1SSachin Kamat # define soc_is_exynos5250()	0
837cb2ded1SSachin Kamat #endif
847cb2ded1SSachin Kamat 
85723c9c7eSTarek Dakhran #if defined(CONFIG_SOC_EXYNOS5410)
86723c9c7eSTarek Dakhran # define soc_is_exynos5410()	is_samsung_exynos5410()
87723c9c7eSTarek Dakhran #else
88723c9c7eSTarek Dakhran # define soc_is_exynos5410()	0
89723c9c7eSTarek Dakhran #endif
90723c9c7eSTarek Dakhran 
917cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS5420)
927cb2ded1SSachin Kamat # define soc_is_exynos5420()	is_samsung_exynos5420()
937cb2ded1SSachin Kamat #else
947cb2ded1SSachin Kamat # define soc_is_exynos5420()	0
957cb2ded1SSachin Kamat #endif
967cb2ded1SSachin Kamat 
977cb2ded1SSachin Kamat #if defined(CONFIG_SOC_EXYNOS5440)
987cb2ded1SSachin Kamat # define soc_is_exynos5440()	is_samsung_exynos5440()
997cb2ded1SSachin Kamat #else
1007cb2ded1SSachin Kamat # define soc_is_exynos5440()	0
1017cb2ded1SSachin Kamat #endif
1027cb2ded1SSachin Kamat 
10386c6f148SArun Kumar K #if defined(CONFIG_SOC_EXYNOS5800)
10486c6f148SArun Kumar K # define soc_is_exynos5800()	is_samsung_exynos5800()
10586c6f148SArun Kumar K #else
10686c6f148SArun Kumar K # define soc_is_exynos5800()	0
10786c6f148SArun Kumar K #endif
10886c6f148SArun Kumar K 
1097cb2ded1SSachin Kamat #define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4212() || \
1107cb2ded1SSachin Kamat 			  soc_is_exynos4412())
111723c9c7eSTarek Dakhran #define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5410() || \
112723c9c7eSTarek Dakhran 			  soc_is_exynos5420() || soc_is_exynos5800())
1137cb2ded1SSachin Kamat 
1142b9d9c32STomasz Figa extern u32 cp15_save_diag;
1152b9d9c32STomasz Figa extern u32 cp15_save_power;
1162b9d9c32STomasz Figa 
117b3205deaSSachin Kamat extern void __iomem *sysram_ns_base_addr;
118cd245f59SDaniel Lezcano extern void __iomem *sysram_base_addr;
119fce9e5bbSPankaj Dubey extern void __iomem *pmu_base_addr;
1201754c42eSOlof Johansson void exynos_sysram_init(void);
121bb13fabcSShawn Guo 
1220b7778a8SBartlomiej Zolnierkiewicz enum {
1230b7778a8SBartlomiej Zolnierkiewicz 	FW_DO_IDLE_SLEEP,
1240b7778a8SBartlomiej Zolnierkiewicz 	FW_DO_IDLE_AFTR,
1250b7778a8SBartlomiej Zolnierkiewicz };
1260b7778a8SBartlomiej Zolnierkiewicz 
127bca28f8fSTomasz Figa void exynos_firmware_init(void);
128bca28f8fSTomasz Figa 
129dc1b9448SBartlomiej Zolnierkiewicz /* CPU BOOT mode flag for Exynos3250 SoC bootloader */
130dc1b9448SBartlomiej Zolnierkiewicz #define C2_STATE	(1 << 3)
131054e6aa1SKrzysztof Kozlowski /*
132054e6aa1SKrzysztof Kozlowski  * Magic values for bootloader indicating chosen low power mode.
133054e6aa1SKrzysztof Kozlowski  * See also Documentation/arm/Samsung/Bootloader-interface.txt
134054e6aa1SKrzysztof Kozlowski  */
135054e6aa1SKrzysztof Kozlowski #define EXYNOS_SLEEP_MAGIC	0x00000bad
136054e6aa1SKrzysztof Kozlowski #define EXYNOS_AFTR_MAGIC	0xfcba0d10
137dc1b9448SBartlomiej Zolnierkiewicz 
138dc1b9448SBartlomiej Zolnierkiewicz void exynos_set_boot_flag(unsigned int cpu, unsigned int mode);
139dc1b9448SBartlomiej Zolnierkiewicz void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode);
140dc1b9448SBartlomiej Zolnierkiewicz 
141d710aa31STomasz Figa extern u32 exynos_get_eint_wake_mask(void);
142d710aa31STomasz Figa 
143559ba237STomasz Figa #ifdef CONFIG_PM_SLEEP
144559ba237STomasz Figa extern void __init exynos_pm_init(void);
145559ba237STomasz Figa #else
146559ba237STomasz Figa static inline void exynos_pm_init(void) {}
147559ba237STomasz Figa #endif
148559ba237STomasz Figa 
149d710aa31STomasz Figa extern void exynos_cpu_resume(void);
1502b9d9c32STomasz Figa extern void exynos_cpu_resume_ns(void);
151d710aa31STomasz Figa 
152*75305275SMasahiro Yamada extern const struct smp_operations exynos_smp_ops;
15306853ae4SMarc Zyngier 
154d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_down(int cpu);
155d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_up(int cpu);
156d3af6976SLeela Krishna Amudala extern int  exynos_cpu_power_state(int cpu);
157096d21c6SAbhilash Kesavan extern void exynos_cluster_power_down(int cluster);
158096d21c6SAbhilash Kesavan extern void exynos_cluster_power_up(int cluster);
159096d21c6SAbhilash Kesavan extern int  exynos_cluster_power_state(int cluster);
1600d713cf1SBartlomiej Zolnierkiewicz extern void exynos_cpu_save_register(void);
1610d713cf1SBartlomiej Zolnierkiewicz extern void exynos_cpu_restore_register(void);
1620d713cf1SBartlomiej Zolnierkiewicz extern void exynos_pm_central_suspend(void);
1630d713cf1SBartlomiej Zolnierkiewicz extern int exynos_pm_central_resume(void);
1643681bafeSDaniel Lezcano extern void exynos_enter_aftr(void);
165ccd458c1SKukjin Kim 
166712eddf7SBartlomiej Zolnierkiewicz extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data;
167712eddf7SBartlomiej Zolnierkiewicz 
1686f024978SKrzysztof Kozlowski extern void exynos_set_delayed_reset_assertion(bool enable);
1696f024978SKrzysztof Kozlowski 
1707cb2ded1SSachin Kamat extern void s5p_init_cpu(void __iomem *cpuid_addr);
1717cb2ded1SSachin Kamat extern unsigned int samsung_rev(void);
172af997114SBartlomiej Zolnierkiewicz extern void exynos_core_restart(u32 core_id);
173af997114SBartlomiej Zolnierkiewicz extern int exynos_set_boot_addr(u32 core_id, unsigned long boot_addr);
174af997114SBartlomiej Zolnierkiewicz extern int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr);
1757cb2ded1SSachin Kamat 
1762e94ac42SPankaj Dubey static inline void pmu_raw_writel(u32 val, u32 offset)
1772e94ac42SPankaj Dubey {
1782e94ac42SPankaj Dubey 	__raw_writel(val, pmu_base_addr + offset);
1792e94ac42SPankaj Dubey }
1802e94ac42SPankaj Dubey 
1812e94ac42SPankaj Dubey static inline u32 pmu_raw_readl(u32 offset)
1822e94ac42SPankaj Dubey {
1832e94ac42SPankaj Dubey 	return __raw_readl(pmu_base_addr + offset);
1842e94ac42SPankaj Dubey }
1852e94ac42SPankaj Dubey 
186cc511b8dSKukjin Kim #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
187