24
24
/* Crashlog discovery header types */
25
25
#define CRASH_TYPE_OOBMSM 1
26
26
27
- /* Control Flags */
28
- #define CRASHLOG_FLAG_DISABLE BIT(28)
29
-
30
- /*
31
- * Bits 29 and 30 control the state of bit 31.
32
- *
33
- * Bit 29 will clear bit 31, if set, allowing a new crashlog to be captured.
34
- * Bit 30 will immediately trigger a crashlog to be generated, setting bit 31.
35
- * Bit 31 is the read-only status with a 1 indicating log is complete.
36
- */
37
- #define CRASHLOG_FLAG_TRIGGER_CLEAR BIT(29)
38
- #define CRASHLOG_FLAG_TRIGGER_EXECUTE BIT(30)
39
- #define CRASHLOG_FLAG_TRIGGER_COMPLETE BIT(31)
40
- #define CRASHLOG_FLAG_TRIGGER_MASK GENMASK(31, 28)
41
-
42
27
/* Crashlog Discovery Header */
43
28
#define CONTROL_OFFSET 0x0
44
29
#define GUID_OFFSET 0x4
50
35
/* size is in bytes */
51
36
#define GET_SIZE (v ) ((v) * sizeof(u32))
52
37
38
+ /*
39
+ * Type 1 Version 0
40
+ * status and control registers are combined.
41
+ *
42
+ * Bits 29 and 30 control the state of bit 31.
43
+ * Bit 29 will clear bit 31, if set, allowing a new crashlog to be captured.
44
+ * Bit 30 will immediately trigger a crashlog to be generated, setting bit 31.
45
+ * Bit 31 is the read-only status with a 1 indicating log is complete.
46
+ */
47
+ #define TYPE1_VER0_STATUS_OFFSET 0x00
48
+ #define TYPE1_VER0_CONTROL_OFFSET 0x00
49
+
50
+ #define TYPE1_VER0_DISABLE BIT(28)
51
+ #define TYPE1_VER0_CLEAR BIT(29)
52
+ #define TYPE1_VER0_EXECUTE BIT(30)
53
+ #define TYPE1_VER0_COMPLETE BIT(31)
54
+ #define TYPE1_VER0_TRIGGER_MASK GENMASK(31, 28)
55
+
56
+ /* After offset, order alphabetically, not bit ordered */
57
+ struct crashlog_status {
58
+ u32 offset ;
59
+ u32 cleared ;
60
+ u32 complete ;
61
+ u32 disabled ;
62
+ };
63
+
64
+ struct crashlog_control {
65
+ u32 offset ;
66
+ u32 trigger_mask ;
67
+ u32 clear ;
68
+ u32 disable ;
69
+ u32 manual ;
70
+ };
71
+
72
+ struct crashlog_info {
73
+ const struct crashlog_status status ;
74
+ const struct crashlog_control control ;
75
+ };
76
+
53
77
struct crashlog_entry {
54
78
/* entry must be first member of struct */
55
79
struct intel_pmt_entry entry ;
56
80
struct mutex control_mutex ;
81
+ const struct crashlog_info * info ;
57
82
};
58
83
59
84
struct pmt_crashlog_priv {
@@ -68,38 +93,39 @@ struct pmt_crashlog_priv {
68
93
/* Read, modify, write the control register, setting or clearing @bit based on @set */
69
94
static void pmt_crashlog_rmw (struct crashlog_entry * crashlog , u32 bit , bool set )
70
95
{
96
+ const struct crashlog_control * control = & crashlog -> info -> control ;
71
97
struct intel_pmt_entry * entry = & crashlog -> entry ;
72
- u32 reg = readl (entry -> disc_table + CONTROL_OFFSET );
98
+ u32 reg = readl (entry -> disc_table + control -> offset );
73
99
74
- reg &= ~CRASHLOG_FLAG_TRIGGER_MASK ;
100
+ reg &= ~control -> trigger_mask ;
75
101
76
102
if (set )
77
103
reg |= bit ;
78
104
else
79
105
reg &= ~bit ;
80
106
81
- writel (reg , entry -> disc_table + CONTROL_OFFSET );
107
+ writel (reg , entry -> disc_table + control -> offset );
82
108
}
83
109
84
110
/* Read the status register and see if the specified @bit is set */
85
111
static bool pmt_crashlog_rc (struct crashlog_entry * crashlog , u32 bit )
86
112
{
87
- struct intel_pmt_entry * entry = & crashlog -> entry ;
88
- u32 reg = readl (entry -> disc_table + CONTROL_OFFSET );
113
+ const struct crashlog_status * status = & crashlog -> info -> status ;
114
+ u32 reg = readl (crashlog -> entry . disc_table + status -> offset );
89
115
90
116
return !!(reg & bit );
91
117
}
92
118
93
119
static bool pmt_crashlog_complete (struct crashlog_entry * crashlog )
94
120
{
95
121
/* return current value of the crashlog complete flag */
96
- return pmt_crashlog_rc (crashlog , CRASHLOG_FLAG_TRIGGER_COMPLETE );
122
+ return pmt_crashlog_rc (crashlog , crashlog -> info -> status . complete );
97
123
}
98
124
99
125
static bool pmt_crashlog_disabled (struct crashlog_entry * crashlog )
100
126
{
101
127
/* return current value of the crashlog disabled flag */
102
- return pmt_crashlog_rc (crashlog , CRASHLOG_FLAG_DISABLE );
128
+ return pmt_crashlog_rc (crashlog , crashlog -> info -> status . disabled );
103
129
}
104
130
105
131
static bool pmt_crashlog_supported (struct intel_pmt_entry * entry )
@@ -120,17 +146,17 @@ static bool pmt_crashlog_supported(struct intel_pmt_entry *entry)
120
146
static void pmt_crashlog_set_disable (struct crashlog_entry * crashlog ,
121
147
bool disable )
122
148
{
123
- pmt_crashlog_rmw (crashlog , CRASHLOG_FLAG_DISABLE , disable );
149
+ pmt_crashlog_rmw (crashlog , crashlog -> info -> control . disable , disable );
124
150
}
125
151
126
152
static void pmt_crashlog_set_clear (struct crashlog_entry * crashlog )
127
153
{
128
- pmt_crashlog_rmw (crashlog , CRASHLOG_FLAG_TRIGGER_CLEAR , true);
154
+ pmt_crashlog_rmw (crashlog , crashlog -> info -> control . clear , true);
129
155
}
130
156
131
157
static void pmt_crashlog_set_execute (struct crashlog_entry * crashlog )
132
158
{
133
- pmt_crashlog_rmw (crashlog , CRASHLOG_FLAG_TRIGGER_EXECUTE , true);
159
+ pmt_crashlog_rmw (crashlog , crashlog -> info -> control . manual , true);
134
160
}
135
161
136
162
/*
@@ -224,6 +250,19 @@ static const struct attribute_group pmt_crashlog_group = {
224
250
.attrs = pmt_crashlog_attrs ,
225
251
};
226
252
253
+ static const struct crashlog_info crashlog_type1_ver0 = {
254
+ .status .offset = TYPE1_VER0_STATUS_OFFSET ,
255
+ .status .cleared = TYPE1_VER0_CLEAR ,
256
+ .status .complete = TYPE1_VER0_COMPLETE ,
257
+ .status .disabled = TYPE1_VER0_DISABLE ,
258
+
259
+ .control .offset = TYPE1_VER0_CONTROL_OFFSET ,
260
+ .control .trigger_mask = TYPE1_VER0_TRIGGER_MASK ,
261
+ .control .clear = TYPE1_VER0_CLEAR ,
262
+ .control .disable = TYPE1_VER0_DISABLE ,
263
+ .control .manual = TYPE1_VER0_EXECUTE ,
264
+ };
265
+
227
266
static int pmt_crashlog_header_decode (struct intel_pmt_entry * entry ,
228
267
struct device * dev )
229
268
{
@@ -234,9 +273,10 @@ static int pmt_crashlog_header_decode(struct intel_pmt_entry *entry,
234
273
if (!pmt_crashlog_supported (entry ))
235
274
return 1 ;
236
275
237
- /* initialize control mutex */
276
+ /* initialize the crashlog struct */
238
277
crashlog = container_of (entry , struct crashlog_entry , entry );
239
278
mutex_init (& crashlog -> control_mutex );
279
+ crashlog -> info = & crashlog_type1_ver0 ;
240
280
241
281
header -> access_type = GET_ACCESS (readl (disc_table ));
242
282
header -> guid = readl (disc_table + GUID_OFFSET );
0 commit comments