Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8599cf05 authored by Paul Mundt's avatar Paul Mundt
Browse files

sh: Cleanup IRQ disabling for hardirq handlers.



The generic hardirq layer already takes care of a lot of the
appropriate locking and disabling for us, no need to duplicate
it in the handlers..

Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent ba463937
Loading
Loading
Loading
Loading
+17 −30
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
 * IRQ functions for a Hitachi Big Sur Evaluation Board.
 * IRQ functions for a Hitachi Big Sur Evaluation Board.
 *
 *
 */
 */
#undef DEBUG


#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/module.h>
@@ -41,10 +42,8 @@
#undef BIGSUR_DEBUG
#undef BIGSUR_DEBUG


#ifdef BIGSUR_DEBUG
#ifdef BIGSUR_DEBUG
#define DPRINTK(args...)        printk(args)
#define DIPRINTK(n, args...)    if (BIGSUR_DEBUG>(n)) printk(args)
#define DIPRINTK(n, args...)    if (BIGSUR_DEBUG>(n)) printk(args)
#else
#else
#define DPRINTK(args...)
#define DIPRINTK(n, args...)
#define DIPRINTK(n, args...)
#endif /* BIGSUR_DEBUG */
#endif /* BIGSUR_DEBUG */


@@ -60,45 +59,39 @@ extern int hd64465_irq_demux(int irq);
/* Level 1 IRQ routines */
/* Level 1 IRQ routines */
static void disable_bigsur_l1irq(unsigned int irq)
static void disable_bigsur_l1irq(unsigned int irq)
{
{
        unsigned long flags;
        unsigned char mask;
        unsigned char mask;
        unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
        unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
        unsigned char bit =  (1 << ((irq - MGATE_IRQ_LOW)%8) );
        unsigned char bit =  (1 << ((irq - MGATE_IRQ_LOW)%8) );


        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
                DPRINTK("Disable L1 IRQ %d\n", irq);
                pr_debug("Disable L1 IRQ %d\n", irq);
                DIPRINTK(2,"disable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
                DIPRINTK(2,"disable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
                        mask_port, bit);
                        mask_port, bit);
                local_irq_save(flags);


                /* Disable IRQ - set mask bit */
                /* Disable IRQ - set mask bit */
                mask = inb(mask_port) | bit;
                mask = inb(mask_port) | bit;
                outb(mask, mask_port);
                outb(mask, mask_port);
                local_irq_restore(flags);
                return;
                return;
        }
        }
        DPRINTK("disable_bigsur_l1irq: Invalid IRQ %d\n", irq);
        pr_debug("disable_bigsur_l1irq: Invalid IRQ %d\n", irq);
}
}


static void enable_bigsur_l1irq(unsigned int irq)
static void enable_bigsur_l1irq(unsigned int irq)
{
{
        unsigned long flags;
        unsigned char mask;
        unsigned char mask;
        unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
        unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
        unsigned char bit =  (1 << ((irq - MGATE_IRQ_LOW)%8) );
        unsigned char bit =  (1 << ((irq - MGATE_IRQ_LOW)%8) );


        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
                DPRINTK("Enable L1 IRQ %d\n", irq);
                pr_debug("Enable L1 IRQ %d\n", irq);
                DIPRINTK(2,"enable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
                DIPRINTK(2,"enable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
                        mask_port, bit);
                        mask_port, bit);
                local_irq_save(flags);
                /* Enable L1 IRQ - clear mask bit */
                /* Enable L1 IRQ - clear mask bit */
                mask = inb(mask_port) & ~bit;
                mask = inb(mask_port) & ~bit;
                outb(mask, mask_port);
                outb(mask, mask_port);
                local_irq_restore(flags);
                return;
                return;
        }
        }
        DPRINTK("enable_bigsur_l1irq: Invalid IRQ %d\n", irq);
        pr_debug("enable_bigsur_l1irq: Invalid IRQ %d\n", irq);
}
}




@@ -126,51 +119,45 @@ static const u32 imr_offset = BIGSUR_IMR0 - BIGSUR_IMR1;
/* Level 2 IRQ routines */
/* Level 2 IRQ routines */
static void disable_bigsur_l2irq(unsigned int irq)
static void disable_bigsur_l2irq(unsigned int irq)
{
{
        unsigned long flags;
        unsigned char mask;
        unsigned char mask;
        unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
        unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
        unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;
        unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;


	if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
	if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
                DPRINTK("Disable L2 IRQ %d\n", irq);
                pr_debug("Disable L2 IRQ %d\n", irq);
                DIPRINTK(2,"disable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
                DIPRINTK(2,"disable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
                        mask_port, bit);
                        mask_port, bit);
                local_irq_save(flags);


                /* Disable L2 IRQ - set mask bit */
                /* Disable L2 IRQ - set mask bit */
                mask = inb(mask_port) | bit;
                mask = inb(mask_port) | bit;
                outb(mask, mask_port);
                outb(mask, mask_port);
                local_irq_restore(flags);
                return;
                return;
        }
        }
        DPRINTK("disable_bigsur_l2irq: Invalid IRQ %d\n", irq);
        pr_debug("disable_bigsur_l2irq: Invalid IRQ %d\n", irq);
}
}


static void enable_bigsur_l2irq(unsigned int irq)
static void enable_bigsur_l2irq(unsigned int irq)
{
{
        unsigned long flags;
        unsigned char mask;
        unsigned char mask;
        unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
        unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
        unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;
        unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;


	if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
	if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
                DPRINTK("Enable L2 IRQ %d\n", irq);
                pr_debug("Enable L2 IRQ %d\n", irq);
                DIPRINTK(2,"enable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
                DIPRINTK(2,"enable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
                        mask_port, bit);
                        mask_port, bit);
                local_irq_save(flags);


                /* Enable L2 IRQ - clear mask bit */
                /* Enable L2 IRQ - clear mask bit */
                mask = inb(mask_port) & ~bit;
                mask = inb(mask_port) & ~bit;
                outb(mask, mask_port);
                outb(mask, mask_port);
                local_irq_restore(flags);
                return;
                return;
        }
        }
        DPRINTK("enable_bigsur_l2irq: Invalid IRQ %d\n", irq);
        pr_debug("enable_bigsur_l2irq: Invalid IRQ %d\n", irq);
}
}


static void mask_and_ack_bigsur(unsigned int irq)
static void mask_and_ack_bigsur(unsigned int irq)
{
{
        DPRINTK("mask_and_ack_bigsur IRQ %d\n", irq);
        pr_debug("mask_and_ack_bigsur IRQ %d\n", irq);
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
                disable_bigsur_l1irq(irq);
                disable_bigsur_l1irq(irq);
        else
        else
@@ -179,7 +166,7 @@ static void mask_and_ack_bigsur(unsigned int irq)


static void end_bigsur_irq(unsigned int irq)
static void end_bigsur_irq(unsigned int irq)
{
{
        DPRINTK("end_bigsur_irq IRQ %d\n", irq);
        pr_debug("end_bigsur_irq IRQ %d\n", irq);
        if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
        if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
                if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
                if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
                        enable_bigsur_l1irq(irq);
                        enable_bigsur_l1irq(irq);
@@ -193,7 +180,7 @@ static unsigned int startup_bigsur_irq(unsigned int irq)
        u8 mask;
        u8 mask;
        u32 reg;
        u32 reg;


        DPRINTK("startup_bigsur_irq IRQ %d\n", irq);
        pr_debug("startup_bigsur_irq IRQ %d\n", irq);


        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
                /* Enable the L1 IRQ */
                /* Enable the L1 IRQ */
@@ -218,7 +205,7 @@ static unsigned int startup_bigsur_irq(unsigned int irq)


static void shutdown_bigsur_irq(unsigned int irq)
static void shutdown_bigsur_irq(unsigned int irq)
{
{
        DPRINTK("shutdown_bigsur_irq IRQ %d\n", irq);
        pr_debug("shutdown_bigsur_irq IRQ %d\n", irq);
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
        if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
                disable_bigsur_l1irq(irq);
                disable_bigsur_l1irq(irq);
        else
        else
@@ -260,7 +247,7 @@ static void make_bigsur_l1isr(unsigned int irq) {
                disable_bigsur_l1irq(irq);
                disable_bigsur_l1irq(irq);
                return;
                return;
        }
        }
        DPRINTK("make_bigsur_l1isr: bad irq, %d\n", irq);
        pr_debug("make_bigsur_l1isr: bad irq, %d\n", irq);
        return;
        return;
}
}


@@ -277,7 +264,7 @@ static void make_bigsur_l2isr(unsigned int irq) {
                disable_bigsur_l2irq(irq);
                disable_bigsur_l2irq(irq);
                return;
                return;
        }
        }
        DPRINTK("make_bigsur_l2isr: bad irq, %d\n", irq);
        pr_debug("make_bigsur_l2isr: bad irq, %d\n", irq);
        return;
        return;
}
}


+0 −7
Original line number Original line Diff line number Diff line
@@ -10,7 +10,6 @@
 */
 */


#include <linux/irq.h>
#include <linux/irq.h>

#include <asm/io.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/irq.h>
#include <asm/dreamcast/sysasic.h>
#include <asm/dreamcast/sysasic.h>
@@ -57,29 +56,23 @@
/* Disable the hardware event by masking its bit in its EMR */
/* Disable the hardware event by masking its bit in its EMR */
static inline void disable_systemasic_irq(unsigned int irq)
static inline void disable_systemasic_irq(unsigned int irq)
{
{
        unsigned long flags;
        __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
        __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
        __u32 mask;
        __u32 mask;


        local_irq_save(flags);
        mask = inl(emr);
        mask = inl(emr);
        mask &= ~(1 << EVENT_BIT(irq));
        mask &= ~(1 << EVENT_BIT(irq));
        outl(mask, emr);
        outl(mask, emr);
        local_irq_restore(flags);
}
}


/* Enable the hardware event by setting its bit in its EMR */
/* Enable the hardware event by setting its bit in its EMR */
static inline void enable_systemasic_irq(unsigned int irq)
static inline void enable_systemasic_irq(unsigned int irq)
{
{
        unsigned long flags;
        __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
        __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
        __u32 mask;
        __u32 mask;


        local_irq_save(flags);
        mask = inl(emr);
        mask = inl(emr);
        mask |= (1 << EVENT_BIT(irq));
        mask |= (1 << EVENT_BIT(irq));
        outl(mask, emr);
        outl(mask, emr);
        local_irq_restore(flags);
}
}


/* Acknowledge a hardware event by writing its bit back to its ESR */
/* Acknowledge a hardware event by writing its bit back to its ESR */
+0 −6
Original line number Original line Diff line number Diff line
@@ -39,30 +39,24 @@ static unsigned int startup_landisk_irq(unsigned int irq)


static void disable_landisk_irq(unsigned int irq)
static void disable_landisk_irq(unsigned int irq)
{
{
	unsigned long flags;
	unsigned char val;
	unsigned char val;
	unsigned char mask = 0xff ^ (0x01 << (irq - 5));
	unsigned char mask = 0xff ^ (0x01 << (irq - 5));


	/* Set the priority in IPR to 0 */
	/* Set the priority in IPR to 0 */
	local_irq_save(flags);
	val = ctrl_inb(PA_IMASK);
	val = ctrl_inb(PA_IMASK);
	val &= mask;
	val &= mask;
	ctrl_outb(val, PA_IMASK);
	ctrl_outb(val, PA_IMASK);
	local_irq_restore(flags);
}
}


static void enable_landisk_irq(unsigned int irq)
static void enable_landisk_irq(unsigned int irq)
{
{
	unsigned long flags;
	unsigned char val;
	unsigned char val;
	unsigned char value = (0x01 << (irq - 5));
	unsigned char value = (0x01 << (irq - 5));


	/* Set priority in IPR back to original value */
	/* Set priority in IPR back to original value */
	local_irq_save(flags);
	val = ctrl_inb(PA_IMASK);
	val = ctrl_inb(PA_IMASK);
	val |= value;
	val |= value;
	ctrl_outb(val, PA_IMASK);
	ctrl_outb(val, PA_IMASK);
	local_irq_restore(flags);
}
}


static void ack_landisk_irq(unsigned int irq)
static void ack_landisk_irq(unsigned int irq)
+0 −14
Original line number Original line Diff line number Diff line
@@ -80,9 +80,6 @@ volatile unsigned long irq_err_count;


static void disable_mpc1211_irq(unsigned int irq)
static void disable_mpc1211_irq(unsigned int irq)
{
{
	unsigned long flags;

	save_and_cli(flags);
	if( irq < 8) {
	if( irq < 8) {
		m_irq_mask |= (1 << irq);
		m_irq_mask |= (1 << irq);
		outb(m_irq_mask,I8259_M_MR);
		outb(m_irq_mask,I8259_M_MR);
@@ -90,16 +87,11 @@ static void disable_mpc1211_irq(unsigned int irq)
		s_irq_mask |= (1 << (irq - 8));
		s_irq_mask |= (1 << (irq - 8));
		outb(s_irq_mask,I8259_S_MR);
		outb(s_irq_mask,I8259_S_MR);
	}
	}
	restore_flags(flags);


}
}


static void enable_mpc1211_irq(unsigned int irq)
static void enable_mpc1211_irq(unsigned int irq)
{
{
	unsigned long flags;

	save_and_cli(flags);

	if( irq < 8) {
	if( irq < 8) {
		m_irq_mask &= ~(1 << irq);
		m_irq_mask &= ~(1 << irq);
		outb(m_irq_mask,I8259_M_MR);
		outb(m_irq_mask,I8259_M_MR);
@@ -107,7 +99,6 @@ static void enable_mpc1211_irq(unsigned int irq)
		s_irq_mask &= ~(1 << (irq - 8));
		s_irq_mask &= ~(1 << (irq - 8));
		outb(s_irq_mask,I8259_S_MR);
		outb(s_irq_mask,I8259_S_MR);
	}
	}
	restore_flags(flags);
}
}


static inline int mpc1211_irq_real(unsigned int irq)
static inline int mpc1211_irq_real(unsigned int irq)
@@ -131,10 +122,6 @@ static inline int mpc1211_irq_real(unsigned int irq)


static void mask_and_ack_mpc1211(unsigned int irq)
static void mask_and_ack_mpc1211(unsigned int irq)
{
{
	unsigned long flags;

	save_and_cli(flags);

	if(irq < 8) {
	if(irq < 8) {
		if(m_irq_mask & (1<<irq)){
		if(m_irq_mask & (1<<irq)){
		  if(!mpc1211_irq_real(irq)){
		  if(!mpc1211_irq_real(irq)){
@@ -162,7 +149,6 @@ static void mask_and_ack_mpc1211(unsigned int irq)
		outb(0x60+(irq-8),I8259_S_CR); 	/* EOI */
		outb(0x60+(irq-8),I8259_S_CR); 	/* EOI */
		outb(0x60+2,I8259_M_CR);
		outb(0x60+2,I8259_M_CR);
	}
	}
	restore_flags(flags);
}
}


static void end_mpc1211_irq(unsigned int irq)
static void end_mpc1211_irq(unsigned int irq)
+0 −6
Original line number Original line Diff line number Diff line
@@ -35,30 +35,24 @@ static unsigned int startup_hs7751rvoip_irq(unsigned int irq)


static void disable_hs7751rvoip_irq(unsigned int irq)
static void disable_hs7751rvoip_irq(unsigned int irq)
{
{
	unsigned long flags;
	unsigned short val;
	unsigned short val;
	unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
	unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);


	/* Set the priority in IPR to 0 */
	/* Set the priority in IPR to 0 */
	local_irq_save(flags);
	val = ctrl_inw(IRLCNTR3);
	val = ctrl_inw(IRLCNTR3);
	val &= mask;
	val &= mask;
	ctrl_outw(val, IRLCNTR3);
	ctrl_outw(val, IRLCNTR3);
	local_irq_restore(flags);
}
}


static void enable_hs7751rvoip_irq(unsigned int irq)
static void enable_hs7751rvoip_irq(unsigned int irq)
{
{
	unsigned long flags;
	unsigned short val;
	unsigned short val;
	unsigned short value = (0x0001 << mask_pos[irq]);
	unsigned short value = (0x0001 << mask_pos[irq]);


	/* Set priority in IPR back to original value */
	/* Set priority in IPR back to original value */
	local_irq_save(flags);
	val = ctrl_inw(IRLCNTR3);
	val = ctrl_inw(IRLCNTR3);
	val |= value;
	val |= value;
	ctrl_outw(val, IRLCNTR3);
	ctrl_outw(val, IRLCNTR3);
	local_irq_restore(flags);
}
}


static void ack_hs7751rvoip_irq(unsigned int irq)
static void ack_hs7751rvoip_irq(unsigned int irq)
Loading