2017-12-26 03:54:32 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
//
|
|
|
|
// Copyright 2003-2005 Simtec Electronics
|
|
|
|
// Ben Dooks <ben@simtec.co.uk>
|
|
|
|
//
|
|
|
|
// http://www.simtec.co.uk/products/EB2410ITX/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/ioport.h>
|
2011-12-22 08:26:03 +08:00
|
|
|
#include <linux/device.h>
|
2008-09-06 19:10:45 +08:00
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/irq.h>
|
2013-01-02 11:56:20 +08:00
|
|
|
#include <asm/mach-types.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/mach/irq.h>
|
2005-09-08 00:24:48 +08:00
|
|
|
|
2013-01-02 11:56:20 +08:00
|
|
|
#include <mach/hardware.h>
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/regs-irq.h>
|
2005-09-08 00:24:48 +08:00
|
|
|
|
2013-01-02 11:56:20 +08:00
|
|
|
#include "bast.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#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
|
|
|
|
*/
|
2016-12-10 21:47:34 +08:00
|
|
|
static const unsigned char bast_pc104_irqmasks[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
2016-12-10 21:47:34 +08:00
|
|
|
static const unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void
|
2011-01-03 18:15:54 +08:00
|
|
|
bast_pc104_mask(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
|
|
|
|
temp = __raw_readb(BAST_VA_PC104_IRQMASK);
|
2011-01-03 18:15:54 +08:00
|
|
|
temp &= ~bast_pc104_irqmasks[data->irq];
|
2005-04-17 06:20:36 +08:00
|
|
|
__raw_writeb(temp, BAST_VA_PC104_IRQMASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-03 18:15:54 +08:00
|
|
|
bast_pc104_maskack(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-01-02 11:56:20 +08:00
|
|
|
struct irq_desc *desc = irq_desc + BAST_IRQ_ISA;
|
2005-09-08 00:24:48 +08:00
|
|
|
|
2011-01-03 18:15:54 +08:00
|
|
|
bast_pc104_mask(data);
|
|
|
|
desc->irq_data.chip->irq_ack(&desc->irq_data);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-03 18:15:54 +08:00
|
|
|
bast_pc104_unmask(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
|
|
|
|
temp = __raw_readb(BAST_VA_PC104_IRQMASK);
|
2011-01-03 18:15:54 +08:00
|
|
|
temp |= bast_pc104_irqmasks[data->irq];
|
2005-04-17 06:20:36 +08:00
|
|
|
__raw_writeb(temp, BAST_VA_PC104_IRQMASK);
|
|
|
|
}
|
|
|
|
|
2006-11-23 19:41:32 +08:00
|
|
|
static struct irq_chip bast_pc104_chip = {
|
2011-01-03 18:15:54 +08:00
|
|
|
.irq_mask = bast_pc104_mask,
|
|
|
|
.irq_unmask = bast_pc104_unmask,
|
|
|
|
.irq_ack = bast_pc104_maskack
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2015-09-14 16:42:37 +08:00
|
|
|
static void bast_irq_pc104_demux(struct irq_desc *desc)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned int stat;
|
|
|
|
unsigned int irqno;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf;
|
|
|
|
|
2005-09-08 00:24:48 +08:00
|
|
|
if (unlikely(stat == 0)) {
|
|
|
|
/* ack if we get an irq with nothing (ie, startup) */
|
|
|
|
|
2013-01-02 11:56:20 +08:00
|
|
|
desc = irq_desc + BAST_IRQ_ISA;
|
2011-01-03 18:15:54 +08:00
|
|
|
desc->irq_data.chip->irq_ack(&desc->irq_data);
|
2005-09-08 00:24:48 +08:00
|
|
|
} else {
|
|
|
|
/* handle the IRQ */
|
|
|
|
|
|
|
|
for (i = 0; stat != 0; i++, stat >>= 1) {
|
|
|
|
if (stat & 1) {
|
|
|
|
irqno = bast_pc104_irqs[i];
|
2008-10-09 20:36:24 +08:00
|
|
|
generic_handle_irq(irqno);
|
2005-09-08 00:24:48 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-08 00:24:48 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-08 00:24:48 +08:00
|
|
|
static __init int bast_irq_init(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (machine_is_bast()) {
|
2009-11-14 06:54:12 +08:00
|
|
|
printk(KERN_INFO "BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n");
|
2005-09-08 00:24:48 +08:00
|
|
|
|
|
|
|
/* zap all the IRQs */
|
|
|
|
|
|
|
|
__raw_writeb(0x0, BAST_VA_PC104_IRQMASK);
|
|
|
|
|
2013-01-02 11:56:20 +08:00
|
|
|
irq_set_chained_handler(BAST_IRQ_ISA, bast_irq_pc104_demux);
|
2005-09-08 00:24:48 +08:00
|
|
|
|
2006-07-02 05:32:39 +08:00
|
|
|
/* register our IRQs */
|
2005-09-08 00:24:48 +08:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
unsigned int irqno = bast_pc104_irqs[i];
|
|
|
|
|
2011-03-24 20:35:09 +08:00
|
|
|
irq_set_chip_and_handler(irqno, &bast_pc104_chip,
|
|
|
|
handle_level_irq);
|
2015-07-28 04:55:13 +08:00
|
|
|
irq_clear_status_flags(irqno, IRQ_NOREQUEST);
|
2005-09-08 00:24:48 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-08 00:24:48 +08:00
|
|
|
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-08 00:24:48 +08:00
|
|
|
|
|
|
|
arch_initcall(bast_irq_init);
|