From patchwork Thu Apr 25 10:20:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10916761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E98214DB for ; Thu, 25 Apr 2019 10:20:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D21328C33 for ; Thu, 25 Apr 2019 10:20:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 810D328C5E; Thu, 25 Apr 2019 10:20:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 162E928C33 for ; Thu, 25 Apr 2019 10:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ztKnkZWY3uALLFKi3GHZv1c+L3wA+h0VVIbkTCyAtR8=; b=lHZjDxX2Erd9zH /TyNQwZl3k/MVnSoz7f1PvEeUorNXtlh0gYJmUlS4MNf//vJcNFJuwHjE8gNSCsM3GJTyPayHza7A bH5veYOcIHreqfz2kahOMIy6YiS6iRoWLf3xT4GeEkxjcWh8ShTMOVJ9dMd8k6jS7/zyn8EQ6a8ab cCfyf8FWhZLhjJogqBR8YhFo7TT5wjN2sKQvKXItDkO9b4fNqy3WKoSnFZ8/HdCvrxXvTW4raFz3/ ivs2dxDjfUtDalW2VMoQ1GzUbtC8nSsDZuDNGWcPeUgCJHrcQ5B8EyHi0LrY/HZmYipqvlr5fpAkW SiTPTqQGFW0BR0aCJ+Uw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJbUh-000563-Si; Thu, 25 Apr 2019 10:20:43 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJbUQ-0004p0-68 for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2019 10:20:29 +0000 Received: by mail-wr1-x443.google.com with SMTP id g3so29492112wrx.9 for ; Thu, 25 Apr 2019 03:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dwxUX4ZrYJxHMDOfE3iUSJEsHb3GI7l9s+2/3rnu8fQ=; b=ApAtigqEc5FJzQDBggGDh4RZWVp7mPonV6ELb9WhOv/RfOXH4daHVpOF9Cf7213nmN sYgvlPjFfB077E198Qppx22/8v8oPV+bSNF0UMalrUK7oKg6i1V3V+q7rPJsMiBXMBHg zDaSLtXPnYP/5mhZZY/SUP+iT+iSDFlxpAW8E9RCSCvdIzL/2hSALvFIG9f4i62pq4Fv iL5eVD8SLoEyfm8+BMD6z0h1mOhGIuQb60nRzbihsrCmBSidjP95dt47mel29VtEgcFP TIJDRRtSrGfSh8w2Xq4NGleFDk2RR0h9XvCb9f+3KqFLPbQmPYavmHwlqjhTqUeCxff5 mCcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dwxUX4ZrYJxHMDOfE3iUSJEsHb3GI7l9s+2/3rnu8fQ=; b=GObbX83m+B2iuhtANINarkUErvbzk16vRkhdgk13RH1+s/xnPKtmfi1AQ5aoggir2+ T5Bz9rlYy2Jo5PAU7fqUXjXcp8Y5vpGZkzkIo7/evpIYANbp524dYT2xzRvUWlP+87WC CWndGnPKViKgQVe2WT+2UoOQJ9Kv8b1sHNyGWm1qsKAk5sRtcyZj05RhLTMxTy+JDifa v9RcpFGe/QC0ZxCaO8b3rnHkdY7c46vcQ/V224w3So+7PEywzPeL5sfDbLOnFSLAH/jA 72S2Mkdq4U7kYPo7eCcSJ6K5I3oFBpbEx9LxdZcUALQJz/opsMIT6+cXPpBhMj4NVDJ1 YN1g== X-Gm-Message-State: APjAAAXT1eb46EPfBJ+qpD1N5qH5ej9AEsGhZbht3k3xD1WrpiX8mwBw IOkHdQQqSnb6ZvYNEDRIC9vRHpZ/O1e7HA== X-Google-Smtp-Source: APXvYqz9Yyxk50etuyfwkPZNZ727oOlwdXNdR0MLFWP45ISkZ+g+pkevUNcVfwoywiaue9SyssIHpg== X-Received: by 2002:a5d:4087:: with SMTP id o7mr26597083wrp.9.1556187624228; Thu, 25 Apr 2019 03:20:24 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:95f:9014:5be9:5288]) by smtp.gmail.com with ESMTPSA id p18sm5611364wrp.38.2019.04.25.03.20.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 03:20:23 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 1/3] irqchip/exiu: preparatory refactor for ACPI support Date: Thu, 25 Apr 2019 12:20:18 +0200 Message-Id: <20190425102020.21533-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190425102020.21533-1-ard.biesheuvel@linaro.org> References: <20190425102020.21533-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190425_032026_272925_54D08DF3 X-CRM114-Status: GOOD ( 14.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Graeme Gregory , Ard Biesheuvel , Marc Zyngier , Linus Walleij , linux-gpio@vger.kernel.org, Masahisa Kojima Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation of exposing the EXIU controller as the irqchip part of the GPIO controller, split the DT init function in a DT specific and a generic part, where the latter will be reused for ACPI support later. Signed-off-by: Ard Biesheuvel --- drivers/irqchip/irq-sni-exiu.c | 77 ++++++++++++-------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/drivers/irqchip/irq-sni-exiu.c b/drivers/irqchip/irq-sni-exiu.c index 1927b2f36ff6..52ce662334d4 100644 --- a/drivers/irqchip/irq-sni-exiu.c +++ b/drivers/irqchip/irq-sni-exiu.c @@ -1,7 +1,7 @@ /* * Driver for Socionext External Interrupt Unit (EXIU) * - * Copyright (c) 2017 Linaro, Ltd. + * Copyright (c) 2017-2019 Linaro, Ltd. * * Based on irq-tegra.c: * Copyright (C) 2011 Google, Inc. @@ -167,35 +167,25 @@ static const struct irq_domain_ops exiu_domain_ops = { .free = irq_domain_free_irqs_common, }; -static int __init exiu_init(struct device_node *node, - struct device_node *parent) +static struct irq_domain *exiu_init(struct irq_domain *parent_domain, + struct fwnode_handle *fwnode, + struct resource *res) { - struct irq_domain *parent_domain, *domain; + struct irq_domain *domain; struct exiu_irq_data *data; int err; - if (!parent) { - pr_err("%pOF: no parent, giving up\n", node); - return -ENODEV; - } - - parent_domain = irq_find_host(parent); - if (!parent_domain) { - pr_err("%pOF: unable to obtain parent domain\n", node); - return -ENXIO; - } - data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - if (of_property_read_u32(node, "socionext,spi-base", &data->spi_base)) { - pr_err("%pOF: failed to parse 'spi-base' property\n", node); + if (fwnode_property_read_u32_array(fwnode, "socionext,spi-base", + &data->spi_base, 1)) { err = -ENODEV; goto out_free; } - data->base = of_iomap(node, 0); + data->base = ioremap(res->start, resource_size(res)); if (!data->base) { err = -ENODEV; goto out_free; @@ -205,23 +195,52 @@ static int __init exiu_init(struct device_node *node, writel_relaxed(0xFFFFFFFF, data->base + EIREQCLR); writel_relaxed(0xFFFFFFFF, data->base + EIMASK); - domain = irq_domain_add_hierarchy(parent_domain, 0, NUM_IRQS, node, - &exiu_domain_ops, data); + domain = irq_domain_create_hierarchy(parent_domain, 0, NUM_IRQS, + fwnode, &exiu_domain_ops, data); if (!domain) { - pr_err("%pOF: failed to allocate domain\n", node); err = -ENOMEM; goto out_unmap; } + return domain; +out_unmap: + iounmap(data->base); +out_free: + kfree(data); + return ERR_PTR(err); +} + +static int __init exiu_dt_init(struct device_node *node, + struct device_node *parent) +{ + struct irq_domain *parent_domain, *domain; + struct resource res; + + if (!parent) { + pr_err("%pOF: no parent, giving up\n", node); + return -ENODEV; + } + + parent_domain = irq_find_host(parent); + if (!parent_domain) { + pr_err("%pOF: unable to obtain parent domain\n", node); + return -ENXIO; + } + + if (of_address_to_resource(node, 0, &res)) { + pr_err("%pOF: failed to parse memory resource\n", node); + return -ENXIO; + } + + domain = exiu_init(parent_domain, of_node_to_fwnode(node), &res); + if (IS_ERR(domain)) { + pr_err("%pOF: failed to create IRQ domain (%ld)\n", node, + PTR_ERR(domain)); + return PTR_ERR(domain); + } pr_info("%pOF: %d interrupts forwarded to %pOF\n", node, NUM_IRQS, parent); return 0; - -out_unmap: - iounmap(data->base); -out_free: - kfree(data); - return err; } -IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_init); +IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_dt_init);