From patchwork Sat Feb 2 17:25:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14423 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 7E02B23F96 for ; Sat, 2 Feb 2013 17:26:34 +0000 (UTC) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by fiordland.canonical.com (Postfix) with ESMTP id 3D6C8A18DE8 for ; Sat, 2 Feb 2013 17:26:34 +0000 (UTC) Received: by mail-ve0-f181.google.com with SMTP id d10so3702593vea.40 for ; Sat, 02 Feb 2013 09:26:33 -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=g+8rfCsmUZjpJt7u5L6sKIyPuK51GPwe1N6XXSKcPQk=; b=KZh02kEGgeopELpkUBvtJbg+RRp9l1JBHNm7i+p2jzZfCkAShLrKEopKcV4uSkjIQW olVBCe1AXdC9yoriIGAtNKLV20T91AwkO9aJKmducM4CZOoZSrt2/rFMFZRPIj3ojskq d6puLhRsbjL8+RFdTu5rIyy2cK/vTNJLyOHoRIuCd1/WnnJlLx/pmDFw3v/nQg0zHgyt O9Gh4/9uHxf0zWy57t0PEcDbeu3loQnKTUSGPR2oB6QSTSGK4bX8vZvpcxeHMZut5t/X 11ftJtaJG3Cb97g0QdV7Oazr1pzwDF5egxEo55brNDjVjr1euD98thpYU5m9vaQ4aFrJ yLEw== X-Received: by 10.58.232.226 with SMTP id tr2mr10933797vec.48.1359825993728; Sat, 02 Feb 2013 09:26:33 -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 zo8csp16818vec; Sat, 2 Feb 2013 09:26:33 -0800 (PST) X-Received: by 10.68.228.74 with SMTP id sg10mr41902943pbc.162.1359825992708; Sat, 02 Feb 2013 09:26:32 -0800 (PST) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx.google.com with ESMTPS id ra6si11297007pbc.8.2013.02.02.09.26.32 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Feb 2013 09:26:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.220.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.52 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-pa0-f52.google.com with SMTP id fb1so1292833pad.25 for ; Sat, 02 Feb 2013 09:26:32 -0800 (PST) X-Received: by 10.68.202.97 with SMTP id kh1mr42695628pbc.91.1359825992268; Sat, 02 Feb 2013 09:26:32 -0800 (PST) Received: from localhost.localdomain ([27.115.121.35]) by mx.google.com with ESMTPS id b3sm10434040pax.14.2013.02.02.09.26.26 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Feb 2013 09:26:31 -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 Cc: patches@linaro.org, Haojian Zhuang Subject: [PATCH v8 04/12] gpio: pl061: allocate irq dynamically Date: Sun, 3 Feb 2013 01:25:45 +0800 Message-Id: <1359825953-15663-5-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359825953-15663-1-git-send-email-haojian.zhuang@linaro.org> References: <1359825953-15663-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQlAm4PgdbAhioMu7eAudAuR6loywXJQMI37vH7dAyTW29ydvSxULDxsZIuoa6ujKos6tc6M 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 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index b820869..fd26f63 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,14 @@ 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 = irq_alloc_descs(-1, 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,