2006-11-05 15:21:09 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/sh/boards/se/7206/irq.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005,2006 Yoshinori Sato
|
|
|
|
*
|
|
|
|
* Hitachi SolutionEngine Support.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
2006-11-05 15:48:42 +08:00
|
|
|
#include <linux/io.h>
|
2006-12-07 17:01:23 +08:00
|
|
|
#include <linux/interrupt.h>
|
2008-07-29 20:41:37 +08:00
|
|
|
#include <mach-se/mach/se7206.h>
|
2006-11-05 15:21:09 +08:00
|
|
|
|
|
|
|
#define INTSTS0 0x31800000
|
|
|
|
#define INTSTS1 0x31800002
|
|
|
|
#define INTMSK0 0x31800004
|
|
|
|
#define INTMSK1 0x31800006
|
|
|
|
#define INTSEL 0x31800008
|
|
|
|
|
2006-12-07 17:01:23 +08:00
|
|
|
#define IRQ0_IRQ 64
|
|
|
|
#define IRQ1_IRQ 65
|
|
|
|
#define IRQ3_IRQ 67
|
|
|
|
|
|
|
|
#define INTC_IPR01 0xfffe0818
|
|
|
|
#define INTC_ICR1 0xfffe0802
|
|
|
|
|
2010-10-27 14:30:07 +08:00
|
|
|
static void disable_se7206_irq(struct irq_data *data)
|
2006-11-05 15:21:09 +08:00
|
|
|
{
|
2010-10-27 14:30:07 +08:00
|
|
|
unsigned int irq = data->irq;
|
2006-11-05 15:21:09 +08:00
|
|
|
unsigned short val;
|
|
|
|
unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
|
|
|
|
unsigned short msk0,msk1;
|
|
|
|
|
|
|
|
/* Set the priority in IPR to 0 */
|
2010-01-26 11:58:40 +08:00
|
|
|
val = __raw_readw(INTC_IPR01);
|
2006-11-05 15:21:09 +08:00
|
|
|
val &= mask;
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(val, INTC_IPR01);
|
2006-11-05 15:21:09 +08:00
|
|
|
/* FPGA mask set */
|
2010-01-26 11:58:40 +08:00
|
|
|
msk0 = __raw_readw(INTMSK0);
|
|
|
|
msk1 = __raw_readw(INTMSK1);
|
2006-11-05 15:21:09 +08:00
|
|
|
|
|
|
|
switch (irq) {
|
|
|
|
case IRQ0_IRQ:
|
|
|
|
msk0 |= 0x0010;
|
|
|
|
break;
|
|
|
|
case IRQ1_IRQ:
|
|
|
|
msk0 |= 0x000f;
|
|
|
|
break;
|
2006-12-07 17:01:23 +08:00
|
|
|
case IRQ3_IRQ:
|
2006-11-05 15:21:09 +08:00
|
|
|
msk0 |= 0x0f00;
|
|
|
|
msk1 |= 0x00ff;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(msk0, INTMSK0);
|
|
|
|
__raw_writew(msk1, INTMSK1);
|
2006-11-05 15:21:09 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 14:30:07 +08:00
|
|
|
static void enable_se7206_irq(struct irq_data *data)
|
2006-11-05 15:21:09 +08:00
|
|
|
{
|
2010-10-27 14:30:07 +08:00
|
|
|
unsigned int irq = data->irq;
|
2006-11-05 15:21:09 +08:00
|
|
|
unsigned short val;
|
|
|
|
unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
|
|
|
|
unsigned short msk0,msk1;
|
|
|
|
|
|
|
|
/* Set priority in IPR back to original value */
|
2010-01-26 11:58:40 +08:00
|
|
|
val = __raw_readw(INTC_IPR01);
|
2006-11-05 15:21:09 +08:00
|
|
|
val |= value;
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(val, INTC_IPR01);
|
2006-11-05 15:21:09 +08:00
|
|
|
|
|
|
|
/* FPGA mask reset */
|
2010-01-26 11:58:40 +08:00
|
|
|
msk0 = __raw_readw(INTMSK0);
|
|
|
|
msk1 = __raw_readw(INTMSK1);
|
2006-11-05 15:21:09 +08:00
|
|
|
|
|
|
|
switch (irq) {
|
|
|
|
case IRQ0_IRQ:
|
|
|
|
msk0 &= ~0x0010;
|
|
|
|
break;
|
|
|
|
case IRQ1_IRQ:
|
|
|
|
msk0 &= ~0x000f;
|
|
|
|
break;
|
2006-12-07 17:01:23 +08:00
|
|
|
case IRQ3_IRQ:
|
2006-11-05 15:21:09 +08:00
|
|
|
msk0 &= ~0x0f00;
|
|
|
|
msk1 &= ~0x00ff;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(msk0, INTMSK0);
|
|
|
|
__raw_writew(msk1, INTMSK1);
|
2006-11-05 15:21:09 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 14:30:07 +08:00
|
|
|
static void eoi_se7206_irq(struct irq_data *data)
|
2006-11-05 15:21:09 +08:00
|
|
|
{
|
|
|
|
unsigned short sts0,sts1;
|
2010-10-27 14:30:07 +08:00
|
|
|
unsigned int irq = data->irq;
|
2010-01-30 10:04:38 +08:00
|
|
|
struct irq_desc *desc = irq_to_desc(irq);
|
2006-11-05 15:21:09 +08:00
|
|
|
|
2010-01-30 10:04:38 +08:00
|
|
|
if (!(desc->status & (IRQ_DISABLED|IRQ_INPROGRESS)))
|
2010-10-27 14:30:07 +08:00
|
|
|
enable_se7206_irq(data);
|
2006-11-05 15:21:09 +08:00
|
|
|
/* FPGA isr clear */
|
2010-01-26 11:58:40 +08:00
|
|
|
sts0 = __raw_readw(INTSTS0);
|
|
|
|
sts1 = __raw_readw(INTSTS1);
|
2006-11-05 15:21:09 +08:00
|
|
|
|
|
|
|
switch (irq) {
|
|
|
|
case IRQ0_IRQ:
|
|
|
|
sts0 &= ~0x0010;
|
|
|
|
break;
|
|
|
|
case IRQ1_IRQ:
|
|
|
|
sts0 &= ~0x000f;
|
|
|
|
break;
|
2006-12-07 17:01:23 +08:00
|
|
|
case IRQ3_IRQ:
|
2006-11-05 15:21:09 +08:00
|
|
|
sts0 &= ~0x0f00;
|
|
|
|
sts1 &= ~0x00ff;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(sts0, INTSTS0);
|
|
|
|
__raw_writew(sts1, INTSTS1);
|
2006-11-05 15:21:09 +08:00
|
|
|
}
|
|
|
|
|
2006-11-05 15:48:42 +08:00
|
|
|
static struct irq_chip se7206_irq_chip __read_mostly = {
|
2006-12-07 17:01:23 +08:00
|
|
|
.name = "SE7206-FPGA",
|
2010-10-27 14:30:07 +08:00
|
|
|
.irq_mask = disable_se7206_irq,
|
|
|
|
.irq_unmask = enable_se7206_irq,
|
|
|
|
.irq_eoi = eoi_se7206_irq,
|
2006-11-05 15:21:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void make_se7206_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_irq_nosync(irq);
|
2006-11-05 15:48:42 +08:00
|
|
|
set_irq_chip_and_handler_name(irq, &se7206_irq_chip,
|
|
|
|
handle_level_irq, "level");
|
2010-10-27 14:30:07 +08:00
|
|
|
disable_se7206_irq(irq_get_irq_data(irq));
|
2006-11-05 15:21:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize IRQ setting
|
|
|
|
*/
|
|
|
|
void __init init_se7206_IRQ(void)
|
|
|
|
{
|
|
|
|
make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */
|
|
|
|
make_se7206_irq(IRQ1_IRQ); /* ATA */
|
|
|
|
make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(inw(INTC_ICR1) | 0x000b ,INTC_ICR1 ) ; /* ICR1 */
|
2006-11-05 15:21:09 +08:00
|
|
|
|
|
|
|
/* FPGA System register setup*/
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(0x0000,INTSTS0); /* Clear INTSTS0 */
|
|
|
|
__raw_writew(0x0000,INTSTS1); /* Clear INTSTS1 */
|
2006-11-05 15:21:09 +08:00
|
|
|
/* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writew(0x0001,INTSEL);
|
2006-11-05 15:21:09 +08:00
|
|
|
}
|