From: Roger Quadros <rogerq@ti.com>
To: <tony@atomide.com>, <computersforpeace@gmail.com>
Cc: <dwmw2@infradead.org>, <ezequiel@vanguardiasur.com.ar>,
<javier@dowhile0.org>, <fcooper@ti.com>, <nsekhar@ti.com>,
<linux-mtd@lists.infradead.org>, <linux-omap@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Roger Quadros <rogerq@ti.com>
Subject: [PATCH v5 15/26] memory: omap-gpmc: Support WAIT pin edge interrupts
Date: Fri, 19 Feb 2016 23:15:37 +0200 [thread overview]
Message-ID: <1455916548-3441-16-git-send-email-rogerq@ti.com> (raw)
In-Reply-To: <1455916548-3441-1-git-send-email-rogerq@ti.com>
OMAPs can have 2 to 4 WAITPINs that can be used as edge triggered
interrupts if not used for memory wait state insertion.
Support these interrupts via the gpmc IRQ domain.
The gpmc IRQ domain interrupt map is:
0 - NAND_fifoevent
1 - NAND_termcount
2 - GPMC_WAIT0 edge
3 - GPMC_WAIT1 edge, and so on
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
.../bindings/memory-controllers/omap-gpmc.txt | 8 ++
drivers/memory/omap-gpmc.c | 106 +++++++++++++++++----
2 files changed, 96 insertions(+), 18 deletions(-)
diff --git a/Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt b/Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
index 8113a52..f64b29c 100644
--- a/Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
+++ b/Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
@@ -35,6 +35,14 @@ Required properties:
- gpio-controller: The GPMC driver implements a GPIO controller for the
GPMC WAIT pins that can be used as general purpose inputs.
0 maps to GPMC_WAIT0 pin.
+ - interrupt-controller: The GPMC driver implements and interrupt controller for
+ the NAND events "fifoevent" and "termcount" plus the
+ rising/falling edges on the GPMC_WAIT pins.
+ The interrupt number mapping is as follows
+ 0 - NAND_fifoevent
+ 1 - NAND_termcount
+ 2 - GPMC_WAIT0 pin edge
+ 3 - GPMC_WAIT1 pin edge, and so on.
Timing properties for child nodes. All are optional and default to 0.
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index af2d57f..d958fb6 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -189,9 +189,7 @@
#define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
#define GPMC_ECC_READSYN 2 /* Reset before syndrom is read back */
-/* XXX: Only NAND irq has been considered,currently these are the only ones used
- */
-#define GPMC_NR_IRQ 2
+#define GPMC_NR_NAND_IRQS 2 /* number of NAND specific IRQs */
enum gpmc_clk_domain {
GPMC_CD_FCLK,
@@ -239,6 +237,7 @@ struct gpmc_device {
int irq;
struct irq_chip irq_chip;
struct gpio_chip gpio_chip;
+ int nirqs;
};
static struct irq_domain *gpmc_irq_domain;
@@ -1135,7 +1134,8 @@ int gpmc_get_client_irq(unsigned irq_config)
return 0;
}
- if (irq_config >= GPMC_NR_IRQ)
+ /* we restrict this to NAND IRQs only */
+ if (irq_config >= GPMC_NR_NAND_IRQS)
return 0;
return irq_create_mapping(gpmc_irq_domain, irq_config);
@@ -1145,6 +1145,10 @@ static int gpmc_irq_endis(unsigned long hwirq, bool endis)
{
u32 regval;
+ /* bits GPMC_NR_NAND_IRQS to 8 are reserved */
+ if (hwirq >= GPMC_NR_NAND_IRQS)
+ hwirq += 8 - GPMC_NR_NAND_IRQS;
+
regval = gpmc_read_reg(GPMC_IRQENABLE);
if (endis)
regval |= BIT(hwirq);
@@ -1165,9 +1169,64 @@ static void gpmc_irq_enable(struct irq_data *p)
gpmc_irq_endis(p->hwirq, true);
}
-static void gpmc_irq_noop(struct irq_data *data) { }
+static void gpmc_irq_mask(struct irq_data *d)
+{
+ gpmc_irq_endis(d->hwirq, false);
+}
+
+static void gpmc_irq_unmask(struct irq_data *d)
+{
+ gpmc_irq_endis(d->hwirq, true);
+}
+
+static void gpmc_irq_edge_config(unsigned long hwirq, bool rising_edge)
+{
+ u32 regval;
+
+ /* NAND IRQs polarity is not configurable */
+ if (hwirq < GPMC_NR_NAND_IRQS)
+ return;
+
+ /* WAITPIN starts at BIT 8 */
+ hwirq += 8 - GPMC_NR_NAND_IRQS;
+
+ regval = gpmc_read_reg(GPMC_CONFIG);
+ if (rising_edge)
+ regval &= ~BIT(hwirq);
+ else
+ regval |= BIT(hwirq);
+
+ gpmc_write_reg(GPMC_CONFIG, regval);
+}
+
+static void gpmc_irq_ack(struct irq_data *d)
+{
+ unsigned hwirq = d->hwirq;
+
+ /* skip reserved bits */
+ if (hwirq >= GPMC_NR_NAND_IRQS)
+ hwirq += 8 - GPMC_NR_NAND_IRQS;
+
+ /* Setting bit to 1 clears (or Acks) the interrupt */
+ gpmc_write_reg(GPMC_IRQSTATUS, BIT(hwirq));
+}
+
+static int gpmc_irq_set_type(struct irq_data *d, unsigned trigger)
+{
+ /* can't set type for NAND IRQs */
+ if (d->hwirq < GPMC_NR_NAND_IRQS)
+ return -EINVAL;
+
+ /* We can support either rising or falling edge at a time */
+ if (trigger == IRQ_TYPE_EDGE_FALLING)
+ gpmc_irq_edge_config(d->hwirq, false);
+ else if (trigger == IRQ_TYPE_EDGE_RISING)
+ gpmc_irq_edge_config(d->hwirq, true);
+ else
+ return -EINVAL;
-static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
+ return 0;
+}
static int gpmc_irq_map(struct irq_domain *d, unsigned int virq,
irq_hw_number_t hw)
@@ -1175,8 +1234,14 @@ static int gpmc_irq_map(struct irq_domain *d, unsigned int virq,
struct gpmc_device *gpmc = d->host_data;
irq_set_chip_data(virq, gpmc);
- irq_set_chip_and_handler(virq, &gpmc->irq_chip, handle_simple_irq);
- irq_modify_status(virq, IRQ_NOREQUEST, IRQ_NOAUTOEN);
+ if (hw < GPMC_NR_NAND_IRQS) {
+ irq_modify_status(virq, IRQ_NOREQUEST, IRQ_NOAUTOEN);
+ irq_set_chip_and_handler(virq, &gpmc->irq_chip,
+ handle_simple_irq);
+ } else {
+ irq_set_chip_and_handler(virq, &gpmc->irq_chip,
+ handle_edge_irq);
+ }
return 0;
}
@@ -1189,16 +1254,21 @@ static const struct irq_domain_ops gpmc_irq_domain_ops = {
static irqreturn_t gpmc_handle_irq(int irq, void *data)
{
int hwirq, virq;
- u32 regval;
+ u32 regval, regvalx;
struct gpmc_device *gpmc = data;
regval = gpmc_read_reg(GPMC_IRQSTATUS);
+ regvalx = regval;
if (!regval)
return IRQ_NONE;
- for (hwirq = 0; hwirq < GPMC_NR_IRQ; hwirq++) {
- if (regval & BIT(hwirq)) {
+ for (hwirq = 0; hwirq < gpmc->nirqs; hwirq++) {
+ /* skip reserved status bits */
+ if (hwirq == GPMC_NR_NAND_IRQS)
+ regvalx >>= 8 - GPMC_NR_NAND_IRQS;
+
+ if (regvalx & BIT(hwirq)) {
virq = irq_find_mapping(gpmc_irq_domain, hwirq);
if (!virq) {
dev_warn(gpmc->dev,
@@ -1228,16 +1298,15 @@ static int gpmc_setup_irq(struct gpmc_device *gpmc)
gpmc_write_reg(GPMC_IRQSTATUS, regval);
gpmc->irq_chip.name = "gpmc";
- gpmc->irq_chip.irq_startup = gpmc_irq_noop_ret;
gpmc->irq_chip.irq_enable = gpmc_irq_enable;
gpmc->irq_chip.irq_disable = gpmc_irq_disable;
- gpmc->irq_chip.irq_shutdown = gpmc_irq_noop;
- gpmc->irq_chip.irq_ack = gpmc_irq_noop;
- gpmc->irq_chip.irq_mask = gpmc_irq_noop;
- gpmc->irq_chip.irq_unmask = gpmc_irq_noop;
+ gpmc->irq_chip.irq_ack = gpmc_irq_ack;
+ gpmc->irq_chip.irq_mask = gpmc_irq_mask;
+ gpmc->irq_chip.irq_unmask = gpmc_irq_unmask;
+ gpmc->irq_chip.irq_set_type = gpmc_irq_set_type;
gpmc_irq_domain = irq_domain_add_linear(gpmc->dev->of_node,
- GPMC_NR_IRQ,
+ gpmc->nirqs,
&gpmc_irq_domain_ops,
gpmc);
if (!gpmc_irq_domain) {
@@ -1262,7 +1331,7 @@ static int gpmc_free_irq(struct gpmc_device *gpmc)
free_irq(gpmc->irq, gpmc);
- for (hwirq = 0; hwirq < GPMC_NR_IRQ; hwirq++)
+ for (hwirq = 0; hwirq < gpmc->nirqs; hwirq++)
irq_dispose_mapping(irq_find_mapping(gpmc_irq_domain, hwirq));
irq_domain_remove(gpmc_irq_domain);
@@ -2264,6 +2333,7 @@ static int gpmc_probe(struct platform_device *pdev)
if (rc)
goto gpio_init_failed;
+ gpmc->nirqs = GPMC_NR_NAND_IRQS + gpmc_nr_waitpins;
rc = gpmc_setup_irq(gpmc);
if (rc) {
dev_err(gpmc->dev, "gpmc_setup_irq failed\n");
--
2.1.4
next prev parent reply other threads:[~2016-02-19 21:17 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 21:15 [PATCH v5 00/26] memory: omap-gpmc: mtd: nand: Support GPMC NAND on non-OMAP platforms Roger Quadros
2016-02-19 21:15 ` [PATCH v5 01/26] ARM: OMAP2+: gpmc: Add platform data Roger Quadros
2016-02-19 21:15 ` [PATCH v5 02/26] ARM: OMAP2+: gpmc: Add gpmc timings and settings to " Roger Quadros
2016-02-19 21:15 ` [PATCH v5 03/26] memory: omap-gpmc: Introduce GPMC to NAND interface Roger Quadros
2016-03-05 1:35 ` Brian Norris
2016-03-07 8:55 ` Roger Quadros
2016-02-19 21:15 ` [PATCH v5 04/26] mtd: nand: omap2: Use gpmc_omap_get_nand_ops() to get NAND registers Roger Quadros
2016-02-19 21:15 ` [PATCH v5 05/26] memory: omap-gpmc: Add GPMC-NAND ops to get writebufferempty status Roger Quadros
2016-02-19 21:15 ` [PATCH v5 06/26] mtd: nand: omap2: Switch to using GPMC-NAND ops for writebuffer empty check Roger Quadros
2016-02-19 21:15 ` [PATCH v5 07/26] memory: omap-gpmc: Implement IRQ domain for NAND IRQs Roger Quadros
2016-02-19 21:15 ` [PATCH v5 08/26] mtd: nand: omap: Copy platform data parameters to omap_nand_info data Roger Quadros
2016-02-19 21:15 ` [PATCH v5 09/26] mtd: nand: omap: Clean up device tree support Roger Quadros
2016-03-05 2:10 ` Brian Norris
2016-03-07 9:06 ` Roger Quadros
2016-03-05 2:28 ` Brian Norris
2016-03-07 9:02 ` Roger Quadros
2016-02-19 21:15 ` [PATCH v5 10/26] mtd: nand: omap: Update DT binding documentation Roger Quadros
2016-02-23 19:41 ` Rob Herring
2016-02-24 9:55 ` Roger Quadros
2016-03-05 2:04 ` Brian Norris
2016-03-07 9:46 ` Roger Quadros
2016-03-07 18:58 ` Brian Norris
2016-03-07 10:32 ` [PATCH v6 " Roger Quadros
2016-03-17 14:48 ` Rob Herring
2016-02-19 21:15 ` [PATCH v5 11/26] memory: omap-gpmc: Prevent mapping into 1st 16MB Roger Quadros
2016-02-19 21:15 ` [PATCH v5 12/26] memory: omap-gpmc: Move device tree binding to correct location Roger Quadros
2016-02-23 20:50 ` Rob Herring
2016-02-24 9:51 ` Roger Quadros
2016-02-19 21:15 ` [PATCH v5 13/26] memory: omap-gpmc: Support general purpose input for WAITPINs Roger Quadros
2016-03-07 9:34 ` Boris Brezillon
2016-03-07 9:38 ` Boris Brezillon
2016-03-07 10:02 ` Roger Quadros
2016-03-07 10:31 ` Boris Brezillon
2016-02-19 21:15 ` [PATCH v5 14/26] memory: omap-gpmc: Reserve WAITPIN if needed for WAIT monitoring Roger Quadros
2016-02-19 21:15 ` Roger Quadros [this message]
2016-02-19 21:15 ` [PATCH v5 16/26] memory: omap-gpmc: Prevent GPMC_STATUS from being accessed via gpmc_regs Roger Quadros
2016-02-19 21:15 ` [PATCH v5 17/26] mtd: nand: omap2: Implement NAND ready using gpiolib Roger Quadros
2016-03-05 1:46 ` Brian Norris
2016-03-07 9:11 ` Roger Quadros
2016-03-07 9:22 ` Boris Brezillon
2016-02-19 21:15 ` [PATCH v5 18/26] ARM: dts: dra7: Fix NAND device nodes Roger Quadros
2016-02-19 21:15 ` [PATCH v5 19/26] ARM: dts: dra7x-evm: Provide NAND ready pin Roger Quadros
2016-02-19 21:15 ` [PATCH v5 20/26] ARM: dts: am437x: Fix NAND device nodes Roger Quadros
2016-02-19 21:15 ` [PATCH v5 21/26] ARM: dts: am437x: Provide NAND ready pin Roger Quadros
2016-02-19 21:15 ` [PATCH v5 22/26] ARM: dts: am335x: Fix NAND device nodes Roger Quadros
2016-02-19 21:15 ` [PATCH v5 23/26] ARM: dts: am335x: Provide NAND ready pin Roger Quadros
2016-02-19 21:15 ` [PATCH v5 24/26] ARM: dts: dm814x: Fix gpmc and NAND node Roger Quadros
2016-02-19 21:15 ` [PATCH v5 25/26] ARM: dts: dm816x: " Roger Quadros
2016-02-19 21:15 ` [PATCH v5 26/26] ARM: dts: omap3: Fix gpmc and NAND nodes Roger Quadros
2016-02-19 22:04 ` [PATCH v5 00/26] memory: omap-gpmc: mtd: nand: Support GPMC NAND on non-OMAP platforms Tony Lindgren
2016-02-22 10:15 ` Roger Quadros
2016-02-22 16:42 ` Tony Lindgren
2016-02-22 20:05 ` Roger Quadros
2016-02-29 16:25 ` Roger Quadros
2016-03-05 2:33 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455916548-3441-16-git-send-email-rogerq@ti.com \
--to=rogerq@ti.com \
--cc=computersforpeace@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=fcooper@ti.com \
--cc=javier@dowhile0.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®