Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36306
b: refs/heads/master
c: ba46393
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mundt committed Sep 27, 2006
1 parent 6923eee commit b7b045d
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5a4053b23262afefa748e1e4c439931d4c27693b
refs/heads/master: ba463937ef75bceaf3943edf01f849257c68623a
3 changes: 3 additions & 0 deletions trunk/arch/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ config CPU_HAS_INTEVT
config CPU_HAS_PINT_IRQ
bool

config CPU_HAS_MASKREG_IRQ
bool

config CPU_HAS_INTC2_IRQ
bool

Expand Down
5 changes: 3 additions & 2 deletions trunk/arch/sh/kernel/cpu/irq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
#
obj-y += ipr.o imask.o

obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o
obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o
obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o
obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o
obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o
99 changes: 99 additions & 0 deletions trunk/arch/sh/kernel/cpu/irq/maskreg.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Interrupt handling for Simple external interrupt mask register
*
* Copyright (C) 2001 A&D Co., Ltd. <http://www.aandd.co.jp>
*
* This is for the machine which have single 16 bit register
* for masking external IRQ individually.
* Each bit of the register is for masking each interrupt.
*
* This file may be copied or modified under the terms of the GNU
* General Public License. See linux/COPYING for more information.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <asm/system.h>
#include <asm/io.h>

/* address of external interrupt mask register */
unsigned long irq_mask_register;

/* forward declaration */
static unsigned int startup_maskreg_irq(unsigned int irq);
static void shutdown_maskreg_irq(unsigned int irq);
static void enable_maskreg_irq(unsigned int irq);
static void disable_maskreg_irq(unsigned int irq);
static void mask_and_ack_maskreg(unsigned int);
static void end_maskreg_irq(unsigned int irq);

/* hw_interrupt_type */
static struct hw_interrupt_type maskreg_irq_type = {
.typename = "Mask Register",
.startup = startup_maskreg_irq,
.shutdown = shutdown_maskreg_irq,
.enable = enable_maskreg_irq,
.disable = disable_maskreg_irq,
.ack = mask_and_ack_maskreg,
.end = end_maskreg_irq
};

/* actual implementatin */
static unsigned int startup_maskreg_irq(unsigned int irq)
{
enable_maskreg_irq(irq);
return 0; /* never anything pending */
}

static void shutdown_maskreg_irq(unsigned int irq)
{
disable_maskreg_irq(irq);
}

static void disable_maskreg_irq(unsigned int irq)
{
unsigned long flags;
unsigned short val, mask = 0x01 << irq;

BUG_ON(!irq_mask_register);

/* Set "irq"th bit */
local_irq_save(flags);
val = ctrl_inw(irq_mask_register);
val |= mask;
ctrl_outw(val, irq_mask_register);
local_irq_restore(flags);
}

static void enable_maskreg_irq(unsigned int irq)
{
unsigned long flags;
unsigned short val, mask = ~(0x01 << irq);

BUG_ON(!irq_mask_register);

/* Clear "irq"th bit */
local_irq_save(flags);
val = ctrl_inw(irq_mask_register);
val &= mask;
ctrl_outw(val, irq_mask_register);
local_irq_restore(flags);
}

static void mask_and_ack_maskreg(unsigned int irq)
{
disable_maskreg_irq(irq);
}

static void end_maskreg_irq(unsigned int irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
enable_maskreg_irq(irq);
}

void make_maskreg_irq(unsigned int irq)
{
disable_irq_nosync(irq);
irq_desc[irq].handler = &maskreg_irq_type;
disable_maskreg_irq(irq);
}

0 comments on commit b7b045d

Please sign in to comment.