forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/mach-exynos/mcpm-exynos.c
....@@ -26,6 +26,7 @@
2626 #define EXYNOS5420_USE_L2_COMMON_UP_STATE BIT(30)
2727
2828 static void __iomem *ns_sram_base_addr __ro_after_init;
29
+static bool secure_firmware __ro_after_init;
2930
3031 /*
3132 * The common v7_exit_coherency_flush API could not be used because of the
....@@ -58,15 +59,16 @@
5859 static int exynos_cpu_powerup(unsigned int cpu, unsigned int cluster)
5960 {
6061 unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
62
+ bool state;
6163
6264 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
6365 if (cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
6466 cluster >= EXYNOS5420_NR_CLUSTERS)
6567 return -EINVAL;
6668
67
- if (!exynos_cpu_power_state(cpunr)) {
68
- exynos_cpu_power_up(cpunr);
69
-
69
+ state = exynos_cpu_power_state(cpunr);
70
+ exynos_cpu_power_up(cpunr);
71
+ if (!state && secure_firmware) {
7072 /*
7173 * This assumes the cluster number of the big cores(Cortex A15)
7274 * is 0 and the Little cores(Cortex A7) is 1.
....@@ -75,14 +77,25 @@
7577 */
7678 if (cluster &&
7779 cluster == MPIDR_AFFINITY_LEVEL(cpu_logical_map(0), 1)) {
80
+ unsigned int timeout = 16;
81
+
7882 /*
7983 * Before we reset the Little cores, we should wait
8084 * the SPARE2 register is set to 1 because the init
8185 * codes of the iROM will set the register after
8286 * initialization.
8387 */
84
- while (!pmu_raw_readl(S5P_PMU_SPARE2))
88
+ while (timeout && !pmu_raw_readl(S5P_PMU_SPARE2)) {
89
+ timeout--;
8590 udelay(10);
91
+ }
92
+
93
+ if (timeout == 0) {
94
+ pr_err("cpu %u cluster %u powerup failed\n",
95
+ cpu, cluster);
96
+ exynos_cpu_power_down(cpunr);
97
+ return -ETIMEDOUT;
98
+ }
8699
87100 pmu_raw_writel(EXYNOS5420_KFC_CORE_RESET(cpu),
88101 EXYNOS_SWRESET);
....@@ -247,6 +260,8 @@
247260 return -ENOMEM;
248261 }
249262
263
+ secure_firmware = exynos_secure_firmware_available();
264
+
250265 /*
251266 * To increase the stability of KFC reset we need to program
252267 * the PMU SPARE3 register