summaryrefslogtreecommitdiffstats
path: root/include/linux/tegra-mce.h
blob: 047ea68f73cbfc8baf37131f3e34f8ddff0aab64 (plain) (blame)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef _LINUX_TEGRA_MCE_H
#define _LINUX_TEGRA_MCE_H

/* NOTE:
 * For correct version validation, below two defines need to be
 * updated whenever there is a new ARI implementation.
 */
#define CUR_ARI_VER_MAJOR	1
#define CUR_ARI_VER_MINOR	2

enum {
	TEGRA_MCE_XOVER_C1_C6, /* Only valid for Denver */
	TEGRA_MCE_XOVER_CC1_CC6,
	TEGRA_MCE_XOVER_CC1_CC7,

	TEGRA_MCE_XOVER_MAX = TEGRA_MCE_XOVER_CC1_CC7
};

enum {
	TEGRA_MCE_CSTATS_CLEAR,

	TEGRA_MCE_CSTATS_ENTRIES_SC7,
	TEGRA_MCE_CSTATS_ENTRIES_SC4,
	TEGRA_MCE_CSTATS_ENTRIES_SC3,
	TEGRA_MCE_CSTATS_ENTRIES_SC2,
	TEGRA_MCE_CSTATS_ENTRIES_CCP3,
	TEGRA_MCE_CSTATS_ENTRIES_A57_CC6,
	TEGRA_MCE_CSTATS_ENTRIES_A57_CC7,
	TEGRA_MCE_CSTATS_ENTRIES_D15_CC6,
	TEGRA_MCE_CSTATS_ENTRIES_D15_CC7,
	TEGRA_MCE_CSTATS_ENTRIES_D15_CORE0_C6,
	TEGRA_MCE_CSTATS_ENTRIES_D15_CORE1_C6,
	/* RESV: 12-13 */
	TEGRA_MCE_CSTATS_ENTRIES_D15_CORE0_C7 = 14,
	TEGRA_MCE_CSTATS_ENTRIES_D15_CORE1_C7,
	/* RESV: 16-17 */
	TEGRA_MCE_CSTATS_ENTRIES_A57_CORE0_C7 = 18,
	TEGRA_MCE_CSTATS_ENTRIES_A57_CORE1_C7,
	TEGRA_MCE_CSTATS_ENTRIES_A57_CORE2_C7,
	TEGRA_MCE_CSTATS_ENTRIES_A57_CORE3_C7,
	TEGRA_MCE_CSTATS_LAST_ENTRY_D15_CORE0,
	TEGRA_MCE_CSTATS_LAST_ENTRY_D15_CORE1,
	/* RESV: 24-25 */
	TEGRA_MCE_CSTATS_LAST_ENTRY_A57_CORE0,
	TEGRA_MCE_CSTATS_LAST_ENTRY_A57_CORE1,
	TEGRA_MCE_CSTATS_LAST_ENTRY_A57_CORE2,
	TEGRA_MCE_CSTATS_LAST_ENTRY_A57_CORE3,

	TEGRA_MCE_CSTATS_MAX = TEGRA_MCE_CSTATS_LAST_ENTRY_A57_CORE3,
};

enum {
	TEGRA_MCE_ENUM_D15_CORE0,
	TEGRA_MCE_D15_CORE1,
	/* RESV: 2-3 */
	TEGRA_MCE_ENUM_A57_0 = 4,
	TEGRA_MCE_ENUM_A57_1,
	TEGRA_MCE_ENUM_A57_2,
	TEGRA_MCE_ENUM_A57_3,

	TEGRA_MCE_ENUM_MAX = TEGRA_MCE_ENUM_A57_3,
};

enum {
	TEGRA_MCE_FEATURE_CCP3,
};

/* MCA support */
typedef union {
	struct {
		u8 cmd;
		u8 subidx;
		u8 idx;
		u8 inst;
	};
	struct {
		u32 low;
		u32 high;
	};
	u64 data;
} mca_cmd_t;

/* NOTE: These functions will return -ENOTSUPP if no implementation */
int tegra_mce_enter_cstate(u32 state, u32 wake_time);
int tegra_mce_update_cstate_info(u32 cluster, u32 ccplex, u32 system,
				 u8 force, u32 wake_mask, bool valid);
int tegra_mce_update_crossover_time(u32 type, u32 time);
int tegra_mce_read_cstate_stats(u32 state, u64 *stats);
int tegra_mce_write_cstate_stats(u32 state, u32 stats);
int tegra_mce_is_sc7_allowed(u32 state, u32 wake, u32 *allowed);
int tegra_mce_online_core(int cpu);
int tegra_mce_cc3_ctrl(u32 ndiv, u32 vindex, u8 enable);
int tegra_mce_echo_data(u32 data, int *matched);
int tegra_mce_read_versions(u32 *major, u32 *minor);
int tegra_mce_enum_features(u64 *features);
int tegra_mce_read_uncore_mca(mca_cmd_t cmd, u64 *data, u32 *error);
int tegra_mce_write_uncore_mca(mca_cmd_t cmd, u64 data, u32 *error);
int tegra_mce_read_uncore_perfmon(u32 req, u32 *data);
int tegra_mce_write_uncore_perfmon(u32 req, u32 data);
int tegra_mce_enable_latic(void);
int tegra_mce_write_dda_ctrl(u32 index, u64 value);
int tegra_mce_read_dda_ctrl(u32 index, u64 *value);

/* Tegra cache functions */
int tegra_flush_cache_all(void);
int tegra_flush_dcache_all(void *__maybe_unused unused);
int tegra_clean_dcache_all(void *__maybe_unused unused);
/* L3 cache ways read/write functions */
int tegra_mce_read_l3_cache_ways(u64 *value);
int tegra_mce_write_l3_cache_ways(u64 data, u64 *value);

#endif /* _LINUX_TEGRA_MCE_H */