1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* arch/arm/mach-tegra/hotplug.c
*
* Copyright (C) 2010-2012 NVIDIA Corporation
*
* 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/io.h>
#include <linux/smp.h>
#include <linux/cpu_pm.h>
#include <asm/cacheflush.h>
#include <asm/cp15.h>
#include <asm/smp_plat.h>
#include <mach/iomap.h>
#include "gic.h"
#include "sleep.h"
#define CPU_CLOCK(cpu) (0x1<<(8+cpu))
#define CLK_RST_CONTROLLER_CLK_CPU_CMPLX \
(IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x4c)
#define CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET \
(IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x340)
#define CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR \
(IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x344)
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
/* For Tegra2 use the software-written value of the reset register for status.*/
#define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET
#else
#define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS \
(IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x470)
#endif
int tegra_cpu_kill(unsigned int cpu)
{
unsigned int reg;
cpu = cpu_logical_map(cpu);
do {
reg = readl(CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
cpu_relax();
} while (!(reg & (1<<cpu)));
reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
writel(reg | CPU_CLOCK(cpu), CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
return 1;
}
/*
* platform-specific code to shutdown a CPU
*
* Called with IRQs disabled
*/
void tegra_cpu_die(unsigned int cpu)
{
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
/* Flush the L1 data cache. */
flush_cache_all();
/* Place the current CPU in reset. */
tegra2_hotplug_shutdown();
#else
#ifdef CONFIG_ARCH_TEGRA_11x_SOC
unsigned int r = 0;
#endif
/* Disable GIC CPU interface for this CPU. */
tegra_gic_cpu_disable(false);
#ifdef CONFIG_ARCH_TEGRA_11x_SOC
/* disable cache */
asm volatile(
" mrc p15, 0, %0, c1, c0, 0\n"
" bic %0, %0, #0x4 \n"
" mcr p15, 0, %0, c1, c0, 0\n"
: "=r" (r)
: "r" (r)
: "cc"
);
#endif
/* Flush the L1 data cache. */
tegra_flush_l1_cache();
/* Shut down the current CPU. */
tegra3_hotplug_shutdown();
#endif
/* Should never return here. */
BUG();
}
|