2018-12-28 16:31:46 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* arch/sh/boards/superh/microdev/irq.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
|
|
|
|
*
|
|
|
|
* SuperH SH4-202 MicroDev board support.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
2007-06-04 09:50:42 +08:00
|
|
|
#include <linux/interrupt.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/io.h>
|
2008-10-20 12:02:48 +08:00
|
|
|
#include <mach/microdev.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define NUM_EXTERNAL_IRQS 16 /* IRL0 .. IRL15 */
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
unsigned char fpgaIrq;
|
|
|
|
unsigned char mapped;
|
|
|
|
const char *name;
|
|
|
|
} fpgaIrqTable[NUM_EXTERNAL_IRQS] = {
|
|
|
|
{ 0, 0, "unused" }, /* IRQ #0 IRL=15 0x200 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_KEYBOARD, 1, "keyboard" }, /* IRQ #1 IRL=14 0x220 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_SERIAL1, 1, "Serial #1"}, /* IRQ #2 IRL=13 0x240 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_ETHERNET, 1, "Ethernet" }, /* IRQ #3 IRL=12 0x260 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_SERIAL2, 0, "Serial #2"}, /* IRQ #4 IRL=11 0x280 */
|
|
|
|
{ 0, 0, "unused" }, /* IRQ #5 IRL=10 0x2a0 */
|
|
|
|
{ 0, 0, "unused" }, /* IRQ #6 IRL=9 0x2c0 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_USB_HC, 1, "USB" }, /* IRQ #7 IRL=8 0x2e0 */
|
|
|
|
{ MICRODEV_IRQ_PCI_INTA, 1, "PCI INTA" }, /* IRQ #8 IRL=7 0x300 */
|
|
|
|
{ MICRODEV_IRQ_PCI_INTB, 1, "PCI INTB" }, /* IRQ #9 IRL=6 0x320 */
|
|
|
|
{ MICRODEV_IRQ_PCI_INTC, 1, "PCI INTC" }, /* IRQ #10 IRL=5 0x340 */
|
|
|
|
{ MICRODEV_IRQ_PCI_INTD, 1, "PCI INTD" }, /* IRQ #11 IRL=4 0x360 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_MOUSE, 1, "mouse" }, /* IRQ #12 IRL=3 0x380 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_IDE2, 1, "IDE #2" }, /* IRQ #13 IRL=2 0x3a0 */
|
|
|
|
{ MICRODEV_FPGA_IRQ_IDE1, 1, "IDE #1" }, /* IRQ #14 IRL=1 0x3c0 */
|
|
|
|
{ 0, 0, "unused" }, /* IRQ #15 IRL=0 0x3e0 */
|
|
|
|
};
|
|
|
|
|
|
|
|
#if (MICRODEV_LINUX_IRQ_KEYBOARD != 1)
|
|
|
|
# error Inconsistancy in defining the IRQ# for Keyboard!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (MICRODEV_LINUX_IRQ_ETHERNET != 3)
|
|
|
|
# error Inconsistancy in defining the IRQ# for Ethernet!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (MICRODEV_LINUX_IRQ_USB_HC != 7)
|
|
|
|
# error Inconsistancy in defining the IRQ# for USB!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (MICRODEV_LINUX_IRQ_MOUSE != 12)
|
|
|
|
# error Inconsistancy in defining the IRQ# for PS/2 Mouse!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (MICRODEV_LINUX_IRQ_IDE2 != 13)
|
|
|
|
# error Inconsistancy in defining the IRQ# for secondary IDE!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (MICRODEV_LINUX_IRQ_IDE1 != 14)
|
|
|
|
# error Inconsistancy in defining the IRQ# for primary IDE!
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 13:54:10 +08:00
|
|
|
static void disable_microdev_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-10-27 13:54:10 +08:00
|
|
|
unsigned int irq = data->irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int fpgaIrq;
|
|
|
|
|
2006-09-27 17:03:34 +08:00
|
|
|
if (irq >= NUM_EXTERNAL_IRQS)
|
|
|
|
return;
|
|
|
|
if (!fpgaIrqTable[irq].mapped)
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
|
|
|
|
|
2007-05-14 07:15:10 +08:00
|
|
|
/* disable interrupts on the FPGA INTC register */
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 13:54:10 +08:00
|
|
|
static void enable_microdev_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-10-27 13:54:10 +08:00
|
|
|
unsigned int irq = data->irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long priorityReg, priorities, pri;
|
|
|
|
unsigned int fpgaIrq;
|
|
|
|
|
2006-09-27 17:03:34 +08:00
|
|
|
if (unlikely(irq >= NUM_EXTERNAL_IRQS))
|
|
|
|
return;
|
|
|
|
if (unlikely(!fpgaIrqTable[irq].mapped))
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
pri = 15 - irq;
|
|
|
|
|
|
|
|
fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
|
|
|
|
priorityReg = MICRODEV_FPGA_INTPRI_REG(fpgaIrq);
|
|
|
|
|
2006-09-27 17:03:34 +08:00
|
|
|
/* set priority for the interrupt */
|
2010-01-26 11:58:40 +08:00
|
|
|
priorities = __raw_readl(priorityReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
priorities &= ~MICRODEV_FPGA_INTPRI_MASK(fpgaIrq);
|
|
|
|
priorities |= MICRODEV_FPGA_INTPRI_LEVEL(fpgaIrq, pri);
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(priorities, priorityReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-14 07:15:10 +08:00
|
|
|
/* enable interrupts on the FPGA INTC register */
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 13:54:10 +08:00
|
|
|
static struct irq_chip microdev_irq_type = {
|
|
|
|
.name = "MicroDev-IRQ",
|
|
|
|
.irq_unmask = enable_microdev_irq,
|
|
|
|
.irq_mask = disable_microdev_irq,
|
|
|
|
};
|
|
|
|
|
2008-12-14 20:02:24 +08:00
|
|
|
/* This function sets the desired irq handler to be a MicroDev type */
|
2005-04-17 06:20:36 +08:00
|
|
|
static void __init make_microdev_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_irq_nosync(irq);
|
2011-03-24 23:31:17 +08:00
|
|
|
irq_set_chip_and_handler(irq, µdev_irq_type, handle_level_irq);
|
2010-10-27 13:54:10 +08:00
|
|
|
disable_microdev_irq(irq_get_irq_data(irq));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
extern void __init init_microdev_irq(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-12-14 20:02:24 +08:00
|
|
|
/* disable interrupts on the FPGA INTC register */
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(~0ul, MICRODEV_FPGA_INTDSB_REG);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_EXTERNAL_IRQS; i++)
|
|
|
|
make_microdev_irq(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void microdev_print_fpga_intc_status(void)
|
|
|
|
{
|
|
|
|
volatile unsigned int * const intenb = (unsigned int*)MICRODEV_FPGA_INTENB_REG;
|
|
|
|
volatile unsigned int * const intdsb = (unsigned int*)MICRODEV_FPGA_INTDSB_REG;
|
|
|
|
volatile unsigned int * const intpria = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(0);
|
|
|
|
volatile unsigned int * const intprib = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(8);
|
|
|
|
volatile unsigned int * const intpric = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(16);
|
|
|
|
volatile unsigned int * const intprid = (unsigned int*)MICRODEV_FPGA_INTPRI_REG(24);
|
|
|
|
volatile unsigned int * const intsrc = (unsigned int*)MICRODEV_FPGA_INTSRC_REG;
|
|
|
|
volatile unsigned int * const intreq = (unsigned int*)MICRODEV_FPGA_INTREQ_REG;
|
|
|
|
|
|
|
|
printk("-------------------------- microdev_print_fpga_intc_status() ------------------\n");
|
|
|
|
printk("FPGA_INTENB = 0x%08x\n", *intenb);
|
|
|
|
printk("FPGA_INTDSB = 0x%08x\n", *intdsb);
|
|
|
|
printk("FPGA_INTSRC = 0x%08x\n", *intsrc);
|
|
|
|
printk("FPGA_INTREQ = 0x%08x\n", *intreq);
|
|
|
|
printk("FPGA_INTPRI[3..0] = %08x:%08x:%08x:%08x\n", *intprid, *intpric, *intprib, *intpria);
|
|
|
|
printk("-------------------------------------------------------------------------------\n");
|
|
|
|
}
|