mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-12 06:46:51 +07:00
Update for Renesas INTC External IRQ pin driver for v3.10
This adds support for shared interrupt lines to the Renesas INTC External IRQ pin driver which has already been queued up for v3.10 (tag renesas-intc-external-irq-for-v3.10). -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAABAgAGBQJRVTadAAoJENfPZGlqN0++mlQP/2tH/AimAHzPdYBpJWHneglu da5dpoqKNHtrPzrJMMJQ5VT5lupjpnX1XhNpbs5Y/GG5lA0PMJtWgQknroxEoIp+ jxYHyzMRYvJitghvwbODQzbVCbcdtLVZFHVDKaBonImEX98Kun6k/61g7L74Xdnq AyAIDKFso6sSjfnkJuKljhKQbK9n0L0Bl1L5WUQeWaKt2lF6rHsAGHqXrRvcvSN9 /V9HPCIQD+4+Efe7VYa/cz8BDsphVp1LQY4AJ9F+fjhELu6izJ7Y//MpXZSxD6/q dL/T0+fXuCrW8kwylKMyJOFAo6kMWhpOhBmHg9dvBvD5UVKvkJU1tQqpTSiT1hqm PPgmpoVCLE1p5d4rml1U4C//tj56IxDPVbr2ld3DnqykSMFqlbin64JBcl5/2tkp SRQA37Qu7oypnNYVqMrCK6KWbhJNGrrsomJqukiJda6PO+8pb6hR3az9cTk4n4+D H6Gbvb6Qf3jj0TLOjwsZ5q4yAB2xQ1sImP3QHKxi7aj0/1jvNwut4Qw2ucxKnujq EHK2rwXNzEZJ3pkcc/5hnLoPI4nCirBXMkkb0ZgrjeaPUSIISjcqOZDPyRFU1JJQ qLAYlq9fUJd6ZgMIV2G83/3cMqAaiVT+G/zIvM+BXMb0ExmW/OUYoR2D2txNBdzs CcdH0m+50ipkNLqndiin =nYUV -----END PGP SIGNATURE----- Merge tag 'renesas-intc-external-irq2-for-v3.10' into soc-base Update for Renesas INTC External IRQ pin driver for v3.10 This adds support for shared interrupt lines to the Renesas INTC External IRQ pin driver which has already been queued up for v3.10 (tag renesas-intc-external-irq-for-v3.10). The patch "irqchip: intc-irqpin: Add support for shared interrupt lines" in renesas-intc-external-irq2-for-v3.10 is a dependency for "ARM: shmobile: r8a7740: Migrate from INTC to GIC". That dependency is the reason for this merge.
This commit is contained in:
commit
4c82e45273
@ -16,6 +16,7 @@ config ARCH_SH73A0
|
||||
select CPU_V7
|
||||
select I2C
|
||||
select SH_CLK_CPG
|
||||
select RENESAS_INTC_IRQPIN
|
||||
|
||||
config ARCH_R8A7740
|
||||
bool "R-Mobile A1 (R8A77400)"
|
||||
@ -31,6 +32,7 @@ config ARCH_R8A7779
|
||||
select SH_CLK_CPG
|
||||
select USB_ARCH_HAS_EHCI
|
||||
select USB_ARCH_HAS_OHCI
|
||||
select RENESAS_INTC_IRQPIN
|
||||
|
||||
config ARCH_EMEV2
|
||||
bool "Emma Mobile EV2"
|
||||
|
@ -81,7 +81,7 @@ static struct resource smsc9221_resources[] = {
|
||||
.flags = IORESOURCE_MEM,
|
||||
},
|
||||
[1] = {
|
||||
.start = intcs_evt2irq(0x260), /* IRQ3 */
|
||||
.start = irq_pin(3), /* IRQ3 */
|
||||
.flags = IORESOURCE_IRQ,
|
||||
},
|
||||
};
|
||||
@ -115,7 +115,7 @@ static struct resource usb_resources[] = {
|
||||
.flags = IORESOURCE_MEM,
|
||||
},
|
||||
[1] = {
|
||||
.start = intcs_evt2irq(0x220), /* IRQ1 */
|
||||
.start = irq_pin(1), /* IRQ1 */
|
||||
.flags = IORESOURCE_IRQ,
|
||||
},
|
||||
};
|
||||
@ -138,7 +138,7 @@ struct usbhs_private {
|
||||
struct renesas_usbhs_platform_info info;
|
||||
};
|
||||
|
||||
#define IRQ15 intcs_evt2irq(0x03e0)
|
||||
#define IRQ15 irq_pin(15)
|
||||
#define USB_PHY_MODE (1 << 4)
|
||||
#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
|
||||
#define USB_PHY_ON (1 << 1)
|
||||
@ -563,25 +563,25 @@ static struct i2c_board_info i2c0_devices[] = {
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("ak8975", 0x0c),
|
||||
.irq = intcs_evt2irq(0x3380), /* IRQ28 */
|
||||
.irq = irq_pin(28), /* IRQ28 */
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("adxl34x", 0x1d),
|
||||
.irq = intcs_evt2irq(0x3340), /* IRQ26 */
|
||||
.irq = irq_pin(26), /* IRQ26 */
|
||||
},
|
||||
};
|
||||
|
||||
static struct i2c_board_info i2c1_devices[] = {
|
||||
{
|
||||
I2C_BOARD_INFO("st1232-ts", 0x55),
|
||||
.irq = intcs_evt2irq(0x300), /* IRQ8 */
|
||||
.irq = irq_pin(8), /* IRQ8 */
|
||||
},
|
||||
};
|
||||
|
||||
static struct i2c_board_info i2c3_devices[] = {
|
||||
{
|
||||
I2C_BOARD_INFO("pcf8575", 0x20),
|
||||
.irq = intcs_evt2irq(0x3260), /* IRQ19 */
|
||||
.irq = irq_pin(19), /* IRQ19 */
|
||||
.platform_data = &pcf8575_pdata,
|
||||
},
|
||||
};
|
||||
|
@ -61,6 +61,7 @@ extern void r8a7740_pm_init(void);
|
||||
|
||||
extern void r8a7779_init_delay(void);
|
||||
extern void r8a7779_init_irq(void);
|
||||
extern void r8a7779_init_irq_extpin(int irlm);
|
||||
extern void r8a7779_init_irq_dt(void);
|
||||
extern void r8a7779_map_io(void);
|
||||
extern void r8a7779_earlytimer_init(void);
|
||||
|
@ -12,4 +12,8 @@
|
||||
#define INTCS_VECT(n, vect) INTC_VECT((n), INTCS_VECT_BASE + (vect))
|
||||
#define intcs_evt2irq(evt) evt2irq(INTCS_VECT_BASE + (evt))
|
||||
|
||||
/* External IRQ pins */
|
||||
#define IRQPIN_BASE 2000
|
||||
#define irq_pin(nr) ((nr) + IRQPIN_BASE)
|
||||
|
||||
#endif /* __ASM_MACH_IRQS_H */
|
||||
|
@ -19,13 +19,16 @@
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/irqchip/arm-gic.h>
|
||||
#include <mach/common.h>
|
||||
#include <linux/platform_data/irq-renesas-intc-irqpin.h>
|
||||
#include <linux/irqchip.h>
|
||||
#include <mach/common.h>
|
||||
#include <mach/intc.h>
|
||||
#include <mach/irqs.h>
|
||||
#include <mach/r8a7779.h>
|
||||
#include <asm/mach-types.h>
|
||||
#include <asm/mach/arch.h>
|
||||
@ -39,6 +42,54 @@
|
||||
#define INT2NTSR0 IOMEM(0xfe700060)
|
||||
#define INT2NTSR1 IOMEM(0xfe700064)
|
||||
|
||||
static struct renesas_intc_irqpin_config irqpin0_platform_data = {
|
||||
.irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
|
||||
.sense_bitfield_width = 2,
|
||||
};
|
||||
|
||||
static struct resource irqpin0_resources[] = {
|
||||
DEFINE_RES_MEM(0xfe78001c, 4), /* ICR1 */
|
||||
DEFINE_RES_MEM(0xfe780010, 4), /* INTPRI */
|
||||
DEFINE_RES_MEM(0xfe780024, 4), /* INTREQ */
|
||||
DEFINE_RES_MEM(0xfe780044, 4), /* INTMSK0 */
|
||||
DEFINE_RES_MEM(0xfe780064, 4), /* INTMSKCLR0 */
|
||||
DEFINE_RES_IRQ(gic_spi(27)), /* IRQ0 */
|
||||
DEFINE_RES_IRQ(gic_spi(28)), /* IRQ1 */
|
||||
DEFINE_RES_IRQ(gic_spi(29)), /* IRQ2 */
|
||||
DEFINE_RES_IRQ(gic_spi(30)), /* IRQ3 */
|
||||
};
|
||||
|
||||
static struct platform_device irqpin0_device = {
|
||||
.name = "renesas_intc_irqpin",
|
||||
.id = 0,
|
||||
.resource = irqpin0_resources,
|
||||
.num_resources = ARRAY_SIZE(irqpin0_resources),
|
||||
.dev = {
|
||||
.platform_data = &irqpin0_platform_data,
|
||||
},
|
||||
};
|
||||
|
||||
void __init r8a7779_init_irq_extpin(int irlm)
|
||||
{
|
||||
void __iomem *icr0 = ioremap_nocache(0xfe780000, PAGE_SIZE);
|
||||
unsigned long tmp;
|
||||
|
||||
if (icr0) {
|
||||
tmp = ioread32(icr0);
|
||||
if (irlm)
|
||||
tmp |= 1 << 23; /* IRQ0 -> IRQ3 as individual pins */
|
||||
else
|
||||
tmp &= ~(1 << 23); /* IRL mode - not supported */
|
||||
tmp |= (1 << 21); /* LVLMODE = 1 */
|
||||
iowrite32(tmp, icr0);
|
||||
iounmap(icr0);
|
||||
|
||||
if (irlm)
|
||||
platform_device_register(&irqpin0_device);
|
||||
} else
|
||||
pr_warn("r8a7779: unable to setup external irq pin mode\n");
|
||||
}
|
||||
|
||||
static int r8a7779_set_wake(struct irq_data *data, unsigned int on)
|
||||
{
|
||||
return 0; /* always allow wakeup */
|
||||
|
@ -260,108 +260,6 @@ static int sh73a0_set_wake(struct irq_data *data, unsigned int on)
|
||||
return 0; /* always allow wakeup */
|
||||
}
|
||||
|
||||
#define RELOC_BASE 0x1200
|
||||
|
||||
/* INTCA IRQ pins at INTCS + RELOC_BASE to make space for GIC+INTC handling */
|
||||
#define INTCS_VECT_RELOC(n, vect) INTCS_VECT((n), (vect) + RELOC_BASE)
|
||||
|
||||
INTC_IRQ_PINS_32(intca_irq_pins, 0xe6900000,
|
||||
INTCS_VECT_RELOC, "sh73a0-intca-irq-pins");
|
||||
|
||||
static int to_gic_irq(struct irq_data *data)
|
||||
{
|
||||
unsigned int vect = irq2evt(data->irq) - INTCS_VECT_BASE;
|
||||
|
||||
if (vect >= 0x3200)
|
||||
vect -= 0x3000;
|
||||
else
|
||||
vect -= 0x0200;
|
||||
|
||||
return gic_spi((vect >> 5) + 1);
|
||||
}
|
||||
|
||||
static int to_intca_reloc_irq(struct irq_data *data)
|
||||
{
|
||||
return data->irq + (RELOC_BASE >> 5);
|
||||
}
|
||||
|
||||
#define irq_cb(cb, irq) irq_get_chip(irq)->cb(irq_get_irq_data(irq))
|
||||
#define irq_cbp(cb, irq, p...) irq_get_chip(irq)->cb(irq_get_irq_data(irq), p)
|
||||
|
||||
static void intca_gic_enable(struct irq_data *data)
|
||||
{
|
||||
irq_cb(irq_unmask, to_intca_reloc_irq(data));
|
||||
irq_cb(irq_unmask, to_gic_irq(data));
|
||||
}
|
||||
|
||||
static void intca_gic_disable(struct irq_data *data)
|
||||
{
|
||||
irq_cb(irq_mask, to_gic_irq(data));
|
||||
irq_cb(irq_mask, to_intca_reloc_irq(data));
|
||||
}
|
||||
|
||||
static void intca_gic_mask_ack(struct irq_data *data)
|
||||
{
|
||||
irq_cb(irq_mask, to_gic_irq(data));
|
||||
irq_cb(irq_mask_ack, to_intca_reloc_irq(data));
|
||||
}
|
||||
|
||||
static void intca_gic_eoi(struct irq_data *data)
|
||||
{
|
||||
irq_cb(irq_eoi, to_gic_irq(data));
|
||||
}
|
||||
|
||||
static int intca_gic_set_type(struct irq_data *data, unsigned int type)
|
||||
{
|
||||
return irq_cbp(irq_set_type, to_intca_reloc_irq(data), type);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
static int intca_gic_set_affinity(struct irq_data *data,
|
||||
const struct cpumask *cpumask,
|
||||
bool force)
|
||||
{
|
||||
return irq_cbp(irq_set_affinity, to_gic_irq(data), cpumask, force);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct irq_chip intca_gic_irq_chip = {
|
||||
.name = "INTCA-GIC",
|
||||
.irq_mask = intca_gic_disable,
|
||||
.irq_unmask = intca_gic_enable,
|
||||
.irq_mask_ack = intca_gic_mask_ack,
|
||||
.irq_eoi = intca_gic_eoi,
|
||||
.irq_enable = intca_gic_enable,
|
||||
.irq_disable = intca_gic_disable,
|
||||
.irq_shutdown = intca_gic_disable,
|
||||
.irq_set_type = intca_gic_set_type,
|
||||
.irq_set_wake = sh73a0_set_wake,
|
||||
#ifdef CONFIG_SMP
|
||||
.irq_set_affinity = intca_gic_set_affinity,
|
||||
#endif
|
||||
};
|
||||
|
||||
static int to_intc_vect(int irq)
|
||||
{
|
||||
unsigned int irq_pin = irq - gic_spi(1);
|
||||
unsigned int offs;
|
||||
|
||||
if (irq_pin < 16)
|
||||
offs = 0x0200;
|
||||
else
|
||||
offs = 0x3000;
|
||||
|
||||
return offs + (irq_pin << 5);
|
||||
}
|
||||
|
||||
static irqreturn_t sh73a0_irq_pin_demux(int irq, void *dev_id)
|
||||
{
|
||||
generic_handle_irq(intcs_evt2irq(to_intc_vect(irq)));
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static struct irqaction sh73a0_irq_pin_cascade[32];
|
||||
|
||||
#define PINTER0_PHYS 0xe69000a0
|
||||
#define PINTER1_PHYS 0xe69000a4
|
||||
#define PINTER0_VIRT IOMEM(0xe69000a0)
|
||||
@ -422,13 +320,11 @@ void __init sh73a0_init_irq(void)
|
||||
void __iomem *gic_dist_base = IOMEM(0xf0001000);
|
||||
void __iomem *gic_cpu_base = IOMEM(0xf0000100);
|
||||
void __iomem *intevtsa = ioremap_nocache(0xffd20100, PAGE_SIZE);
|
||||
int k, n;
|
||||
|
||||
gic_init(0, 29, gic_dist_base, gic_cpu_base);
|
||||
gic_arch_extn.irq_set_wake = sh73a0_set_wake;
|
||||
|
||||
register_intc_controller(&intcs_desc);
|
||||
register_intc_controller(&intca_irq_pins_desc);
|
||||
register_intc_controller(&intc_pint0_desc);
|
||||
register_intc_controller(&intc_pint1_desc);
|
||||
|
||||
@ -438,19 +334,6 @@ void __init sh73a0_init_irq(void)
|
||||
sh73a0_intcs_cascade.dev_id = intevtsa;
|
||||
setup_irq(gic_spi(50), &sh73a0_intcs_cascade);
|
||||
|
||||
/* IRQ pins require special handling through INTCA and GIC */
|
||||
for (k = 0; k < 32; k++) {
|
||||
sh73a0_irq_pin_cascade[k].name = "INTCA-GIC cascade";
|
||||
sh73a0_irq_pin_cascade[k].handler = sh73a0_irq_pin_demux;
|
||||
setup_irq(gic_spi(1 + k), &sh73a0_irq_pin_cascade[k]);
|
||||
|
||||
n = intcs_evt2irq(to_intc_vect(gic_spi(1 + k)));
|
||||
WARN_ON(irq_alloc_desc_at(n, numa_node_id()) != n);
|
||||
irq_set_chip_and_handler_name(n, &intca_gic_irq_chip,
|
||||
handle_level_irq, "level");
|
||||
set_irq_flags(n, IRQF_VALID); /* yuck */
|
||||
}
|
||||
|
||||
/* PINT pins are sanely tied to the GIC as SPI */
|
||||
sh73a0_pint0_cascade.name = "PINT0 cascade";
|
||||
sh73a0_pint0_cascade.handler = sh73a0_pint0_demux;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <linux/sh_intc.h>
|
||||
#include <linux/sh_timer.h>
|
||||
#include <linux/platform_data/sh_ipmmu.h>
|
||||
#include <linux/platform_data/irq-renesas-intc-irqpin.h>
|
||||
#include <mach/dma-register.h>
|
||||
#include <mach/hardware.h>
|
||||
#include <mach/irqs.h>
|
||||
@ -811,6 +812,127 @@ static struct platform_device ipmmu_device = {
|
||||
.num_resources = ARRAY_SIZE(ipmmu_resources),
|
||||
};
|
||||
|
||||
static struct renesas_intc_irqpin_config irqpin0_platform_data = {
|
||||
.irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
|
||||
};
|
||||
|
||||
static struct resource irqpin0_resources[] = {
|
||||
DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
|
||||
DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
|
||||
DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
|
||||
DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
|
||||
DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
|
||||
DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
|
||||
DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
|
||||
DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
|
||||
DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
|
||||
DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
|
||||
DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
|
||||
DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
|
||||
DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
|
||||
};
|
||||
|
||||
static struct platform_device irqpin0_device = {
|
||||
.name = "renesas_intc_irqpin",
|
||||
.id = 0,
|
||||
.resource = irqpin0_resources,
|
||||
.num_resources = ARRAY_SIZE(irqpin0_resources),
|
||||
.dev = {
|
||||
.platform_data = &irqpin0_platform_data,
|
||||
},
|
||||
};
|
||||
|
||||
static struct renesas_intc_irqpin_config irqpin1_platform_data = {
|
||||
.irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
|
||||
.control_parent = true, /* Disable spurious IRQ10 */
|
||||
};
|
||||
|
||||
static struct resource irqpin1_resources[] = {
|
||||
DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
|
||||
DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
|
||||
DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
|
||||
DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
|
||||
DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
|
||||
DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
|
||||
DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
|
||||
DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
|
||||
DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
|
||||
DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
|
||||
DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
|
||||
DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
|
||||
DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
|
||||
};
|
||||
|
||||
static struct platform_device irqpin1_device = {
|
||||
.name = "renesas_intc_irqpin",
|
||||
.id = 1,
|
||||
.resource = irqpin1_resources,
|
||||
.num_resources = ARRAY_SIZE(irqpin1_resources),
|
||||
.dev = {
|
||||
.platform_data = &irqpin1_platform_data,
|
||||
},
|
||||
};
|
||||
|
||||
static struct renesas_intc_irqpin_config irqpin2_platform_data = {
|
||||
.irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
|
||||
};
|
||||
|
||||
static struct resource irqpin2_resources[] = {
|
||||
DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
|
||||
DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
|
||||
DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
|
||||
DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
|
||||
DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
|
||||
DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
|
||||
DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
|
||||
DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
|
||||
DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
|
||||
DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
|
||||
DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
|
||||
DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
|
||||
DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
|
||||
};
|
||||
|
||||
static struct platform_device irqpin2_device = {
|
||||
.name = "renesas_intc_irqpin",
|
||||
.id = 2,
|
||||
.resource = irqpin2_resources,
|
||||
.num_resources = ARRAY_SIZE(irqpin2_resources),
|
||||
.dev = {
|
||||
.platform_data = &irqpin2_platform_data,
|
||||
},
|
||||
};
|
||||
|
||||
static struct renesas_intc_irqpin_config irqpin3_platform_data = {
|
||||
.irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
|
||||
};
|
||||
|
||||
static struct resource irqpin3_resources[] = {
|
||||
DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
|
||||
DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
|
||||
DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
|
||||
DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
|
||||
DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
|
||||
DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
|
||||
DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
|
||||
DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
|
||||
DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
|
||||
DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
|
||||
DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
|
||||
DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
|
||||
DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
|
||||
};
|
||||
|
||||
static struct platform_device irqpin3_device = {
|
||||
.name = "renesas_intc_irqpin",
|
||||
.id = 3,
|
||||
.resource = irqpin3_resources,
|
||||
.num_resources = ARRAY_SIZE(irqpin3_resources),
|
||||
.dev = {
|
||||
.platform_data = &irqpin3_platform_data,
|
||||
},
|
||||
};
|
||||
|
||||
static struct platform_device *sh73a0_devices_dt[] __initdata = {
|
||||
&scif0_device,
|
||||
&scif1_device,
|
||||
@ -839,6 +961,10 @@ static struct platform_device *sh73a0_late_devices[] __initdata = {
|
||||
&dma0_device,
|
||||
&mpdma0_device,
|
||||
&pmu_device,
|
||||
&irqpin0_device,
|
||||
&irqpin1_device,
|
||||
&irqpin2_device,
|
||||
&irqpin3_device,
|
||||
};
|
||||
|
||||
#define SRCR2 IOMEM(0xe61580b0)
|
||||
|
@ -25,6 +25,14 @@ config ARM_VIC_NR
|
||||
The maximum number of VICs available in the system, for
|
||||
power management.
|
||||
|
||||
config RENESAS_INTC_IRQPIN
|
||||
bool
|
||||
select IRQ_DOMAIN
|
||||
|
||||
config RENESAS_IRQC
|
||||
bool
|
||||
select IRQ_DOMAIN
|
||||
|
||||
config VERSATILE_FPGA_IRQ
|
||||
bool
|
||||
select IRQ_DOMAIN
|
||||
|
@ -8,4 +8,6 @@ obj-$(CONFIG_ARCH_SUNXI) += irq-sunxi.o
|
||||
obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o
|
||||
obj-$(CONFIG_ARM_GIC) += irq-gic.o
|
||||
obj-$(CONFIG_ARM_VIC) += irq-vic.o
|
||||
obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o
|
||||
obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o
|
||||
obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o
|
||||
|
547
drivers/irqchip/irq-renesas-intc-irqpin.c
Normal file
547
drivers/irqchip/irq-renesas-intc-irqpin.c
Normal file
@ -0,0 +1,547 @@
|
||||
/*
|
||||
* Renesas INTC External IRQ Pin Driver
|
||||
*
|
||||
* Copyright (C) 2013 Magnus Damm
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_data/irq-renesas-intc-irqpin.h>
|
||||
|
||||
#define INTC_IRQPIN_MAX 8 /* maximum 8 interrupts per driver instance */
|
||||
|
||||
#define INTC_IRQPIN_REG_SENSE 0 /* ICRn */
|
||||
#define INTC_IRQPIN_REG_PRIO 1 /* INTPRInn */
|
||||
#define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */
|
||||
#define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */
|
||||
#define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */
|
||||
#define INTC_IRQPIN_REG_NR 5
|
||||
|
||||
/* INTC external IRQ PIN hardware register access:
|
||||
*
|
||||
* SENSE is read-write 32-bit with 2-bits or 4-bits per IRQ (*)
|
||||
* PRIO is read-write 32-bit with 4-bits per IRQ (**)
|
||||
* SOURCE is read-only 32-bit or 8-bit with 1-bit per IRQ (***)
|
||||
* MASK is write-only 32-bit or 8-bit with 1-bit per IRQ (***)
|
||||
* CLEAR is write-only 32-bit or 8-bit with 1-bit per IRQ (***)
|
||||
*
|
||||
* (*) May be accessed by more than one driver instance - lock needed
|
||||
* (**) Read-modify-write access by one driver instance - lock needed
|
||||
* (***) Accessed by one driver instance only - no locking needed
|
||||
*/
|
||||
|
||||
struct intc_irqpin_iomem {
|
||||
void __iomem *iomem;
|
||||
unsigned long (*read)(void __iomem *iomem);
|
||||
void (*write)(void __iomem *iomem, unsigned long data);
|
||||
int width;
|
||||
};
|
||||
|
||||
struct intc_irqpin_irq {
|
||||
int hw_irq;
|
||||
int requested_irq;
|
||||
int domain_irq;
|
||||
struct intc_irqpin_priv *p;
|
||||
};
|
||||
|
||||
struct intc_irqpin_priv {
|
||||
struct intc_irqpin_iomem iomem[INTC_IRQPIN_REG_NR];
|
||||
struct intc_irqpin_irq irq[INTC_IRQPIN_MAX];
|
||||
struct renesas_intc_irqpin_config config;
|
||||
unsigned int number_of_irqs;
|
||||
struct platform_device *pdev;
|
||||
struct irq_chip irq_chip;
|
||||
struct irq_domain *irq_domain;
|
||||
bool shared_irqs;
|
||||
u8 shared_irq_mask;
|
||||
};
|
||||
|
||||
static unsigned long intc_irqpin_read32(void __iomem *iomem)
|
||||
{
|
||||
return ioread32(iomem);
|
||||
}
|
||||
|
||||
static unsigned long intc_irqpin_read8(void __iomem *iomem)
|
||||
{
|
||||
return ioread8(iomem);
|
||||
}
|
||||
|
||||
static void intc_irqpin_write32(void __iomem *iomem, unsigned long data)
|
||||
{
|
||||
iowrite32(data, iomem);
|
||||
}
|
||||
|
||||
static void intc_irqpin_write8(void __iomem *iomem, unsigned long data)
|
||||
{
|
||||
iowrite8(data, iomem);
|
||||
}
|
||||
|
||||
static inline unsigned long intc_irqpin_read(struct intc_irqpin_priv *p,
|
||||
int reg)
|
||||
{
|
||||
struct intc_irqpin_iomem *i = &p->iomem[reg];
|
||||
|
||||
return i->read(i->iomem);
|
||||
}
|
||||
|
||||
static inline void intc_irqpin_write(struct intc_irqpin_priv *p,
|
||||
int reg, unsigned long data)
|
||||
{
|
||||
struct intc_irqpin_iomem *i = &p->iomem[reg];
|
||||
|
||||
i->write(i->iomem, data);
|
||||
}
|
||||
|
||||
static inline unsigned long intc_irqpin_hwirq_mask(struct intc_irqpin_priv *p,
|
||||
int reg, int hw_irq)
|
||||
{
|
||||
return BIT((p->iomem[reg].width - 1) - hw_irq);
|
||||
}
|
||||
|
||||
static inline void intc_irqpin_irq_write_hwirq(struct intc_irqpin_priv *p,
|
||||
int reg, int hw_irq)
|
||||
{
|
||||
intc_irqpin_write(p, reg, intc_irqpin_hwirq_mask(p, reg, hw_irq));
|
||||
}
|
||||
|
||||
static DEFINE_RAW_SPINLOCK(intc_irqpin_lock); /* only used by slow path */
|
||||
|
||||
static void intc_irqpin_read_modify_write(struct intc_irqpin_priv *p,
|
||||
int reg, int shift,
|
||||
int width, int value)
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned long tmp;
|
||||
|
||||
raw_spin_lock_irqsave(&intc_irqpin_lock, flags);
|
||||
|
||||
tmp = intc_irqpin_read(p, reg);
|
||||
tmp &= ~(((1 << width) - 1) << shift);
|
||||
tmp |= value << shift;
|
||||
intc_irqpin_write(p, reg, tmp);
|
||||
|
||||
raw_spin_unlock_irqrestore(&intc_irqpin_lock, flags);
|
||||
}
|
||||
|
||||
static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p,
|
||||
int irq, int do_mask)
|
||||
{
|
||||
int bitfield_width = 4; /* PRIO assumed to have fixed bitfield width */
|
||||
int shift = (7 - irq) * bitfield_width; /* PRIO assumed to be 32-bit */
|
||||
|
||||
intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_PRIO,
|
||||
shift, bitfield_width,
|
||||
do_mask ? 0 : (1 << bitfield_width) - 1);
|
||||
}
|
||||
|
||||
static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value)
|
||||
{
|
||||
int bitfield_width = p->config.sense_bitfield_width;
|
||||
int shift = (7 - irq) * bitfield_width; /* SENSE assumed to be 32-bit */
|
||||
|
||||
dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value);
|
||||
|
||||
if (value >= (1 << bitfield_width))
|
||||
return -EINVAL;
|
||||
|
||||
intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_SENSE, shift,
|
||||
bitfield_width, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void intc_irqpin_dbg(struct intc_irqpin_irq *i, char *str)
|
||||
{
|
||||
dev_dbg(&i->p->pdev->dev, "%s (%d:%d:%d)\n",
|
||||
str, i->requested_irq, i->hw_irq, i->domain_irq);
|
||||
}
|
||||
|
||||
static void intc_irqpin_irq_enable(struct irq_data *d)
|
||||
{
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
|
||||
intc_irqpin_dbg(&p->irq[hw_irq], "enable");
|
||||
intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_CLEAR, hw_irq);
|
||||
}
|
||||
|
||||
static void intc_irqpin_irq_disable(struct irq_data *d)
|
||||
{
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
|
||||
intc_irqpin_dbg(&p->irq[hw_irq], "disable");
|
||||
intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_MASK, hw_irq);
|
||||
}
|
||||
|
||||
static void intc_irqpin_shared_irq_enable(struct irq_data *d)
|
||||
{
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
|
||||
intc_irqpin_dbg(&p->irq[hw_irq], "shared enable");
|
||||
intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_CLEAR, hw_irq);
|
||||
|
||||
p->shared_irq_mask &= ~BIT(hw_irq);
|
||||
}
|
||||
|
||||
static void intc_irqpin_shared_irq_disable(struct irq_data *d)
|
||||
{
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
|
||||
intc_irqpin_dbg(&p->irq[hw_irq], "shared disable");
|
||||
intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_MASK, hw_irq);
|
||||
|
||||
p->shared_irq_mask |= BIT(hw_irq);
|
||||
}
|
||||
|
||||
static void intc_irqpin_irq_enable_force(struct irq_data *d)
|
||||
{
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int irq = p->irq[irqd_to_hwirq(d)].requested_irq;
|
||||
|
||||
intc_irqpin_irq_enable(d);
|
||||
|
||||
/* enable interrupt through parent interrupt controller,
|
||||
* assumes non-shared interrupt with 1:1 mapping
|
||||
* needed for busted IRQs on some SoCs like sh73a0
|
||||
*/
|
||||
irq_get_chip(irq)->irq_unmask(irq_get_irq_data(irq));
|
||||
}
|
||||
|
||||
static void intc_irqpin_irq_disable_force(struct irq_data *d)
|
||||
{
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int irq = p->irq[irqd_to_hwirq(d)].requested_irq;
|
||||
|
||||
/* disable interrupt through parent interrupt controller,
|
||||
* assumes non-shared interrupt with 1:1 mapping
|
||||
* needed for busted IRQs on some SoCs like sh73a0
|
||||
*/
|
||||
irq_get_chip(irq)->irq_mask(irq_get_irq_data(irq));
|
||||
intc_irqpin_irq_disable(d);
|
||||
}
|
||||
|
||||
#define INTC_IRQ_SENSE_VALID 0x10
|
||||
#define INTC_IRQ_SENSE(x) (x + INTC_IRQ_SENSE_VALID)
|
||||
|
||||
static unsigned char intc_irqpin_sense[IRQ_TYPE_SENSE_MASK + 1] = {
|
||||
[IRQ_TYPE_EDGE_FALLING] = INTC_IRQ_SENSE(0x00),
|
||||
[IRQ_TYPE_EDGE_RISING] = INTC_IRQ_SENSE(0x01),
|
||||
[IRQ_TYPE_LEVEL_LOW] = INTC_IRQ_SENSE(0x02),
|
||||
[IRQ_TYPE_LEVEL_HIGH] = INTC_IRQ_SENSE(0x03),
|
||||
[IRQ_TYPE_EDGE_BOTH] = INTC_IRQ_SENSE(0x04),
|
||||
};
|
||||
|
||||
static int intc_irqpin_irq_set_type(struct irq_data *d, unsigned int type)
|
||||
{
|
||||
unsigned char value = intc_irqpin_sense[type & IRQ_TYPE_SENSE_MASK];
|
||||
struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
|
||||
|
||||
if (!(value & INTC_IRQ_SENSE_VALID))
|
||||
return -EINVAL;
|
||||
|
||||
return intc_irqpin_set_sense(p, irqd_to_hwirq(d),
|
||||
value ^ INTC_IRQ_SENSE_VALID);
|
||||
}
|
||||
|
||||
static irqreturn_t intc_irqpin_irq_handler(int irq, void *dev_id)
|
||||
{
|
||||
struct intc_irqpin_irq *i = dev_id;
|
||||
struct intc_irqpin_priv *p = i->p;
|
||||
unsigned long bit;
|
||||
|
||||
intc_irqpin_dbg(i, "demux1");
|
||||
bit = intc_irqpin_hwirq_mask(p, INTC_IRQPIN_REG_SOURCE, i->hw_irq);
|
||||
|
||||
if (intc_irqpin_read(p, INTC_IRQPIN_REG_SOURCE) & bit) {
|
||||
intc_irqpin_write(p, INTC_IRQPIN_REG_SOURCE, ~bit);
|
||||
intc_irqpin_dbg(i, "demux2");
|
||||
generic_handle_irq(i->domain_irq);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
static irqreturn_t intc_irqpin_shared_irq_handler(int irq, void *dev_id)
|
||||
{
|
||||
struct intc_irqpin_priv *p = dev_id;
|
||||
unsigned int reg_source = intc_irqpin_read(p, INTC_IRQPIN_REG_SOURCE);
|
||||
irqreturn_t status = IRQ_NONE;
|
||||
int k;
|
||||
|
||||
for (k = 0; k < 8; k++) {
|
||||
if (reg_source & BIT(7 - k)) {
|
||||
if (BIT(k) & p->shared_irq_mask)
|
||||
continue;
|
||||
|
||||
status |= intc_irqpin_irq_handler(irq, &p->irq[k]);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int intc_irqpin_irq_domain_map(struct irq_domain *h, unsigned int virq,
|
||||
irq_hw_number_t hw)
|
||||
{
|
||||
struct intc_irqpin_priv *p = h->host_data;
|
||||
|
||||
p->irq[hw].domain_irq = virq;
|
||||
p->irq[hw].hw_irq = hw;
|
||||
|
||||
intc_irqpin_dbg(&p->irq[hw], "map");
|
||||
irq_set_chip_data(virq, h->host_data);
|
||||
irq_set_chip_and_handler(virq, &p->irq_chip, handle_level_irq);
|
||||
set_irq_flags(virq, IRQF_VALID); /* kill me now */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct irq_domain_ops intc_irqpin_irq_domain_ops = {
|
||||
.map = intc_irqpin_irq_domain_map,
|
||||
.xlate = irq_domain_xlate_twocell,
|
||||
};
|
||||
|
||||
static int intc_irqpin_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct renesas_intc_irqpin_config *pdata = pdev->dev.platform_data;
|
||||
struct intc_irqpin_priv *p;
|
||||
struct intc_irqpin_iomem *i;
|
||||
struct resource *io[INTC_IRQPIN_REG_NR];
|
||||
struct resource *irq;
|
||||
struct irq_chip *irq_chip;
|
||||
void (*enable_fn)(struct irq_data *d);
|
||||
void (*disable_fn)(struct irq_data *d);
|
||||
const char *name = dev_name(&pdev->dev);
|
||||
int ref_irq;
|
||||
int ret;
|
||||
int k;
|
||||
|
||||
p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
|
||||
if (!p) {
|
||||
dev_err(&pdev->dev, "failed to allocate driver data\n");
|
||||
ret = -ENOMEM;
|
||||
goto err0;
|
||||
}
|
||||
|
||||
/* deal with driver instance configuration */
|
||||
if (pdata)
|
||||
memcpy(&p->config, pdata, sizeof(*pdata));
|
||||
if (!p->config.sense_bitfield_width)
|
||||
p->config.sense_bitfield_width = 4; /* default to 4 bits */
|
||||
|
||||
p->pdev = pdev;
|
||||
platform_set_drvdata(pdev, p);
|
||||
|
||||
/* get hold of manadatory IOMEM */
|
||||
for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
|
||||
io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
|
||||
if (!io[k]) {
|
||||
dev_err(&pdev->dev, "not enough IOMEM resources\n");
|
||||
ret = -EINVAL;
|
||||
goto err0;
|
||||
}
|
||||
}
|
||||
|
||||
/* allow any number of IRQs between 1 and INTC_IRQPIN_MAX */
|
||||
for (k = 0; k < INTC_IRQPIN_MAX; k++) {
|
||||
irq = platform_get_resource(pdev, IORESOURCE_IRQ, k);
|
||||
if (!irq)
|
||||
break;
|
||||
|
||||
p->irq[k].p = p;
|
||||
p->irq[k].requested_irq = irq->start;
|
||||
}
|
||||
|
||||
p->number_of_irqs = k;
|
||||
if (p->number_of_irqs < 1) {
|
||||
dev_err(&pdev->dev, "not enough IRQ resources\n");
|
||||
ret = -EINVAL;
|
||||
goto err0;
|
||||
}
|
||||
|
||||
/* ioremap IOMEM and setup read/write callbacks */
|
||||
for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
|
||||
i = &p->iomem[k];
|
||||
|
||||
switch (resource_size(io[k])) {
|
||||
case 1:
|
||||
i->width = 8;
|
||||
i->read = intc_irqpin_read8;
|
||||
i->write = intc_irqpin_write8;
|
||||
break;
|
||||
case 4:
|
||||
i->width = 32;
|
||||
i->read = intc_irqpin_read32;
|
||||
i->write = intc_irqpin_write32;
|
||||
break;
|
||||
default:
|
||||
dev_err(&pdev->dev, "IOMEM size mismatch\n");
|
||||
ret = -EINVAL;
|
||||
goto err0;
|
||||
}
|
||||
|
||||
i->iomem = devm_ioremap_nocache(&pdev->dev, io[k]->start,
|
||||
resource_size(io[k]));
|
||||
if (!i->iomem) {
|
||||
dev_err(&pdev->dev, "failed to remap IOMEM\n");
|
||||
ret = -ENXIO;
|
||||
goto err0;
|
||||
}
|
||||
}
|
||||
|
||||
/* mask all interrupts using priority */
|
||||
for (k = 0; k < p->number_of_irqs; k++)
|
||||
intc_irqpin_mask_unmask_prio(p, k, 1);
|
||||
|
||||
/* clear all pending interrupts */
|
||||
intc_irqpin_write(p, INTC_IRQPIN_REG_SOURCE, 0x0);
|
||||
|
||||
/* scan for shared interrupt lines */
|
||||
ref_irq = p->irq[0].requested_irq;
|
||||
p->shared_irqs = true;
|
||||
for (k = 1; k < p->number_of_irqs; k++) {
|
||||
if (ref_irq != p->irq[k].requested_irq) {
|
||||
p->shared_irqs = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* use more severe masking method if requested */
|
||||
if (p->config.control_parent) {
|
||||
enable_fn = intc_irqpin_irq_enable_force;
|
||||
disable_fn = intc_irqpin_irq_disable_force;
|
||||
} else if (!p->shared_irqs) {
|
||||
enable_fn = intc_irqpin_irq_enable;
|
||||
disable_fn = intc_irqpin_irq_disable;
|
||||
} else {
|
||||
enable_fn = intc_irqpin_shared_irq_enable;
|
||||
disable_fn = intc_irqpin_shared_irq_disable;
|
||||
}
|
||||
|
||||
irq_chip = &p->irq_chip;
|
||||
irq_chip->name = name;
|
||||
irq_chip->irq_mask = disable_fn;
|
||||
irq_chip->irq_unmask = enable_fn;
|
||||
irq_chip->irq_enable = enable_fn;
|
||||
irq_chip->irq_disable = disable_fn;
|
||||
irq_chip->irq_set_type = intc_irqpin_irq_set_type;
|
||||
irq_chip->flags = IRQCHIP_SKIP_SET_WAKE;
|
||||
|
||||
p->irq_domain = irq_domain_add_simple(pdev->dev.of_node,
|
||||
p->number_of_irqs,
|
||||
p->config.irq_base,
|
||||
&intc_irqpin_irq_domain_ops, p);
|
||||
if (!p->irq_domain) {
|
||||
ret = -ENXIO;
|
||||
dev_err(&pdev->dev, "cannot initialize irq domain\n");
|
||||
goto err0;
|
||||
}
|
||||
|
||||
if (p->shared_irqs) {
|
||||
/* request one shared interrupt */
|
||||
if (devm_request_irq(&pdev->dev, p->irq[0].requested_irq,
|
||||
intc_irqpin_shared_irq_handler,
|
||||
IRQF_SHARED, name, p)) {
|
||||
dev_err(&pdev->dev, "failed to request low IRQ\n");
|
||||
ret = -ENOENT;
|
||||
goto err1;
|
||||
}
|
||||
} else {
|
||||
/* request interrupts one by one */
|
||||
for (k = 0; k < p->number_of_irqs; k++) {
|
||||
if (devm_request_irq(&pdev->dev,
|
||||
p->irq[k].requested_irq,
|
||||
intc_irqpin_irq_handler,
|
||||
0, name, &p->irq[k])) {
|
||||
dev_err(&pdev->dev,
|
||||
"failed to request low IRQ\n");
|
||||
ret = -ENOENT;
|
||||
goto err1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* unmask all interrupts on prio level */
|
||||
for (k = 0; k < p->number_of_irqs; k++)
|
||||
intc_irqpin_mask_unmask_prio(p, k, 0);
|
||||
|
||||
dev_info(&pdev->dev, "driving %d irqs\n", p->number_of_irqs);
|
||||
|
||||
/* warn in case of mismatch if irq base is specified */
|
||||
if (p->config.irq_base) {
|
||||
if (p->config.irq_base != p->irq[0].domain_irq)
|
||||
dev_warn(&pdev->dev, "irq base mismatch (%d/%d)\n",
|
||||
p->config.irq_base, p->irq[0].domain_irq);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err1:
|
||||
irq_domain_remove(p->irq_domain);
|
||||
err0:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int intc_irqpin_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct intc_irqpin_priv *p = platform_get_drvdata(pdev);
|
||||
|
||||
irq_domain_remove(p->irq_domain);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id intc_irqpin_dt_ids[] = {
|
||||
{ .compatible = "renesas,intc-irqpin", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
|
||||
|
||||
static struct platform_driver intc_irqpin_device_driver = {
|
||||
.probe = intc_irqpin_probe,
|
||||
.remove = intc_irqpin_remove,
|
||||
.driver = {
|
||||
.name = "renesas_intc_irqpin",
|
||||
.of_match_table = intc_irqpin_dt_ids,
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init intc_irqpin_init(void)
|
||||
{
|
||||
return platform_driver_register(&intc_irqpin_device_driver);
|
||||
}
|
||||
postcore_initcall(intc_irqpin_init);
|
||||
|
||||
static void __exit intc_irqpin_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&intc_irqpin_device_driver);
|
||||
}
|
||||
module_exit(intc_irqpin_exit);
|
||||
|
||||
MODULE_AUTHOR("Magnus Damm");
|
||||
MODULE_DESCRIPTION("Renesas INTC External IRQ Pin Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
307
drivers/irqchip/irq-renesas-irqc.c
Normal file
307
drivers/irqchip/irq-renesas-irqc.c
Normal file
@ -0,0 +1,307 @@
|
||||
/*
|
||||
* Renesas IRQC Driver
|
||||
*
|
||||
* Copyright (C) 2013 Magnus Damm
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_data/irq-renesas-irqc.h>
|
||||
|
||||
#define IRQC_IRQ_MAX 32 /* maximum 32 interrupts per driver instance */
|
||||
|
||||
#define IRQC_REQ_STS 0x00
|
||||
#define IRQC_EN_STS 0x04
|
||||
#define IRQC_EN_SET 0x08
|
||||
#define IRQC_INT_CPU_BASE(n) (0x000 + ((n) * 0x10))
|
||||
#define DETECT_STATUS 0x100
|
||||
#define IRQC_CONFIG(n) (0x180 + ((n) * 0x04))
|
||||
|
||||
struct irqc_irq {
|
||||
int hw_irq;
|
||||
int requested_irq;
|
||||
int domain_irq;
|
||||
struct irqc_priv *p;
|
||||
};
|
||||
|
||||
struct irqc_priv {
|
||||
void __iomem *iomem;
|
||||
void __iomem *cpu_int_base;
|
||||
struct irqc_irq irq[IRQC_IRQ_MAX];
|
||||
struct renesas_irqc_config config;
|
||||
unsigned int number_of_irqs;
|
||||
struct platform_device *pdev;
|
||||
struct irq_chip irq_chip;
|
||||
struct irq_domain *irq_domain;
|
||||
};
|
||||
|
||||
static void irqc_dbg(struct irqc_irq *i, char *str)
|
||||
{
|
||||
dev_dbg(&i->p->pdev->dev, "%s (%d:%d:%d)\n",
|
||||
str, i->requested_irq, i->hw_irq, i->domain_irq);
|
||||
}
|
||||
|
||||
static void irqc_irq_enable(struct irq_data *d)
|
||||
{
|
||||
struct irqc_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
|
||||
irqc_dbg(&p->irq[hw_irq], "enable");
|
||||
iowrite32(BIT(hw_irq), p->cpu_int_base + IRQC_EN_SET);
|
||||
}
|
||||
|
||||
static void irqc_irq_disable(struct irq_data *d)
|
||||
{
|
||||
struct irqc_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
|
||||
irqc_dbg(&p->irq[hw_irq], "disable");
|
||||
iowrite32(BIT(hw_irq), p->cpu_int_base + IRQC_EN_STS);
|
||||
}
|
||||
|
||||
#define INTC_IRQ_SENSE_VALID 0x10
|
||||
#define INTC_IRQ_SENSE(x) (x + INTC_IRQ_SENSE_VALID)
|
||||
|
||||
static unsigned char irqc_sense[IRQ_TYPE_SENSE_MASK + 1] = {
|
||||
[IRQ_TYPE_LEVEL_LOW] = INTC_IRQ_SENSE(0x01),
|
||||
[IRQ_TYPE_LEVEL_HIGH] = INTC_IRQ_SENSE(0x02),
|
||||
[IRQ_TYPE_EDGE_FALLING] = INTC_IRQ_SENSE(0x04), /* Synchronous */
|
||||
[IRQ_TYPE_EDGE_RISING] = INTC_IRQ_SENSE(0x08), /* Synchronous */
|
||||
[IRQ_TYPE_EDGE_BOTH] = INTC_IRQ_SENSE(0x0c), /* Synchronous */
|
||||
};
|
||||
|
||||
static int irqc_irq_set_type(struct irq_data *d, unsigned int type)
|
||||
{
|
||||
struct irqc_priv *p = irq_data_get_irq_chip_data(d);
|
||||
int hw_irq = irqd_to_hwirq(d);
|
||||
unsigned char value = irqc_sense[type & IRQ_TYPE_SENSE_MASK];
|
||||
unsigned long tmp;
|
||||
|
||||
irqc_dbg(&p->irq[hw_irq], "sense");
|
||||
|
||||
if (!(value & INTC_IRQ_SENSE_VALID))
|
||||
return -EINVAL;
|
||||
|
||||
tmp = ioread32(p->iomem + IRQC_CONFIG(hw_irq));
|
||||
tmp &= ~0x3f;
|
||||
tmp |= value ^ INTC_IRQ_SENSE_VALID;
|
||||
iowrite32(tmp, p->iomem + IRQC_CONFIG(hw_irq));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static irqreturn_t irqc_irq_handler(int irq, void *dev_id)
|
||||
{
|
||||
struct irqc_irq *i = dev_id;
|
||||
struct irqc_priv *p = i->p;
|
||||
unsigned long bit = BIT(i->hw_irq);
|
||||
|
||||
irqc_dbg(i, "demux1");
|
||||
|
||||
if (ioread32(p->iomem + DETECT_STATUS) & bit) {
|
||||
iowrite32(bit, p->iomem + DETECT_STATUS);
|
||||
irqc_dbg(i, "demux2");
|
||||
generic_handle_irq(i->domain_irq);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
static int irqc_irq_domain_map(struct irq_domain *h, unsigned int virq,
|
||||
irq_hw_number_t hw)
|
||||
{
|
||||
struct irqc_priv *p = h->host_data;
|
||||
|
||||
p->irq[hw].domain_irq = virq;
|
||||
p->irq[hw].hw_irq = hw;
|
||||
|
||||
irqc_dbg(&p->irq[hw], "map");
|
||||
irq_set_chip_data(virq, h->host_data);
|
||||
irq_set_chip_and_handler(virq, &p->irq_chip, handle_level_irq);
|
||||
set_irq_flags(virq, IRQF_VALID); /* kill me now */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct irq_domain_ops irqc_irq_domain_ops = {
|
||||
.map = irqc_irq_domain_map,
|
||||
.xlate = irq_domain_xlate_twocell,
|
||||
};
|
||||
|
||||
static int irqc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct renesas_irqc_config *pdata = pdev->dev.platform_data;
|
||||
struct irqc_priv *p;
|
||||
struct resource *io;
|
||||
struct resource *irq;
|
||||
struct irq_chip *irq_chip;
|
||||
const char *name = dev_name(&pdev->dev);
|
||||
int ret;
|
||||
int k;
|
||||
|
||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
||||
if (!p) {
|
||||
dev_err(&pdev->dev, "failed to allocate driver data\n");
|
||||
ret = -ENOMEM;
|
||||
goto err0;
|
||||
}
|
||||
|
||||
/* deal with driver instance configuration */
|
||||
if (pdata)
|
||||
memcpy(&p->config, pdata, sizeof(*pdata));
|
||||
|
||||
p->pdev = pdev;
|
||||
platform_set_drvdata(pdev, p);
|
||||
|
||||
/* get hold of manadatory IOMEM */
|
||||
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!io) {
|
||||
dev_err(&pdev->dev, "not enough IOMEM resources\n");
|
||||
ret = -EINVAL;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
/* allow any number of IRQs between 1 and IRQC_IRQ_MAX */
|
||||
for (k = 0; k < IRQC_IRQ_MAX; k++) {
|
||||
irq = platform_get_resource(pdev, IORESOURCE_IRQ, k);
|
||||
if (!irq)
|
||||
break;
|
||||
|
||||
p->irq[k].p = p;
|
||||
p->irq[k].requested_irq = irq->start;
|
||||
}
|
||||
|
||||
p->number_of_irqs = k;
|
||||
if (p->number_of_irqs < 1) {
|
||||
dev_err(&pdev->dev, "not enough IRQ resources\n");
|
||||
ret = -EINVAL;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
/* ioremap IOMEM and setup read/write callbacks */
|
||||
p->iomem = ioremap_nocache(io->start, resource_size(io));
|
||||
if (!p->iomem) {
|
||||
dev_err(&pdev->dev, "failed to remap IOMEM\n");
|
||||
ret = -ENXIO;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
p->cpu_int_base = p->iomem + IRQC_INT_CPU_BASE(0); /* SYS-SPI */
|
||||
|
||||
irq_chip = &p->irq_chip;
|
||||
irq_chip->name = name;
|
||||
irq_chip->irq_mask = irqc_irq_disable;
|
||||
irq_chip->irq_unmask = irqc_irq_enable;
|
||||
irq_chip->irq_enable = irqc_irq_enable;
|
||||
irq_chip->irq_disable = irqc_irq_disable;
|
||||
irq_chip->irq_set_type = irqc_irq_set_type;
|
||||
irq_chip->flags = IRQCHIP_SKIP_SET_WAKE;
|
||||
|
||||
p->irq_domain = irq_domain_add_simple(pdev->dev.of_node,
|
||||
p->number_of_irqs,
|
||||
p->config.irq_base,
|
||||
&irqc_irq_domain_ops, p);
|
||||
if (!p->irq_domain) {
|
||||
ret = -ENXIO;
|
||||
dev_err(&pdev->dev, "cannot initialize irq domain\n");
|
||||
goto err2;
|
||||
}
|
||||
|
||||
/* request interrupts one by one */
|
||||
for (k = 0; k < p->number_of_irqs; k++) {
|
||||
if (request_irq(p->irq[k].requested_irq, irqc_irq_handler,
|
||||
0, name, &p->irq[k])) {
|
||||
dev_err(&pdev->dev, "failed to request IRQ\n");
|
||||
ret = -ENOENT;
|
||||
goto err3;
|
||||
}
|
||||
}
|
||||
|
||||
dev_info(&pdev->dev, "driving %d irqs\n", p->number_of_irqs);
|
||||
|
||||
/* warn in case of mismatch if irq base is specified */
|
||||
if (p->config.irq_base) {
|
||||
if (p->config.irq_base != p->irq[0].domain_irq)
|
||||
dev_warn(&pdev->dev, "irq base mismatch (%d/%d)\n",
|
||||
p->config.irq_base, p->irq[0].domain_irq);
|
||||
}
|
||||
|
||||
return 0;
|
||||
err3:
|
||||
for (; k >= 0; k--)
|
||||
free_irq(p->irq[k - 1].requested_irq, &p->irq[k - 1]);
|
||||
|
||||
irq_domain_remove(p->irq_domain);
|
||||
err2:
|
||||
iounmap(p->iomem);
|
||||
err1:
|
||||
kfree(p);
|
||||
err0:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int irqc_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct irqc_priv *p = platform_get_drvdata(pdev);
|
||||
int k;
|
||||
|
||||
for (k = 0; k < p->number_of_irqs; k++)
|
||||
free_irq(p->irq[k].requested_irq, &p->irq[k]);
|
||||
|
||||
irq_domain_remove(p->irq_domain);
|
||||
iounmap(p->iomem);
|
||||
kfree(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id irqc_dt_ids[] = {
|
||||
{ .compatible = "renesas,irqc", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, irqc_dt_ids);
|
||||
|
||||
static struct platform_driver irqc_device_driver = {
|
||||
.probe = irqc_probe,
|
||||
.remove = irqc_remove,
|
||||
.driver = {
|
||||
.name = "renesas_irqc",
|
||||
.of_match_table = irqc_dt_ids,
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init irqc_init(void)
|
||||
{
|
||||
return platform_driver_register(&irqc_device_driver);
|
||||
}
|
||||
postcore_initcall(irqc_init);
|
||||
|
||||
static void __exit irqc_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&irqc_device_driver);
|
||||
}
|
||||
module_exit(irqc_exit);
|
||||
|
||||
MODULE_AUTHOR("Magnus Damm");
|
||||
MODULE_DESCRIPTION("Renesas IRQC Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
@ -2733,9 +2733,9 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
|
||||
{ },
|
||||
};
|
||||
|
||||
/* IRQ pins through INTCS with IRQ0->15 from 0x200 and IRQ16-31 from 0x3200 */
|
||||
#define EXT_IRQ16L(n) intcs_evt2irq(0x200 + ((n) << 5))
|
||||
#define EXT_IRQ16H(n) intcs_evt2irq(0x3200 + ((n - 16) << 5))
|
||||
/* External IRQ pins mapped at IRQPIN_BASE */
|
||||
#define EXT_IRQ16L(n) irq_pin(n)
|
||||
#define EXT_IRQ16H(n) irq_pin(n)
|
||||
|
||||
static struct pinmux_irq pinmux_irqs[] = {
|
||||
PINMUX_IRQ(EXT_IRQ16H(19), PORT9_FN0),
|
||||
|
29
include/linux/platform_data/irq-renesas-intc-irqpin.h
Normal file
29
include/linux/platform_data/irq-renesas-intc-irqpin.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Renesas INTC External IRQ Pin Driver
|
||||
*
|
||||
* Copyright (C) 2013 Magnus Damm
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __IRQ_RENESAS_INTC_IRQPIN_H__
|
||||
#define __IRQ_RENESAS_INTC_IRQPIN_H__
|
||||
|
||||
struct renesas_intc_irqpin_config {
|
||||
unsigned int sense_bitfield_width;
|
||||
unsigned int irq_base;
|
||||
bool control_parent;
|
||||
};
|
||||
|
||||
#endif /* __IRQ_RENESAS_INTC_IRQPIN_H__ */
|
27
include/linux/platform_data/irq-renesas-irqc.h
Normal file
27
include/linux/platform_data/irq-renesas-irqc.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Renesas IRQC Driver
|
||||
*
|
||||
* Copyright (C) 2013 Magnus Damm
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __IRQ_RENESAS_IRQC_H__
|
||||
#define __IRQ_RENESAS_IRQC_H__
|
||||
|
||||
struct renesas_irqc_config {
|
||||
unsigned int irq_base;
|
||||
};
|
||||
|
||||
#endif /* __IRQ_RENESAS_IRQC_H__ */
|
Loading…
Reference in New Issue
Block a user