@@ -64,20 +64,40 @@ struct pmt_crashlog_priv {
6464/*
6565 * I/O
6666 */
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 )
6870{
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+ }
7090
91+ static bool pmt_crashlog_complete (struct intel_pmt_entry * entry )
92+ {
7193 /* 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 );
7395}
7496
7597static bool pmt_crashlog_disabled (struct intel_pmt_entry * entry )
7698{
77- u32 control = readl (entry -> disc_table + CONTROL_OFFSET );
78-
7999 /* return current value of the crashlog disabled flag */
80- return !!( control & CRASHLOG_FLAG_DISABLE );
100+ return pmt_crashlog_rc ( entry , CRASHLOG_FLAG_DISABLE );
81101}
82102
83103static bool pmt_crashlog_supported (struct intel_pmt_entry * entry )
@@ -98,37 +118,17 @@ static bool pmt_crashlog_supported(struct intel_pmt_entry *entry)
98118static void pmt_crashlog_set_disable (struct intel_pmt_entry * entry ,
99119 bool disable )
100120{
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 );
112122}
113123
114124static void pmt_crashlog_set_clear (struct intel_pmt_entry * entry )
115125{
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);
122127}
123128
124129static void pmt_crashlog_set_execute (struct intel_pmt_entry * entry )
125130{
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);
132132}
133133
134134/*
0 commit comments