Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / mips / vr41xx / common / vrc4173.c
index 3b00635..3e31f81 100644 (file)
@@ -3,7 +3,8 @@
  *
  *  Copyright (C) 2001-2003  MontaVista Software Inc.
  *    Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
- *  Copyright (C) 2004  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
+ *  Copyright (C) 2004  Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
+ *  Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
  *
  *  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
@@ -19,7 +20,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
@@ -56,6 +56,9 @@ MODULE_LICENSE("GPL");
 
 #define VRC4173_SYSINT1REG     0x060
 #define VRC4173_MSYSINT1REG    0x06c
+#define VRC4173_MPIUINTREG     0x06e
+#define VRC4173_MAIUINTREG     0x070
+#define VRC4173_MKIUINTREG     0x072
 
 #define VRC4173_SELECTREG      0x09e
  #define SEL3                  0x0008
@@ -78,8 +81,8 @@ EXPORT_SYMBOL(vrc4173_io_offset);
 static int vrc4173_initialized;
 static uint16_t vrc4173_cmuclkmsk;
 static uint16_t vrc4173_selectreg;
-static spinlock_t vrc4173_cmu_lock;
-static spinlock_t vrc4173_giu_lock;
+static DEFINE_SPINLOCK(vrc4173_cmu_lock);
+static DEFINE_SPINLOCK(vrc4173_giu_lock);
 
 static inline void set_cmusrst(uint16_t val)
 {
@@ -316,6 +319,96 @@ static inline void vrc4173_giu_init(void)
        spin_lock_init(&vrc4173_giu_lock);
 }
 
+void vrc4173_enable_piuint(uint16_t mask)
+{
+       irq_desc_t *desc = irq_desc + VRC4173_PIU_IRQ;
+       unsigned long flags;
+       uint16_t val;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       val = vrc4173_inw(VRC4173_MPIUINTREG);
+       val |= mask;
+       vrc4173_outw(val, VRC4173_MPIUINTREG);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vrc4173_enable_piuint);
+
+void vrc4173_disable_piuint(uint16_t mask)
+{
+       irq_desc_t *desc = irq_desc + VRC4173_PIU_IRQ;
+       unsigned long flags;
+       uint16_t val;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       val = vrc4173_inw(VRC4173_MPIUINTREG);
+       val &= ~mask;
+       vrc4173_outw(val, VRC4173_MPIUINTREG);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vrc4173_disable_piuint);
+
+void vrc4173_enable_aiuint(uint16_t mask)
+{
+       irq_desc_t *desc = irq_desc + VRC4173_AIU_IRQ;
+       unsigned long flags;
+       uint16_t val;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       val = vrc4173_inw(VRC4173_MAIUINTREG);
+       val |= mask;
+       vrc4173_outw(val, VRC4173_MAIUINTREG);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vrc4173_enable_aiuint);
+
+void vrc4173_disable_aiuint(uint16_t mask)
+{
+       irq_desc_t *desc = irq_desc + VRC4173_AIU_IRQ;
+       unsigned long flags;
+       uint16_t val;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       val = vrc4173_inw(VRC4173_MAIUINTREG);
+       val &= ~mask;
+       vrc4173_outw(val, VRC4173_MAIUINTREG);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vrc4173_disable_aiuint);
+
+void vrc4173_enable_kiuint(uint16_t mask)
+{
+       irq_desc_t *desc = irq_desc + VRC4173_KIU_IRQ;
+       unsigned long flags;
+       uint16_t val;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       val = vrc4173_inw(VRC4173_MKIUINTREG);
+       val |= mask;
+       vrc4173_outw(val, VRC4173_MKIUINTREG);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vrc4173_enable_kiuint);
+
+void vrc4173_disable_kiuint(uint16_t mask)
+{
+       irq_desc_t *desc = irq_desc + VRC4173_KIU_IRQ;
+       unsigned long flags;
+       uint16_t val;
+
+       spin_lock_irqsave(&desc->lock, flags);
+       val = vrc4173_inw(VRC4173_MKIUINTREG);
+       val &= ~mask;
+       vrc4173_outw(val, VRC4173_MKIUINTREG);
+       spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+EXPORT_SYMBOL(vrc4173_disable_kiuint);
+
 static void enable_vrc4173_irq(unsigned int irq)
 {
        uint16_t val;
@@ -383,7 +476,7 @@ static inline int vrc4173_icu_init(int cascade_irq)
 
        if (cascade_irq < GIU_IRQ(0) || cascade_irq > GIU_IRQ(15))
                return -EINVAL;
-       
+
        vrc4173_outw(0, VRC4173_MSYSINT1REG);
 
        vr41xx_set_irq_trigger(GIU_IRQ_TO_PIN(cascade_irq), TRIGGER_LEVEL, SIGNAL_THROUGH);
@@ -468,7 +561,7 @@ static int __devinit vrc4173_init(void)
 {
        int err;
 
-       err = pci_module_init(&vrc4173_driver);
+       err = pci_register_driver(&vrc4173_driver);
        if (err < 0)
                return err;