From patchwork Fri Jun 21 08:27:39 2013
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 2761001
Return-Path:
X-Original-To: patchwork-linux-arm@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.19.201])
by patchwork1.web.kernel.org (Postfix) with ESMTP id 30E879F756
for ;
Fri, 21 Jun 2013 08:29:20 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id F1F8A20185
for ;
Fri, 21 Jun 2013 08:29:18 +0000 (UTC)
Received: from casper.infradead.org (casper.infradead.org [85.118.1.10])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 721EA20123
for ;
Fri, 21 Jun 2013 08:29:17 +0000 (UTC)
Received: from merlin.infradead.org ([2001:4978:20e::2])
by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux))
id 1Upwhr-0002mT-Sz; Fri, 21 Jun 2013 08:28:32 +0000
Received: from localhost ([::1] helo=merlin.infradead.org)
by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux))
id 1Upwhi-0003yW-Dp; Fri, 21 Jun 2013 08:28:22 +0000
Received: from metis.ext.pengutronix.de
([2001:6f8:1178:4:290:27ff:fe1d:cc33])
by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux))
id 1UpwhW-0003wd-KX for linux-arm-kernel@lists.infradead.org;
Fri, 21 Jun 2013 08:28:12 +0000
Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de)
by metis.ext.pengutronix.de with esmtp (Exim 4.72)
(envelope-from )
id 1Upwh3-0007fM-FU; Fri, 21 Jun 2013 10:27:41 +0200
From: Philipp Zabel
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] staging: drm/imx: convert IPU irq driver to
irq_domain_add_linear
Date: Fri, 21 Jun 2013 10:27:39 +0200
Message-Id: <1371803259-18369-3-git-send-email-p.zabel@pengutronix.de>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1371803259-18369-1-git-send-email-p.zabel@pengutronix.de>
References: <1371803259-18369-1-git-send-email-p.zabel@pengutronix.de>
X-SA-Exim-Connect-IP: 10.1.0.7
X-SA-Exim-Mail-From: p.zabel@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de);
SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20130621_042811_125564_DEB12C46
X-CRM114-Status: GOOD ( 22.75 )
X-Spam-Score: -3.2 (---)
Cc: kernel@pengutronix.de, Greg Kroah-Hartman ,
dri-devel@lists.freedesktop.org, Philipp Zabel ,
Shawn Guo , Fabio Estevam
X-BeenThere: linux-arm-kernel@lists.infradead.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id:
List-Unsubscribe:
,
List-Archive:
List-Post:
List-Help:
List-Subscribe:
,
MIME-Version: 1.0
Sender: "linux-arm-kernel"
Errors-To:
linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org
X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED,
RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP
The IPU has a lot of interrupts. Instead of allocating descs for all
of them, register a linear irq domain and create mappings as needed.
This was listed in the TODO as a prerequisite to move the IPU driver
out of staging.
Signed-off-by: Philipp Zabel
---
drivers/staging/imx-drm/TODO | 1 -
drivers/staging/imx-drm/ipu-v3/ipu-common.c | 66 +++++++++++++++++++----------
drivers/staging/imx-drm/ipu-v3/ipu-prv.h | 2 +-
3 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/imx-drm/TODO b/drivers/staging/imx-drm/TODO
index 123acbe..f806415 100644
--- a/drivers/staging/imx-drm/TODO
+++ b/drivers/staging/imx-drm/TODO
@@ -6,7 +6,6 @@ TODO:
- Factor out more code to common helper functions
- decide where to put the base driver. It is not specific to a subsystem
and would be used by DRM/KMS and media/V4L2
-- convert irq driver to irq_domain_add_linear
Missing features (not necessarily for moving out of staging):
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c
index 0127601..1a7b59e 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include
#include "imx-ipu-v3.h"
@@ -799,16 +800,18 @@ err_di_0:
static void ipu_irq_handle(struct ipu_soc *ipu, const int *regs, int num_regs)
{
unsigned long status;
- int i, bit, irq_base;
+ int i, bit, irq;
for (i = 0; i < num_regs; i++) {
status = ipu_cm_read(ipu, IPU_INT_STAT(regs[i]));
status &= ipu_cm_read(ipu, IPU_INT_CTRL(regs[i]));
- irq_base = ipu->irq_start + regs[i] * 32;
- for_each_set_bit(bit, &status, 32)
- generic_handle_irq(irq_base + bit);
+ for_each_set_bit(bit, &status, 32) {
+ irq = irq_linear_revmap(ipu->domain, regs[i] * 32 + bit);
+ if (irq)
+ generic_handle_irq(irq);
+ }
}
}
@@ -841,7 +844,7 @@ static void ipu_err_irq_handler(unsigned int irq, struct irq_desc *desc)
static void ipu_ack_irq(struct irq_data *d)
{
struct ipu_soc *ipu = irq_data_get_irq_chip_data(d);
- unsigned int irq = d->irq - ipu->irq_start;
+ irq_hw_number_t irq = d->hwirq;
ipu_cm_write(ipu, 1 << (irq % 32), IPU_INT_STAT(irq / 32));
}
@@ -849,7 +852,7 @@ static void ipu_ack_irq(struct irq_data *d)
static void ipu_unmask_irq(struct irq_data *d)
{
struct ipu_soc *ipu = irq_data_get_irq_chip_data(d);
- unsigned int irq = d->irq - ipu->irq_start;
+ irq_hw_number_t irq = d->hwirq;
unsigned long flags;
u32 reg;
@@ -865,7 +868,7 @@ static void ipu_unmask_irq(struct irq_data *d)
static void ipu_mask_irq(struct irq_data *d)
{
struct ipu_soc *ipu = irq_data_get_irq_chip_data(d);
- unsigned int irq = d->irq - ipu->irq_start;
+ irq_hw_number_t irq = d->hwirq;
unsigned long flags;
u32 reg;
@@ -888,7 +891,12 @@ static struct irq_chip ipu_irq_chip = {
int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
enum ipu_channel_irq irq_type)
{
- return ipu->irq_start + irq_type + channel->num;
+ int irq = irq_linear_revmap(ipu->domain, irq_type + channel->num);
+
+ if (!irq)
+ irq = irq_create_mapping(ipu->domain, irq_type + channel->num);
+
+ return irq;
}
EXPORT_SYMBOL_GPL(ipu_idmac_channel_irq);
@@ -975,18 +983,30 @@ err_register:
return ret;
}
-static int ipu_irq_init(struct ipu_soc *ipu)
+static int ipu_irq_map(struct irq_domain *h, unsigned int irq,
+ irq_hw_number_t hw)
{
- int i;
+ struct ipu_soc *ipu = h->host_data;
+
+ irq_set_chip_and_handler(irq, &ipu_irq_chip, handle_level_irq);
+ set_irq_flags(irq, IRQF_VALID);
+ irq_set_chip_data(irq, ipu);
+
+ return 0;
+}
- ipu->irq_start = irq_alloc_descs(-1, 0, IPU_NUM_IRQS, 0);
- if (ipu->irq_start < 0)
- return ipu->irq_start;
+const struct irq_domain_ops ipu_irq_domain_ops = {
+ .map = ipu_irq_map,
+ .xlate = irq_domain_xlate_onecell,
+};
- for (i = ipu->irq_start; i < ipu->irq_start + IPU_NUM_IRQS; i++) {
- irq_set_chip_and_handler(i, &ipu_irq_chip, handle_level_irq);
- set_irq_flags(i, IRQF_VALID);
- irq_set_chip_data(i, ipu);
+static int ipu_irq_init(struct ipu_soc *ipu)
+{
+ ipu->domain = irq_domain_add_linear(ipu->dev->of_node, IPU_NUM_IRQS,
+ &ipu_irq_domain_ops, ipu);
+ if (!ipu->domain) {
+ dev_err(ipu->dev, "failed to add irq domain\n");
+ return -ENODEV;
}
irq_set_chained_handler(ipu->irq_sync, ipu_irq_handler);
@@ -999,20 +1019,20 @@ static int ipu_irq_init(struct ipu_soc *ipu)
static void ipu_irq_exit(struct ipu_soc *ipu)
{
- int i;
+ int i, irq;
irq_set_chained_handler(ipu->irq_err, NULL);
irq_set_handler_data(ipu->irq_err, NULL);
irq_set_chained_handler(ipu->irq_sync, NULL);
irq_set_handler_data(ipu->irq_sync, NULL);
- for (i = ipu->irq_start; i < ipu->irq_start + IPU_NUM_IRQS; i++) {
- set_irq_flags(i, 0);
- irq_set_chip(i, NULL);
- irq_set_chip_data(i, NULL);
+ for (i = 0; i < IPU_NUM_IRQS; i++) {
+ irq = irq_linear_revmap(ipu->domain, i);
+ if (irq)
+ irq_dispose_mapping(irq);
}
- irq_free_descs(ipu->irq_start, IPU_NUM_IRQS);
+ irq_domain_remove(ipu->domain);
}
static int ipu_probe(struct platform_device *pdev)
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h b/drivers/staging/imx-drm/ipu-v3/ipu-prv.h
index 12d7eaf..4df0050 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-prv.h
@@ -170,9 +170,9 @@ struct ipu_soc {
struct ipuv3_channel channel[64];
- int irq_start;
int irq_sync;
int irq_err;
+ struct irq_domain *domain;
struct ipu_dc_priv *dc_priv;
struct ipu_dp_priv *dp_priv;