@@ -64,20 +64,40 @@ struct pmt_crashlog_priv {
64
64
/*
65
65
* I/O
66
66
*/
67
- static bool pmt_crashlog_complete (struct intel_pmt_entry * entry )
67
+
68
+ /* Read, modify, write the control register, setting or clearing @bit based on @set */
69
+ static void pmt_crashlog_rmw (struct intel_pmt_entry * entry , u32 bit , bool set )
68
70
{
69
- u32 control = readl (entry -> disc_table + CONTROL_OFFSET );
71
+ u32 reg = readl (entry -> disc_table + CONTROL_OFFSET );
72
+
73
+ reg &= ~CRASHLOG_FLAG_TRIGGER_MASK ;
74
+
75
+ if (set )
76
+ reg |= bit ;
77
+ else
78
+ reg &= ~bit ;
79
+
80
+ writel (reg , entry -> disc_table + CONTROL_OFFSET );
81
+ }
82
+
83
+ /* Read the status register and see if the specified @bit is set */
84
+ static bool pmt_crashlog_rc (struct intel_pmt_entry * entry , u32 bit )
85
+ {
86
+ u32 reg = readl (entry -> disc_table + CONTROL_OFFSET );
87
+
88
+ return !!(reg & bit );
89
+ }
70
90
91
+ static bool pmt_crashlog_complete (struct intel_pmt_entry * entry )
92
+ {
71
93
/* return current value of the crashlog complete flag */
72
- return !!( control & CRASHLOG_FLAG_TRIGGER_COMPLETE );
94
+ return pmt_crashlog_rc ( entry , CRASHLOG_FLAG_TRIGGER_COMPLETE );
73
95
}
74
96
75
97
static bool pmt_crashlog_disabled (struct intel_pmt_entry * entry )
76
98
{
77
- u32 control = readl (entry -> disc_table + CONTROL_OFFSET );
78
-
79
99
/* return current value of the crashlog disabled flag */
80
- return !!( control & CRASHLOG_FLAG_DISABLE );
100
+ return pmt_crashlog_rc ( entry , CRASHLOG_FLAG_DISABLE );
81
101
}
82
102
83
103
static bool pmt_crashlog_supported (struct intel_pmt_entry * entry )
@@ -98,37 +118,17 @@ static bool pmt_crashlog_supported(struct intel_pmt_entry *entry)
98
118
static void pmt_crashlog_set_disable (struct intel_pmt_entry * entry ,
99
119
bool disable )
100
120
{
101
- u32 control = readl (entry -> disc_table + CONTROL_OFFSET );
102
-
103
- /* clear trigger bits so we are only modifying disable flag */
104
- control &= ~CRASHLOG_FLAG_TRIGGER_MASK ;
105
-
106
- if (disable )
107
- control |= CRASHLOG_FLAG_DISABLE ;
108
- else
109
- control &= ~CRASHLOG_FLAG_DISABLE ;
110
-
111
- writel (control , entry -> disc_table + CONTROL_OFFSET );
121
+ pmt_crashlog_rmw (entry , CRASHLOG_FLAG_DISABLE , disable );
112
122
}
113
123
114
124
static void pmt_crashlog_set_clear (struct intel_pmt_entry * entry )
115
125
{
116
- u32 control = readl (entry -> disc_table + CONTROL_OFFSET );
117
-
118
- control &= ~CRASHLOG_FLAG_TRIGGER_MASK ;
119
- control |= CRASHLOG_FLAG_TRIGGER_CLEAR ;
120
-
121
- writel (control , entry -> disc_table + CONTROL_OFFSET );
126
+ pmt_crashlog_rmw (entry , CRASHLOG_FLAG_TRIGGER_CLEAR , true);
122
127
}
123
128
124
129
static void pmt_crashlog_set_execute (struct intel_pmt_entry * entry )
125
130
{
126
- u32 control = readl (entry -> disc_table + CONTROL_OFFSET );
127
-
128
- control &= ~CRASHLOG_FLAG_TRIGGER_MASK ;
129
- control |= CRASHLOG_FLAG_TRIGGER_EXECUTE ;
130
-
131
- writel (control , entry -> disc_table + CONTROL_OFFSET );
131
+ pmt_crashlog_rmw (entry , CRASHLOG_FLAG_TRIGGER_EXECUTE , true);
132
132
}
133
133
134
134
/*
0 commit comments