Pull cpuidle into release branch
[pandora-kernel.git] / arch / mips / vr41xx / common / icu.c
index 54b92a7..1899601 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Copyright (C) 2001-2002  MontaVista Software Inc.
  *    Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
- *  Copyright (C) 2003-2005  Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
+ *  Copyright (C) 2003-2006  Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -68,6 +68,7 @@ static unsigned char sysint2_assign[16] = {
 #define MPIUINTREG     0x0e
 #define MAIUINTREG     0x10
 #define MKIUINTREG     0x12
+#define MMACINTREG     0x12
 #define MGIUINTLREG    0x14
 #define MDSIUINTREG    0x16
 #define NMIREG         0x18
@@ -156,8 +157,8 @@ void vr41xx_enable_piuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + PIU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4111 ||
-           current_cpu_data.cputype == CPU_VR4121) {
+       if (current_cpu_type() == CPU_VR4111 ||
+           current_cpu_type() == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
                icu1_set(MPIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -171,8 +172,8 @@ void vr41xx_disable_piuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + PIU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4111 ||
-           current_cpu_data.cputype == CPU_VR4121) {
+       if (current_cpu_type() == CPU_VR4111 ||
+           current_cpu_type() == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
                icu1_clear(MPIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -186,8 +187,8 @@ void vr41xx_enable_aiuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + AIU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4111 ||
-           current_cpu_data.cputype == CPU_VR4121) {
+       if (current_cpu_type() == CPU_VR4111 ||
+           current_cpu_type() == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
                icu1_set(MAIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -201,8 +202,8 @@ void vr41xx_disable_aiuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + AIU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4111 ||
-           current_cpu_data.cputype == CPU_VR4121) {
+       if (current_cpu_type() == CPU_VR4111 ||
+           current_cpu_type() == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
                icu1_clear(MAIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -216,8 +217,8 @@ void vr41xx_enable_kiuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + KIU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4111 ||
-           current_cpu_data.cputype == CPU_VR4121) {
+       if (current_cpu_type() == CPU_VR4111 ||
+           current_cpu_type() == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
                icu1_set(MKIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -231,8 +232,8 @@ void vr41xx_disable_kiuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + KIU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4111 ||
-           current_cpu_data.cputype == CPU_VR4121) {
+       if (current_cpu_type() == CPU_VR4111 ||
+           current_cpu_type() == CPU_VR4121) {
                spin_lock_irqsave(&desc->lock, flags);
                icu1_clear(MKIUINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -241,6 +242,30 @@ void vr41xx_disable_kiuint(uint16_t mask)
 
 EXPORT_SYMBOL(vr41xx_disable_kiuint);
 
+void vr41xx_enable_macint(uint16_t mask)
+{
+       struct irq_desc *desc = irq_desc + ETHERNET_IRQ;
+       unsigned long flags;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       icu1_set(MMACINTREG, mask);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vr41xx_enable_macint);
+
+void vr41xx_disable_macint(uint16_t mask)
+{
+       struct irq_desc *desc = irq_desc + ETHERNET_IRQ;
+       unsigned long flags;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       icu1_clear(MMACINTREG, mask);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vr41xx_disable_macint);
+
 void vr41xx_enable_dsiuint(uint16_t mask)
 {
        struct irq_desc *desc = irq_desc + DSIU_IRQ;
@@ -294,9 +319,9 @@ void vr41xx_enable_pciint(void)
        struct irq_desc *desc = irq_desc + PCI_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MPCIINTREG, PCIINT0);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -310,9 +335,9 @@ void vr41xx_disable_pciint(void)
        struct irq_desc *desc = irq_desc + PCI_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MPCIINTREG, 0);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -326,9 +351,9 @@ void vr41xx_enable_scuint(void)
        struct irq_desc *desc = irq_desc + SCU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MSCUINTREG, SCUINT0);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -342,9 +367,9 @@ void vr41xx_disable_scuint(void)
        struct irq_desc *desc = irq_desc + SCU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MSCUINTREG, 0);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -358,9 +383,9 @@ void vr41xx_enable_csiint(uint16_t mask)
        struct irq_desc *desc = irq_desc + CSI_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_set(MCSIINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -374,9 +399,9 @@ void vr41xx_disable_csiint(uint16_t mask)
        struct irq_desc *desc = irq_desc + CSI_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_clear(MCSIINTREG, mask);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -390,9 +415,9 @@ void vr41xx_enable_bcuint(void)
        struct irq_desc *desc = irq_desc + BCU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MBCUINTREG, BCUINTR);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -406,9 +431,9 @@ void vr41xx_disable_bcuint(void)
        struct irq_desc *desc = irq_desc + BCU_IRQ;
        unsigned long flags;
 
-       if (current_cpu_data.cputype == CPU_VR4122 ||
-           current_cpu_data.cputype == CPU_VR4131 ||
-           current_cpu_data.cputype == CPU_VR4133) {
+       if (current_cpu_type() == CPU_VR4122 ||
+           current_cpu_type() == CPU_VR4131 ||
+           current_cpu_type() == CPU_VR4133) {
                spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MBCUINTREG, 0);
                spin_unlock_irqrestore(&desc->lock, flags);
@@ -427,19 +452,12 @@ static void enable_sysint1_irq(unsigned int irq)
        icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
 }
 
-static void end_sysint1_irq(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
-}
-
 static struct irq_chip sysint1_irq_type = {
-       .typename       = "SYSINT1",
+       .name           = "SYSINT1",
        .ack            = disable_sysint1_irq,
        .mask           = disable_sysint1_irq,
        .mask_ack       = disable_sysint1_irq,
        .unmask         = enable_sysint1_irq,
-       .end            = end_sysint1_irq,
 };
 
 static void disable_sysint2_irq(unsigned int irq)
@@ -452,19 +470,12 @@ static void enable_sysint2_irq(unsigned int irq)
        icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
 }
 
-static void end_sysint2_irq(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
-}
-
 static struct irq_chip sysint2_irq_type = {
-       .typename       = "SYSINT2",
+       .name           = "SYSINT2",
        .ack            = disable_sysint2_irq,
        .mask           = disable_sysint2_irq,
        .mask_ack       = disable_sysint2_irq,
        .unmask         = enable_sysint2_irq,
-       .end            = end_sysint2_irq,
 };
 
 static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
@@ -597,7 +608,7 @@ int vr41xx_set_intassign(unsigned int irq, unsigned char intassign)
 {
        int retval = -EINVAL;
 
-       if (current_cpu_data.cputype != CPU_VR4133)
+       if (current_cpu_type() != CPU_VR4133)
                return -EINVAL;
 
        if (intassign > INTASSIGN_MAX)
@@ -654,7 +665,7 @@ static int __init vr41xx_icu_init(void)
        unsigned long icu1_start, icu2_start;
        int i;
 
-       switch (current_cpu_data.cputype) {
+       switch (current_cpu_type()) {
        case CPU_VR4111:
        case CPU_VR4121:
                icu1_start = ICU1_TYPE1_BASE;