2006-01-17 01:14:14 -05:00
|
|
|
/*
|
2006-10-06 04:55:25 -04:00
|
|
|
* Interrupt handling for IPR-based IRQ.
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
|
|
|
|
* Copyright (C) 2000 Kazumoto Kojima
|
2006-10-06 04:55:25 -04:00
|
|
|
* Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
|
|
|
|
* Copyright (C) 2006 Paul Mundt
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* Supported system:
|
|
|
|
* On-chip supporting modules (TMU, RTC, etc.).
|
2007-07-24 22:42:56 -04:00
|
|
|
* On-chip supporting modules for SH7709/SH7709A/SH7729.
|
2005-04-16 18:20:36 -04:00
|
|
|
* Hitachi SolutionEngine external I/O:
|
|
|
|
* MS7709SE01, MS7709ASE01, and MS7750SE01
|
|
|
|
*
|
2006-10-06 04:55:25 -04:00
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
2005-04-16 18:20:36 -04:00
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/module.h>
|
2006-11-19 23:55:34 -05:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-06-15 05:56:19 -04:00
|
|
|
static inline struct ipr_desc *get_ipr_desc(unsigned int irq)
|
|
|
|
{
|
|
|
|
struct irq_chip *chip = get_irq_chip(irq);
|
|
|
|
return (void *)((char *)chip - offsetof(struct ipr_desc, chip));
|
|
|
|
}
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
static void disable_ipr_irq(unsigned int irq)
|
|
|
|
{
|
2006-10-06 04:55:25 -04:00
|
|
|
struct ipr_data *p = get_irq_chip_data(irq);
|
2007-06-15 05:56:19 -04:00
|
|
|
unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx];
|
2005-04-16 18:20:36 -04:00
|
|
|
/* Set the priority in IPR to 0 */
|
2007-06-15 05:56:19 -04:00
|
|
|
ctrl_outw(ctrl_inw(addr) & (0xffff ^ (0xf << p->shift)), addr);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void enable_ipr_irq(unsigned int irq)
|
|
|
|
{
|
2006-10-06 04:55:25 -04:00
|
|
|
struct ipr_data *p = get_irq_chip_data(irq);
|
2007-06-15 05:56:19 -04:00
|
|
|
unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx];
|
2005-04-16 18:20:36 -04:00
|
|
|
/* Set priority in IPR back to original value */
|
2007-06-15 05:56:19 -04:00
|
|
|
ctrl_outw(ctrl_inw(addr) | (p->priority << p->shift), addr);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2007-06-15 05:56:19 -04:00
|
|
|
/*
|
|
|
|
* The shift value is now the number of bits to shift, not the number of
|
|
|
|
* bits/4. This is to make it easier to read the value directly from the
|
|
|
|
* datasheets. The IPR address is calculated using the ipr_offset table.
|
|
|
|
*/
|
|
|
|
void register_ipr_controller(struct ipr_desc *desc)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2006-10-30 22:35:02 -05:00
|
|
|
int i;
|
2006-10-06 04:55:25 -04:00
|
|
|
|
2007-06-15 05:56:19 -04:00
|
|
|
desc->chip.mask = disable_ipr_irq;
|
|
|
|
desc->chip.unmask = enable_ipr_irq;
|
|
|
|
desc->chip.mask_ack = disable_ipr_irq;
|
2006-12-25 04:35:24 -05:00
|
|
|
|
2007-06-15 05:56:19 -04:00
|
|
|
for (i = 0; i < desc->nr_irqs; i++) {
|
|
|
|
struct ipr_data *p = desc->ipr_data + i;
|
2006-12-25 04:35:24 -05:00
|
|
|
|
2007-06-15 05:56:19 -04:00
|
|
|
BUG_ON(p->ipr_idx >= desc->nr_offsets);
|
|
|
|
BUG_ON(!desc->ipr_offsets[p->ipr_idx]);
|
2006-12-25 04:35:24 -05:00
|
|
|
|
2007-06-15 05:56:19 -04:00
|
|
|
disable_irq_nosync(p->irq);
|
|
|
|
set_irq_chip_and_handler_name(p->irq, &desc->chip,
|
2006-10-19 04:32:56 -04:00
|
|
|
handle_level_irq, "level");
|
2007-06-15 05:56:19 -04:00
|
|
|
set_irq_chip_data(p->irq, p);
|
|
|
|
disable_ipr_irq(p->irq);
|
2006-10-30 22:35:02 -05:00
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
2007-06-15 05:56:19 -04:00
|
|
|
EXPORT_SYMBOL(register_ipr_controller);
|