]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - arch/arm/mach-tegra/hotplug.c
ARM: tegra: powermon: Fix copyrights from GPLv3 to GPLv2
[linux-3.10.git] / arch / arm / mach-tegra / hotplug.c
index f3294040d357d5b5cd53fe7bd7c943a7061f26fb..dbafc361447a07f27742ea09c01a7264dd76fe3f 100644 (file)
@@ -1,93 +1,34 @@
 /*
- *  linux/arch/arm/mach-realview/hotplug.c
  *
  *  Copyright (C) 2002 ARM Ltd.
  *  All Rights Reserved
+ *  Copyright (c) 2010, 2012 NVIDIA Corporation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
 #include <linux/kernel.h>
-#include <linux/errno.h>
 #include <linux/smp.h>
+#include <linux/clk/tegra.h>
+#include <linux/cpu_pm.h>
 
 #include <asm/cacheflush.h>
+#include <asm/smp_plat.h>
 
-static inline void cpu_enter_lowpower(void)
-{
-       unsigned int v;
+#include "gic.h"
+#include "sleep.h"
 
-       flush_cache_all();
-       asm volatile(
-       "       mcr     p15, 0, %1, c7, c5, 0\n"
-       "       mcr     p15, 0, %1, c7, c10, 4\n"
-       /*
-        * Turn off coherency
-        */
-       "       mrc     p15, 0, %0, c1, c0, 1\n"
-       "       bic     %0, %0, #0x20\n"
-       "       mcr     p15, 0, %0, c1, c0, 1\n"
-       "       mrc     p15, 0, %0, c1, c0, 0\n"
-       "       bic     %0, %0, %2\n"
-       "       mcr     p15, 0, %0, c1, c0, 0\n"
-         : "=&r" (v)
-         : "r" (0), "Ir" (CR_C)
-         : "cc");
-}
+static void (*tegra_hotplug_shutdown)(void);
 
-static inline void cpu_leave_lowpower(void)
+int tegra_cpu_kill(unsigned int cpu)
 {
-       unsigned int v;
+       cpu = cpu_logical_map(cpu);
 
-       asm volatile(
-       "mrc    p15, 0, %0, c1, c0, 0\n"
-       "       orr     %0, %0, %1\n"
-       "       mcr     p15, 0, %0, c1, c0, 0\n"
-       "       mrc     p15, 0, %0, c1, c0, 1\n"
-       "       orr     %0, %0, #0x20\n"
-       "       mcr     p15, 0, %0, c1, c0, 1\n"
-         : "=&r" (v)
-         : "Ir" (CR_C)
-         : "cc");
-}
+       tegra_wait_cpu_in_reset(cpu);
 
-static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
-{
-       /*
-        * there is no power-control hardware on this platform, so all
-        * we can do is put the core into WFI; this is safe as the calling
-        * code will have already disabled interrupts
-        */
-       for (;;) {
-               /*
-                * here's the WFI
-                */
-               asm(".word      0xe320f003\n"
-                   :
-                   :
-                   : "memory", "cc");
-
-               /*if (pen_release == cpu) {*/
-                       /*
-                        * OK, proper wakeup, we're done
-                        */
-                       break;
-               /*}*/
-
-               /*
-                * Getting here, means that we have come out of WFI without
-                * having been woken up - this shouldn't happen
-                *
-                * Just note it happening - when we're woken, we can report
-                * its occurrence.
-                */
-               (*spurious)++;
-       }
-}
+       tegra_disable_cpu_clock(cpu);
 
-int platform_cpu_kill(unsigned int cpu)
-{
        return 1;
 }
 
@@ -96,31 +37,42 @@ int platform_cpu_kill(unsigned int cpu)
  *
  * Called with IRQs disabled
  */
-void platform_cpu_die(unsigned int cpu)
+void tegra_cpu_die(unsigned int cpu)
 {
-       int spurious = 0;
+       cpu = cpu_logical_map(cpu);
+
+#ifndef CONFIG_ARCH_TEGRA_2x_SOC
+       /* Disable GIC CPU interface for this CPU. */
+       tegra_gic_cpu_disable(false);
+#endif
+
+       /* Flush the L1 data cache. */
+       tegra_flush_l1_cache();
 
-       /*
-        * we're ready for shutdown now, so do it
-        */
-       cpu_enter_lowpower();
-       platform_do_lowpower(cpu, &spurious);
+       /* Shut down the current CPU. */
+       tegra_hotplug_shutdown();
 
-       /*
-        * bring this CPU back into the world of cache
-        * coherency, and then restore interrupts
-        */
-       cpu_leave_lowpower();
+       /* Clock gate the CPU */
+       tegra_wait_cpu_in_reset(cpu);
+       tegra_disable_cpu_clock(cpu);
 
-       if (spurious)
-               pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
+       /* Should never return here. */
+       BUG();
+}
+
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+extern void tegra20_hotplug_shutdown(void);
+void __init tegra20_hotplug_init(void)
+{
+       tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
 }
+#endif
 
-int platform_cpu_disable(unsigned int cpu)
+#if defined(CONFIG_ARCH_TEGRA_3x_SOC) || defined(CONFIG_ARCH_TEGRA_11x_SOC) || \
+    defined(CONFIG_ARCH_TEGRA_14x_SOC)
+extern void tegra30_hotplug_shutdown(void);
+void __init tegra30_hotplug_init(void)
 {
-       /*
-        * we don't allow CPU 0 to be shutdown (it is still too special
-        * e.g. clock tick interrupts)
-        */
-       return cpu == 0 ? -EPERM : 0;
+       tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
 }
+#endif