]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/arm/mach-tegra/hotplug.c
arm: tegra: cardhu: Use fixed regulator
[linux-2.6.git] / arch / arm / mach-tegra / hotplug.c
1 /*
2  *  arch/arm/mach-tegra/hotplug.c
3  *
4  *  Copyright (C) 2010-2011 NVIDIA Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/kernel.h>
11 #include <linux/io.h>
12 #include <linux/smp.h>
13 #include <linux/cpu_pm.h>
14
15 #include <asm/cacheflush.h>
16
17 #include <mach/iomap.h>
18
19 #include "gic.h"
20 #include "sleep.h"
21
22 #define CPU_CLOCK(cpu) (0x1<<(8+cpu))
23
24 #define CLK_RST_CONTROLLER_CLK_CPU_CMPLX \
25         (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x4c)
26 #define CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET \
27         (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x340)
28 #define CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR \
29         (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x344)
30
31 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
32 /* For Tegra2 use the software-written value of the reset register for status.*/
33 #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET
34 #else
35 #define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS \
36         (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x470)
37 #endif
38
39 int platform_cpu_kill(unsigned int cpu)
40 {
41         unsigned int reg;
42
43         do {
44                 reg = readl(CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
45                 cpu_relax();
46         } while (!(reg & (1<<cpu)));
47
48         reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
49         writel(reg | CPU_CLOCK(cpu), CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
50
51         return 1;
52 }
53
54 void platform_cpu_die(unsigned int cpu)
55 {
56 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
57         /* Flush the L1 data cache. */
58         flush_cache_all();
59
60         /* Place the current CPU in reset. */
61         tegra2_hotplug_shutdown();
62 #else
63         /* Disable GIC CPU interface for this CPU. */
64         tegra_gic_cpu_disable();
65
66         /* Tegra3 enters LPx states via WFI - do not propagate legacy IRQs
67            to CPU core to avoid fall through WFI; then GIC output will be
68            enabled, however at this time - CPU is dying - no interrupt should
69            have affinity to this CPU. */
70         tegra_gic_pass_through_disable();
71
72         /* Flush the L1 data cache. */
73         flush_cache_all();
74
75         /* Shut down the current CPU. */
76         tegra3_hotplug_shutdown();
77 #endif
78
79         /* Should never return here. */
80         BUG();
81 }
82
83 int platform_cpu_disable(unsigned int cpu)
84 {
85         /*
86          * we don't allow CPU 0 to be shutdown (it is still too special
87          * e.g. clock tick interrupts)
88          */
89         return cpu == 0 ? -EPERM : 0;
90 }