diff options
Diffstat (limited to 'drivers/misc/mei/hw-me.c')
-rw-r--r-- | drivers/misc/mei/hw-me.c | 170 |
1 files changed, 101 insertions, 69 deletions
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index f8fd503dfbd6..6fb75e62a764 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "hw-me.h" | 25 | #include "hw-me.h" |
26 | #include "hw-me-regs.h" | 26 | #include "hw-me-regs.h" |
27 | 27 | ||
28 | #include "mei-trace.h" | ||
29 | |||
28 | /** | 30 | /** |
29 | * mei_me_reg_read - Reads 32bit data from the mei device | 31 | * mei_me_reg_read - Reads 32bit data from the mei device |
30 | * | 32 | * |
@@ -61,45 +63,79 @@ static inline void mei_me_reg_write(const struct mei_me_hw *hw, | |||
61 | * | 63 | * |
62 | * Return: ME_CB_RW register value (u32) | 64 | * Return: ME_CB_RW register value (u32) |
63 | */ | 65 | */ |
64 | static u32 mei_me_mecbrw_read(const struct mei_device *dev) | 66 | static inline u32 mei_me_mecbrw_read(const struct mei_device *dev) |
65 | { | 67 | { |
66 | return mei_me_reg_read(to_me_hw(dev), ME_CB_RW); | 68 | return mei_me_reg_read(to_me_hw(dev), ME_CB_RW); |
67 | } | 69 | } |
70 | |||
71 | /** | ||
72 | * mei_me_hcbww_write - write 32bit data to the host circular buffer | ||
73 | * | ||
74 | * @dev: the device structure | ||
75 | * @data: 32bit data to be written to the host circular buffer | ||
76 | */ | ||
77 | static inline void mei_me_hcbww_write(struct mei_device *dev, u32 data) | ||
78 | { | ||
79 | mei_me_reg_write(to_me_hw(dev), H_CB_WW, data); | ||
80 | } | ||
81 | |||
68 | /** | 82 | /** |
69 | * mei_me_mecsr_read - Reads 32bit data from the ME CSR | 83 | * mei_me_mecsr_read - Reads 32bit data from the ME CSR |
70 | * | 84 | * |
71 | * @hw: the me hardware structure | 85 | * @dev: the device structure |
72 | * | 86 | * |
73 | * Return: ME_CSR_HA register value (u32) | 87 | * Return: ME_CSR_HA register value (u32) |
74 | */ | 88 | */ |
75 | static inline u32 mei_me_mecsr_read(const struct mei_me_hw *hw) | 89 | static inline u32 mei_me_mecsr_read(const struct mei_device *dev) |
76 | { | 90 | { |
77 | return mei_me_reg_read(hw, ME_CSR_HA); | 91 | u32 reg; |
92 | |||
93 | reg = mei_me_reg_read(to_me_hw(dev), ME_CSR_HA); | ||
94 | trace_mei_reg_read(dev->dev, "ME_CSR_HA", ME_CSR_HA, reg); | ||
95 | |||
96 | return reg; | ||
78 | } | 97 | } |
79 | 98 | ||
80 | /** | 99 | /** |
81 | * mei_hcsr_read - Reads 32bit data from the host CSR | 100 | * mei_hcsr_read - Reads 32bit data from the host CSR |
82 | * | 101 | * |
83 | * @hw: the me hardware structure | 102 | * @dev: the device structure |
84 | * | 103 | * |
85 | * Return: H_CSR register value (u32) | 104 | * Return: H_CSR register value (u32) |
86 | */ | 105 | */ |
87 | static inline u32 mei_hcsr_read(const struct mei_me_hw *hw) | 106 | static inline u32 mei_hcsr_read(const struct mei_device *dev) |
107 | { | ||
108 | u32 reg; | ||
109 | |||
110 | reg = mei_me_reg_read(to_me_hw(dev), H_CSR); | ||
111 | trace_mei_reg_read(dev->dev, "H_CSR", H_CSR, reg); | ||
112 | |||
113 | return reg; | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * mei_hcsr_write - writes H_CSR register to the mei device | ||
118 | * | ||
119 | * @dev: the device structure | ||
120 | * @reg: new register value | ||
121 | */ | ||
122 | static inline void mei_hcsr_write(struct mei_device *dev, u32 reg) | ||
88 | { | 123 | { |
89 | return mei_me_reg_read(hw, H_CSR); | 124 | trace_mei_reg_write(dev->dev, "H_CSR", H_CSR, reg); |
125 | mei_me_reg_write(to_me_hw(dev), H_CSR, reg); | ||
90 | } | 126 | } |
91 | 127 | ||
92 | /** | 128 | /** |
93 | * mei_hcsr_set - writes H_CSR register to the mei device, | 129 | * mei_hcsr_set - writes H_CSR register to the mei device, |
94 | * and ignores the H_IS bit for it is write-one-to-zero. | 130 | * and ignores the H_IS bit for it is write-one-to-zero. |
95 | * | 131 | * |
96 | * @hw: the me hardware structure | 132 | * @dev: the device structure |
97 | * @hcsr: new register value | 133 | * @reg: new register value |
98 | */ | 134 | */ |
99 | static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr) | 135 | static inline void mei_hcsr_set(struct mei_device *dev, u32 reg) |
100 | { | 136 | { |
101 | hcsr &= ~H_IS; | 137 | reg &= ~H_IS; |
102 | mei_me_reg_write(hw, H_CSR, hcsr); | 138 | mei_hcsr_write(dev, reg); |
103 | } | 139 | } |
104 | 140 | ||
105 | /** | 141 | /** |
@@ -141,7 +177,7 @@ static int mei_me_fw_status(struct mei_device *dev, | |||
141 | static void mei_me_hw_config(struct mei_device *dev) | 177 | static void mei_me_hw_config(struct mei_device *dev) |
142 | { | 178 | { |
143 | struct mei_me_hw *hw = to_me_hw(dev); | 179 | struct mei_me_hw *hw = to_me_hw(dev); |
144 | u32 hcsr = mei_hcsr_read(to_me_hw(dev)); | 180 | u32 hcsr = mei_hcsr_read(dev); |
145 | /* Doesn't change in runtime */ | 181 | /* Doesn't change in runtime */ |
146 | dev->hbuf_depth = (hcsr & H_CBD) >> 24; | 182 | dev->hbuf_depth = (hcsr & H_CBD) >> 24; |
147 | 183 | ||
@@ -170,11 +206,10 @@ static inline enum mei_pg_state mei_me_pg_state(struct mei_device *dev) | |||
170 | */ | 206 | */ |
171 | static void mei_me_intr_clear(struct mei_device *dev) | 207 | static void mei_me_intr_clear(struct mei_device *dev) |
172 | { | 208 | { |
173 | struct mei_me_hw *hw = to_me_hw(dev); | 209 | u32 hcsr = mei_hcsr_read(dev); |
174 | u32 hcsr = mei_hcsr_read(hw); | ||
175 | 210 | ||
176 | if ((hcsr & H_IS) == H_IS) | 211 | if ((hcsr & H_IS) == H_IS) |
177 | mei_me_reg_write(hw, H_CSR, hcsr); | 212 | mei_hcsr_write(dev, hcsr); |
178 | } | 213 | } |
179 | /** | 214 | /** |
180 | * mei_me_intr_enable - enables mei device interrupts | 215 | * mei_me_intr_enable - enables mei device interrupts |
@@ -183,11 +218,10 @@ static void mei_me_intr_clear(struct mei_device *dev) | |||
183 | */ | 218 | */ |
184 | static void mei_me_intr_enable(struct mei_device *dev) | 219 | static void mei_me_intr_enable(struct mei_device *dev) |
185 | { | 220 | { |
186 | struct mei_me_hw *hw = to_me_hw(dev); | 221 | u32 hcsr = mei_hcsr_read(dev); |
187 | u32 hcsr = mei_hcsr_read(hw); | ||
188 | 222 | ||
189 | hcsr |= H_IE; | 223 | hcsr |= H_IE; |
190 | mei_hcsr_set(hw, hcsr); | 224 | mei_hcsr_set(dev, hcsr); |
191 | } | 225 | } |
192 | 226 | ||
193 | /** | 227 | /** |
@@ -197,11 +231,10 @@ static void mei_me_intr_enable(struct mei_device *dev) | |||
197 | */ | 231 | */ |
198 | static void mei_me_intr_disable(struct mei_device *dev) | 232 | static void mei_me_intr_disable(struct mei_device *dev) |
199 | { | 233 | { |
200 | struct mei_me_hw *hw = to_me_hw(dev); | 234 | u32 hcsr = mei_hcsr_read(dev); |
201 | u32 hcsr = mei_hcsr_read(hw); | ||
202 | 235 | ||
203 | hcsr &= ~H_IE; | 236 | hcsr &= ~H_IE; |
204 | mei_hcsr_set(hw, hcsr); | 237 | mei_hcsr_set(dev, hcsr); |
205 | } | 238 | } |
206 | 239 | ||
207 | /** | 240 | /** |
@@ -211,12 +244,11 @@ static void mei_me_intr_disable(struct mei_device *dev) | |||
211 | */ | 244 | */ |
212 | static void mei_me_hw_reset_release(struct mei_device *dev) | 245 | static void mei_me_hw_reset_release(struct mei_device *dev) |
213 | { | 246 | { |
214 | struct mei_me_hw *hw = to_me_hw(dev); | 247 | u32 hcsr = mei_hcsr_read(dev); |
215 | u32 hcsr = mei_hcsr_read(hw); | ||
216 | 248 | ||
217 | hcsr |= H_IG; | 249 | hcsr |= H_IG; |
218 | hcsr &= ~H_RST; | 250 | hcsr &= ~H_RST; |
219 | mei_hcsr_set(hw, hcsr); | 251 | mei_hcsr_set(dev, hcsr); |
220 | 252 | ||
221 | /* complete this write before we set host ready on another CPU */ | 253 | /* complete this write before we set host ready on another CPU */ |
222 | mmiowb(); | 254 | mmiowb(); |
@@ -231,8 +263,7 @@ static void mei_me_hw_reset_release(struct mei_device *dev) | |||
231 | */ | 263 | */ |
232 | static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) | 264 | static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) |
233 | { | 265 | { |
234 | struct mei_me_hw *hw = to_me_hw(dev); | 266 | u32 hcsr = mei_hcsr_read(dev); |
235 | u32 hcsr = mei_hcsr_read(hw); | ||
236 | 267 | ||
237 | /* H_RST may be found lit before reset is started, | 268 | /* H_RST may be found lit before reset is started, |
238 | * for example if preceding reset flow hasn't completed. | 269 | * for example if preceding reset flow hasn't completed. |
@@ -242,8 +273,8 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) | |||
242 | if ((hcsr & H_RST) == H_RST) { | 273 | if ((hcsr & H_RST) == H_RST) { |
243 | dev_warn(dev->dev, "H_RST is set = 0x%08X", hcsr); | 274 | dev_warn(dev->dev, "H_RST is set = 0x%08X", hcsr); |
244 | hcsr &= ~H_RST; | 275 | hcsr &= ~H_RST; |
245 | mei_hcsr_set(hw, hcsr); | 276 | mei_hcsr_set(dev, hcsr); |
246 | hcsr = mei_hcsr_read(hw); | 277 | hcsr = mei_hcsr_read(dev); |
247 | } | 278 | } |
248 | 279 | ||
249 | hcsr |= H_RST | H_IG | H_IS; | 280 | hcsr |= H_RST | H_IG | H_IS; |
@@ -254,13 +285,13 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) | |||
254 | hcsr &= ~H_IE; | 285 | hcsr &= ~H_IE; |
255 | 286 | ||
256 | dev->recvd_hw_ready = false; | 287 | dev->recvd_hw_ready = false; |
257 | mei_me_reg_write(hw, H_CSR, hcsr); | 288 | mei_hcsr_write(dev, hcsr); |
258 | 289 | ||
259 | /* | 290 | /* |
260 | * Host reads the H_CSR once to ensure that the | 291 | * Host reads the H_CSR once to ensure that the |
261 | * posted write to H_CSR completes. | 292 | * posted write to H_CSR completes. |
262 | */ | 293 | */ |
263 | hcsr = mei_hcsr_read(hw); | 294 | hcsr = mei_hcsr_read(dev); |
264 | 295 | ||
265 | if ((hcsr & H_RST) == 0) | 296 | if ((hcsr & H_RST) == 0) |
266 | dev_warn(dev->dev, "H_RST is not set = 0x%08X", hcsr); | 297 | dev_warn(dev->dev, "H_RST is not set = 0x%08X", hcsr); |
@@ -281,11 +312,10 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) | |||
281 | */ | 312 | */ |
282 | static void mei_me_host_set_ready(struct mei_device *dev) | 313 | static void mei_me_host_set_ready(struct mei_device *dev) |
283 | { | 314 | { |
284 | struct mei_me_hw *hw = to_me_hw(dev); | 315 | u32 hcsr = mei_hcsr_read(dev); |
285 | u32 hcsr = mei_hcsr_read(hw); | ||
286 | 316 | ||
287 | hcsr |= H_IE | H_IG | H_RDY; | 317 | hcsr |= H_IE | H_IG | H_RDY; |
288 | mei_hcsr_set(hw, hcsr); | 318 | mei_hcsr_set(dev, hcsr); |
289 | } | 319 | } |
290 | 320 | ||
291 | /** | 321 | /** |
@@ -296,8 +326,7 @@ static void mei_me_host_set_ready(struct mei_device *dev) | |||
296 | */ | 326 | */ |
297 | static bool mei_me_host_is_ready(struct mei_device *dev) | 327 | static bool mei_me_host_is_ready(struct mei_device *dev) |
298 | { | 328 | { |
299 | struct mei_me_hw *hw = to_me_hw(dev); | 329 | u32 hcsr = mei_hcsr_read(dev); |
300 | u32 hcsr = mei_hcsr_read(hw); | ||
301 | 330 | ||
302 | return (hcsr & H_RDY) == H_RDY; | 331 | return (hcsr & H_RDY) == H_RDY; |
303 | } | 332 | } |
@@ -310,8 +339,7 @@ static bool mei_me_host_is_ready(struct mei_device *dev) | |||
310 | */ | 339 | */ |
311 | static bool mei_me_hw_is_ready(struct mei_device *dev) | 340 | static bool mei_me_hw_is_ready(struct mei_device *dev) |
312 | { | 341 | { |
313 | struct mei_me_hw *hw = to_me_hw(dev); | 342 | u32 mecsr = mei_me_mecsr_read(dev); |
314 | u32 mecsr = mei_me_mecsr_read(hw); | ||
315 | 343 | ||
316 | return (mecsr & ME_RDY_HRA) == ME_RDY_HRA; | 344 | return (mecsr & ME_RDY_HRA) == ME_RDY_HRA; |
317 | } | 345 | } |
@@ -368,11 +396,10 @@ static int mei_me_hw_start(struct mei_device *dev) | |||
368 | */ | 396 | */ |
369 | static unsigned char mei_hbuf_filled_slots(struct mei_device *dev) | 397 | static unsigned char mei_hbuf_filled_slots(struct mei_device *dev) |
370 | { | 398 | { |
371 | struct mei_me_hw *hw = to_me_hw(dev); | ||
372 | u32 hcsr; | 399 | u32 hcsr; |
373 | char read_ptr, write_ptr; | 400 | char read_ptr, write_ptr; |
374 | 401 | ||
375 | hcsr = mei_hcsr_read(hw); | 402 | hcsr = mei_hcsr_read(dev); |
376 | 403 | ||
377 | read_ptr = (char) ((hcsr & H_CBRP) >> 8); | 404 | read_ptr = (char) ((hcsr & H_CBRP) >> 8); |
378 | write_ptr = (char) ((hcsr & H_CBWP) >> 16); | 405 | write_ptr = (char) ((hcsr & H_CBWP) >> 16); |
@@ -439,7 +466,6 @@ static int mei_me_write_message(struct mei_device *dev, | |||
439 | struct mei_msg_hdr *header, | 466 | struct mei_msg_hdr *header, |
440 | unsigned char *buf) | 467 | unsigned char *buf) |
441 | { | 468 | { |
442 | struct mei_me_hw *hw = to_me_hw(dev); | ||
443 | unsigned long rem; | 469 | unsigned long rem; |
444 | unsigned long length = header->length; | 470 | unsigned long length = header->length; |
445 | u32 *reg_buf = (u32 *)buf; | 471 | u32 *reg_buf = (u32 *)buf; |
@@ -457,21 +483,21 @@ static int mei_me_write_message(struct mei_device *dev, | |||
457 | if (empty_slots < 0 || dw_cnt > empty_slots) | 483 | if (empty_slots < 0 || dw_cnt > empty_slots) |
458 | return -EMSGSIZE; | 484 | return -EMSGSIZE; |
459 | 485 | ||
460 | mei_me_reg_write(hw, H_CB_WW, *((u32 *) header)); | 486 | mei_me_hcbww_write(dev, *((u32 *) header)); |
461 | 487 | ||
462 | for (i = 0; i < length / 4; i++) | 488 | for (i = 0; i < length / 4; i++) |
463 | mei_me_reg_write(hw, H_CB_WW, reg_buf[i]); | 489 | mei_me_hcbww_write(dev, reg_buf[i]); |
464 | 490 | ||
465 | rem = length & 0x3; | 491 | rem = length & 0x3; |
466 | if (rem > 0) { | 492 | if (rem > 0) { |
467 | u32 reg = 0; | 493 | u32 reg = 0; |
468 | 494 | ||
469 | memcpy(®, &buf[length - rem], rem); | 495 | memcpy(®, &buf[length - rem], rem); |
470 | mei_me_reg_write(hw, H_CB_WW, reg); | 496 | mei_me_hcbww_write(dev, reg); |
471 | } | 497 | } |
472 | 498 | ||
473 | hcsr = mei_hcsr_read(hw) | H_IG; | 499 | hcsr = mei_hcsr_read(dev) | H_IG; |
474 | mei_hcsr_set(hw, hcsr); | 500 | mei_hcsr_set(dev, hcsr); |
475 | if (!mei_me_hw_is_ready(dev)) | 501 | if (!mei_me_hw_is_ready(dev)) |
476 | return -EIO; | 502 | return -EIO; |
477 | 503 | ||
@@ -487,12 +513,11 @@ static int mei_me_write_message(struct mei_device *dev, | |||
487 | */ | 513 | */ |
488 | static int mei_me_count_full_read_slots(struct mei_device *dev) | 514 | static int mei_me_count_full_read_slots(struct mei_device *dev) |
489 | { | 515 | { |
490 | struct mei_me_hw *hw = to_me_hw(dev); | ||
491 | u32 me_csr; | 516 | u32 me_csr; |
492 | char read_ptr, write_ptr; | 517 | char read_ptr, write_ptr; |
493 | unsigned char buffer_depth, filled_slots; | 518 | unsigned char buffer_depth, filled_slots; |
494 | 519 | ||
495 | me_csr = mei_me_mecsr_read(hw); | 520 | me_csr = mei_me_mecsr_read(dev); |
496 | buffer_depth = (unsigned char)((me_csr & ME_CBD_HRA) >> 24); | 521 | buffer_depth = (unsigned char)((me_csr & ME_CBD_HRA) >> 24); |
497 | read_ptr = (char) ((me_csr & ME_CBRP_HRA) >> 8); | 522 | read_ptr = (char) ((me_csr & ME_CBRP_HRA) >> 8); |
498 | write_ptr = (char) ((me_csr & ME_CBWP_HRA) >> 16); | 523 | write_ptr = (char) ((me_csr & ME_CBWP_HRA) >> 16); |
@@ -518,7 +543,6 @@ static int mei_me_count_full_read_slots(struct mei_device *dev) | |||
518 | static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer, | 543 | static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer, |
519 | unsigned long buffer_length) | 544 | unsigned long buffer_length) |
520 | { | 545 | { |
521 | struct mei_me_hw *hw = to_me_hw(dev); | ||
522 | u32 *reg_buf = (u32 *)buffer; | 546 | u32 *reg_buf = (u32 *)buffer; |
523 | u32 hcsr; | 547 | u32 hcsr; |
524 | 548 | ||
@@ -531,49 +555,59 @@ static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer, | |||
531 | memcpy(reg_buf, ®, buffer_length); | 555 | memcpy(reg_buf, ®, buffer_length); |
532 | } | 556 | } |
533 | 557 | ||
534 | hcsr = mei_hcsr_read(hw) | H_IG; | 558 | hcsr = mei_hcsr_read(dev) | H_IG; |
535 | mei_hcsr_set(hw, hcsr); | 559 | mei_hcsr_set(dev, hcsr); |
536 | return 0; | 560 | return 0; |
537 | } | 561 | } |
538 | 562 | ||
539 | /** | 563 | /** |
540 | * mei_me_pg_enter - write pg enter register | 564 | * mei_me_pg_set - write pg enter register |
541 | * | 565 | * |
542 | * @dev: the device structure | 566 | * @dev: the device structure |
543 | */ | 567 | */ |
544 | static void mei_me_pg_enter(struct mei_device *dev) | 568 | static void mei_me_pg_set(struct mei_device *dev) |
545 | { | 569 | { |
546 | struct mei_me_hw *hw = to_me_hw(dev); | 570 | struct mei_me_hw *hw = to_me_hw(dev); |
547 | u32 reg = mei_me_reg_read(hw, H_HPG_CSR); | 571 | u32 reg; |
572 | |||
573 | reg = mei_me_reg_read(hw, H_HPG_CSR); | ||
574 | trace_mei_reg_read(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); | ||
548 | 575 | ||
549 | reg |= H_HPG_CSR_PGI; | 576 | reg |= H_HPG_CSR_PGI; |
577 | |||
578 | trace_mei_reg_write(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); | ||
550 | mei_me_reg_write(hw, H_HPG_CSR, reg); | 579 | mei_me_reg_write(hw, H_HPG_CSR, reg); |
551 | } | 580 | } |
552 | 581 | ||
553 | /** | 582 | /** |
554 | * mei_me_pg_exit - write pg exit register | 583 | * mei_me_pg_unset - write pg exit register |
555 | * | 584 | * |
556 | * @dev: the device structure | 585 | * @dev: the device structure |
557 | */ | 586 | */ |
558 | static void mei_me_pg_exit(struct mei_device *dev) | 587 | static void mei_me_pg_unset(struct mei_device *dev) |
559 | { | 588 | { |
560 | struct mei_me_hw *hw = to_me_hw(dev); | 589 | struct mei_me_hw *hw = to_me_hw(dev); |
561 | u32 reg = mei_me_reg_read(hw, H_HPG_CSR); | 590 | u32 reg; |
591 | |||
592 | reg = mei_me_reg_read(hw, H_HPG_CSR); | ||
593 | trace_mei_reg_read(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); | ||
562 | 594 | ||
563 | WARN(!(reg & H_HPG_CSR_PGI), "PGI is not set\n"); | 595 | WARN(!(reg & H_HPG_CSR_PGI), "PGI is not set\n"); |
564 | 596 | ||
565 | reg |= H_HPG_CSR_PGIHEXR; | 597 | reg |= H_HPG_CSR_PGIHEXR; |
598 | |||
599 | trace_mei_reg_write(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); | ||
566 | mei_me_reg_write(hw, H_HPG_CSR, reg); | 600 | mei_me_reg_write(hw, H_HPG_CSR, reg); |
567 | } | 601 | } |
568 | 602 | ||
569 | /** | 603 | /** |
570 | * mei_me_pg_set_sync - perform pg entry procedure | 604 | * mei_me_pg_enter_sync - perform pg entry procedure |
571 | * | 605 | * |
572 | * @dev: the device structure | 606 | * @dev: the device structure |
573 | * | 607 | * |
574 | * Return: 0 on success an error code otherwise | 608 | * Return: 0 on success an error code otherwise |
575 | */ | 609 | */ |
576 | int mei_me_pg_set_sync(struct mei_device *dev) | 610 | int mei_me_pg_enter_sync(struct mei_device *dev) |
577 | { | 611 | { |
578 | struct mei_me_hw *hw = to_me_hw(dev); | 612 | struct mei_me_hw *hw = to_me_hw(dev); |
579 | unsigned long timeout = mei_secs_to_jiffies(MEI_PGI_TIMEOUT); | 613 | unsigned long timeout = mei_secs_to_jiffies(MEI_PGI_TIMEOUT); |
@@ -591,7 +625,7 @@ int mei_me_pg_set_sync(struct mei_device *dev) | |||
591 | mutex_lock(&dev->device_lock); | 625 | mutex_lock(&dev->device_lock); |
592 | 626 | ||
593 | if (dev->pg_event == MEI_PG_EVENT_RECEIVED) { | 627 | if (dev->pg_event == MEI_PG_EVENT_RECEIVED) { |
594 | mei_me_pg_enter(dev); | 628 | mei_me_pg_set(dev); |
595 | ret = 0; | 629 | ret = 0; |
596 | } else { | 630 | } else { |
597 | ret = -ETIME; | 631 | ret = -ETIME; |
@@ -604,13 +638,13 @@ int mei_me_pg_set_sync(struct mei_device *dev) | |||
604 | } | 638 | } |
605 | 639 | ||
606 | /** | 640 | /** |
607 | * mei_me_pg_unset_sync - perform pg exit procedure | 641 | * mei_me_pg_exit_sync - perform pg exit procedure |
608 | * | 642 | * |
609 | * @dev: the device structure | 643 | * @dev: the device structure |
610 | * | 644 | * |
611 | * Return: 0 on success an error code otherwise | 645 | * Return: 0 on success an error code otherwise |
612 | */ | 646 | */ |
613 | int mei_me_pg_unset_sync(struct mei_device *dev) | 647 | int mei_me_pg_exit_sync(struct mei_device *dev) |
614 | { | 648 | { |
615 | struct mei_me_hw *hw = to_me_hw(dev); | 649 | struct mei_me_hw *hw = to_me_hw(dev); |
616 | unsigned long timeout = mei_secs_to_jiffies(MEI_PGI_TIMEOUT); | 650 | unsigned long timeout = mei_secs_to_jiffies(MEI_PGI_TIMEOUT); |
@@ -621,7 +655,7 @@ int mei_me_pg_unset_sync(struct mei_device *dev) | |||
621 | 655 | ||
622 | dev->pg_event = MEI_PG_EVENT_WAIT; | 656 | dev->pg_event = MEI_PG_EVENT_WAIT; |
623 | 657 | ||
624 | mei_me_pg_exit(dev); | 658 | mei_me_pg_unset(dev); |
625 | 659 | ||
626 | mutex_unlock(&dev->device_lock); | 660 | mutex_unlock(&dev->device_lock); |
627 | wait_event_timeout(dev->wait_pg, | 661 | wait_event_timeout(dev->wait_pg, |
@@ -649,8 +683,7 @@ reply: | |||
649 | */ | 683 | */ |
650 | static bool mei_me_pg_is_enabled(struct mei_device *dev) | 684 | static bool mei_me_pg_is_enabled(struct mei_device *dev) |
651 | { | 685 | { |
652 | struct mei_me_hw *hw = to_me_hw(dev); | 686 | u32 reg = mei_me_mecsr_read(dev); |
653 | u32 reg = mei_me_reg_read(hw, ME_CSR_HA); | ||
654 | 687 | ||
655 | if ((reg & ME_PGIC_HRA) == 0) | 688 | if ((reg & ME_PGIC_HRA) == 0) |
656 | goto notsupported; | 689 | goto notsupported; |
@@ -683,14 +716,13 @@ notsupported: | |||
683 | irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id) | 716 | irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id) |
684 | { | 717 | { |
685 | struct mei_device *dev = (struct mei_device *) dev_id; | 718 | struct mei_device *dev = (struct mei_device *) dev_id; |
686 | struct mei_me_hw *hw = to_me_hw(dev); | 719 | u32 hcsr = mei_hcsr_read(dev); |
687 | u32 csr_reg = mei_hcsr_read(hw); | ||
688 | 720 | ||
689 | if ((csr_reg & H_IS) != H_IS) | 721 | if ((hcsr & H_IS) != H_IS) |
690 | return IRQ_NONE; | 722 | return IRQ_NONE; |
691 | 723 | ||
692 | /* clear H_IS bit in H_CSR */ | 724 | /* clear H_IS bit in H_CSR */ |
693 | mei_me_reg_write(hw, H_CSR, csr_reg); | 725 | mei_hcsr_write(dev, hcsr); |
694 | 726 | ||
695 | return IRQ_WAKE_THREAD; | 727 | return IRQ_WAKE_THREAD; |
696 | } | 728 | } |