2006-01-17 06:14:14 +00:00
|
|
|
/*
|
|
|
|
* arch/sh/kernel/cpu/irq/imask.c
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1999, 2000 Niibe Yutaka
|
|
|
|
*
|
|
|
|
* Simple interrupt handling using IMASK of SR register.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* NOTE: Will not work on level 15 */
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/cache.h>
|
|
|
|
#include <linux/irq.h>
|
2009-05-21 16:16:17 +00:00
|
|
|
#include <linux/bitmap.h>
|
2006-01-17 06:14:14 +00:00
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/irq.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Bitmap of IRQ masked */
|
|
|
|
#define IMASK_PRIORITY 15
|
|
|
|
|
2009-05-21 16:16:17 +00:00
|
|
|
static DECLARE_BITMAP(imask_mask, IMASK_PRIORITY);
|
|
|
|
static int interrupt_priority;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-05-21 16:16:17 +00:00
|
|
|
static inline void set_interrupt_registers(int ip)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long __dummy;
|
|
|
|
|
2006-11-05 06:40:13 +00:00
|
|
|
asm volatile(
|
|
|
|
#ifdef CONFIG_CPU_HAS_SR_RB
|
|
|
|
"ldc %2, r6_bank\n\t"
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
"stc sr, %0\n\t"
|
|
|
|
"and #0xf0, %0\n\t"
|
|
|
|
"shlr2 %0\n\t"
|
|
|
|
"cmp/eq #0x3c, %0\n\t"
|
|
|
|
"bt/s 1f ! CLI-ed\n\t"
|
|
|
|
" stc sr, %0\n\t"
|
|
|
|
"and %1, %0\n\t"
|
|
|
|
"or %2, %0\n\t"
|
|
|
|
"ldc %0, sr\n"
|
|
|
|
"1:"
|
|
|
|
: "=&z" (__dummy)
|
|
|
|
: "r" (~0xf0), "r" (ip << 4)
|
|
|
|
: "t");
|
|
|
|
}
|
|
|
|
|
2009-05-21 16:16:17 +00:00
|
|
|
static void mask_imask_irq(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-05-26 04:52:28 +00:00
|
|
|
clear_bit(irq, imask_mask);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (interrupt_priority < IMASK_PRIORITY - irq)
|
|
|
|
interrupt_priority = IMASK_PRIORITY - irq;
|
|
|
|
set_interrupt_registers(interrupt_priority);
|
|
|
|
}
|
|
|
|
|
2009-05-21 16:16:17 +00:00
|
|
|
static void unmask_imask_irq(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-05-26 04:52:28 +00:00
|
|
|
set_bit(irq, imask_mask);
|
2009-05-21 16:16:17 +00:00
|
|
|
interrupt_priority = IMASK_PRIORITY -
|
|
|
|
find_first_zero_bit(imask_mask, IMASK_PRIORITY);
|
2005-04-16 22:20:36 +00:00
|
|
|
set_interrupt_registers(interrupt_priority);
|
|
|
|
}
|
|
|
|
|
2009-05-21 16:16:17 +00:00
|
|
|
static struct irq_chip imask_irq_chip = {
|
|
|
|
.typename = "SR.IMASK",
|
|
|
|
.mask = mask_imask_irq,
|
|
|
|
.unmask = unmask_imask_irq,
|
|
|
|
.mask_ack = mask_imask_irq,
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
void make_imask_irq(unsigned int irq)
|
|
|
|
{
|
2009-05-21 16:16:17 +00:00
|
|
|
set_irq_chip_and_handler_name(irq, &imask_irq_chip,
|
|
|
|
handle_level_irq, "level");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|