diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2012-12-25 12:06:06 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-07 13:31:29 -0500 |
commit | 3a65dd4ea32c3e3a3befec58ad20d1c96580834e (patch) | |
tree | 4c8226f14b9cb96b68faecf19f3b3fe8c12d5ddd | |
parent | db7da79df1a9eafb4f07653bf9011537325a9b62 (diff) |
mei: move hw dependent functions to interface.c
1. move direct register handling to interface.c and make them static
2. add new function mei_clear_interrupts that wraps direct register
access
3. export other functions in mei_dev.h
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/misc/mei/init.c | 3 | ||||
-rw-r--r-- | drivers/misc/mei/interface.c | 92 | ||||
-rw-r--r-- | drivers/misc/mei/interrupt.c | 24 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 71 |
4 files changed, 97 insertions, 93 deletions
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 08884ef13f31..eb180555d282 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -142,8 +142,7 @@ int mei_hw_init(struct mei_device *dev) | |||
142 | dev->host_hw_state, dev->me_hw_state); | 142 | dev->host_hw_state, dev->me_hw_state); |
143 | 143 | ||
144 | /* acknowledge interrupt and stop interupts */ | 144 | /* acknowledge interrupt and stop interupts */ |
145 | if ((dev->host_hw_state & H_IS) == H_IS) | 145 | mei_clear_interrupts(dev); |
146 | mei_reg_write(dev, H_CSR, dev->host_hw_state); | ||
147 | 146 | ||
148 | /* Doesn't change in runtime */ | 147 | /* Doesn't change in runtime */ |
149 | dev->hbuf_depth = (dev->host_hw_state & H_CBD) >> 24; | 148 | dev->hbuf_depth = (dev->host_hw_state & H_CBD) >> 24; |
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c index 810431e30cd2..939d85b40738 100644 --- a/drivers/misc/mei/interface.c +++ b/drivers/misc/mei/interface.c | |||
@@ -20,7 +20,61 @@ | |||
20 | #include "mei_dev.h" | 20 | #include "mei_dev.h" |
21 | #include "interface.h" | 21 | #include "interface.h" |
22 | 22 | ||
23 | /** | ||
24 | * mei_reg_read - Reads 32bit data from the mei device | ||
25 | * | ||
26 | * @dev: the device structure | ||
27 | * @offset: offset from which to read the data | ||
28 | * | ||
29 | * returns register value (u32) | ||
30 | */ | ||
31 | static inline u32 mei_reg_read(const struct mei_device *dev, | ||
32 | unsigned long offset) | ||
33 | { | ||
34 | return ioread32(dev->mem_addr + offset); | ||
35 | } | ||
36 | |||
37 | |||
38 | /** | ||
39 | * mei_reg_write - Writes 32bit data to the mei device | ||
40 | * | ||
41 | * @dev: the device structure | ||
42 | * @offset: offset from which to write the data | ||
43 | * @value: register value to write (u32) | ||
44 | */ | ||
45 | static inline void mei_reg_write(const struct mei_device *dev, | ||
46 | unsigned long offset, u32 value) | ||
47 | { | ||
48 | iowrite32(value, dev->mem_addr + offset); | ||
49 | } | ||
23 | 50 | ||
51 | /** | ||
52 | * mei_hcsr_read - Reads 32bit data from the host CSR | ||
53 | * | ||
54 | * @dev: the device structure | ||
55 | * | ||
56 | * returns the byte read. | ||
57 | */ | ||
58 | u32 mei_hcsr_read(const struct mei_device *dev) | ||
59 | { | ||
60 | return mei_reg_read(dev, H_CSR); | ||
61 | } | ||
62 | |||
63 | u32 mei_mecbrw_read(const struct mei_device *dev) | ||
64 | { | ||
65 | return mei_reg_read(dev, ME_CB_RW); | ||
66 | } | ||
67 | /** | ||
68 | * mei_mecsr_read - Reads 32bit data from the ME CSR | ||
69 | * | ||
70 | * @dev: the device structure | ||
71 | * | ||
72 | * returns ME_CSR_HA register value (u32) | ||
73 | */ | ||
74 | u32 mei_mecsr_read(const struct mei_device *dev) | ||
75 | { | ||
76 | return mei_reg_read(dev, ME_CSR_HA); | ||
77 | } | ||
24 | 78 | ||
25 | /** | 79 | /** |
26 | * mei_set_csr_register - writes H_CSR register to the mei device, | 80 | * mei_set_csr_register - writes H_CSR register to the mei device, |
@@ -37,7 +91,18 @@ void mei_hcsr_set(struct mei_device *dev) | |||
37 | } | 91 | } |
38 | 92 | ||
39 | /** | 93 | /** |
40 | * mei_csr_enable_interrupts - enables mei device interrupts | 94 | * mei_enable_interrupts - clear and stop interrupts |
95 | * | ||
96 | * @dev: the device structure | ||
97 | */ | ||
98 | void mei_clear_interrupts(struct mei_device *dev) | ||
99 | { | ||
100 | if ((dev->host_hw_state & H_IS) == H_IS) | ||
101 | mei_reg_write(dev, H_CSR, dev->host_hw_state); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * mei_enable_interrupts - enables mei device interrupts | ||
41 | * | 106 | * |
42 | * @dev: the device structure | 107 | * @dev: the device structure |
43 | */ | 108 | */ |
@@ -48,7 +113,7 @@ void mei_enable_interrupts(struct mei_device *dev) | |||
48 | } | 113 | } |
49 | 114 | ||
50 | /** | 115 | /** |
51 | * mei_csr_disable_interrupts - disables mei device interrupts | 116 | * mei_disable_interrupts - disables mei device interrupts |
52 | * | 117 | * |
53 | * @dev: the device structure | 118 | * @dev: the device structure |
54 | */ | 119 | */ |
@@ -58,6 +123,29 @@ void mei_disable_interrupts(struct mei_device *dev) | |||
58 | mei_hcsr_set(dev); | 123 | mei_hcsr_set(dev); |
59 | } | 124 | } |
60 | 125 | ||
126 | |||
127 | /** | ||
128 | * mei_interrupt_quick_handler - The ISR of the MEI device | ||
129 | * | ||
130 | * @irq: The irq number | ||
131 | * @dev_id: pointer to the device structure | ||
132 | * | ||
133 | * returns irqreturn_t | ||
134 | */ | ||
135 | irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id) | ||
136 | { | ||
137 | struct mei_device *dev = (struct mei_device *) dev_id; | ||
138 | u32 csr_reg = mei_hcsr_read(dev); | ||
139 | |||
140 | if ((csr_reg & H_IS) != H_IS) | ||
141 | return IRQ_NONE; | ||
142 | |||
143 | /* clear H_IS bit in H_CSR */ | ||
144 | mei_reg_write(dev, H_CSR, csr_reg); | ||
145 | |||
146 | return IRQ_WAKE_THREAD; | ||
147 | } | ||
148 | |||
61 | /** | 149 | /** |
62 | * mei_hbuf_filled_slots - gets number of device filled buffer slots | 150 | * mei_hbuf_filled_slots - gets number of device filled buffer slots |
63 | * | 151 | * |
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 0a020ad92f00..cd89b68fcf43 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -28,28 +28,6 @@ | |||
28 | 28 | ||
29 | 29 | ||
30 | /** | 30 | /** |
31 | * mei_interrupt_quick_handler - The ISR of the MEI device | ||
32 | * | ||
33 | * @irq: The irq number | ||
34 | * @dev_id: pointer to the device structure | ||
35 | * | ||
36 | * returns irqreturn_t | ||
37 | */ | ||
38 | irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id) | ||
39 | { | ||
40 | struct mei_device *dev = (struct mei_device *) dev_id; | ||
41 | u32 csr_reg = mei_hcsr_read(dev); | ||
42 | |||
43 | if ((csr_reg & H_IS) != H_IS) | ||
44 | return IRQ_NONE; | ||
45 | |||
46 | /* clear H_IS bit in H_CSR */ | ||
47 | mei_reg_write(dev, H_CSR, csr_reg); | ||
48 | |||
49 | return IRQ_WAKE_THREAD; | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * _mei_cmpl - processes completed operation. | 31 | * _mei_cmpl - processes completed operation. |
54 | * | 32 | * |
55 | * @cl: private data of the file object. | 33 | * @cl: private data of the file object. |
@@ -1150,7 +1128,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) | |||
1150 | /* Ack the interrupt here | 1128 | /* Ack the interrupt here |
1151 | * In case of MSI we don't go through the quick handler */ | 1129 | * In case of MSI we don't go through the quick handler */ |
1152 | if (pci_dev_msi_enabled(dev->pdev)) | 1130 | if (pci_dev_msi_enabled(dev->pdev)) |
1153 | mei_reg_write(dev, H_CSR, dev->host_hw_state); | 1131 | mei_clear_interrupts(dev); |
1154 | 1132 | ||
1155 | dev->me_hw_state = mei_mecsr_read(dev); | 1133 | dev->me_hw_state = mei_mecsr_read(dev); |
1156 | 1134 | ||
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 228a98c97b37..472c9cacc543 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -440,79 +440,18 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots); | |||
440 | * Register Access Function | 440 | * Register Access Function |
441 | */ | 441 | */ |
442 | 442 | ||
443 | /** | 443 | u32 mei_hcsr_read(const struct mei_device *dev); |
444 | * mei_reg_read - Reads 32bit data from the mei device | 444 | u32 mei_mecsr_read(const struct mei_device *dev); |
445 | * | 445 | u32 mei_mecbrw_read(const struct mei_device *dev); |
446 | * @dev: the device structure | ||
447 | * @offset: offset from which to read the data | ||
448 | * | ||
449 | * returns register value (u32) | ||
450 | */ | ||
451 | static inline u32 mei_reg_read(const struct mei_device *dev, | ||
452 | unsigned long offset) | ||
453 | { | ||
454 | return ioread32(dev->mem_addr + offset); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * mei_reg_write - Writes 32bit data to the mei device | ||
459 | * | ||
460 | * @dev: the device structure | ||
461 | * @offset: offset from which to write the data | ||
462 | * @value: register value to write (u32) | ||
463 | */ | ||
464 | static inline void mei_reg_write(const struct mei_device *dev, | ||
465 | unsigned long offset, u32 value) | ||
466 | { | ||
467 | iowrite32(value, dev->mem_addr + offset); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * mei_hcsr_read - Reads 32bit data from the host CSR | ||
472 | * | ||
473 | * @dev: the device structure | ||
474 | * | ||
475 | * returns the byte read. | ||
476 | */ | ||
477 | static inline u32 mei_hcsr_read(const struct mei_device *dev) | ||
478 | { | ||
479 | return mei_reg_read(dev, H_CSR); | ||
480 | } | ||
481 | 446 | ||
482 | /** | ||
483 | * mei_mecsr_read - Reads 32bit data from the ME CSR | ||
484 | * | ||
485 | * @dev: the device structure | ||
486 | * | ||
487 | * returns ME_CSR_HA register value (u32) | ||
488 | */ | ||
489 | static inline u32 mei_mecsr_read(const struct mei_device *dev) | ||
490 | { | ||
491 | return mei_reg_read(dev, ME_CSR_HA); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * get_me_cb_rw - Reads 32bit data from the mei ME_CB_RW register | ||
496 | * | ||
497 | * @dev: the device structure | ||
498 | * | ||
499 | * returns ME_CB_RW register value (u32) | ||
500 | */ | ||
501 | static inline u32 mei_mecbrw_read(const struct mei_device *dev) | ||
502 | { | ||
503 | return mei_reg_read(dev, ME_CB_RW); | ||
504 | } | ||
505 | |||
506 | |||
507 | /* | ||
508 | * mei interface function prototypes | ||
509 | */ | ||
510 | void mei_hcsr_set(struct mei_device *dev); | 447 | void mei_hcsr_set(struct mei_device *dev); |
511 | void mei_csr_clear_his(struct mei_device *dev); | 448 | void mei_csr_clear_his(struct mei_device *dev); |
512 | 449 | ||
450 | void mei_clear_interrupts(struct mei_device *dev); | ||
513 | void mei_enable_interrupts(struct mei_device *dev); | 451 | void mei_enable_interrupts(struct mei_device *dev); |
514 | void mei_disable_interrupts(struct mei_device *dev); | 452 | void mei_disable_interrupts(struct mei_device *dev); |
515 | 453 | ||
454 | |||
516 | static inline struct mei_msg_hdr *mei_hbm_hdr(u32 *buf, size_t length) | 455 | static inline struct mei_msg_hdr *mei_hbm_hdr(u32 *buf, size_t length) |
517 | { | 456 | { |
518 | struct mei_msg_hdr *hdr = (struct mei_msg_hdr *)buf; | 457 | struct mei_msg_hdr *hdr = (struct mei_msg_hdr *)buf; |