13 #include <linux/kernel.h>
14 #include <linux/module.h>
20 static u32 used_sram_bitmap[4];
22 static void *irq_pdevs[
QUEUES];
25 char qmgr_queue_descs[
QUEUES][32];
29 void (*handler)(
void *pdev),
void *pdev)
38 reg = &qmgr_regs->
irqsrc[queue >> 3];
39 bit = (queue % 8) * 4;
47 irq_pdevs[queue] = pdev;
48 spin_unlock_irqrestore(&qmgr_lock, flags);
52 static irqreturn_t qmgr_irq1_a0(
int irq,
void *pdev)
60 en_bitmap = qmgr_regs->
irqen[0];
64 src = qmgr_regs->
irqsrc[i >> 3];
65 stat = qmgr_regs->
stat1[i >> 3];
68 if (stat &
BIT(src & 3)) {
69 irq_handlers[
i](irq_pdevs[
i]);
77 static irqreturn_t qmgr_irq2_a0(
int irq,
void *pdev)
87 i =
__fls(req_bitmap);
88 req_bitmap &= ~
BIT(i);
106 i =
__fls(req_bitmap);
107 req_bitmap &= ~
BIT(i);
109 irq_handlers[
i](irq_pdevs[
i]);
118 int half = queue / 32;
123 &qmgr_regs->
irqen[half]);
124 spin_unlock_irqrestore(&qmgr_lock, flags);
130 int half = queue / 32;
135 &qmgr_regs->
irqen[half]);
137 spin_unlock_irqrestore(&qmgr_lock, flags);
140 static inline void shift_mask(
u32 *
mask)
142 mask[3] = mask[3] << 1 | mask[2] >> 31;
143 mask[2] = mask[2] << 1 | mask[1] >> 31;
144 mask[1] = mask[1] << 1 | mask[0] >> 31;
150 unsigned int nearly_empty_watermark,
151 unsigned int nearly_full_watermark,
152 const char *desc_format,
const char*
name)
155 unsigned int nearly_empty_watermark,
156 unsigned int nearly_full_watermark)
164 if ((nearly_empty_watermark | nearly_full_watermark) & ~7)
188 cfg |= nearly_empty_watermark << 26;
189 cfg |= nearly_full_watermark << 29;
196 spin_lock_irq(&qmgr_lock);
203 if (!(used_sram_bitmap[0] &
mask[0]) &&
204 !(used_sram_bitmap[1] & mask[1]) &&
205 !(used_sram_bitmap[2] & mask[2]) &&
206 !(used_sram_bitmap[3] & mask[3]))
213 " queue %i\n", queue);
219 used_sram_bitmap[0] |=
mask[0];
220 used_sram_bitmap[1] |=
mask[1];
221 used_sram_bitmap[2] |=
mask[2];
222 used_sram_bitmap[3] |=
mask[3];
225 snprintf(qmgr_queue_descs[queue],
sizeof(qmgr_queue_descs[0]),
228 qmgr_queue_descs[queue], queue, addr);
230 spin_unlock_irq(&qmgr_lock);
234 spin_unlock_irq(&qmgr_lock);
245 spin_lock_irq(&qmgr_lock);
247 addr = (cfg >> 14) & 0xFF;
251 switch ((cfg >> 24) & 3) {
252 case 0: mask[0] = 0x1;
break;
253 case 1: mask[0] = 0x3;
break;
254 case 2: mask[0] = 0xF;
break;
255 case 3: mask[0] = 0xFF;
break;
258 mask[1] = mask[2] = mask[3] = 0;
265 qmgr_queue_descs[queue], queue);
266 qmgr_queue_descs[queue][0] =
'\x0';
269 while ((addr = qmgr_get_entry(queue)))
275 used_sram_bitmap[0] &= ~mask[0];
276 used_sram_bitmap[1] &= ~mask[1];
277 used_sram_bitmap[2] &= ~mask[2];
278 used_sram_bitmap[3] &= ~mask[3];
279 irq_handlers[queue] =
NULL;
280 spin_unlock_irq(&qmgr_lock);
285 static int qmgr_init(
void)
292 "IXP4xx Queue Manager");
297 for (i = 0; i < 4; i++) {
301 for (i = 0; i < 2; i++) {
310 for (i = 0; i <
QUEUES; i++)
314 handler1 = qmgr_irq1_a0;
315 handler2 = qmgr_irq2_a0;
317 handler1 = handler2 = qmgr_irq;
335 used_sram_bitmap[0] = 0xF;
348 static void qmgr_remove(
void)