common.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * Common Header for EXYNOS machines
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
  12. #define __ARCH_ARM_MACH_EXYNOS_COMMON_H
  13. #include <linux/reboot.h>
  14. #include <linux/of.h>
  15. #define EXYNOS3250_SOC_ID 0xE3472000
  16. #define EXYNOS3_SOC_MASK 0xFFFFF000
  17. #define EXYNOS4210_CPU_ID 0x43210000
  18. #define EXYNOS4212_CPU_ID 0x43220000
  19. #define EXYNOS4412_CPU_ID 0xE4412200
  20. #define EXYNOS4_CPU_MASK 0xFFFE0000
  21. #define EXYNOS5250_SOC_ID 0x43520000
  22. #define EXYNOS5410_SOC_ID 0xE5410000
  23. #define EXYNOS5420_SOC_ID 0xE5420000
  24. #define EXYNOS5440_SOC_ID 0xE5440000
  25. #define EXYNOS5800_SOC_ID 0xE5422000
  26. #define EXYNOS5_SOC_MASK 0xFFFFF000
  27. extern unsigned long samsung_cpu_id;
  28. #define IS_SAMSUNG_CPU(name, id, mask) \
  29. static inline int is_samsung_##name(void) \
  30. { \
  31. return ((samsung_cpu_id & mask) == (id & mask)); \
  32. }
  33. IS_SAMSUNG_CPU(exynos3250, EXYNOS3250_SOC_ID, EXYNOS3_SOC_MASK)
  34. IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
  35. IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK)
  36. IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
  37. IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
  38. IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK)
  39. IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
  40. IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
  41. IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
  42. #if defined(CONFIG_SOC_EXYNOS3250)
  43. # define soc_is_exynos3250() is_samsung_exynos3250()
  44. #else
  45. # define soc_is_exynos3250() 0
  46. #endif
  47. #if defined(CONFIG_CPU_EXYNOS4210)
  48. # define soc_is_exynos4210() is_samsung_exynos4210()
  49. #else
  50. # define soc_is_exynos4210() 0
  51. #endif
  52. #if defined(CONFIG_SOC_EXYNOS4212)
  53. # define soc_is_exynos4212() is_samsung_exynos4212()
  54. #else
  55. # define soc_is_exynos4212() 0
  56. #endif
  57. #if defined(CONFIG_SOC_EXYNOS4412)
  58. # define soc_is_exynos4412() is_samsung_exynos4412()
  59. #else
  60. # define soc_is_exynos4412() 0
  61. #endif
  62. #define EXYNOS4210_REV_0 (0x0)
  63. #define EXYNOS4210_REV_1_0 (0x10)
  64. #define EXYNOS4210_REV_1_1 (0x11)
  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. #if defined(CONFIG_SOC_EXYNOS5410)
  71. # define soc_is_exynos5410() is_samsung_exynos5410()
  72. #else
  73. # define soc_is_exynos5410() 0
  74. #endif
  75. #if defined(CONFIG_SOC_EXYNOS5420)
  76. # define soc_is_exynos5420() is_samsung_exynos5420()
  77. #else
  78. # define soc_is_exynos5420() 0
  79. #endif
  80. #if defined(CONFIG_SOC_EXYNOS5440)
  81. # define soc_is_exynos5440() is_samsung_exynos5440()
  82. #else
  83. # define soc_is_exynos5440() 0
  84. #endif
  85. #if defined(CONFIG_SOC_EXYNOS5800)
  86. # define soc_is_exynos5800() is_samsung_exynos5800()
  87. #else
  88. # define soc_is_exynos5800() 0
  89. #endif
  90. #define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4212() || \
  91. soc_is_exynos4412())
  92. #define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5410() || \
  93. soc_is_exynos5420() || soc_is_exynos5800())
  94. extern void __iomem *sysram_ns_base_addr;
  95. extern void __iomem *sysram_base_addr;
  96. extern void __iomem *pmu_base_addr;
  97. void exynos_sysram_init(void);
  98. void exynos_firmware_init(void);
  99. extern u32 exynos_get_eint_wake_mask(void);
  100. #ifdef CONFIG_PM_SLEEP
  101. extern void __init exynos_pm_init(void);
  102. #else
  103. static inline void exynos_pm_init(void) {}
  104. #endif
  105. extern void exynos_cpu_resume(void);
  106. extern struct smp_operations exynos_smp_ops;
  107. extern void exynos_cpu_die(unsigned int cpu);
  108. /* PMU(Power Management Unit) support */
  109. #define PMU_TABLE_END (-1U)
  110. enum sys_powerdown {
  111. SYS_AFTR,
  112. SYS_LPA,
  113. SYS_SLEEP,
  114. NUM_SYS_POWERDOWN,
  115. };
  116. struct exynos_pmu_conf {
  117. unsigned int offset;
  118. unsigned int val[NUM_SYS_POWERDOWN];
  119. };
  120. extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
  121. extern void exynos_cpu_power_down(int cpu);
  122. extern void exynos_cpu_power_up(int cpu);
  123. extern int exynos_cpu_power_state(int cpu);
  124. extern void exynos_cluster_power_down(int cluster);
  125. extern void exynos_cluster_power_up(int cluster);
  126. extern int exynos_cluster_power_state(int cluster);
  127. extern void exynos_enter_aftr(void);
  128. extern void s5p_init_cpu(void __iomem *cpuid_addr);
  129. extern unsigned int samsung_rev(void);
  130. static inline void pmu_raw_writel(u32 val, u32 offset)
  131. {
  132. __raw_writel(val, pmu_base_addr + offset);
  133. }
  134. static inline u32 pmu_raw_readl(u32 offset)
  135. {
  136. return __raw_readl(pmu_base_addr + offset);
  137. }
  138. #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */