summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/reset.h
blob: 7aefb702e76b9b37b7423422e3351d60795d460b (plain)
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
/*
 * arch/arm/mach-tegra/reset.h
 *
 * Declarations for reset dispatcher.
 *
 * Copyright (c) 2011, NVIDIA Corporation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef __MACH_TEGRA_RESET_H
#define __MACH_TEGRA_RESET_H

#define TEGRA_RESET_MASK_PRESENT_PTR	0
#define TEGRA_RESET_MASK_ONLINE_PTR	1
#define TEGRA_RESET_MASK_INIT		2
#define TEGRA_RESET_MASK_LP1		3
#define TEGRA_RESET_MASK_LP2		4
#define TEGRA_RESET_STARTUP_SECONDARY	5
#define TEGRA_RESET_STARTUP_HOTPLUG	6
#define TEGRA_RESET_STARTUP_LP2		7
#define TEGRA_RESET_STARTUP_LP1		8
#define TEGRA_RESET_DATA_SIZE		9

#ifndef __ASSEMBLY__

#include <asm/localtimer.h>

extern unsigned long __tegra_cpu_reset_handler_data[TEGRA_RESET_DATA_SIZE];
extern unsigned long tegra_wfi_fail_count[CONFIG_NR_CPUS];
extern void __tegra_cpu_reset_handler_start(void);

#ifdef CONFIG_SMP
#define tegra_cpu_init_map (*(unsigned long *)(IO_ADDRESS(TEGRA_RESET_HANDLER_BASE + \
		((unsigned long)&__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_INIT] - \
		 (unsigned long)__tegra_cpu_reset_handler_start))))
#endif
#ifdef CONFIG_PM
#define tegra_cpu_lp1_map (*(unsigned long *)(IO_ADDRESS(TEGRA_RESET_HANDLER_BASE + \
		((unsigned long)&__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_LP1] - \
		 (unsigned long)__tegra_cpu_reset_handler_start))))

#define tegra_cpu_reset_handler_ptr ((unsigned long *)(IO_ADDRESS(TEGRA_RESET_HANDLER_BASE + \
		((unsigned long)__tegra_cpu_reset_handler_data - \
		 (unsigned long)__tegra_cpu_reset_handler_start))))
#endif

#define tegra_cpu_lp2_map (*(unsigned long *)(IO_ADDRESS(TEGRA_RESET_HANDLER_BASE + \
		((unsigned long)&__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_LP2] - \
		 (unsigned long)__tegra_cpu_reset_handler_start))))

extern spinlock_t lp2_map_lock;

static inline bool suspend_wfi_failed(void)
{
#if defined(CONFIG_HAVE_ARM_TWD) /* !!!FIXME!!! && defined(DEBUG) */
	u32 twd_load = readl(twd_base);
	unsigned int cpu = hard_smp_processor_id();

	/* Did the WFI fail? */
	if (twd_load == (0xBAD00000 | cpu))
		return true;
#endif
	return false;
}

void tegra_cpu_reset_handler_enable(void);
void tegra_cpu_reset_handler_flush(bool l1cache);

#ifdef CONFIG_PM
void tegra_cpu_reset_handler_save(void);
void tegra_cpu_reset_handler_restore(void);
#endif

void __init tegra_cpu_reset_handler_init(void);

#endif

#endif