Commit 74be8d08 authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] m68k: convert amiga irq code

Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 68387c44
......@@ -23,8 +23,6 @@ EXPORT_SYMBOL(amiga_chip_avail);
EXPORT_SYMBOL(amiga_chip_size);
EXPORT_SYMBOL(amiga_audio_period);
EXPORT_SYMBOL(amiga_audio_min_period);
EXPORT_SYMBOL(amiga_do_irq);
EXPORT_SYMBOL(amiga_do_irq_list);
#ifdef CONFIG_AMIGA_PCMCIA
EXPORT_SYMBOL(pcmcia_reset);
......
This diff is collapsed.
......@@ -29,21 +29,18 @@ struct ciabase {
unsigned short int_mask;
int handler_irq, cia_irq, server_irq;
char *name;
irq_handler_t irq_list[CIA_IRQS];
} ciaa_base = {
.cia = &ciaa,
.int_mask = IF_PORTS,
.handler_irq = IRQ_AUTO_2,
.handler_irq = IRQ_AMIGA_PORTS,
.cia_irq = IRQ_AMIGA_CIAA,
.server_irq = IRQ_AMIGA_PORTS,
.name = "CIAA handler"
.name = "CIAA"
}, ciab_base = {
.cia = &ciab,
.int_mask = IF_EXTER,
.handler_irq = IRQ_AUTO_6,
.handler_irq = IRQ_AMIGA_EXTER,
.cia_irq = IRQ_AMIGA_CIAB,
.server_irq = IRQ_AMIGA_EXTER,
.name = "CIAB handler"
.name = "CIAB"
};
/*
......@@ -66,13 +63,11 @@ unsigned char cia_set_irq(struct ciabase *base, unsigned char mask)
/*
* Enable or disable CIA interrupts, return old interrupt mask,
* interrupts will only be enabled if a handler exists
*/
unsigned char cia_able_irq(struct ciabase *base, unsigned char mask)
{
unsigned char old, tmp;
int i;
unsigned char old;
old = base->icr_mask;
base->icr_data |= base->cia->icr;
......@@ -82,98 +77,104 @@ unsigned char cia_able_irq(struct ciabase *base, unsigned char mask)
else
base->icr_mask &= ~mask;
base->icr_mask &= CIA_ICR_ALL;
for (i = 0, tmp = 1; i < CIA_IRQS; i++, tmp <<= 1) {
if ((tmp & base->icr_mask) && !base->irq_list[i].handler) {
base->icr_mask &= ~tmp;
base->cia->icr = tmp;
}
}
if (base->icr_data & base->icr_mask)
amiga_custom.intreq = IF_SETCLR | base->int_mask;
return old;
}
int cia_request_irq(struct ciabase *base, unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname, void *dev_id)
{
unsigned char mask;
base->irq_list[irq].handler = handler;
base->irq_list[irq].flags = flags;
base->irq_list[irq].dev_id = dev_id;
base->irq_list[irq].devname = devname;
/* enable the interrupt */
mask = 1 << irq;
cia_set_irq(base, mask);
cia_able_irq(base, CIA_ICR_SETCLR | mask);
return 0;
}
void cia_free_irq(struct ciabase *base, unsigned int irq, void *dev_id)
{
if (base->irq_list[irq].dev_id != dev_id)
printk("%s: removing probably wrong IRQ %i from %s\n",
__FUNCTION__, base->cia_irq + irq,
base->irq_list[irq].devname);
base->irq_list[irq].handler = NULL;
base->irq_list[irq].flags = 0;
cia_able_irq(base, 1 << irq);
}
static irqreturn_t cia_handler(int irq, void *dev_id, struct pt_regs *fp)
{
struct ciabase *base = (struct ciabase *)dev_id;
int mach_irq, i;
int mach_irq;
unsigned char ints;
mach_irq = base->cia_irq;
ints = cia_set_irq(base, CIA_ICR_ALL);
amiga_custom.intreq = base->int_mask;
for (i = 0; i < CIA_IRQS; i++, mach_irq++) {
if (ints & 1) {
kstat_cpu(0).irqs[mach_irq]++;
base->irq_list[i].handler(mach_irq, base->irq_list[i].dev_id, fp);
}
ints >>= 1;
for (; ints; mach_irq++, ints >>= 1) {
if (ints & 1)
m68k_handle_int(mach_irq, fp);
}
amiga_do_irq_list(base->server_irq, fp);
return IRQ_HANDLED;
}
void __init cia_init_IRQ(struct ciabase *base)
static void cia_enable_irq(unsigned int irq)
{
int i;
unsigned char mask;
/* init isr handlers */
for (i = 0; i < CIA_IRQS; i++) {
base->irq_list[i].handler = NULL;
base->irq_list[i].flags = 0;
if (irq >= IRQ_AMIGA_CIAB) {
mask = 1 << (irq - IRQ_AMIGA_CIAB);
cia_set_irq(&ciab_base, mask);
cia_able_irq(&ciab_base, CIA_ICR_SETCLR | mask);
} else {
mask = 1 << (irq - IRQ_AMIGA_CIAA);
cia_set_irq(&ciaa_base, mask);
cia_able_irq(&ciaa_base, CIA_ICR_SETCLR | mask);
}
}
/* clear any pending interrupt and turn off all interrupts */
cia_set_irq(base, CIA_ICR_ALL);
cia_able_irq(base, CIA_ICR_ALL);
static void cia_disable_irq(unsigned int irq)
{
if (irq >= IRQ_AMIGA_CIAB)
cia_able_irq(&ciab_base, 1 << (irq - IRQ_AMIGA_CIAB));
else
cia_able_irq(&ciaa_base, 1 << (irq - IRQ_AMIGA_CIAA));
}
/* install CIA handler */
request_irq(base->handler_irq, cia_handler, 0, base->name, base);
static struct irq_controller cia_irq_controller = {
.name = "cia",
.lock = SPIN_LOCK_UNLOCKED,
.enable = cia_enable_irq,
.disable = cia_disable_irq,
};
/*
* Override auto irq 2 & 6 and use them as general chain
* for external interrupts, we link the CIA interrupt sources
* into this chain.
*/
amiga_custom.intena = IF_SETCLR | base->int_mask;
static void auto_enable_irq(unsigned int irq)
{
switch (irq) {
case IRQ_AUTO_2:
amiga_custom.intena = IF_SETCLR | IF_PORTS;
break;
case IRQ_AUTO_6:
amiga_custom.intena = IF_SETCLR | IF_EXTER;
break;
}
}
int cia_get_irq_list(struct ciabase *base, struct seq_file *p)
static void auto_disable_irq(unsigned int irq)
{
int i, j;
j = base->cia_irq;
for (i = 0; i < CIA_IRQS; i++) {
seq_printf(p, "cia %2d: %10d ", j + i,
kstat_cpu(0).irqs[j + i]);
seq_puts(p, " ");
seq_printf(p, "%s\n", base->irq_list[i].devname);
switch (irq) {
case IRQ_AUTO_2:
amiga_custom.intena = IF_PORTS;
break;
case IRQ_AUTO_6:
amiga_custom.intena = IF_EXTER;
break;
}
return 0;
}
static struct irq_controller auto_irq_controller = {
.name = "auto",
.lock = SPIN_LOCK_UNLOCKED,
.enable = auto_enable_irq,
.disable = auto_disable_irq,
};
void __init cia_init_IRQ(struct ciabase *base)
{
m68k_setup_irq_controller(&cia_irq_controller, base->cia_irq, CIA_IRQS);
/* clear any pending interrupt and turn off all interrupts */
cia_set_irq(base, CIA_ICR_ALL);
cia_able_irq(base, CIA_ICR_ALL);
/* override auto int and install CIA handler */
m68k_setup_irq_controller(&auto_irq_controller, base->handler_irq, 1);
m68k_irq_startup(base->handler_irq);
request_irq(base->handler_irq, cia_handler, SA_SHIRQ, base->name, base);
}
......@@ -87,17 +87,8 @@ extern char m68k_debug_device[];
static void amiga_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
/* amiga specific irq functions */
extern void amiga_init_IRQ (void);
extern irqreturn_t (*amiga_default_handler[]) (int, void *, struct pt_regs *);
extern int amiga_request_irq (unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname,
void *dev_id);
extern void amiga_free_irq (unsigned int irq, void *dev_id);
extern void amiga_enable_irq (unsigned int);
extern void amiga_disable_irq (unsigned int);
static void amiga_get_model(char *model);
static int amiga_get_hardware_list(char *buffer);
extern int show_amiga_interrupts (struct seq_file *, void *);
/* amiga specific timer functions */
static unsigned long amiga_gettimeoffset (void);
static int a3000_hwclk (int, struct rtc_time *);
......@@ -392,14 +383,8 @@ void __init config_amiga(void)
mach_sched_init = amiga_sched_init;
mach_init_IRQ = amiga_init_IRQ;
mach_default_handler = &amiga_default_handler;
mach_request_irq = amiga_request_irq;
mach_free_irq = amiga_free_irq;
enable_irq = amiga_enable_irq;
disable_irq = amiga_disable_irq;
mach_get_model = amiga_get_model;
mach_get_hardware_list = amiga_get_hardware_list;
mach_get_irq_list = show_amiga_interrupts;
mach_gettimeoffset = amiga_gettimeoffset;
if (AMIGAHW_PRESENT(A3000_CLK)){
mach_hwclk = a3000_hwclk;
......
......@@ -37,8 +37,8 @@
#define IRQ_AMIGA_SOFT (IRQ_USER+2)
/* interrupts from external hardware */
#define IRQ_AMIGA_PORTS (IRQ_USER+3)
#define IRQ_AMIGA_EXTER (IRQ_USER+13)
#define IRQ_AMIGA_PORTS IRQ_AUTO_2
#define IRQ_AMIGA_EXTER IRQ_AUTO_6
/* copper interrupt */
#define IRQ_AMIGA_COPPER (IRQ_USER+4)
......@@ -88,9 +88,6 @@
#define IF_DSKBLK 0x0002 /* diskblock DMA finished */
#define IF_TBE 0x0001 /* serial transmit buffer empty interrupt */
extern void amiga_do_irq(int irq, struct pt_regs *fp);
extern void amiga_do_irq_list(int irq, struct pt_regs *fp);
/* CIA interrupt control register bits */
#define CIA_ICR_TA 0x01
......@@ -107,6 +104,7 @@ extern void amiga_do_irq_list(int irq, struct pt_regs *fp);
extern struct ciabase ciaa_base, ciab_base;
extern void cia_init_IRQ(struct ciabase *base);
extern unsigned char cia_set_irq(struct ciabase *base, unsigned char mask);
extern unsigned char cia_able_irq(struct ciabase *base, unsigned char mask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment