blob: afd988a92836d248abcb1f016f1d1f76669ce8e9 [file] [log] [blame]
Krzysztof Kozlowski347863d2017-12-25 20:54:31 +01001/* SPDX-License-Identifier: GPL-2.0 */
Kukjin Kimcc511b82011-12-27 08:18:36 +01002/*
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
Krzysztof Kozlowski45984f02020-01-04 16:20:51 +01006 * Common Header for Exynos machines
Kukjin Kimcc511b82011-12-27 08:18:36 +01007 */
8
9#ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
10#define __ARCH_ARM_MACH_EXYNOS_COMMON_H
11
Bartlomiej Zolnierkiewicz712eddf72015-01-24 14:05:50 +090012#include <linux/platform_data/cpuidle-exynos.h>
Thomas Abraham6e6aac72013-03-09 17:03:05 +090013
Chanwoo Choi940bc582014-05-26 04:12:26 +090014#define EXYNOS3250_SOC_ID 0xE3472000
15#define EXYNOS3_SOC_MASK 0xFFFFF000
16
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090017#define EXYNOS4210_CPU_ID 0x43210000
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090018#define EXYNOS4412_CPU_ID 0xE4412200
19#define EXYNOS4_CPU_MASK 0xFFFE0000
20
21#define EXYNOS5250_SOC_ID 0x43520000
Tarek Dakhran723c9c72014-05-27 06:54:12 +090022#define EXYNOS5410_SOC_ID 0xE5410000
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090023#define EXYNOS5420_SOC_ID 0xE5420000
Arun Kumar K86c6f142014-05-26 04:16:11 +090024#define EXYNOS5800_SOC_ID 0xE5422000
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090025#define EXYNOS5_SOC_MASK 0xFFFFF000
26
27extern unsigned long samsung_cpu_id;
28
29#define IS_SAMSUNG_CPU(name, id, mask) \
30static inline int is_samsung_##name(void) \
31{ \
32 return ((samsung_cpu_id & mask) == (id & mask)); \
33}
34
Chanwoo Choi940bc582014-05-26 04:12:26 +090035IS_SAMSUNG_CPU(exynos3250, EXYNOS3250_SOC_ID, EXYNOS3_SOC_MASK)
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090036IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090037IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
38IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
Tarek Dakhran723c9c72014-05-27 06:54:12 +090039IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK)
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090040IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
Arun Kumar K86c6f142014-05-26 04:16:11 +090041IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
Sachin Kamat7cb2ded2014-05-13 07:11:57 +090042
Chanwoo Choi940bc582014-05-26 04:12:26 +090043#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 Kamat7cb2ded2014-05-13 07:11:57 +090049#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 Kamat7cb2ded2014-05-13 07:11:57 +090055#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 Dakhran723c9c72014-05-27 06:54:12 +090071#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 Kamat7cb2ded2014-05-13 07:11:57 +090077#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 K86c6f142014-05-26 04:16:11 +090083#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 Figa2b9d9c32014-09-24 01:24:39 +090089extern u32 cp15_save_diag;
90extern u32 cp15_save_power;
91
Sachin Kamatb3205de2014-05-13 07:13:44 +090092extern void __iomem *sysram_ns_base_addr;
Daniel Lezcanocd245f52014-05-26 04:50:34 +090093extern void __iomem *sysram_base_addr;
Joonyoung Shim3a1f2f32019-02-18 15:34:11 +010094extern phys_addr_t sysram_base_phys;
Pankaj Dubeyfce9e5b2014-07-11 08:08:29 +090095extern void __iomem *pmu_base_addr;
Olof Johansson1754c422014-06-02 21:47:46 -070096void exynos_sysram_init(void);
Shawn Guobb13fab2012-04-26 10:35:40 +080097
Bartlomiej Zolnierkiewicz0b7778a2014-09-25 17:59:41 +090098enum {
99 FW_DO_IDLE_SLEEP,
100 FW_DO_IDLE_AFTR,
101};
102
Tomasz Figabca28f82012-12-11 13:58:43 +0900103void exynos_firmware_init(void);
104
Bartlomiej Zolnierkiewiczdc1b9442015-03-27 02:32:56 +0900105/* CPU BOOT mode flag for Exynos3250 SoC bootloader */
106#define C2_STATE (1 << 3)
Krzysztof Kozlowski054e6aa2015-06-14 13:38:23 +0900107/*
108 * Magic values for bootloader indicating chosen low power mode.
Mauro Carvalho Chehabdc7a12b2019-04-14 15:51:10 -0300109 * See also Documentation/arm/samsung/bootloader-interface.rst
Krzysztof Kozlowski054e6aa2015-06-14 13:38:23 +0900110 */
111#define EXYNOS_SLEEP_MAGIC 0x00000bad
112#define EXYNOS_AFTR_MAGIC 0xfcba0d10
Bartlomiej Zolnierkiewiczdc1b9442015-03-27 02:32:56 +0900113
Krzysztof Kozlowskie0b35c12018-07-24 18:49:46 +0200114bool __init exynos_secure_firmware_available(void);
Bartlomiej Zolnierkiewiczdc1b9442015-03-27 02:32:56 +0900115void exynos_set_boot_flag(unsigned int cpu, unsigned int mode);
116void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode);
117
Tomasz Figa559ba232014-03-18 07:28:22 +0900118#ifdef CONFIG_PM_SLEEP
119extern void __init exynos_pm_init(void);
120#else
121static inline void exynos_pm_init(void) {}
122#endif
123
Tomasz Figad710aa32014-03-18 07:28:27 +0900124extern void exynos_cpu_resume(void);
Tomasz Figa2b9d9c32014-09-24 01:24:39 +0900125extern void exynos_cpu_resume_ns(void);
Tomasz Figad710aa32014-03-18 07:28:27 +0900126
Masahiro Yamada75305272015-11-15 10:39:53 +0900127extern const struct smp_operations exynos_smp_ops;
Marc Zyngier06853ae2011-09-08 13:15:22 +0100128
Leela Krishna Amudalad3af6972014-05-16 04:23:24 +0900129extern void exynos_cpu_power_down(int cpu);
130extern void exynos_cpu_power_up(int cpu);
131extern int exynos_cpu_power_state(int cpu);
Abhilash Kesavan096d21c2014-05-16 04:23:26 +0900132extern void exynos_cluster_power_down(int cluster);
133extern void exynos_cluster_power_up(int cluster);
134extern int exynos_cluster_power_state(int cluster);
Bartlomiej Zolnierkiewicz0d713cf2014-09-25 18:02:45 +0900135extern void exynos_cpu_save_register(void);
136extern void exynos_cpu_restore_register(void);
137extern void exynos_pm_central_suspend(void);
138extern int exynos_pm_central_resume(void);
Daniel Lezcano3681baf2014-05-09 06:53:00 +0900139extern void exynos_enter_aftr(void);
Pankaj Dubey3c337102018-05-10 13:02:54 +0200140#ifdef CONFIG_SMP
141extern void exynos_scu_enable(void);
142#else
143static inline void exynos_scu_enable(void) { }
144#endif
Kukjin Kimccd458c2012-12-31 10:06:48 -0800145
Bartlomiej Zolnierkiewicz712eddf72015-01-24 14:05:50 +0900146extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data;
147
Krzysztof Kozlowski6f024972015-03-11 11:13:57 +0100148extern void exynos_set_delayed_reset_assertion(bool enable);
149
Sachin Kamat7cb2ded2014-05-13 07:11:57 +0900150extern unsigned int samsung_rev(void);
Bartlomiej Zolnierkiewiczaf997112015-03-18 14:09:57 +0100151extern void exynos_core_restart(u32 core_id);
152extern int exynos_set_boot_addr(u32 core_id, unsigned long boot_addr);
153extern int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr);
Sachin Kamat7cb2ded2014-05-13 07:11:57 +0900154
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900155static inline void pmu_raw_writel(u32 val, u32 offset)
156{
Ben Dooksd0ceee02016-06-21 11:20:25 +0100157 writel_relaxed(val, pmu_base_addr + offset);
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900158}
159
160static inline u32 pmu_raw_readl(u32 offset)
161{
Ben Dooksd0ceee02016-06-21 11:20:25 +0100162 return readl_relaxed(pmu_base_addr + offset);
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900163}
164
Kukjin Kimcc511b82011-12-27 08:18:36 +0100165#endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */