From patchwork Mon Feb 11 17:10:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14744 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C70CD23DEA for ; Mon, 11 Feb 2013 17:11:32 +0000 (UTC) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by fiordland.canonical.com (Postfix) with ESMTP id 808DDA19245 for ; Mon, 11 Feb 2013 17:11:32 +0000 (UTC) Received: by mail-vc0-f170.google.com with SMTP id p16so3935461vcq.1 for ; Mon, 11 Feb 2013 09:11:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=jUHqBX54WUGhxss10XKOJUI8Pocl0frxmIZHay/6qXI=; b=H68v7EdaTFL7gpUd9WQw0J3XEhSJuaTTDZp1IaLos73sZcEPoaSHnKx1xpWfPajTUP 2x59iQfK3qNNpMc9CDHkdQ/QtHkDj59HwT2AKFBfYJ5h1QurQ2lPKnf+MUTXp8OUhoZy Q9A1wUxWpikbROSOKfrTkLJT7VBGVCnKArS5rLHMakZW3VFPm3wiPNVSJkFBUwb3zN5q ZIMsrbRuBAYeMJzwCRV034C7NK1YVZlyJ/xUMlP0+PSCiDEGCp51kBHzENIFvSCGnaiP JCpSnpIQE8rjcciAAG9VxmxvD9W4Vv/vpMyzcAEUN63hGnppED/uuRIjYqoLfKnR+oQe MuaQ== X-Received: by 10.220.219.204 with SMTP id hv12mr19588994vcb.71.1360602690559; Mon, 11 Feb 2013 09:11:30 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp107990vec; Mon, 11 Feb 2013 09:11:30 -0800 (PST) X-Received: by 10.50.189.193 with SMTP id gk1mr13083574igc.87.1360602689765; Mon, 11 Feb 2013 09:11:29 -0800 (PST) Received: from mail-da0-f49.google.com (mail-da0-f49.google.com [209.85.210.49]) by mx.google.com with ESMTPS id d8si37406412paz.19.2013.02.11.09.11.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Feb 2013 09:11:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.49 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.210.49; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.49 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) smtp.mail=haojian.zhuang@linaro.org Received: by mail-da0-f49.google.com with SMTP id t11so2816218daj.36 for ; Mon, 11 Feb 2013 09:11:29 -0800 (PST) X-Received: by 10.66.192.162 with SMTP id hh2mr28001750pac.79.1360602689153; Mon, 11 Feb 2013 09:11:29 -0800 (PST) Received: from localhost.localdomain ([27.115.121.35]) by mx.google.com with ESMTPS id m3sm67935973pav.4.2013.02.11.09.11.23 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Feb 2013 09:11:28 -0800 (PST) From: Haojian Zhuang To: shiraz.hashim@st.com, shiraz.linux.kernel@gmail.com, linux@arm.linux.org.uk, tony@atomide.com, linux-arm-kernel@lists.infradead.org, swarren@nvidia.com, grant.likely@secretlab.ca, linus.walleij@linaro.org Cc: patches@linaro.org, Haojian Zhuang Subject: [PATCH v8 03/12] gpio: pl061: allocate irq dynamically Date: Tue, 12 Feb 2013 01:10:50 +0800 Message-Id: <1360602659-4774-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360602659-4774-1-git-send-email-haojian.zhuang@linaro.org> References: <1360602659-4774-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQmBDLW5I3xcDuElZOTlpiWXXi2WW1cn74SU0m//GdY0YjDrr/vR+hcTPwNAH4UMplS/ZEbF In original implementation, irq base is always specified in platform data. If it's not specified, pl061 gpio driver can't pass the probe() function since irq base is missing. While moving to device tree, everything should be parsed from DTS file. So allocate irq dynamically for irq base. Signed-off-by: Haojian Zhuang --- drivers/gpio/gpio-pl061.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index b820869..1a6d05c 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -211,6 +212,10 @@ static void __init pl061_init_gc(struct pl061_gpio *chip, int irq_base) IRQ_GC_INIT_NESTED_LOCK, IRQ_NOREQUEST, 0); } +static const struct irq_domain_ops pl061_domain_ops = { + .xlate = irq_domain_xlate_twocell, +}; + static int pl061_probe(struct amba_device *adev, const struct amba_id *id) { struct device *dev = &adev->dev; @@ -225,10 +230,15 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) if (pdata) { chip->gc.base = pdata->gpio_base; chip->irq_base = pdata->irq_base; - } else if (adev->dev.of_node) { + } else { chip->gc.base = -1; - chip->irq_base = 0; - } else + chip->irq_base = -1; + } + chip->irq_base = irq_alloc_descs(chip->irq_base, 0, PL061_GPIO_NR, 0); + if (chip->irq_base < 0) + return chip->irq_base; + if (!irq_domain_add_legacy(adev->dev.of_node, PL061_GPIO_NR, + chip->irq_base, 0, &pl061_domain_ops, chip)) return -ENODEV; if (!devm_request_mem_region(dev, adev->res.start,