android_kernel_xiaomi_sm8350/arch/ppc/syslib/cpc700_pic.c
Ingo Molnar d1bef4ed5f [PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.

While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.

The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.

This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.

As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.

The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.

We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.

This patch:

rename desc->handler to desc->chip.

Originally i did not want to do this, because it's a big patch.  But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.

I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.

So lets get over with this quickly.  The conversion was done automatically
via scripts and converts all the code in the kernel.

This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.

[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 10:26:21 -07:00

182 lines
3.9 KiB
C

/*
* Interrupt controller support for IBM Spruce
*
* Authors: Mark Greer, Matt Porter, and Johnnie Peters
* mgreer@mvista.com
* mporter@mvista.com
* jpeters@mvista.com
*
* 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#include <linux/stddef.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/irq.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/irq.h>
#include "cpc700.h"
static void
cpc700_unmask_irq(unsigned int irq)
{
unsigned int tr_bits;
/*
* IRQ 31 is largest IRQ supported.
* IRQs 17-19 are reserved.
*/
if ((irq <= 31) && ((irq < 17) || (irq > 19))) {
tr_bits = CPC700_IN_32(CPC700_UIC_UICTR);
if ((tr_bits & (1 << (31 - irq))) == 0) {
/* level trigger interrupt, clear bit in status
* register */
CPC700_OUT_32(CPC700_UIC_UICSR, 1 << (31 - irq));
}
/* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
ppc_cached_irq_mask[0] |= CPC700_UIC_IRQ_BIT(irq);
CPC700_OUT_32(CPC700_UIC_UICER, ppc_cached_irq_mask[0]);
}
return;
}
static void
cpc700_mask_irq(unsigned int irq)
{
/*
* IRQ 31 is largest IRQ supported.
* IRQs 17-19 are reserved.
*/
if ((irq <= 31) && ((irq < 17) || (irq > 19))) {
/* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
ppc_cached_irq_mask[0] &=
~CPC700_UIC_IRQ_BIT(irq);
CPC700_OUT_32(CPC700_UIC_UICER, ppc_cached_irq_mask[0]);
}
return;
}
static void
cpc700_mask_and_ack_irq(unsigned int irq)
{
u_int bit;
/*
* IRQ 31 is largest IRQ supported.
* IRQs 17-19 are reserved.
*/
if ((irq <= 31) && ((irq < 17) || (irq > 19))) {
/* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
bit = CPC700_UIC_IRQ_BIT(irq);
ppc_cached_irq_mask[0] &= ~bit;
CPC700_OUT_32(CPC700_UIC_UICER, ppc_cached_irq_mask[0]);
CPC700_OUT_32(CPC700_UIC_UICSR, bit); /* Write 1 clears IRQ */
}
return;
}
static struct hw_interrupt_type cpc700_pic = {
.typename = "CPC700 PIC",
.enable = cpc700_unmask_irq,
.disable = cpc700_mask_irq,
.ack = cpc700_mask_and_ack_irq,
};
__init static void
cpc700_pic_init_irq(unsigned int irq)
{
unsigned int tmp;
/* Set interrupt sense */
tmp = CPC700_IN_32(CPC700_UIC_UICTR);
if (cpc700_irq_assigns[irq][0] == 0) {
tmp &= ~CPC700_UIC_IRQ_BIT(irq);
} else {
tmp |= CPC700_UIC_IRQ_BIT(irq);
}
CPC700_OUT_32(CPC700_UIC_UICTR, tmp);
/* Set interrupt polarity */
tmp = CPC700_IN_32(CPC700_UIC_UICPR);
if (cpc700_irq_assigns[irq][1]) {
tmp |= CPC700_UIC_IRQ_BIT(irq);
} else {
tmp &= ~CPC700_UIC_IRQ_BIT(irq);
}
CPC700_OUT_32(CPC700_UIC_UICPR, tmp);
/* Set interrupt critical */
tmp = CPC700_IN_32(CPC700_UIC_UICCR);
tmp |= CPC700_UIC_IRQ_BIT(irq);
CPC700_OUT_32(CPC700_UIC_UICCR, tmp);
return;
}
__init void
cpc700_init_IRQ(void)
{
int i;
ppc_cached_irq_mask[0] = 0;
CPC700_OUT_32(CPC700_UIC_UICER, 0x00000000); /* Disable all irq's */
CPC700_OUT_32(CPC700_UIC_UICSR, 0xffffffff); /* Clear cur intrs */
CPC700_OUT_32(CPC700_UIC_UICCR, 0xffffffff); /* Gen INT not MCP */
CPC700_OUT_32(CPC700_UIC_UICPR, 0x00000000); /* Active low */
CPC700_OUT_32(CPC700_UIC_UICTR, 0x00000000); /* Level Sensitive */
CPC700_OUT_32(CPC700_UIC_UICVR, CPC700_UIC_UICVCR_0_HI);
/* IRQ 0 is highest */
for (i = 0; i < 17; i++) {
irq_desc[i].chip = &cpc700_pic;
cpc700_pic_init_irq(i);
}
for (i = 20; i < 32; i++) {
irq_desc[i].chip = &cpc700_pic;
cpc700_pic_init_irq(i);
}
return;
}
/*
* Find the highest IRQ that generating an interrupt, if any.
*/
int
cpc700_get_irq(struct pt_regs *regs)
{
int irq = 0;
u_int irq_status, irq_test = 1;
irq_status = CPC700_IN_32(CPC700_UIC_UICMSR);
do
{
if (irq_status & irq_test)
break;
irq++;
irq_test <<= 1;
} while (irq < NR_IRQS);
if (irq == NR_IRQS)
irq = 33;
return (31 - irq);
}