diff options
author | Magnus Damm <damm+renesas@opensource.se> | 2014-12-03 07:18:03 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-01-26 05:38:22 -0500 |
commit | e03f9088e22ca7e2b0de826466540e2527518e52 (patch) | |
tree | 78e192dab008ea8852d9fb57836338d160ed96af /drivers/irqchip/irq-renesas-intc-irqpin.c | |
parent | 64c96a57b73397415eafa4ac2020ea7d99d7168c (diff) |
irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support
Add r8a7779 specific support for IRLM bit configuration
in the INTC-IRQPIN driver. Without this code we need
special workaround code in arch/arm/mach-shmobile.
The IRLM bit for the INTC hardware exists on various
older SH-based SoCs and is used to select between two
modes for the external interrupt pins IRQ0 to IRQ3:
IRLM = 0: (default from reset on r8a7779)
In this mode the pins IRQ0 to IRQ3 are used together
to give a value between 0 and 15 to the SoC. External
logic is required for masking. This mode is not
supported by the INTC-IRQPIN driver.
IRLM = 1: (needs this patch or configuration elsewhere)
In this mode IRQ0 to IRQ3 operate as 4 individual
external interrupt pins. In this mode the SMSC ethernet
chip can be used via IRQ1 on r8a7779 Marzen. This mode
is the only supported mode by the INTC-IRQPIN driver.
For this patch to work the r8a7779 DTS needs to pass
the ICR0 register as the last register bank.
Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: horms@verge.net.au
Cc: jason@lakedaemon.net
Link: http://lkml.kernel.org/r/20141203121803.5936.35881.sendpatchset@w520
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/irqchip/irq-renesas-intc-irqpin.c')
-rw-r--r-- | drivers/irqchip/irq-renesas-intc-irqpin.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c index 078cac5e2d08..9a0767b9c89d 100644 --- a/drivers/irqchip/irq-renesas-intc-irqpin.c +++ b/drivers/irqchip/irq-renesas-intc-irqpin.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/of_device.h> | ||
33 | #include <linux/platform_data/irq-renesas-intc-irqpin.h> | 34 | #include <linux/platform_data/irq-renesas-intc-irqpin.h> |
34 | #include <linux/pm_runtime.h> | 35 | #include <linux/pm_runtime.h> |
35 | 36 | ||
@@ -40,7 +41,9 @@ | |||
40 | #define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */ | 41 | #define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */ |
41 | #define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */ | 42 | #define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */ |
42 | #define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */ | 43 | #define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */ |
43 | #define INTC_IRQPIN_REG_NR 5 | 44 | #define INTC_IRQPIN_REG_NR_MANDATORY 5 |
45 | #define INTC_IRQPIN_REG_IRLM 5 /* ICR0 with IRLM bit (optional) */ | ||
46 | #define INTC_IRQPIN_REG_NR 6 | ||
44 | 47 | ||
45 | /* INTC external IRQ PIN hardware register access: | 48 | /* INTC external IRQ PIN hardware register access: |
46 | * | 49 | * |
@@ -82,6 +85,10 @@ struct intc_irqpin_priv { | |||
82 | u8 shared_irq_mask; | 85 | u8 shared_irq_mask; |
83 | }; | 86 | }; |
84 | 87 | ||
88 | struct intc_irqpin_irlm_config { | ||
89 | unsigned int irlm_bit; | ||
90 | }; | ||
91 | |||
85 | static unsigned long intc_irqpin_read32(void __iomem *iomem) | 92 | static unsigned long intc_irqpin_read32(void __iomem *iomem) |
86 | { | 93 | { |
87 | return ioread32(iomem); | 94 | return ioread32(iomem); |
@@ -345,10 +352,23 @@ static struct irq_domain_ops intc_irqpin_irq_domain_ops = { | |||
345 | .xlate = irq_domain_xlate_twocell, | 352 | .xlate = irq_domain_xlate_twocell, |
346 | }; | 353 | }; |
347 | 354 | ||
355 | static const struct intc_irqpin_irlm_config intc_irqpin_irlm_r8a7779 = { | ||
356 | .irlm_bit = 23, /* ICR0.IRLM0 */ | ||
357 | }; | ||
358 | |||
359 | static const struct of_device_id intc_irqpin_dt_ids[] = { | ||
360 | { .compatible = "renesas,intc-irqpin", }, | ||
361 | { .compatible = "renesas,intc-irqpin-r8a7779", | ||
362 | .data = &intc_irqpin_irlm_r8a7779 }, | ||
363 | {}, | ||
364 | }; | ||
365 | MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids); | ||
366 | |||
348 | static int intc_irqpin_probe(struct platform_device *pdev) | 367 | static int intc_irqpin_probe(struct platform_device *pdev) |
349 | { | 368 | { |
350 | struct device *dev = &pdev->dev; | 369 | struct device *dev = &pdev->dev; |
351 | struct renesas_intc_irqpin_config *pdata = dev->platform_data; | 370 | struct renesas_intc_irqpin_config *pdata = dev->platform_data; |
371 | const struct of_device_id *of_id; | ||
352 | struct intc_irqpin_priv *p; | 372 | struct intc_irqpin_priv *p; |
353 | struct intc_irqpin_iomem *i; | 373 | struct intc_irqpin_iomem *i; |
354 | struct resource *io[INTC_IRQPIN_REG_NR]; | 374 | struct resource *io[INTC_IRQPIN_REG_NR]; |
@@ -391,10 +411,11 @@ static int intc_irqpin_probe(struct platform_device *pdev) | |||
391 | pm_runtime_enable(dev); | 411 | pm_runtime_enable(dev); |
392 | pm_runtime_get_sync(dev); | 412 | pm_runtime_get_sync(dev); |
393 | 413 | ||
394 | /* get hold of manadatory IOMEM */ | 414 | /* get hold of register banks */ |
415 | memset(io, 0, sizeof(io)); | ||
395 | for (k = 0; k < INTC_IRQPIN_REG_NR; k++) { | 416 | for (k = 0; k < INTC_IRQPIN_REG_NR; k++) { |
396 | io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k); | 417 | io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k); |
397 | if (!io[k]) { | 418 | if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) { |
398 | dev_err(dev, "not enough IOMEM resources\n"); | 419 | dev_err(dev, "not enough IOMEM resources\n"); |
399 | ret = -EINVAL; | 420 | ret = -EINVAL; |
400 | goto err0; | 421 | goto err0; |
@@ -422,6 +443,10 @@ static int intc_irqpin_probe(struct platform_device *pdev) | |||
422 | for (k = 0; k < INTC_IRQPIN_REG_NR; k++) { | 443 | for (k = 0; k < INTC_IRQPIN_REG_NR; k++) { |
423 | i = &p->iomem[k]; | 444 | i = &p->iomem[k]; |
424 | 445 | ||
446 | /* handle optional registers */ | ||
447 | if (!io[k]) | ||
448 | continue; | ||
449 | |||
425 | switch (resource_size(io[k])) { | 450 | switch (resource_size(io[k])) { |
426 | case 1: | 451 | case 1: |
427 | i->width = 8; | 452 | i->width = 8; |
@@ -448,6 +473,19 @@ static int intc_irqpin_probe(struct platform_device *pdev) | |||
448 | } | 473 | } |
449 | } | 474 | } |
450 | 475 | ||
476 | /* configure "individual IRQ mode" where needed */ | ||
477 | of_id = of_match_device(intc_irqpin_dt_ids, dev); | ||
478 | if (of_id && of_id->data) { | ||
479 | const struct intc_irqpin_irlm_config *irlm_config = of_id->data; | ||
480 | |||
481 | if (io[INTC_IRQPIN_REG_IRLM]) | ||
482 | intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_IRLM, | ||
483 | irlm_config->irlm_bit, | ||
484 | 1, 1); | ||
485 | else | ||
486 | dev_warn(dev, "unable to select IRLM mode\n"); | ||
487 | } | ||
488 | |||
451 | /* mask all interrupts using priority */ | 489 | /* mask all interrupts using priority */ |
452 | for (k = 0; k < p->number_of_irqs; k++) | 490 | for (k = 0; k < p->number_of_irqs; k++) |
453 | intc_irqpin_mask_unmask_prio(p, k, 1); | 491 | intc_irqpin_mask_unmask_prio(p, k, 1); |
@@ -550,12 +588,6 @@ static int intc_irqpin_remove(struct platform_device *pdev) | |||
550 | return 0; | 588 | return 0; |
551 | } | 589 | } |
552 | 590 | ||
553 | static const struct of_device_id intc_irqpin_dt_ids[] = { | ||
554 | { .compatible = "renesas,intc-irqpin", }, | ||
555 | {}, | ||
556 | }; | ||
557 | MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids); | ||
558 | |||
559 | static struct platform_driver intc_irqpin_device_driver = { | 591 | static struct platform_driver intc_irqpin_device_driver = { |
560 | .probe = intc_irqpin_probe, | 592 | .probe = intc_irqpin_probe, |
561 | .remove = intc_irqpin_remove, | 593 | .remove = intc_irqpin_remove, |