2019-05-27 13:55:06 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2013-01-30 01:25:22 +07:00
|
|
|
/*
|
|
|
|
* S3C24XX IRQ handling
|
2007-02-12 00:31:01 +07:00
|
|
|
*
|
2009-11-14 05:54:13 +07:00
|
|
|
* Copyright (c) 2003-2004 Simtec Electronics
|
2007-02-12 00:31:01 +07:00
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
2013-01-30 01:25:22 +07:00
|
|
|
* Copyright (c) 2012 Heiko Stuebner <heiko@sntech.de>
|
2007-02-12 00:31:01 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
2013-01-30 01:25:22 +07:00
|
|
|
#include <linux/slab.h>
|
2007-02-12 00:31:01 +07:00
|
|
|
#include <linux/module.h>
|
2013-01-30 01:25:22 +07:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/err.h>
|
2007-02-12 00:31:01 +07:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
2011-12-22 07:26:03 +07:00
|
|
|
#include <linux/device.h>
|
2013-01-30 01:25:22 +07:00
|
|
|
#include <linux/irqdomain.h>
|
2015-07-08 04:11:46 +07:00
|
|
|
#include <linux/irqchip.h>
|
2013-01-18 22:31:37 +07:00
|
|
|
#include <linux/irqchip/chained_irq.h>
|
2013-04-04 12:55:10 +07:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_irq.h>
|
|
|
|
#include <linux/of_address.h>
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:25 +07:00
|
|
|
#include <asm/exception.h>
|
2007-02-12 00:31:01 +07:00
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
#include <mach/regs-irq.h>
|
|
|
|
#include <mach/regs-gpio.h>
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2008-10-08 04:26:09 +07:00
|
|
|
#include <plat/cpu.h>
|
2013-01-30 01:25:22 +07:00
|
|
|
#include <plat/regs-irqtype.h>
|
2008-10-08 04:26:09 +07:00
|
|
|
#include <plat/pm.h>
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
#define S3C_IRQTYPE_NONE 0
|
|
|
|
#define S3C_IRQTYPE_EINT 1
|
|
|
|
#define S3C_IRQTYPE_EDGE 2
|
|
|
|
#define S3C_IRQTYPE_LEVEL 3
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
struct s3c_irq_data {
|
|
|
|
unsigned int type;
|
2013-04-04 12:53:52 +07:00
|
|
|
unsigned long offset;
|
2013-01-30 01:25:22 +07:00
|
|
|
unsigned long parent_irq;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
/* data gets filled during init */
|
|
|
|
struct s3c_irq_intc *intc;
|
|
|
|
unsigned long sub_bits;
|
|
|
|
struct s3c_irq_intc *sub_intc;
|
2007-02-12 00:31:01 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
/*
|
2018-12-03 17:44:51 +07:00
|
|
|
* Structure holding the controller data
|
2013-01-30 01:25:22 +07:00
|
|
|
* @reg_pending register holding pending irqs
|
|
|
|
* @reg_intpnd special register intpnd in main intc
|
|
|
|
* @reg_mask mask register
|
|
|
|
* @domain irq_domain of the controller
|
|
|
|
* @parent parent controller for ext and sub irqs
|
|
|
|
* @irqs irq-data, always s3c_irq_data[32]
|
|
|
|
*/
|
|
|
|
struct s3c_irq_intc {
|
|
|
|
void __iomem *reg_pending;
|
|
|
|
void __iomem *reg_intpnd;
|
|
|
|
void __iomem *reg_mask;
|
|
|
|
struct irq_domain *domain;
|
|
|
|
struct s3c_irq_intc *parent;
|
|
|
|
struct s3c_irq_data *irqs;
|
2007-02-12 00:31:01 +07:00
|
|
|
};
|
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
/*
|
|
|
|
* Array holding pointers to the global controller structs
|
|
|
|
* [0] ... main_intc
|
|
|
|
* [1] ... sub_intc
|
|
|
|
* [2] ... main_intc2 on s3c2416
|
|
|
|
*/
|
|
|
|
static struct s3c_irq_intc *s3c_intc[3];
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static void s3c_irq_mask(struct irq_data *data)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-04-04 12:53:52 +07:00
|
|
|
struct s3c_irq_data *irq_data = irq_data_get_irq_chip_data(data);
|
|
|
|
struct s3c_irq_intc *intc = irq_data->intc;
|
2013-01-30 01:25:22 +07:00
|
|
|
struct s3c_irq_intc *parent_intc = intc->parent;
|
|
|
|
struct s3c_irq_data *parent_data;
|
2007-02-12 00:31:01 +07:00
|
|
|
unsigned long mask;
|
2013-01-30 01:25:22 +07:00
|
|
|
unsigned int irqno;
|
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
mask = readl_relaxed(intc->reg_mask);
|
2013-04-04 12:53:52 +07:00
|
|
|
mask |= (1UL << irq_data->offset);
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(mask, intc->reg_mask);
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-03-07 10:38:16 +07:00
|
|
|
if (parent_intc) {
|
2013-01-30 01:25:22 +07:00
|
|
|
parent_data = &parent_intc->irqs[irq_data->parent_irq];
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-04-04 12:55:10 +07:00
|
|
|
/* check to see if we need to mask the parent IRQ
|
|
|
|
* The parent_irq is always in main_intc, so the hwirq
|
|
|
|
* for find_mapping does not need an offset in any case.
|
|
|
|
*/
|
2013-01-30 01:25:22 +07:00
|
|
|
if ((mask & parent_data->sub_bits) == parent_data->sub_bits) {
|
|
|
|
irqno = irq_find_mapping(parent_intc->domain,
|
|
|
|
irq_data->parent_irq);
|
|
|
|
s3c_irq_mask(irq_get_irq_data(irqno));
|
|
|
|
}
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static void s3c_irq_unmask(struct irq_data *data)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-04-04 12:53:52 +07:00
|
|
|
struct s3c_irq_data *irq_data = irq_data_get_irq_chip_data(data);
|
|
|
|
struct s3c_irq_intc *intc = irq_data->intc;
|
2013-01-30 01:25:22 +07:00
|
|
|
struct s3c_irq_intc *parent_intc = intc->parent;
|
2007-02-12 00:31:01 +07:00
|
|
|
unsigned long mask;
|
2013-01-30 01:25:22 +07:00
|
|
|
unsigned int irqno;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
mask = readl_relaxed(intc->reg_mask);
|
2013-04-04 12:53:52 +07:00
|
|
|
mask &= ~(1UL << irq_data->offset);
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(mask, intc->reg_mask);
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:16 +07:00
|
|
|
if (parent_intc) {
|
2013-01-30 01:25:22 +07:00
|
|
|
irqno = irq_find_mapping(parent_intc->domain,
|
|
|
|
irq_data->parent_irq);
|
|
|
|
s3c_irq_unmask(irq_get_irq_data(irqno));
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static inline void s3c_irq_ack(struct irq_data *data)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-04-04 12:53:52 +07:00
|
|
|
struct s3c_irq_data *irq_data = irq_data_get_irq_chip_data(data);
|
|
|
|
struct s3c_irq_intc *intc = irq_data->intc;
|
|
|
|
unsigned long bitval = 1UL << irq_data->offset;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(bitval, intc->reg_pending);
|
2013-01-30 01:25:22 +07:00
|
|
|
if (intc->reg_intpnd)
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(bitval, intc->reg_intpnd);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-04-04 12:53:45 +07:00
|
|
|
static int s3c_irq_type(struct irq_data *data, unsigned int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case IRQ_TYPE_NONE:
|
|
|
|
break;
|
|
|
|
case IRQ_TYPE_EDGE_RISING:
|
|
|
|
case IRQ_TYPE_EDGE_FALLING:
|
|
|
|
case IRQ_TYPE_EDGE_BOTH:
|
|
|
|
irq_set_handler(data->irq, handle_edge_irq);
|
|
|
|
break;
|
|
|
|
case IRQ_TYPE_LEVEL_LOW:
|
|
|
|
case IRQ_TYPE_LEVEL_HIGH:
|
|
|
|
irq_set_handler(data->irq, handle_level_irq);
|
|
|
|
break;
|
|
|
|
default:
|
2017-11-13 20:53:48 +07:00
|
|
|
pr_err("No such irq type %d\n", type);
|
2013-04-04 12:53:45 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static int s3c_irqext_type_set(void __iomem *gpcon_reg,
|
|
|
|
void __iomem *extint_reg,
|
|
|
|
unsigned long gpcon_offset,
|
|
|
|
unsigned long extint_offset,
|
|
|
|
unsigned int type)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
|
|
|
unsigned long newvalue = 0, value;
|
|
|
|
|
|
|
|
/* Set the GPIO to external interrupt mode */
|
2016-06-21 17:20:30 +07:00
|
|
|
value = readl_relaxed(gpcon_reg);
|
2007-02-12 00:31:01 +07:00
|
|
|
value = (value & ~(3 << gpcon_offset)) | (0x02 << gpcon_offset);
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(value, gpcon_reg);
|
2007-02-12 00:31:01 +07:00
|
|
|
|
|
|
|
/* Set the external interrupt to pointed trigger type */
|
|
|
|
switch (type)
|
|
|
|
{
|
2008-07-27 10:23:31 +07:00
|
|
|
case IRQ_TYPE_NONE:
|
2013-01-30 01:25:22 +07:00
|
|
|
pr_warn("No edge setting!\n");
|
2007-02-12 00:31:01 +07:00
|
|
|
break;
|
|
|
|
|
2008-07-27 10:23:31 +07:00
|
|
|
case IRQ_TYPE_EDGE_RISING:
|
2007-02-12 00:31:01 +07:00
|
|
|
newvalue = S3C2410_EXTINT_RISEEDGE;
|
|
|
|
break;
|
|
|
|
|
2008-07-27 10:23:31 +07:00
|
|
|
case IRQ_TYPE_EDGE_FALLING:
|
2007-02-12 00:31:01 +07:00
|
|
|
newvalue = S3C2410_EXTINT_FALLEDGE;
|
|
|
|
break;
|
|
|
|
|
2008-07-27 10:23:31 +07:00
|
|
|
case IRQ_TYPE_EDGE_BOTH:
|
2007-02-12 00:31:01 +07:00
|
|
|
newvalue = S3C2410_EXTINT_BOTHEDGE;
|
|
|
|
break;
|
|
|
|
|
2008-07-27 10:23:31 +07:00
|
|
|
case IRQ_TYPE_LEVEL_LOW:
|
2007-02-12 00:31:01 +07:00
|
|
|
newvalue = S3C2410_EXTINT_LOWLEV;
|
|
|
|
break;
|
|
|
|
|
2008-07-27 10:23:31 +07:00
|
|
|
case IRQ_TYPE_LEVEL_HIGH:
|
2007-02-12 00:31:01 +07:00
|
|
|
newvalue = S3C2410_EXTINT_HILEV;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2017-11-13 20:53:48 +07:00
|
|
|
pr_err("No such irq type %d\n", type);
|
2013-01-30 01:25:22 +07:00
|
|
|
return -EINVAL;
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
value = readl_relaxed(extint_reg);
|
2007-02-12 00:31:01 +07:00
|
|
|
value = (value & ~(7 << extint_offset)) | (newvalue << extint_offset);
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(value, extint_reg);
|
2007-02-12 00:31:01 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-13 05:23:01 +07:00
|
|
|
static int s3c_irqext_type(struct irq_data *data, unsigned int type)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-01-30 01:25:22 +07:00
|
|
|
void __iomem *extint_reg;
|
|
|
|
void __iomem *gpcon_reg;
|
|
|
|
unsigned long gpcon_offset, extint_offset;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
if ((data->hwirq >= 4) && (data->hwirq <= 7)) {
|
|
|
|
gpcon_reg = S3C2410_GPFCON;
|
|
|
|
extint_reg = S3C24XX_EXTINT0;
|
|
|
|
gpcon_offset = (data->hwirq) * 2;
|
|
|
|
extint_offset = (data->hwirq) * 4;
|
|
|
|
} else if ((data->hwirq >= 8) && (data->hwirq <= 15)) {
|
|
|
|
gpcon_reg = S3C2410_GPGCON;
|
|
|
|
extint_reg = S3C24XX_EXTINT1;
|
|
|
|
gpcon_offset = (data->hwirq - 8) * 2;
|
|
|
|
extint_offset = (data->hwirq - 8) * 4;
|
|
|
|
} else if ((data->hwirq >= 16) && (data->hwirq <= 23)) {
|
|
|
|
gpcon_reg = S3C2410_GPGCON;
|
|
|
|
extint_reg = S3C24XX_EXTINT2;
|
|
|
|
gpcon_offset = (data->hwirq - 8) * 2;
|
|
|
|
extint_offset = (data->hwirq - 16) * 4;
|
|
|
|
} else {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
return s3c_irqext_type_set(gpcon_reg, extint_reg, gpcon_offset,
|
|
|
|
extint_offset, type);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static int s3c_irqext0_type(struct irq_data *data, unsigned int type)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-01-30 01:25:22 +07:00
|
|
|
void __iomem *extint_reg;
|
|
|
|
void __iomem *gpcon_reg;
|
|
|
|
unsigned long gpcon_offset, extint_offset;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2018-08-13 22:11:44 +07:00
|
|
|
if (data->hwirq <= 3) {
|
2013-01-30 01:25:22 +07:00
|
|
|
gpcon_reg = S3C2410_GPFCON;
|
|
|
|
extint_reg = S3C24XX_EXTINT0;
|
|
|
|
gpcon_offset = (data->hwirq) * 2;
|
|
|
|
extint_offset = (data->hwirq) * 4;
|
|
|
|
} else {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
return s3c_irqext_type_set(gpcon_reg, extint_reg, gpcon_offset,
|
|
|
|
extint_offset, type);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-02-13 05:23:01 +07:00
|
|
|
static struct irq_chip s3c_irq_chip = {
|
2013-01-30 01:25:22 +07:00
|
|
|
.name = "s3c",
|
|
|
|
.irq_ack = s3c_irq_ack,
|
|
|
|
.irq_mask = s3c_irq_mask,
|
|
|
|
.irq_unmask = s3c_irq_unmask,
|
2013-04-04 12:53:45 +07:00
|
|
|
.irq_set_type = s3c_irq_type,
|
2013-01-30 01:25:22 +07:00
|
|
|
.irq_set_wake = s3c_irq_wake
|
2007-02-12 00:31:01 +07:00
|
|
|
};
|
|
|
|
|
2013-02-13 05:23:01 +07:00
|
|
|
static struct irq_chip s3c_irq_level_chip = {
|
2013-01-30 01:25:22 +07:00
|
|
|
.name = "s3c-level",
|
|
|
|
.irq_mask = s3c_irq_mask,
|
|
|
|
.irq_unmask = s3c_irq_unmask,
|
|
|
|
.irq_ack = s3c_irq_ack,
|
2013-04-04 12:53:45 +07:00
|
|
|
.irq_set_type = s3c_irq_type,
|
2007-02-12 00:31:01 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static struct irq_chip s3c_irqext_chip = {
|
|
|
|
.name = "s3c-ext",
|
|
|
|
.irq_mask = s3c_irq_mask,
|
|
|
|
.irq_unmask = s3c_irq_unmask,
|
|
|
|
.irq_ack = s3c_irq_ack,
|
|
|
|
.irq_set_type = s3c_irqext_type,
|
|
|
|
.irq_set_wake = s3c_irqext_wake
|
2007-02-12 00:31:01 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static struct irq_chip s3c_irq_eint0t4 = {
|
|
|
|
.name = "s3c-ext0",
|
|
|
|
.irq_ack = s3c_irq_ack,
|
|
|
|
.irq_mask = s3c_irq_mask,
|
|
|
|
.irq_unmask = s3c_irq_unmask,
|
|
|
|
.irq_set_wake = s3c_irq_wake,
|
|
|
|
.irq_set_type = s3c_irqext0_type,
|
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2015-09-14 15:42:37 +07:00
|
|
|
static void s3c_irq_demux(struct irq_desc *desc)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-01-30 01:25:22 +07:00
|
|
|
struct irq_chip *chip = irq_desc_get_chip(desc);
|
2013-04-04 12:53:52 +07:00
|
|
|
struct s3c_irq_data *irq_data = irq_desc_get_chip_data(desc);
|
2013-04-04 12:55:10 +07:00
|
|
|
struct s3c_irq_intc *intc = irq_data->intc;
|
2013-01-30 01:25:22 +07:00
|
|
|
struct s3c_irq_intc *sub_intc = irq_data->sub_intc;
|
2015-07-17 03:39:29 +07:00
|
|
|
unsigned int n, offset, irq;
|
|
|
|
unsigned long src, msk;
|
2013-04-04 12:55:10 +07:00
|
|
|
|
|
|
|
/* we're using individual domains for the non-dt case
|
|
|
|
* and one big domain for the dt case where the subintc
|
|
|
|
* starts at hwirq number 32.
|
|
|
|
*/
|
2015-10-13 18:51:29 +07:00
|
|
|
offset = irq_domain_get_of_node(intc->domain) ? 32 : 0;
|
2013-01-30 01:25:22 +07:00
|
|
|
|
|
|
|
chained_irq_enter(chip, desc);
|
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
src = readl_relaxed(sub_intc->reg_pending);
|
|
|
|
msk = readl_relaxed(sub_intc->reg_mask);
|
2013-01-30 01:25:22 +07:00
|
|
|
|
|
|
|
src &= ~msk;
|
|
|
|
src &= irq_data->sub_bits;
|
|
|
|
|
|
|
|
while (src) {
|
|
|
|
n = __ffs(src);
|
|
|
|
src &= ~(1 << n);
|
2013-04-04 12:55:10 +07:00
|
|
|
irq = irq_find_mapping(sub_intc->domain, offset + n);
|
|
|
|
generic_handle_irq(irq);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
chained_irq_exit(chip, desc);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-03-07 10:38:25 +07:00
|
|
|
static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
|
2013-04-04 12:55:10 +07:00
|
|
|
struct pt_regs *regs, int intc_offset)
|
2013-03-07 10:38:25 +07:00
|
|
|
{
|
|
|
|
int pnd;
|
|
|
|
int offset;
|
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
pnd = readl_relaxed(intc->reg_intpnd);
|
2013-03-07 10:38:25 +07:00
|
|
|
if (!pnd)
|
|
|
|
return false;
|
|
|
|
|
2013-04-04 12:55:10 +07:00
|
|
|
/* non-dt machines use individual domains */
|
2015-10-13 18:51:29 +07:00
|
|
|
if (!irq_domain_get_of_node(intc->domain))
|
2013-04-04 12:55:10 +07:00
|
|
|
intc_offset = 0;
|
|
|
|
|
2013-03-07 10:38:25 +07:00
|
|
|
/* We have a problem that the INTOFFSET register does not always
|
|
|
|
* show one interrupt. Occasionally we get two interrupts through
|
|
|
|
* the prioritiser, and this causes the INTOFFSET register to show
|
|
|
|
* what looks like the logical-or of the two interrupt numbers.
|
|
|
|
*
|
|
|
|
* Thanks to Klaus, Shannon, et al for helping to debug this problem
|
|
|
|
*/
|
2016-06-21 17:20:30 +07:00
|
|
|
offset = readl_relaxed(intc->reg_intpnd + 4);
|
2013-03-07 10:38:25 +07:00
|
|
|
|
|
|
|
/* Find the bit manually, when the offset is wrong.
|
|
|
|
* The pending register only ever contains the one bit of the next
|
|
|
|
* interrupt to handle.
|
|
|
|
*/
|
|
|
|
if (!(pnd & (1 << offset)))
|
|
|
|
offset = __ffs(pnd);
|
|
|
|
|
2014-08-26 17:03:26 +07:00
|
|
|
handle_domain_irq(intc->domain, intc_offset + offset, regs);
|
2013-03-07 10:38:25 +07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
do {
|
2013-04-04 12:53:49 +07:00
|
|
|
if (likely(s3c_intc[0]))
|
2013-04-04 12:55:10 +07:00
|
|
|
if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
|
2013-03-07 10:38:25 +07:00
|
|
|
continue;
|
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
if (s3c_intc[2])
|
2013-04-04 12:55:10 +07:00
|
|
|
if (s3c24xx_handle_intc(s3c_intc[2], regs, 64))
|
2013-03-07 10:38:25 +07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
break;
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2009-08-03 23:26:57 +07:00
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
/**
|
|
|
|
* s3c24xx_set_fiq - set the FIQ routing
|
|
|
|
* @irq: IRQ number to route to FIQ on processor.
|
|
|
|
* @on: Whether to route @irq to the FIQ, or to remove the FIQ routing.
|
|
|
|
*
|
|
|
|
* Change the state of the IRQ to FIQ routing depending on @irq and @on. If
|
|
|
|
* @on is true, the @irq is checked to see if it can be routed and the
|
|
|
|
* interrupt controller updated to route the IRQ. If @on is false, the FIQ
|
|
|
|
* routing is cleared, regardless of which @irq is specified.
|
|
|
|
*/
|
|
|
|
int s3c24xx_set_fiq(unsigned int irq, bool on)
|
|
|
|
{
|
|
|
|
u32 intmod;
|
|
|
|
unsigned offs;
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
offs = irq - FIQ_START;
|
|
|
|
if (offs > 31)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
intmod = 1 << offs;
|
|
|
|
} else {
|
|
|
|
intmod = 0;
|
|
|
|
}
|
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(intmod, S3C2410_INTMOD);
|
2009-08-03 23:26:57 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2009-12-07 21:51:38 +07:00
|
|
|
|
|
|
|
EXPORT_SYMBOL_GPL(s3c24xx_set_fiq);
|
2009-08-03 23:26:57 +07:00
|
|
|
#endif
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static int s3c24xx_irq_map(struct irq_domain *h, unsigned int virq,
|
|
|
|
irq_hw_number_t hw)
|
2007-02-12 00:31:01 +07:00
|
|
|
{
|
2013-01-30 01:25:22 +07:00
|
|
|
struct s3c_irq_intc *intc = h->host_data;
|
|
|
|
struct s3c_irq_data *irq_data = &intc->irqs[hw];
|
|
|
|
struct s3c_irq_intc *parent_intc;
|
|
|
|
struct s3c_irq_data *parent_irq_data;
|
|
|
|
unsigned int irqno;
|
|
|
|
|
|
|
|
/* attach controller pointer to irq_data */
|
|
|
|
irq_data->intc = intc;
|
2013-04-04 12:53:52 +07:00
|
|
|
irq_data->offset = hw;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:16 +07:00
|
|
|
parent_intc = intc->parent;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
/* set handler and flags */
|
|
|
|
switch (irq_data->type) {
|
|
|
|
case S3C_IRQTYPE_NONE:
|
|
|
|
return 0;
|
|
|
|
case S3C_IRQTYPE_EINT:
|
2013-02-13 01:12:09 +07:00
|
|
|
/* On the S3C2412, the EINT0to3 have a parent irq
|
|
|
|
* but need the s3c_irq_eint0t4 chip
|
|
|
|
*/
|
2013-03-07 10:38:16 +07:00
|
|
|
if (parent_intc && (!soc_is_s3c2412() || hw >= 4))
|
2013-01-30 01:25:22 +07:00
|
|
|
irq_set_chip_and_handler(virq, &s3c_irqext_chip,
|
|
|
|
handle_edge_irq);
|
|
|
|
else
|
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_eint0t4,
|
|
|
|
handle_edge_irq);
|
|
|
|
break;
|
|
|
|
case S3C_IRQTYPE_EDGE:
|
2013-03-07 10:38:16 +07:00
|
|
|
if (parent_intc || intc->reg_pending == S3C2416_SRCPND2)
|
2013-01-30 01:25:22 +07:00
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_level_chip,
|
|
|
|
handle_edge_irq);
|
|
|
|
else
|
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_chip,
|
|
|
|
handle_edge_irq);
|
|
|
|
break;
|
|
|
|
case S3C_IRQTYPE_LEVEL:
|
2013-03-07 10:38:16 +07:00
|
|
|
if (parent_intc)
|
2013-01-30 01:25:22 +07:00
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_level_chip,
|
|
|
|
handle_level_irq);
|
|
|
|
else
|
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_chip,
|
|
|
|
handle_level_irq);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_err("irq-s3c24xx: unsupported irqtype %d\n", irq_data->type);
|
|
|
|
return -EINVAL;
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
2013-04-04 12:53:52 +07:00
|
|
|
|
|
|
|
irq_set_chip_data(virq, irq_data);
|
|
|
|
|
2013-03-07 10:38:16 +07:00
|
|
|
if (parent_intc && irq_data->type != S3C_IRQTYPE_NONE) {
|
2013-03-07 10:38:13 +07:00
|
|
|
if (irq_data->parent_irq > 31) {
|
|
|
|
pr_err("irq-s3c24xx: parent irq %lu is out of range\n",
|
|
|
|
irq_data->parent_irq);
|
2015-08-30 06:01:22 +07:00
|
|
|
return -EINVAL;
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
|
|
|
|
parent_irq_data->sub_intc = intc;
|
|
|
|
parent_irq_data->sub_bits |= (1UL << hw);
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
/* attach the demuxer to the parent irq */
|
|
|
|
irqno = irq_find_mapping(parent_intc->domain,
|
|
|
|
irq_data->parent_irq);
|
|
|
|
if (!irqno) {
|
|
|
|
pr_err("irq-s3c24xx: could not find mapping for parent irq %lu\n",
|
|
|
|
irq_data->parent_irq);
|
2015-08-30 06:01:22 +07:00
|
|
|
return -EINVAL;
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
|
|
|
irq_set_chained_handler(irqno, s3c_irq_demux);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2015-04-27 19:54:24 +07:00
|
|
|
static const struct irq_domain_ops s3c24xx_irq_ops = {
|
2013-01-30 01:25:22 +07:00
|
|
|
.map = s3c24xx_irq_map,
|
|
|
|
.xlate = irq_domain_xlate_twocell,
|
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static void s3c24xx_clear_intc(struct s3c_irq_intc *intc)
|
|
|
|
{
|
|
|
|
void __iomem *reg_source;
|
|
|
|
unsigned long pend;
|
|
|
|
unsigned long last;
|
|
|
|
int i;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
/* if intpnd is set, read the next pending irq from there */
|
|
|
|
reg_source = intc->reg_intpnd ? intc->reg_intpnd : intc->reg_pending;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
last = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
2016-06-21 17:20:30 +07:00
|
|
|
pend = readl_relaxed(reg_source);
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
if (pend == 0 || pend == last)
|
2007-02-12 00:31:01 +07:00
|
|
|
break;
|
|
|
|
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(pend, intc->reg_pending);
|
2013-01-30 01:25:22 +07:00
|
|
|
if (intc->reg_intpnd)
|
2016-06-21 17:20:30 +07:00
|
|
|
writel_relaxed(pend, intc->reg_intpnd);
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
pr_info("irq: clearing pending status %08x\n", (int)pend);
|
|
|
|
last = pend;
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-04-25 21:49:05 +07:00
|
|
|
static struct s3c_irq_intc * __init s3c24xx_init_intc(struct device_node *np,
|
2013-01-30 01:25:22 +07:00
|
|
|
struct s3c_irq_data *irq_data,
|
|
|
|
struct s3c_irq_intc *parent,
|
|
|
|
unsigned long address)
|
|
|
|
{
|
|
|
|
struct s3c_irq_intc *intc;
|
|
|
|
void __iomem *base = (void *)0xf6000000; /* static mapping */
|
|
|
|
int irq_num;
|
|
|
|
int irq_start;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL);
|
|
|
|
if (!intc)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
intc->irqs = irq_data;
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
intc->parent = parent;
|
|
|
|
|
|
|
|
/* select the correct data for the controller.
|
|
|
|
* Need to hard code the irq num start and offset
|
|
|
|
* to preserve the static mapping for now
|
|
|
|
*/
|
|
|
|
switch (address) {
|
|
|
|
case 0x4a000000:
|
|
|
|
pr_debug("irq: found main intc\n");
|
|
|
|
intc->reg_pending = base;
|
|
|
|
intc->reg_mask = base + 0x08;
|
|
|
|
intc->reg_intpnd = base + 0x10;
|
|
|
|
irq_num = 32;
|
|
|
|
irq_start = S3C2410_IRQ(0);
|
|
|
|
break;
|
|
|
|
case 0x4a000018:
|
|
|
|
pr_debug("irq: found subintc\n");
|
|
|
|
intc->reg_pending = base + 0x18;
|
|
|
|
intc->reg_mask = base + 0x1c;
|
|
|
|
irq_num = 29;
|
|
|
|
irq_start = S3C2410_IRQSUB(0);
|
|
|
|
break;
|
|
|
|
case 0x4a000040:
|
|
|
|
pr_debug("irq: found intc2\n");
|
|
|
|
intc->reg_pending = base + 0x40;
|
|
|
|
intc->reg_mask = base + 0x48;
|
|
|
|
intc->reg_intpnd = base + 0x50;
|
|
|
|
irq_num = 8;
|
|
|
|
irq_start = S3C2416_IRQ(0);
|
|
|
|
break;
|
|
|
|
case 0x560000a4:
|
|
|
|
pr_debug("irq: found eintc\n");
|
|
|
|
base = (void *)0xfd000000;
|
|
|
|
|
|
|
|
intc->reg_mask = base + 0xa4;
|
2013-04-09 21:52:21 +07:00
|
|
|
intc->reg_pending = base + 0xa8;
|
2013-02-13 01:12:04 +07:00
|
|
|
irq_num = 24;
|
2013-01-30 01:25:22 +07:00
|
|
|
irq_start = S3C2410_IRQ(32);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_err("irq: unsupported controller address\n");
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
/* now that all the data is complete, init the irq-domain */
|
|
|
|
s3c24xx_clear_intc(intc);
|
|
|
|
intc->domain = irq_domain_add_legacy(np, irq_num, irq_start,
|
2013-02-13 01:12:04 +07:00
|
|
|
0, &s3c24xx_irq_ops,
|
2013-01-30 01:25:22 +07:00
|
|
|
intc);
|
|
|
|
if (!intc->domain) {
|
|
|
|
pr_err("irq: could not create irq-domain\n");
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:25 +07:00
|
|
|
set_handle_irq(s3c24xx_handle_irq);
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
return intc;
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
err:
|
|
|
|
kfree(intc);
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2016-01-25 22:58:08 +07:00
|
|
|
static struct s3c_irq_data __maybe_unused init_eint[32] = {
|
2013-03-07 10:38:19 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT4 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT5 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT6 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT7 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT8 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT9 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT10 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT11 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT12 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT13 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT14 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT15 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT16 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT17 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT18 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT19 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT20 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT21 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT22 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT23 */
|
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:19 +07:00
|
|
|
#ifdef CONFIG_CPU_S3C2410
|
|
|
|
static struct s3c_irq_data init_s3c2410base[32] = {
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TICK */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* WDT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* LCD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBH */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* IIC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* RTC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
|
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:19 +07:00
|
|
|
static struct s3c_irq_data init_s3c2410subint[32] = {
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
|
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-03-07 10:38:19 +07:00
|
|
|
void __init s3c2410_init_irq(void)
|
2013-01-30 01:25:22 +07:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
init_FIQ(FIQ_START);
|
|
|
|
#endif
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2410base[0], NULL,
|
|
|
|
0x4a000000);
|
|
|
|
if (IS_ERR(s3c_intc[0])) {
|
2013-01-30 01:25:22 +07:00
|
|
|
pr_err("irq: could not create main interrupt controller\n");
|
|
|
|
return;
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2410subint[0],
|
|
|
|
s3c_intc[0], 0x4a000018);
|
|
|
|
s3c24xx_init_intc(NULL, &init_eint[0], s3c_intc[0], 0x560000a4);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
2013-03-07 10:38:19 +07:00
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-02-13 01:09:13 +07:00
|
|
|
#ifdef CONFIG_CPU_S3C2412
|
2013-02-13 01:09:21 +07:00
|
|
|
static struct s3c_irq_data init_s3c2412base[32] = {
|
2013-02-13 01:12:09 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT3 */
|
2013-02-13 01:09:21 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
2013-02-13 01:09:21 +07:00
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TICK */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* WDT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* LCD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* SDI/CF */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
2013-02-13 01:09:21 +07:00
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBH */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* IIC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* RTC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
|
|
|
|
};
|
2013-02-13 01:09:13 +07:00
|
|
|
|
2013-02-13 01:12:09 +07:00
|
|
|
static struct s3c_irq_data init_s3c2412eint[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 0 }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 1 }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 2 }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 3 }, /* EINT3 */
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT4 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT5 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT6 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT7 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT8 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT9 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT10 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT11 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT12 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT13 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT14 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT15 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT16 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT17 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT18 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT19 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT20 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT21 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT22 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT23 */
|
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-02-13 01:09:21 +07:00
|
|
|
static struct s3c_irq_data init_s3c2412subint[32] = {
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
|
2013-02-13 01:09:21 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE, },
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, },
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 21 }, /* SDI */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 21 }, /* CF */
|
2013-01-30 01:25:22 +07:00
|
|
|
};
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-04-25 21:49:05 +07:00
|
|
|
void __init s3c2412_init_irq(void)
|
2013-01-30 01:25:22 +07:00
|
|
|
{
|
2013-02-13 01:09:21 +07:00
|
|
|
pr_info("S3C2412: IRQ Support\n");
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
init_FIQ(FIQ_START);
|
|
|
|
#endif
|
2007-02-12 00:31:01 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2412base[0], NULL,
|
|
|
|
0x4a000000);
|
|
|
|
if (IS_ERR(s3c_intc[0])) {
|
2013-01-30 01:25:22 +07:00
|
|
|
pr_err("irq: could not create main interrupt controller\n");
|
|
|
|
return;
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c24xx_init_intc(NULL, &init_s3c2412eint[0], s3c_intc[0], 0x560000a4);
|
|
|
|
s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2412subint[0],
|
|
|
|
s3c_intc[0], 0x4a000018);
|
2007-02-12 00:31:01 +07:00
|
|
|
}
|
2013-02-13 01:09:13 +07:00
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_CPU_S3C2416
|
2013-01-30 01:25:22 +07:00
|
|
|
static struct s3c_irq_data init_s3c2416base[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TICK */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* WDT/AC97 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* LCD */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* DMA */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART3 */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* NAND */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBH */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* IIC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE, },
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* RTC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
|
2013-01-30 01:25:22 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static struct s3c_irq_data init_s3c2416subint[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA1 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA5 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* WDT */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* AC97 */
|
2013-01-30 01:25:22 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
static struct s3c_irq_data init_s3c2416_second[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE }, /* 2D */
|
2013-04-04 12:53:41 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE }, /* PCM0 */
|
2013-04-04 12:53:41 +07:00
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
2013-01-30 01:25:22 +07:00
|
|
|
{ .type = S3C_IRQTYPE_EDGE }, /* I2S0 */
|
2013-01-30 01:25:22 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
void __init s3c2416_init_irq(void)
|
2013-01-30 01:25:22 +07:00
|
|
|
{
|
2013-01-30 01:25:22 +07:00
|
|
|
pr_info("S3C2416: IRQ Support\n");
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-01-30 01:25:22 +07:00
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
init_FIQ(FIQ_START);
|
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2416base[0], NULL,
|
|
|
|
0x4a000000);
|
|
|
|
if (IS_ERR(s3c_intc[0])) {
|
2013-01-30 01:25:22 +07:00
|
|
|
pr_err("irq: could not create main interrupt controller\n");
|
|
|
|
return;
|
|
|
|
}
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c24xx_init_intc(NULL, &init_eint[0], s3c_intc[0], 0x560000a4);
|
|
|
|
s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2416subint[0],
|
|
|
|
s3c_intc[0], 0x4a000018);
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[2] = s3c24xx_init_intc(NULL, &init_s3c2416_second[0],
|
|
|
|
NULL, 0x4a000040);
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-02-13 00:59:20 +07:00
|
|
|
#ifdef CONFIG_CPU_S3C2440
|
2013-02-13 00:59:35 +07:00
|
|
|
static struct s3c_irq_data init_s3c2440base[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* CAM */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TICK */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* WDT/AC97 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* LCD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* NFCON */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBH */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* IIC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* RTC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
|
|
|
|
};
|
2013-02-13 00:59:24 +07:00
|
|
|
|
2013-02-13 00:59:35 +07:00
|
|
|
static struct s3c_irq_data init_s3c2440subint[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
|
2013-04-04 12:53:37 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_C */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_P */
|
2013-02-13 00:59:35 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* WDT */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* AC97 */
|
2013-02-13 00:59:24 +07:00
|
|
|
};
|
|
|
|
|
2013-02-13 00:59:27 +07:00
|
|
|
void __init s3c2440_init_irq(void)
|
2013-02-13 00:59:24 +07:00
|
|
|
{
|
2013-02-13 00:59:35 +07:00
|
|
|
pr_info("S3C2440: IRQ Support\n");
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-02-13 00:59:35 +07:00
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
init_FIQ(FIQ_START);
|
|
|
|
#endif
|
2013-02-13 00:59:17 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2440base[0], NULL,
|
|
|
|
0x4a000000);
|
|
|
|
if (IS_ERR(s3c_intc[0])) {
|
2013-02-13 00:59:35 +07:00
|
|
|
pr_err("irq: could not create main interrupt controller\n");
|
|
|
|
return;
|
2013-02-13 00:59:17 +07:00
|
|
|
}
|
2013-02-13 00:59:27 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c24xx_init_intc(NULL, &init_eint[0], s3c_intc[0], 0x560000a4);
|
|
|
|
s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2440subint[0],
|
|
|
|
s3c_intc[0], 0x4a000018);
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
2013-02-13 00:59:20 +07:00
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-02-13 00:59:20 +07:00
|
|
|
#ifdef CONFIG_CPU_S3C2442
|
2013-02-13 00:59:31 +07:00
|
|
|
static struct s3c_irq_data init_s3c2442base[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* CAM */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TICK */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* WDT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* LCD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* DMA3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* NFCON */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBH */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* IIC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* RTC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
|
|
|
|
};
|
2013-02-13 00:59:17 +07:00
|
|
|
|
2013-02-13 00:59:31 +07:00
|
|
|
static struct s3c_irq_data init_s3c2442subint[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
|
2013-04-04 12:53:37 +07:00
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_C */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_P */
|
2013-02-13 00:59:31 +07:00
|
|
|
};
|
2013-02-13 00:59:17 +07:00
|
|
|
|
2013-02-13 00:59:31 +07:00
|
|
|
void __init s3c2442_init_irq(void)
|
|
|
|
{
|
|
|
|
pr_info("S3C2442: IRQ Support\n");
|
2013-02-13 00:59:17 +07:00
|
|
|
|
2013-02-13 00:59:31 +07:00
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
init_FIQ(FIQ_START);
|
|
|
|
#endif
|
2013-02-13 00:59:20 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2442base[0], NULL,
|
|
|
|
0x4a000000);
|
|
|
|
if (IS_ERR(s3c_intc[0])) {
|
2013-02-13 00:59:31 +07:00
|
|
|
pr_err("irq: could not create main interrupt controller\n");
|
|
|
|
return;
|
2013-02-13 00:59:20 +07:00
|
|
|
}
|
2013-02-13 00:59:31 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c24xx_init_intc(NULL, &init_eint[0], s3c_intc[0], 0x560000a4);
|
|
|
|
s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2442subint[0],
|
|
|
|
s3c_intc[0], 0x4a000018);
|
2013-02-13 00:59:17 +07:00
|
|
|
}
|
2013-01-30 01:25:22 +07:00
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_CPU_S3C2443
|
2013-01-30 01:25:23 +07:00
|
|
|
static struct s3c_irq_data init_s3c2443base[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* CAM */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TICK */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* WDT/AC97 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* LCD */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* DMA */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART3 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* CFON */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SDI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* NAND */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBD */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* USBH */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* IIC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, }, /* RTC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
|
2013-01-30 01:25:22 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-30 01:25:23 +07:00
|
|
|
static struct s3c_irq_data init_s3c2443subint[32] = {
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
|
|
|
|
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_C */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_P */
|
|
|
|
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD1 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA0 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA1 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA2 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA3 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA4 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA5 */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-RX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-TX */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-ERR */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* WDT */
|
|
|
|
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* AC97 */
|
2013-01-30 01:25:22 +07:00
|
|
|
};
|
|
|
|
|
2013-01-30 01:25:23 +07:00
|
|
|
void __init s3c2443_init_irq(void)
|
2013-01-30 01:25:22 +07:00
|
|
|
{
|
2013-01-30 01:25:23 +07:00
|
|
|
pr_info("S3C2443: IRQ Support\n");
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-01-30 01:25:23 +07:00
|
|
|
#ifdef CONFIG_FIQ
|
|
|
|
init_FIQ(FIQ_START);
|
|
|
|
#endif
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c_intc[0] = s3c24xx_init_intc(NULL, &init_s3c2443base[0], NULL,
|
|
|
|
0x4a000000);
|
|
|
|
if (IS_ERR(s3c_intc[0])) {
|
2013-01-30 01:25:23 +07:00
|
|
|
pr_err("irq: could not create main interrupt controller\n");
|
|
|
|
return;
|
|
|
|
}
|
2013-01-30 01:25:22 +07:00
|
|
|
|
2013-04-04 12:53:49 +07:00
|
|
|
s3c24xx_init_intc(NULL, &init_eint[0], s3c_intc[0], 0x560000a4);
|
|
|
|
s3c_intc[1] = s3c24xx_init_intc(NULL, &init_s3c2443subint[0],
|
|
|
|
s3c_intc[0], 0x4a000018);
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
|
|
|
#endif
|
2013-04-04 12:55:10 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_OF
|
|
|
|
static int s3c24xx_irq_map_of(struct irq_domain *h, unsigned int virq,
|
|
|
|
irq_hw_number_t hw)
|
|
|
|
{
|
|
|
|
unsigned int ctrl_num = hw / 32;
|
|
|
|
unsigned int intc_hw = hw % 32;
|
|
|
|
struct s3c_irq_intc *intc = s3c_intc[ctrl_num];
|
|
|
|
struct s3c_irq_intc *parent_intc = intc->parent;
|
|
|
|
struct s3c_irq_data *irq_data = &intc->irqs[intc_hw];
|
|
|
|
|
|
|
|
/* attach controller pointer to irq_data */
|
|
|
|
irq_data->intc = intc;
|
|
|
|
irq_data->offset = intc_hw;
|
|
|
|
|
|
|
|
if (!parent_intc)
|
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_chip, handle_edge_irq);
|
|
|
|
else
|
|
|
|
irq_set_chip_and_handler(virq, &s3c_irq_level_chip,
|
|
|
|
handle_edge_irq);
|
|
|
|
|
|
|
|
irq_set_chip_data(virq, irq_data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translate our of irq notation
|
|
|
|
* format: <ctrl_num ctrl_irq parent_irq type>
|
|
|
|
*/
|
|
|
|
static int s3c24xx_irq_xlate_of(struct irq_domain *d, struct device_node *n,
|
|
|
|
const u32 *intspec, unsigned int intsize,
|
|
|
|
irq_hw_number_t *out_hwirq, unsigned int *out_type)
|
|
|
|
{
|
|
|
|
struct s3c_irq_intc *intc;
|
|
|
|
struct s3c_irq_intc *parent_intc;
|
|
|
|
struct s3c_irq_data *irq_data;
|
|
|
|
struct s3c_irq_data *parent_irq_data;
|
|
|
|
int irqno;
|
|
|
|
|
|
|
|
if (WARN_ON(intsize < 4))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (intspec[0] > 2 || !s3c_intc[intspec[0]]) {
|
|
|
|
pr_err("controller number %d invalid\n", intspec[0]);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
intc = s3c_intc[intspec[0]];
|
|
|
|
|
|
|
|
*out_hwirq = intspec[0] * 32 + intspec[2];
|
|
|
|
*out_type = intspec[3] & IRQ_TYPE_SENSE_MASK;
|
|
|
|
|
|
|
|
parent_intc = intc->parent;
|
|
|
|
if (parent_intc) {
|
|
|
|
irq_data = &intc->irqs[intspec[2]];
|
|
|
|
irq_data->parent_irq = intspec[1];
|
|
|
|
parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
|
|
|
|
parent_irq_data->sub_intc = intc;
|
|
|
|
parent_irq_data->sub_bits |= (1UL << intspec[2]);
|
|
|
|
|
|
|
|
/* parent_intc is always s3c_intc[0], so no offset */
|
|
|
|
irqno = irq_create_mapping(parent_intc->domain, intspec[1]);
|
|
|
|
if (irqno < 0) {
|
|
|
|
pr_err("irq: could not map parent interrupt\n");
|
|
|
|
return irqno;
|
|
|
|
}
|
|
|
|
|
|
|
|
irq_set_chained_handler(irqno, s3c_irq_demux);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-27 19:54:24 +07:00
|
|
|
static const struct irq_domain_ops s3c24xx_irq_ops_of = {
|
2013-04-04 12:55:10 +07:00
|
|
|
.map = s3c24xx_irq_map_of,
|
|
|
|
.xlate = s3c24xx_irq_xlate_of,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct s3c24xx_irq_of_ctrl {
|
|
|
|
char *name;
|
|
|
|
unsigned long offset;
|
|
|
|
struct s3c_irq_intc **handle;
|
|
|
|
struct s3c_irq_intc **parent;
|
|
|
|
struct irq_domain_ops *ops;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init s3c_init_intc_of(struct device_node *np,
|
|
|
|
struct device_node *interrupt_parent,
|
|
|
|
struct s3c24xx_irq_of_ctrl *s3c_ctrl, int num_ctrl)
|
|
|
|
{
|
|
|
|
struct s3c_irq_intc *intc;
|
|
|
|
struct s3c24xx_irq_of_ctrl *ctrl;
|
|
|
|
struct irq_domain *domain;
|
|
|
|
void __iomem *reg_base;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
reg_base = of_iomap(np, 0);
|
|
|
|
if (!reg_base) {
|
|
|
|
pr_err("irq-s3c24xx: could not map irq registers\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
domain = irq_domain_add_linear(np, num_ctrl * 32,
|
|
|
|
&s3c24xx_irq_ops_of, NULL);
|
|
|
|
if (!domain) {
|
|
|
|
pr_err("irq: could not create irq-domain\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_ctrl; i++) {
|
|
|
|
ctrl = &s3c_ctrl[i];
|
|
|
|
|
|
|
|
pr_debug("irq: found controller %s\n", ctrl->name);
|
|
|
|
|
|
|
|
intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL);
|
|
|
|
if (!intc)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
intc->domain = domain;
|
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 04:03:40 +07:00
|
|
|
intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data),
|
2013-04-04 12:55:10 +07:00
|
|
|
GFP_KERNEL);
|
|
|
|
if (!intc->irqs) {
|
|
|
|
kfree(intc);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctrl->parent) {
|
|
|
|
intc->reg_pending = reg_base + ctrl->offset;
|
|
|
|
intc->reg_mask = reg_base + ctrl->offset + 0x4;
|
|
|
|
|
|
|
|
if (*(ctrl->parent)) {
|
|
|
|
intc->parent = *(ctrl->parent);
|
|
|
|
} else {
|
|
|
|
pr_warn("irq: parent of %s missing\n",
|
|
|
|
ctrl->name);
|
|
|
|
kfree(intc->irqs);
|
|
|
|
kfree(intc);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
intc->reg_pending = reg_base + ctrl->offset;
|
|
|
|
intc->reg_mask = reg_base + ctrl->offset + 0x08;
|
|
|
|
intc->reg_intpnd = reg_base + ctrl->offset + 0x10;
|
|
|
|
}
|
|
|
|
|
|
|
|
s3c24xx_clear_intc(intc);
|
|
|
|
s3c_intc[i] = intc;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_handle_irq(s3c24xx_handle_irq);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = {
|
|
|
|
{
|
|
|
|
.name = "intc",
|
|
|
|
.offset = 0,
|
|
|
|
}, {
|
|
|
|
.name = "subintc",
|
|
|
|
.offset = 0x18,
|
|
|
|
.parent = &s3c_intc[0],
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int __init s3c2410_init_intc_of(struct device_node *np,
|
2014-05-12 23:35:52 +07:00
|
|
|
struct device_node *interrupt_parent)
|
2013-04-04 12:55:10 +07:00
|
|
|
{
|
|
|
|
return s3c_init_intc_of(np, interrupt_parent,
|
|
|
|
s3c2410_ctrl, ARRAY_SIZE(s3c2410_ctrl));
|
|
|
|
}
|
|
|
|
IRQCHIP_DECLARE(s3c2410_irq, "samsung,s3c2410-irq", s3c2410_init_intc_of);
|
|
|
|
|
|
|
|
static struct s3c24xx_irq_of_ctrl s3c2416_ctrl[] = {
|
|
|
|
{
|
|
|
|
.name = "intc",
|
|
|
|
.offset = 0,
|
|
|
|
}, {
|
|
|
|
.name = "subintc",
|
|
|
|
.offset = 0x18,
|
|
|
|
.parent = &s3c_intc[0],
|
|
|
|
}, {
|
|
|
|
.name = "intc2",
|
|
|
|
.offset = 0x40,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int __init s3c2416_init_intc_of(struct device_node *np,
|
2014-05-12 23:35:52 +07:00
|
|
|
struct device_node *interrupt_parent)
|
2013-04-04 12:55:10 +07:00
|
|
|
{
|
|
|
|
return s3c_init_intc_of(np, interrupt_parent,
|
|
|
|
s3c2416_ctrl, ARRAY_SIZE(s3c2416_ctrl));
|
2013-01-30 01:25:22 +07:00
|
|
|
}
|
2013-04-04 12:55:10 +07:00
|
|
|
IRQCHIP_DECLARE(s3c2416_irq, "samsung,s3c2416-irq", s3c2416_init_intc_of);
|
2013-01-30 01:25:22 +07:00
|
|
|
#endif
|