From: Masahiro A. <m-...@aa...> - 2001-07-18 11:09:45
|
I'm sending a series of patches needed to support our custom board, called ADX. First two of three are similar to what I've posted before. Those may be used not only for ADX but some other boards. The last one is ADX only patches. I'm going to send them in separate emails. They should be able to be applied to current CVS kernel, consecutively. Niibe-san, could you please consider applying those to CVS? Here is the first one - Simple Mask Register Support. ----- diff -ruN linux-cvs0718/ChangeLog linux-cvs0718-mr/ChangeLog --- linux-cvs0718/ChangeLog Wed Jul 18 18:41:59 2001 +++ linux-cvs0718-mr/ChangeLog Wed Jul 18 18:48:28 2001 @@ -1,3 +1,9 @@ +2001-07-18 Masahiro ABE <m-...@aa...> + + * arch/sh/kernel/irq_maskreg.c : Add support for simple word-size + IRQ mask register. + * include/asm-sh/irq.h : Likewise. + 2001-07-18 NIIBE Yutaka <gn...@m1...> * arch/sh/mm/fault.c (__do_page_fault): Use pte_not_present. diff -ruN linux-cvs0718/arch/sh/kernel/irq_maskreg.c linux-cvs0718-mr/arch/sh/kernel/irq_maskreg.c --- linux-cvs0718/arch/sh/kernel/irq_maskreg.c Thu Jan 1 09:00:00 1970 +++ linux-cvs0718-mr/arch/sh/kernel/irq_maskreg.c Wed Jul 18 18:44:55 2001 @@ -0,0 +1,107 @@ +/* + * linux/arch/sh/kernel/irq_maskreg.c + * + * Copyright (C) 2001 A&D Co., Ltd. <http://www.aandd.co.jp> + * + * May be copied or modified under the terms of the GNU General Public + * License. See linux/COPYING for more information. + * + * Interrupt handling for Simple external interrupt mask register + * + * 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. + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/irq.h> + +#include <asm/system.h> +#include <asm/io.h> +#include <asm/machvec.h> + +/* address of external interrupt mask register + * address must be set prior to use these (maybe in init_XXX_irq()) + * XXX : is it better to use .config than specifying it in code? */ +unsigned short *irq_mask_register = 0; + +/* 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 = { + " Mask Register", + startup_maskreg_irq, + shutdown_maskreg_irq, + enable_maskreg_irq, + disable_maskreg_irq, + mask_and_ack_maskreg, + 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) +{ + if (irq_mask_register) { + unsigned long flags; + unsigned short val, mask = 0x01 << irq; + + /* Set "irq"th bit */ + save_and_cli(flags); + val = ctrl_inw((unsigned long)irq_mask_register); + val |= mask; + ctrl_outw(val, (unsigned long)irq_mask_register); + restore_flags(flags); + } +} + +static void enable_maskreg_irq(unsigned int irq) +{ + if (irq_mask_register) { + unsigned long flags; + unsigned short val, mask = ~(0x01 << irq); + + /* Clear "irq"th bit */ + save_and_cli(flags); + val = ctrl_inw((unsigned long)irq_mask_register); + val &= mask; + ctrl_outw(val, (unsigned long)irq_mask_register); + restore_flags(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); +} diff -ruN linux-cvs0718/include/asm-sh/irq.h linux-cvs0718-mr/include/asm-sh/irq.h --- linux-cvs0718/include/asm-sh/irq.h Wed Jul 18 18:39:45 2001 +++ linux-cvs0718-mr/include/asm-sh/irq.h Wed Jul 18 18:44:55 2001 @@ -170,6 +170,12 @@ extern void enable_irq(unsigned int); /* + * Simple Mask Register Support + */ +extern void make_maskreg_irq(unsigned int irq); +extern unsigned short *irq_mask_register; + +/* * Function for "on chip support modules". */ extern void make_ipr_irq(unsigned int irq, unsigned int addr, ----- ================================= Masahiro ABE, A&D Co., Ltd. Japan |