Files
OrangePi_CM5/arch/sh/kernel/cpu/irq/ipr.c
T

73 lines
2.2 KiB
C
Raw Normal View History

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