]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/sysdev/qe_lib/qe_ic.c
Driver core: change sysdev classes to use dynamic kobject names
[linux-2.6-omap-h63xx.git] / arch / powerpc / sysdev / qe_lib / qe_ic.c
index 6995f51b94882bdcf55815572c305d42516e4771..f59444d3be752aa9580d751a9a76c0cd008a5f85 100644 (file)
@@ -223,23 +223,15 @@ static void qe_ic_mask_irq(unsigned int virq)
        qe_ic_write(qe_ic->regs, qe_ic_info[src].mask_reg,
                    temp & ~qe_ic_info[src].mask);
 
-       spin_unlock_irqrestore(&qe_ic_lock, flags);
-}
-
-static void qe_ic_mask_irq_and_ack(unsigned int virq)
-{
-       struct qe_ic *qe_ic = qe_ic_from_irq(virq);
-       unsigned int src = virq_to_hw(virq);
-       unsigned long flags;
-       u32 temp;
-
-       spin_lock_irqsave(&qe_ic_lock, flags);
-
-       temp = qe_ic_read(qe_ic->regs, qe_ic_info[src].mask_reg);
-       qe_ic_write(qe_ic->regs, qe_ic_info[src].mask_reg,
-                   temp & ~qe_ic_info[src].mask);
-
-       /* There is nothing to do for ack here, ack is handled in ISR */
+       /* Flush the above write before enabling interrupts; otherwise,
+        * spurious interrupts will sometimes happen.  To be 100% sure
+        * that the write has reached the device before interrupts are
+        * enabled, the mask register would have to be read back; however,
+        * this is not required for correctness, only to avoid wasting
+        * time on a large number of spurious interrupts.  In testing,
+        * a sync reduced the observed spurious interrupts to zero.
+        */
+       mb();
 
        spin_unlock_irqrestore(&qe_ic_lock, flags);
 }
@@ -248,15 +240,13 @@ static struct irq_chip qe_ic_irq_chip = {
        .typename = " QEIC  ",
        .unmask = qe_ic_unmask_irq,
        .mask = qe_ic_mask_irq,
-       .mask_ack = qe_ic_mask_irq_and_ack,
+       .mask_ack = qe_ic_mask_irq,
 };
 
 static int qe_ic_host_match(struct irq_host *h, struct device_node *node)
 {
-       struct qe_ic *qe_ic = h->host_data;
-
        /* Exact match, unless qe_ic node is NULL */
-       return qe_ic->of_node == NULL || qe_ic->of_node == node;
+       return h->of_node == NULL || h->of_node == node;
 }
 
 static int qe_ic_host_map(struct irq_host *h, unsigned int virq,
@@ -331,37 +321,9 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)
        return irq_linear_revmap(qe_ic->irqhost, irq);
 }
 
-/* FIXME: We mask all the QE Low interrupts while handling.  We should
- * let other interrupt come in, but BAD interrupts are generated */
-void fastcall qe_ic_cascade_low(unsigned int irq, struct irq_desc *desc)
-{
-       struct qe_ic *qe_ic = desc->handler_data;
-       struct irq_chip *chip = irq_desc[irq].chip;
-
-       unsigned int cascade_irq = qe_ic_get_low_irq(qe_ic);
-
-       chip->mask_ack(irq);
-       if (cascade_irq != NO_IRQ)
-               generic_handle_irq(cascade_irq);
-       chip->unmask(irq);
-}
-
-/* FIXME: We mask all the QE High interrupts while handling.  We should
- * let other interrupt come in, but BAD interrupts are generated */
-void fastcall qe_ic_cascade_high(unsigned int irq, struct irq_desc *desc)
-{
-       struct qe_ic *qe_ic = desc->handler_data;
-       struct irq_chip *chip = irq_desc[irq].chip;
-
-       unsigned int cascade_irq = qe_ic_get_high_irq(qe_ic);
-
-       chip->mask_ack(irq);
-       if (cascade_irq != NO_IRQ)
-               generic_handle_irq(cascade_irq);
-       chip->unmask(irq);
-}
-
-void __init qe_ic_init(struct device_node *node, unsigned int flags)
+void __init qe_ic_init(struct device_node *node, unsigned int flags,
+               void (*low_handler)(unsigned int irq, struct irq_desc *desc),
+               void (*high_handler)(unsigned int irq, struct irq_desc *desc))
 {
        struct qe_ic *qe_ic;
        struct resource res;
@@ -372,9 +334,8 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags)
                return;
 
        memset(qe_ic, 0, sizeof(struct qe_ic));
-       qe_ic->of_node = node ? of_node_get(node) : NULL;
 
-       qe_ic->irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR,
+       qe_ic->irqhost = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
                                        NR_QE_IC_INTS, &qe_ic_host_ops, 0);
        if (qe_ic->irqhost == NULL) {
                of_node_put(node);
@@ -422,14 +383,13 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags)
        qe_ic_write(qe_ic->regs, QEIC_CICR, temp);
 
        set_irq_data(qe_ic->virq_low, qe_ic);
-       set_irq_chained_handler(qe_ic->virq_low, qe_ic_cascade_low);
+       set_irq_chained_handler(qe_ic->virq_low, low_handler);
 
-       if (qe_ic->virq_high != NO_IRQ) {
+       if (qe_ic->virq_high != NO_IRQ &&
+                       qe_ic->virq_high != qe_ic->virq_low) {
                set_irq_data(qe_ic->virq_high, qe_ic);
-               set_irq_chained_handler(qe_ic->virq_high, qe_ic_cascade_high);
+               set_irq_chained_handler(qe_ic->virq_high, high_handler);
        }
-
-       printk("QEIC (%d IRQ sources) at %p\n", NR_QE_IC_INTS, qe_ic->regs);
 }
 
 void qe_ic_set_highest_priority(unsigned int virq, int high)
@@ -523,7 +483,7 @@ int qe_ic_set_high_priority(unsigned int virq, unsigned int priority, int high)
 }
 
 static struct sysdev_class qe_ic_sysclass = {
-       set_kset_name("qe_ic"),
+       .name = "qe_ic",
 };
 
 static struct sys_device device_qe_ic = {