]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/arm/bsp/pic-arm-pxa_sa1100.cpp
update
[l4.git] / kernel / fiasco / src / kern / arm / bsp / pic-arm-pxa_sa1100.cpp
1 INTERFACE [arm && pxa]: // -------------------------------------
2
3 #include "kmem.h"
4
5 EXTENSION class Pic
6 {
7 public:
8   enum
9   {
10     Multi_irq_pending = 1,
11     No_irq_pending = 0,
12   };
13
14   enum {
15     ICIP = Kmem::Pic_map_base + 0x000000,
16     ICMR = Kmem::Pic_map_base + 0x000004,
17     ICLR = Kmem::Pic_map_base + 0x000008,
18     ICCR = Kmem::Pic_map_base + 0x000014,
19     ICFP = Kmem::Pic_map_base + 0x00000c,
20     ICPR = Kmem::Pic_map_base + 0x000010,
21   };
22 };
23
24 INTERFACE [arm && sa1100]: // ----------------------------------
25
26 #include "kmem.h"
27
28 EXTENSION class Pic
29 {
30 public:
31   enum
32   {
33     Multi_irq_pending = 1,
34     No_irq_pending = 0,
35   };
36
37   enum {
38     ICIP = Kmem::Pic_map_base + 0x00000,
39     ICMR = Kmem::Pic_map_base + 0x00004,
40     ICLR = Kmem::Pic_map_base + 0x00008,
41     ICCR = Kmem::Pic_map_base + 0x0000c,
42     ICFP = Kmem::Pic_map_base + 0x00010,
43     ICPR = Kmem::Pic_map_base + 0x00020,
44   };
45 };
46
47 // -------------------------------------------------------------
48 IMPLEMENTATION [arm && (sa1100 || pxa)]:
49
50 #include <cstring>
51 #include <cstdio>
52
53 #include "boot_info.h"
54 #include "config.h"
55 #include "initcalls.h"
56 #include "irq.h"
57 #include "irq_pin.h"
58 #include "irq_chip_generic.h"
59 #include "io.h"
60 #include "vkey.h"
61
62 class Pxa_sa_pin : public Irq_pin
63 {
64 public:
65   explicit Pxa_sa_pin(unsigned irq) { payload()[0] = irq; }
66   unsigned irq() const { return payload()[0]; }
67 };
68
69 class Irq_chip_arm_pxa_sa : public Irq_chip_gen
70 {
71 };
72
73 PUBLIC
74 void
75 Irq_chip_arm_pxa_sa::setup(Irq_base *irq, unsigned irqnum)
76 {
77   irq->pin()->replace<Pxa_sa_pin>(irqnum);
78 }
79
80 PUBLIC
81 void
82 Pxa_sa_pin::unbind_irq()
83 {
84   mask();
85   disable();
86   Irq_chip::hw_chip->free(Irq::self(this), irq());
87   replace<Sw_irq_pin>();
88 }
89
90 PUBLIC
91 void
92 Pxa_sa_pin::do_mask()
93 {
94   assert (cpu_lock.test());
95   Io::write(Io::read<Mword>(Pic::ICMR) & ~(1 << irq()), Pic::ICMR);
96 }
97
98 PUBLIC
99 void
100 Pxa_sa_pin::do_mask_and_ack()
101 {
102   assert (cpu_lock.test());
103   __mask();
104   Io::write(Io::read<Mword>(Pic::ICMR) & ~(1 << irq()), Pic::ICMR);
105   // ack is empty
106 }
107
108 PUBLIC
109 void
110 Pxa_sa_pin::ack()
111 {
112   // ack is empty
113 }
114
115 PUBLIC
116 void
117 Pxa_sa_pin::do_unmask()
118 {
119   Io::write(Io::read<Mword>(Pic::ICMR) | (1 << irq()), Pic::ICMR);
120 }
121
122 PUBLIC
123 void
124 Pxa_sa_pin::do_set_mode(unsigned)
125 {
126 }
127
128 PUBLIC
129 bool
130 Pxa_sa_pin::check_debug_irq()
131 {
132   return !Vkey::check_(irq());
133 }
134
135 PUBLIC
136 void
137 Pxa_sa_pin::set_cpu(unsigned)
138 {
139 }
140
141
142
143 IMPLEMENT FIASCO_INIT
144 void Pic::init()
145 {
146   // only unmasked interrupts wakeup from idle
147   Io::write(0x01, ICCR);
148   // mask all interrupts
149   Io::write(0x00, ICMR);
150   // all interrupts are IRQ's (no FIQ)
151   Io::write(0x00, ICLR);
152 }
153
154 IMPLEMENT inline NEEDS["io.h"]
155 Pic::Status Pic::disable_all_save()
156 {
157   Status s;
158   s  = Io::read<Mword>(ICMR);
159   Io::write(0, ICMR);
160   return s;
161 }
162
163 IMPLEMENT inline NEEDS["io.h"]
164 void Pic::restore_all( Status s )
165 {
166   Io::write(s, ICMR);
167 }
168
169 PUBLIC static inline NEEDS["io.h"]
170 Unsigned32 Pic::pending()
171 {
172   return Io::read<Unsigned32>(ICIP);
173 }
174
175 PUBLIC static inline NEEDS[Pic::pending]
176 Mword Pic::is_pending(Mword &irqs, Mword irq)
177 {
178   Mword ret = irqs & (1 << irq);
179   irqs &= ~(1 << irq);
180   return ret;
181 }
182
183 // -------------------------------------------------------------
184 IMPLEMENTATION [arm && debug && (sa1100 || pxa)]:
185
186 PUBLIC
187 char const *
188 Pxa_sa_pin::pin_type() const
189 { return "HW PXA/SA IRQ"; }