2005-04-16 18:20:36 -04:00
|
|
|
/* linux/arch/arm/mach-s3c2410/bast-irq.c
|
|
|
|
*
|
2005-09-07 12:24:48 -04:00
|
|
|
* Copyright (c) 2003,2005 Simtec Electronics
|
2005-04-16 18:20:36 -04:00
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
*
|
|
|
|
* http://www.simtec.co.uk/products/EB2410ITX/
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
* 08-Jan-2003 BJD Moved from central IRQ code
|
2005-09-07 12:24:48 -04:00
|
|
|
* 21-Aug-2005 BJD Fixed missing code and compile errors
|
|
|
|
*/
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/sysdev.h>
|
|
|
|
|
2005-09-07 12:24:48 -04:00
|
|
|
#include <asm/mach-types.h>
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
#include <asm/hardware.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include <asm/mach/irq.h>
|
2005-09-07 12:24:48 -04:00
|
|
|
|
|
|
|
#include <asm/arch/regs-irq.h>
|
|
|
|
#include <asm/arch/bast-map.h>
|
|
|
|
#include <asm/arch/bast-irq.h>
|
|
|
|
|
|
|
|
#include "irq.h"
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
#include <asm/debug-ll.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define irqdbf(x...)
|
|
|
|
#define irqdbf2(x...)
|
|
|
|
|
|
|
|
|
|
|
|
/* handle PC104 ISA interrupts from the system CPLD */
|
|
|
|
|
|
|
|
/* table of ISA irq nos to the relevant mask... zero means
|
|
|
|
* the irq is not implemented
|
|
|
|
*/
|
|
|
|
static unsigned char bast_pc104_irqmasks[] = {
|
|
|
|
0, /* 0 */
|
|
|
|
0, /* 1 */
|
|
|
|
0, /* 2 */
|
|
|
|
1, /* 3 */
|
|
|
|
0, /* 4 */
|
|
|
|
2, /* 5 */
|
|
|
|
0, /* 6 */
|
|
|
|
4, /* 7 */
|
|
|
|
0, /* 8 */
|
|
|
|
0, /* 9 */
|
|
|
|
8, /* 10 */
|
|
|
|
0, /* 11 */
|
|
|
|
0, /* 12 */
|
|
|
|
0, /* 13 */
|
|
|
|
0, /* 14 */
|
|
|
|
0, /* 15 */
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
|
|
|
|
|
|
|
|
static void
|
|
|
|
bast_pc104_mask(unsigned int irqno)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
|
|
|
|
temp = __raw_readb(BAST_VA_PC104_IRQMASK);
|
|
|
|
temp &= ~bast_pc104_irqmasks[irqno];
|
|
|
|
__raw_writeb(temp, BAST_VA_PC104_IRQMASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-09-07 12:24:48 -04:00
|
|
|
bast_pc104_maskack(unsigned int irqno)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-09-07 12:24:48 -04:00
|
|
|
struct irqdesc *desc = irq_desc + IRQ_ISA;
|
|
|
|
|
|
|
|
bast_pc104_mask(irqno);
|
|
|
|
desc->chip->ack(IRQ_ISA);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bast_pc104_unmask(unsigned int irqno)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
|
|
|
|
temp = __raw_readb(BAST_VA_PC104_IRQMASK);
|
|
|
|
temp |= bast_pc104_irqmasks[irqno];
|
|
|
|
__raw_writeb(temp, BAST_VA_PC104_IRQMASK);
|
|
|
|
}
|
|
|
|
|
2005-09-07 12:24:48 -04:00
|
|
|
static struct irqchip bast_pc104_chip = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.mask = bast_pc104_mask,
|
|
|
|
.unmask = bast_pc104_unmask,
|
2005-09-07 12:24:48 -04:00
|
|
|
.ack = bast_pc104_maskack
|
2005-04-16 18:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bast_irq_pc104_demux(unsigned int irq,
|
|
|
|
struct irqdesc *desc,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
unsigned int stat;
|
|
|
|
unsigned int irqno;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf;
|
|
|
|
|
2005-09-07 12:24:48 -04:00
|
|
|
if (unlikely(stat == 0)) {
|
|
|
|
/* ack if we get an irq with nothing (ie, startup) */
|
|
|
|
|
|
|
|
desc = irq_desc + IRQ_ISA;
|
|
|
|
desc->chip->ack(IRQ_ISA);
|
|
|
|
} else {
|
|
|
|
/* handle the IRQ */
|
|
|
|
|
|
|
|
for (i = 0; stat != 0; i++, stat >>= 1) {
|
|
|
|
if (stat & 1) {
|
|
|
|
irqno = bast_pc104_irqs[i];
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-09-07 12:24:48 -04:00
|
|
|
desc_handle_irq(irqno, irq_desc + irqno, regs);
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
2005-09-07 12:24:48 -04:00
|
|
|
}
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-09-07 12:24:48 -04:00
|
|
|
static __init int bast_irq_init(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (machine_is_bast()) {
|
|
|
|
printk(KERN_INFO "BAST PC104 IRQ routing, (c) 2005 Simtec Electronics\n");
|
|
|
|
|
|
|
|
/* zap all the IRQs */
|
|
|
|
|
|
|
|
__raw_writeb(0x0, BAST_VA_PC104_IRQMASK);
|
|
|
|
|
|
|
|
set_irq_chained_handler(IRQ_ISA, bast_irq_pc104_demux);
|
|
|
|
|
|
|
|
/* reigster our IRQs */
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
unsigned int irqno = bast_pc104_irqs[i];
|
|
|
|
|
|
|
|
set_irq_chip(irqno, &bast_pc104_chip);
|
|
|
|
set_irq_handler(irqno, do_level_IRQ);
|
|
|
|
set_irq_flags(irqno, IRQF_VALID);
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
2005-09-07 12:24:48 -04:00
|
|
|
|
|
|
|
return 0;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
2005-09-07 12:24:48 -04:00
|
|
|
|
|
|
|
arch_initcall(bast_irq_init);
|