xref: /linux/arch/arm/mach-exynos/common.h (revision 712eddf70225ab5ae65e946e22d2dfe6b93e8dd1)
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>
16*712eddf7SBartlomiej 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 
129d710aa31STomasz Figa extern u32 exynos_get_eint_wake_mask(void);
130d710aa31STomasz Figa 
131559ba237STomasz Figa #ifdef CONFIG_PM_SLEEP
132559ba237STomasz Figa extern void __init exynos_pm_init(void);
133559ba237STomasz Figa #else
134559ba237STomasz Figa static inline void exynos_pm_init(void) {}
135559ba237STomasz Figa #endif
136559ba237STomasz Figa 
137d710aa31STomasz Figa extern void exynos_cpu_resume(void);
1382b9d9c32STomasz Figa extern void exynos_cpu_resume_ns(void);
139d710aa31STomasz Figa 
14006853ae4SMarc Zyngier extern struct smp_operations exynos_smp_ops;
14106853ae4SMarc Zyngier 
142d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_down(int cpu);
143d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_up(int cpu);
144d3af6976SLeela Krishna Amudala extern int  exynos_cpu_power_state(int cpu);
145096d21c6SAbhilash Kesavan extern void exynos_cluster_power_down(int cluster);
146096d21c6SAbhilash Kesavan extern void exynos_cluster_power_up(int cluster);
147096d21c6SAbhilash Kesavan extern int  exynos_cluster_power_state(int cluster);
1480d713cf1SBartlomiej Zolnierkiewicz extern void exynos_cpu_save_register(void);
1490d713cf1SBartlomiej Zolnierkiewicz extern void exynos_cpu_restore_register(void);
1500d713cf1SBartlomiej Zolnierkiewicz extern void exynos_pm_central_suspend(void);
1510d713cf1SBartlomiej Zolnierkiewicz extern int exynos_pm_central_resume(void);
1523681bafeSDaniel Lezcano extern void exynos_enter_aftr(void);
153ccd458c1SKukjin Kim 
154*712eddf7SBartlomiej Zolnierkiewicz extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data;
155*712eddf7SBartlomiej Zolnierkiewicz 
1567cb2ded1SSachin Kamat extern void s5p_init_cpu(void __iomem *cpuid_addr);
1577cb2ded1SSachin Kamat extern unsigned int samsung_rev(void);
158*712eddf7SBartlomiej Zolnierkiewicz extern void __iomem *cpu_boot_reg_base(void);
1597cb2ded1SSachin Kamat 
1602e94ac42SPankaj Dubey static inline void pmu_raw_writel(u32 val, u32 offset)
1612e94ac42SPankaj Dubey {
1622e94ac42SPankaj Dubey 	__raw_writel(val, pmu_base_addr + offset);
1632e94ac42SPankaj Dubey }
1642e94ac42SPankaj Dubey 
1652e94ac42SPankaj Dubey static inline u32 pmu_raw_readl(u32 offset)
1662e94ac42SPankaj Dubey {
1672e94ac42SPankaj Dubey 	return __raw_readl(pmu_base_addr + offset);
1682e94ac42SPankaj Dubey }
1692e94ac42SPankaj Dubey 
170cc511b8dSKukjin Kim #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
171