Intel® Quark™ Microcontroller Software Interface 1.4.0 Intel® Quark™ Microcontroller BSP

- Main Page
- Modules
- Data Structures
- Files

- File List

mvic.h
1 /*
2 * {% copyright %}
3 */
4
5 #ifndef __MVIC_H__
6 #define __MVIC_H__
7
8 #include <stdint.h>
9
10 #include "qm_common.h"
11 #include "qm_soc_regs.h"
12
13 #define NUM_IRQ_LINES (32)
14
15 static uint32_t _mvic_get_irq_val(unsigned int irq)
16 {
17 /* Register Select - select which IRQ line we are configuring
18 * Bits 0 and 4 are reserved
19 * So, for IRQ 15 ( 0x01111 ) write 0x101110
20 */
21 QM_IOAPIC->ioregsel.reg = ((irq & 0x7) << 1) | ((irq & 0x18) << 2);
22 return QM_IOAPIC->iowin.reg;
23 }
24
25 static void _mvic_set_irq_val(unsigned int irq, uint32_t value)
26 {
27 /* Register Select - select which IRQ line we are configuring
28 * Bits 0 and 4 are reserved
29 * So, for IRQ 15 ( 0x01111 ) write 0x101110
30 */
31 QM_IOAPIC->ioregsel.reg = ((irq & 0x7) << 1) | ((irq & 0x18) << 2);
32 QM_IOAPIC->iowin.reg = value;
33 }
34
35 /**
36 * Initialise MVIC.
37 */
38 static __inline__ void mvic_init(void)
39 {
40 uint32_t i;
41
42 for (i = 0; i < NUM_IRQ_LINES; i++) {
43 /* Clear up any spurious LAPIC interrupts, each call only
44 * clears one bit.
45 */
46 QM_MVIC->eoi.reg = 0;
47
48 /* Mask interrupt */
49 _mvic_set_irq_val(i, BIT(16));
50 }
51 }
52
53 /**
54 * Register IRQ with MVIC.
55 *
56 * @param irq IRQ to register.
57 */
58 static __inline__ void mvic_register_irq(uint32_t irq)
59 {
60 /* Set IRQ triggering scheme and unmask the line. */
61
62 switch (irq) {
63 case QM_IRQ_RTC_0_INT:
64 case QM_IRQ_AONPT_0_INT:
65 case QM_IRQ_PIC_TIMER:
66 case QM_IRQ_WDT_0_INT:
67 /* positive edge */
68 _mvic_set_irq_val(irq, 0);
69 break;
70 default:
71 /* high level */
72 _mvic_set_irq_val(irq, BIT(15));
73 break;
74 }
75 }
76
77 /**
78 * Unmask IRQ with MVIC.
79 *
80 * @param irq IRQ to unmask.
81 */
82 static __inline__ void mvic_unmask_irq(uint32_t irq)
83 {
84 uint32_t value = _mvic_get_irq_val(irq);
85
86 value &= ~BIT(16);
87
88 _mvic_set_irq_val(irq, value);
89 }
90
91 /**
92 * Mask IRQ with MVIC.
93 *
94 * @param irq IRQ to mask.
95 */
96 static __inline__ void mvic_mask_irq(uint32_t irq)
97 {
98 uint32_t value = _mvic_get_irq_val(irq);
99
100 value |= BIT(16);
101
102 _mvic_set_irq_val(irq, value);
103 }
104
105 #endif /* __MVIC_H__ */