2006-01-17 06:14:14 +00:00
|
|
|
/*
|
2006-10-06 08:55:25 +00:00
|
|
|
* Interrupt handling for IPR-based IRQ.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
|
|
|
|
* Copyright (C) 2000 Kazumoto Kojima
|
2006-10-06 08:55:25 +00:00
|
|
|
* Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
|
|
|
|
* Copyright (C) 2006 Paul Mundt
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Supported system:
|
|
|
|
* On-chip supporting modules (TMU, RTC, etc.).
|
2007-07-25 02:42:56 +00:00
|
|
|
* On-chip supporting modules for SH7709/SH7709A/SH7729.
|
2005-04-16 22:20:36 +00:00
|
|
|
* Hitachi SolutionEngine external I/O:
|
|
|
|
* MS7709SE01, MS7709ASE01, and MS7750SE01
|
|
|
|
*
|
2006-10-06 08:55:25 +00: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 22:20:36 +00:00
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/module.h>
|
2006-11-20 04:55:34 +00:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-06-15 09:56:19 +00: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 22:20:36 +00:00
|
|
|
static void disable_ipr_irq(unsigned int irq)
|
|
|
|
{
|
2006-10-06 08:55:25 +00:00
|
|
|
struct ipr_data *p = get_irq_chip_data(irq);
|
2007-06-15 09:56:19 +00:00
|
|
|
unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx];
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Set the priority in IPR to 0 */
|
2008-10-01 06:19:10 +00:00
|
|
|
__raw_writew(__raw_readw(addr) & (0xffff ^ (0xf << p->shift)), addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void enable_ipr_irq(unsigned int irq)
|
|
|
|
{
|
2006-10-06 08:55:25 +00:00
|
|
|
struct ipr_data *p = get_irq_chip_data(irq);
|
2007-06-15 09:56:19 +00:00
|
|
|
unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx];
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Set priority in IPR back to original value */
|
2008-10-01 06:19:10 +00:00
|
|
|
__raw_writew(__raw_readw(addr) | (p->priority << p->shift), addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-06-15 09:56:19 +00: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 22:20:36 +00:00
|
|
|
{
|
2006-10-31 03:35:02 +00:00
|
|
|
int i;
|
2006-10-06 08:55:25 +00:00
|
|
|
|
2007-06-15 09:56:19 +00:00
|
|
|
desc->chip.mask = disable_ipr_irq;
|
|
|
|
desc->chip.unmask = enable_ipr_irq;
|
|
|
|
desc->chip.mask_ack = disable_ipr_irq;
|
2006-12-25 09:35:24 +00:00
|
|
|
|
2007-06-15 09:56:19 +00:00
|
|
|
for (i = 0; i < desc->nr_irqs; i++) {
|
|
|
|
struct ipr_data *p = desc->ipr_data + i;
|
2006-12-25 09:35:24 +00:00
|
|
|
|
2007-06-15 09:56:19 +00:00
|
|
|
BUG_ON(p->ipr_idx >= desc->nr_offsets);
|
|
|
|
BUG_ON(!desc->ipr_offsets[p->ipr_idx]);
|
2006-12-25 09:35:24 +00:00
|
|
|
|
2007-06-15 09:56:19 +00:00
|
|
|
disable_irq_nosync(p->irq);
|
|
|
|
set_irq_chip_and_handler_name(p->irq, &desc->chip,
|
2006-10-19 08:32:56 +00:00
|
|
|
handle_level_irq, "level");
|
2007-06-15 09:56:19 +00:00
|
|
|
set_irq_chip_data(p->irq, p);
|
|
|
|
disable_ipr_irq(p->irq);
|
2006-10-31 03:35:02 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-06-15 09:56:19 +00:00
|
|
|
EXPORT_SYMBOL(register_ipr_controller);
|