2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 YAEGASHI Takeshi
|
|
|
|
* Hitachi HD64461 companion chip support
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/param.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
2008-11-28 08:58:30 +00:00
|
|
|
#include <linux/io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/irq.h>
|
2006-09-27 04:42:57 +00:00
|
|
|
#include <asm/hd64461.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-09-11 03:48:45 +00:00
|
|
|
/* This belongs in cpu specific */
|
|
|
|
#define INTC_ICR1 0xA4140010UL
|
|
|
|
|
2010-10-27 06:18:15 +00:00
|
|
|
static void hd64461_mask_irq(struct irq_data *data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-10-27 06:18:15 +00:00
|
|
|
unsigned int irq = data->irq;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned short nimr;
|
|
|
|
unsigned short mask = 1 << (irq - HD64461_IRQBASE);
|
|
|
|
|
2008-11-28 08:58:30 +00:00
|
|
|
nimr = __raw_readw(HD64461_NIMR);
|
2005-04-16 22:20:36 +00:00
|
|
|
nimr |= mask;
|
2008-11-28 08:58:30 +00:00
|
|
|
__raw_writew(nimr, HD64461_NIMR);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-27 06:18:15 +00:00
|
|
|
static void hd64461_unmask_irq(struct irq_data *data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-10-27 06:18:15 +00:00
|
|
|
unsigned int irq = data->irq;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned short nimr;
|
|
|
|
unsigned short mask = 1 << (irq - HD64461_IRQBASE);
|
|
|
|
|
2008-11-28 08:58:30 +00:00
|
|
|
nimr = __raw_readw(HD64461_NIMR);
|
2005-04-16 22:20:36 +00:00
|
|
|
nimr &= ~mask;
|
2008-11-28 08:58:30 +00:00
|
|
|
__raw_writew(nimr, HD64461_NIMR);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-27 06:18:15 +00:00
|
|
|
static void hd64461_mask_and_ack_irq(struct irq_data *data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-10-27 06:18:15 +00:00
|
|
|
hd64461_mask_irq(data);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_HD64461_ENABLER
|
2010-10-27 06:18:15 +00:00
|
|
|
if (data->irq == HD64461_IRQBASE + 13)
|
2008-11-28 08:58:30 +00:00
|
|
|
__raw_writeb(0x00, HD64461_PCC1CSCR);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-11-28 08:58:30 +00:00
|
|
|
static struct irq_chip hd64461_irq_chip = {
|
|
|
|
.name = "HD64461-IRQ",
|
2010-10-27 06:18:15 +00:00
|
|
|
.irq_mask = hd64461_mask_irq,
|
|
|
|
.irq_mask_ack = hd64461_mask_and_ack_irq,
|
|
|
|
.irq_unmask = hd64461_unmask_irq,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2009-03-20 02:08:22 +00:00
|
|
|
static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-01-26 03:58:40 +00:00
|
|
|
unsigned short intv = __raw_readw(HD64461_NIRR);
|
2009-03-20 02:08:22 +00:00
|
|
|
unsigned int ext_irq = HD64461_IRQBASE;
|
|
|
|
|
|
|
|
intv &= (1 << HD64461_IRQ_NUM) - 1;
|
|
|
|
|
2010-02-05 08:45:14 +00:00
|
|
|
for (; intv; intv >>= 1, ext_irq++) {
|
|
|
|
if (!(intv & 1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
generic_handle_irq(ext_irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int __init setup_hd64461(void)
|
|
|
|
{
|
2010-02-02 08:48:17 +00:00
|
|
|
int i, nid = cpu_to_node(boot_cpu_data);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!MACH_HD64461)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
printk(KERN_INFO
|
|
|
|
"HD64461 configured at 0x%x on irq %d(mapped into %d to %d)\n",
|
2009-05-20 02:27:13 +00:00
|
|
|
HD64461_IOBASE, CONFIG_HD64461_IRQ, HD64461_IRQBASE,
|
2005-04-16 22:20:36 +00:00
|
|
|
HD64461_IRQBASE + 15);
|
|
|
|
|
2008-11-28 08:58:30 +00:00
|
|
|
/* Should be at processor specific part.. */
|
|
|
|
#if defined(CONFIG_CPU_SUBTYPE_SH7709)
|
|
|
|
__raw_writew(0x2240, INTC_ICR1);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2008-11-28 08:58:30 +00:00
|
|
|
__raw_writew(0xffff, HD64461_NIMR);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-09-11 03:48:45 +00:00
|
|
|
/* IRQ 80 -> 95 belongs to HD64461 */
|
2010-02-02 08:48:17 +00:00
|
|
|
for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++) {
|
|
|
|
unsigned int irq;
|
|
|
|
|
|
|
|
irq = create_irq_nr(i, nid);
|
|
|
|
if (unlikely(irq == 0)) {
|
|
|
|
pr_err("%s: failed hooking irq %d for HD64461\n",
|
|
|
|
__func__, i);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(irq != i)) {
|
|
|
|
pr_err("%s: got irq %d but wanted %d, bailing.\n",
|
|
|
|
__func__, irq, i);
|
|
|
|
destroy_irq(irq);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-11-28 08:58:30 +00:00
|
|
|
set_irq_chip_and_handler(i, &hd64461_irq_chip,
|
|
|
|
handle_level_irq);
|
2010-02-02 08:48:17 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-20 02:08:22 +00:00
|
|
|
set_irq_chained_handler(CONFIG_HD64461_IRQ, hd64461_irq_demux);
|
|
|
|
set_irq_type(CONFIG_HD64461_IRQ, IRQ_TYPE_LEVEL_LOW);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_HD64461_ENABLER
|
|
|
|
printk(KERN_INFO "HD64461: enabling PCMCIA devices\n");
|
2008-11-28 08:58:30 +00:00
|
|
|
__raw_writeb(0x4c, HD64461_PCC1CSCIER);
|
|
|
|
__raw_writeb(0x00, HD64461_PCC1CSCR);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(setup_hd64461);
|