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 157b6d864bSRobin Holt #include <linux/reboot.h> 166e6aac75SThomas Abraham #include <linux/of.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 114*2b9d9c32STomasz Figa extern u32 cp15_save_diag; 115*2b9d9c32STomasz Figa extern u32 cp15_save_power; 116*2b9d9c32STomasz 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 122bca28f8fSTomasz Figa void exynos_firmware_init(void); 123bca28f8fSTomasz Figa 124d710aa31STomasz Figa extern u32 exynos_get_eint_wake_mask(void); 125d710aa31STomasz Figa 126559ba237STomasz Figa #ifdef CONFIG_PM_SLEEP 127559ba237STomasz Figa extern void __init exynos_pm_init(void); 128559ba237STomasz Figa #else 129559ba237STomasz Figa static inline void exynos_pm_init(void) {} 130559ba237STomasz Figa #endif 131559ba237STomasz Figa 132d710aa31STomasz Figa extern void exynos_cpu_resume(void); 133*2b9d9c32STomasz Figa extern void exynos_cpu_resume_ns(void); 134d710aa31STomasz Figa 13506853ae4SMarc Zyngier extern struct smp_operations exynos_smp_ops; 13606853ae4SMarc Zyngier 13706853ae4SMarc Zyngier extern void exynos_cpu_die(unsigned int cpu); 13806853ae4SMarc Zyngier 139ccd458c1SKukjin Kim /* PMU(Power Management Unit) support */ 140ccd458c1SKukjin Kim 1412e94ac42SPankaj Dubey #define PMU_TABLE_END (-1U) 142ccd458c1SKukjin Kim 143ccd458c1SKukjin Kim enum sys_powerdown { 144ccd458c1SKukjin Kim SYS_AFTR, 145ccd458c1SKukjin Kim SYS_LPA, 146ccd458c1SKukjin Kim SYS_SLEEP, 147ccd458c1SKukjin Kim NUM_SYS_POWERDOWN, 148ccd458c1SKukjin Kim }; 149ccd458c1SKukjin Kim 150ccd458c1SKukjin Kim struct exynos_pmu_conf { 1512e94ac42SPankaj Dubey unsigned int offset; 152ccd458c1SKukjin Kim unsigned int val[NUM_SYS_POWERDOWN]; 153ccd458c1SKukjin Kim }; 154ccd458c1SKukjin Kim 155ccd458c1SKukjin Kim extern void exynos_sys_powerdown_conf(enum sys_powerdown mode); 156d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_down(int cpu); 157d3af6976SLeela Krishna Amudala extern void exynos_cpu_power_up(int cpu); 158d3af6976SLeela Krishna Amudala extern int exynos_cpu_power_state(int cpu); 159096d21c6SAbhilash Kesavan extern void exynos_cluster_power_down(int cluster); 160096d21c6SAbhilash Kesavan extern void exynos_cluster_power_up(int cluster); 161096d21c6SAbhilash Kesavan extern int exynos_cluster_power_state(int cluster); 1623681bafeSDaniel Lezcano extern void exynos_enter_aftr(void); 163ccd458c1SKukjin Kim 1647cb2ded1SSachin Kamat extern void s5p_init_cpu(void __iomem *cpuid_addr); 1657cb2ded1SSachin Kamat extern unsigned int samsung_rev(void); 1667cb2ded1SSachin Kamat 1672e94ac42SPankaj Dubey static inline void pmu_raw_writel(u32 val, u32 offset) 1682e94ac42SPankaj Dubey { 1692e94ac42SPankaj Dubey __raw_writel(val, pmu_base_addr + offset); 1702e94ac42SPankaj Dubey } 1712e94ac42SPankaj Dubey 1722e94ac42SPankaj Dubey static inline u32 pmu_raw_readl(u32 offset) 1732e94ac42SPankaj Dubey { 1742e94ac42SPankaj Dubey return __raw_readl(pmu_base_addr + offset); 1752e94ac42SPankaj Dubey } 1762e94ac42SPankaj Dubey 177cc511b8dSKukjin Kim #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ 178