#
 irqinit-$(CONFIG_SH_R7780MP)   := irq-r7780mp.o
 irqinit-$(CONFIG_SH_R7785RP)   := irq-r7785rp.o
-irqinit-$(CONFIG_SH_R7780RP)   := irq-r7780rp.o irq.o
+irqinit-$(CONFIG_SH_R7780RP)   := irq-r7780rp.o
 obj-y                          := setup.o $(irqinit-y)
 
 ifneq ($(CONFIG_SH_R7785RP),y)
 
  *
  * Copyright (C) 2002  Atom Create Engineering Co., Ltd.
  * Copyright (C) 2006  Paul Mundt
+ * Copyright (C) 2008  Magnus Damm
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  */
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/io.h>
 #include <asm/r7780rp.h>
 
+enum {
+       UNUSED = 0,
+
+       /* board specific interrupt sources */
+
+       AX88796,          /* Ethernet controller */
+       PSW,              /* Push Switch */
+       CF,               /* Compact Flash */
+
+       PCI_A,
+       PCI_B,
+       PCI_C,
+       PCI_D,
+};
+
+static struct intc_vect vectors[] __initdata = {
+       INTC_IRQ(PCI_A, 65), /* dirty: overwrite cpu vectors for pci */
+       INTC_IRQ(PCI_B, 66),
+       INTC_IRQ(PCI_C, 67),
+       INTC_IRQ(PCI_D, 68),
+       INTC_IRQ(CF, IRQ_CF),
+       INTC_IRQ(PSW, IRQ_PSW),
+       INTC_IRQ(AX88796, IRQ_AX88796),
+};
+
+static struct intc_mask_reg mask_registers[] __initdata = {
+       { 0xa5000000, 0, 16, /* IRLMSK */
+         { PCI_A, PCI_B, PCI_C, PCI_D, CF, 0, 0, 0,
+           0, 0, 0, 0, 0, 0, PSW, AX88796 } },
+};
+
+static unsigned char irl2irq[HL_NR_IRL] __initdata = {
+       65, 66, 67, 68,
+       IRQ_CF, 0, 0, 0,
+       0, 0, 0, 0,
+       IRQ_AX88796, IRQ_PSW
+};
+
+static DECLARE_INTC_DESC(intc_desc, "r7780rp", vectors,
+                        NULL, mask_registers, NULL, NULL);
+
 unsigned char * __init highlander_init_irq_r7780rp(void)
 {
-       int i;
-
-       for (i = 0; i < 15; i++)
-               make_r7780rp_irq(i);
+       if (ctrl_inw(0xa5000600)) {
+               printk(KERN_INFO "Using r7780rp interrupt controller.\n");
+               register_intc_controller(&intc_desc);
+               return irl2irq;
+       }
 
        return NULL;
 }
 
+++ /dev/null
-/*
- * Renesas Solutions Highlander R7780RP-1 Support.
- *
- * Copyright (C) 2002  Atom Create Engineering Co., Ltd.
- * Copyright (C) 2006  Paul Mundt
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-#include <asm/r7780rp.h>
-
-#ifdef CONFIG_SH_R7780RP
-static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
-#elif defined(CONFIG_SH_R7780MP)
-static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
-#elif defined(CONFIG_SH_R7785RP)
-static int mask_pos[] = {2, 11, 2, 2, 2, 2, 9, 8, 7, 5, 10, 2, 2, 2, 2, 2};
-#endif
-
-static void enable_r7780rp_irq(unsigned int irq)
-{
-       /* Set priority in IPR back to original value */
-       ctrl_outw(ctrl_inw(IRLCNTR1) | (1 << mask_pos[irq]), IRLCNTR1);
-}
-
-static void disable_r7780rp_irq(unsigned int irq)
-{
-       /* Set the priority in IPR to 0 */
-       ctrl_outw(ctrl_inw(IRLCNTR1) & (0xffff ^ (1 << mask_pos[irq])),
-                 IRLCNTR1);
-}
-
-static struct irq_chip r7780rp_irq_chip __read_mostly = {
-       .name           = "R7780RP",
-       .mask           = disable_r7780rp_irq,
-       .unmask         = enable_r7780rp_irq,
-       .mask_ack       = disable_r7780rp_irq,
-};
-
-void make_r7780rp_irq(unsigned int irq)
-{
-       disable_irq_nosync(irq);
-       set_irq_chip_and_handler_name(irq, &r7780rp_irq_chip,
-                                     handle_level_irq, "level");
-       enable_r7780rp_irq(irq);
-}
 
 static struct platform_device *r7780rp_devices[] __initdata = {
        &r8a66597_usb_host_device,
        &m66592_usb_peripheral_device,
-       &cf_ide_device,
        &heartbeat_device,
+#ifndef CONFIG_SH_R7780RP
+       &cf_ide_device,
        &ax88796_device,
+#endif
 };
 
 static int __init r7780rp_devices_setup(void)
                        break;
 #endif
 #ifdef CONFIG_SH_R7780RP
-               highlander_init_irq_r7780rp();
-               ucp = irl2irq;
-               break;
+               ucp = highlander_init_irq_r7780rp();
+               if (ucp)
+                       break;
 #endif
        } while (0);
 
 
 #include <asm/io.h>
 #include "pci-sh4.h"
 
-static char r7780rp_irq_tab[] __initdata = {
-       0, 1, 2, 3,
-};
-
-static char r7780mp_irq_tab[] __initdata = {
+static char irq_tab[] __initdata = {
        65, 66, 67, 68,
 };
 
 int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
 {
-       if (mach_is_r7780rp())
-               return r7780rp_irq_tab[slot];
-       if (mach_is_r7780mp() || mach_is_r7785rp())
-               return r7780mp_irq_tab[slot];
-
-       printk(KERN_ERR "PCI: Bad IRQ mapping "
-              "request for slot %d, func %d\n", slot, pin-1);
-
-       return -1;
+       return irq_tab[slot];
 }
 
 static struct resource sh7780_io_resource = {
 
 
 #define IRLCNTR1       (PA_BCR + 0)    /* Interrupt Control Register1 */
 
-#define IRQ_PCISLOT1   0               /* PCI Slot #1 IRQ */
-#define IRQ_PCISLOT2   1               /* PCI Slot #2 IRQ */
-#define IRQ_PCISLOT3   2               /* PCI Slot #3 IRQ */
-#define IRQ_PCISLOT4   3               /* PCI Slot #4 IRQ */
-#define IRQ_CFINST     5               /* CF Card Insert IRQ */
-#define IRQ_M66596     6               /* M66596 IRQ */
-#define IRQ_SDCARD     7               /* SD Card IRQ */
-#define IRQ_TUCHPANEL  8               /* Touch Panel IRQ */
-#define IRQ_SCI                9               /* SCI IRQ */
-#define IRQ_2SERIAL    10              /* Serial IRQ */
-#define        IRQ_EXTENTION   11              /* EXTn IRQ */
-#define IRQ_ONETH      12              /* On board Ethernet IRQ */
-#define IRQ_PSW                13              /* Push Switch IRQ */
-#define IRQ_ZIGBEE     14              /* Ziggbee IO IRQ */
-
 #define IVDR_CK_ON     8               /* iVDR Clock ON */
 
 #elif defined(CONFIG_SH_R7785RP)
 
 #define IRQ_AX88796            (HL_FPGA_IRQ_BASE + 0)
 #define IRQ_CF                 (HL_FPGA_IRQ_BASE + 1)
-#ifndef IRQ_PSW
 #define IRQ_PSW                        (HL_FPGA_IRQ_BASE + 2)
-#endif
 #define IRQ_EXT0               (HL_FPGA_IRQ_BASE + 3)
 #define IRQ_EXT1               (HL_FPGA_IRQ_BASE + 4)
 #define IRQ_EXT2               (HL_FPGA_IRQ_BASE + 5)
 #define IRQ_RTC                        (HL_FPGA_IRQ_BASE + 13)
 #define IRQ_TH_ALERT           (HL_FPGA_IRQ_BASE + 14)
 
-void make_r7780rp_irq(unsigned int irq);
-
 unsigned char *highlander_init_irq_r7780mp(void);
 unsigned char *highlander_init_irq_r7780rp(void);
 unsigned char *highlander_init_irq_r7785rp(void);