From patchwork Tue May 28 13:36:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10964941 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 47F866C5 for ; Tue, 28 May 2019 13:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36A651FE8A for ; Tue, 28 May 2019 13:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A86526E78; Tue, 28 May 2019 13:37:23 +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=unavailable 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 BEE181FE8A for ; Tue, 28 May 2019 13:37:22 +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=ak8ixTzSceeVOksVhX//5DVOR7w2KKPZ+n4ok1F5yaY=; b=jYs0fef1bRHr+v lY/e9fVFId/rxZ7idzK8U4u0LNvt2pEQdG29BbC2iwBo+SLs3Ge6CXQoiMeHClYQSDRFX26D/+KmR XzI8JM0lUPyg+rlzGVx8/zkFaGLGPcidlkqb2KsDgVZ9BCTJDmIS5vlSz4qtxBn6pQMXr5SRjUSWi StENKS6D3QhgFg1TLUISebnjMmlkSzyGW/CQkUNIFg2LqZrmjIoiFQAtOn7xuvAcyd58v7aYzpw1i OwnLR6HsySR3nxxTfeDmmg/BefpMay2SeJ8484RhbNc4lxkqNSYu749Zj4//gWrqk1b3z0I2W9lP7 kOFmmstuzKhYI/zbt6Zw==; 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 1hVcHz-0007sJ-4r; Tue, 28 May 2019 13:37:15 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVcHm-0007a3-SX for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2019 13:37:06 +0000 Received: by mail-wr1-x441.google.com with SMTP id c2so5076624wrm.8 for ; Tue, 28 May 2019 06:36:59 -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=Ce8JB4XUI/WvY+NITbCG46XF1cnECw0qEl06Q1Mp/6Q=; b=P/jGceWxx8v4ni8+lxF2N/eLIfQmpPLTRxWN2UiaK2Bp1kohbPKJIrNXBc7yP+Ph/b XT7wb92Kbe06wMgapYg99AEwL1lrR+r2KY5jX8JOPyIhRYlC2hD1ZXIKZylwz5WYff8J 95YCxb0D/XNQOzuA2qIt4qUrIj+OOwhHjlnhwgxIZXJ+hBVMbv6zd2DOCooJKyWH+vtD 3n4qdvaqtCopkxCxkMRVvJBtXaSVdKmqjKw1A/TUEIsKXm0xGrssVJ66v+bE4N1JYRy2 TQOSN1fppopXHuPcLxN3r3xxVco9Xphd6RhQNBDHZVTySETNbp7npBDN2cJ/riXq3EBO OgUw== 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=Ce8JB4XUI/WvY+NITbCG46XF1cnECw0qEl06Q1Mp/6Q=; b=nnGzE0ZFUx6nydGbsrOGbv3WmnQS5ZvoRTR6Z85DbzBbGLrBhZoJ4wv0raI4NmzLAP gQbne/ugMEEKD7ix5yfUkMUFh1oVSRaGvwG3qyHuu+jgSADIfAkDxOxwdnR3B4O682+D uSXRKEPljOIDN9BfCR/OpK/RG1dWHLBEuiPZzq9YgNPYwOU1/ZGq8AUe35zama947FOB +4kZxLX9xrR+GnTdPlzRoQqJTLD4G42dbvIN250gXVGB4ZCyEApC0enwqn5NpZs4FpVN rr/ilfgz7yL4TGvZov5Ub56osbC2jBDFvD2mSGJug1n5XFvPHCrYL8OEsTTiLpkcUnhx c8sQ== X-Gm-Message-State: APjAAAWDBMe86Y4ls3RkZbyYnWlW50pptwrwxC2MYpH59s9NF4sc7BqY rUT6EWov+/CkymM0qv5bijRGSxPFv5JChw== X-Google-Smtp-Source: APXvYqx2CE57SmrhiCjOkLL+8sPrYUtF2G/COWgH9e10bLXzDIkX0v+1Au3LnYdN5q2CDra5lG5b2Q== X-Received: by 2002:adf:f246:: with SMTP id b6mr4672878wrp.92.1559050617427; Tue, 28 May 2019 06:36:57 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:c8c7:f81b:b165:1aa7]) by smtp.gmail.com with ESMTPSA id 95sm8652668wrk.70.2019.05.28.06.36.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 06:36:56 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 1/4] acpi/irq: implement helper to create hierachical domains Date: Tue, 28 May 2019 15:36:44 +0200 Message-Id: <20190528133647.3362-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528133647.3362-1-ard.biesheuvel@linaro.org> References: <20190528133647.3362-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-20190528_063703_197646_4919FB60 X-CRM114-Status: GOOD ( 14.85 ) 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: Lorenzo Pieralisi , Graeme Gregory , Ard Biesheuvel , Marc Zyngier , Linus Walleij , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, Masahisa Kojima , Mika Westerberg , Len Brown 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 ACPI permits arbitrary producer->consumer interrupt links to be described in AML, which means a topology such as the following is perfectly legal: Device (EXIU) { Name (_HID, "SCX0008") Name (_UID, Zero) Name (_CRS, ResourceTemplate () { ... }) } Device (GPIO) { Name (_HID, "SCX0007") Name (_UID, Zero) Name (_CRS, ResourceTemplate () { Memory32Fixed (ReadWrite, SYNQUACER_GPIO_BASE, SYNQUACER_GPIO_SIZE) Interrupt (ResourceConsumer, Edge, ActiveHigh, ExclusiveAndWake, 0, "\\_SB.EXIU") { 7, } }) ... } The EXIU in this example is the external interrupt unit as can be found on Socionext SynQuacer based platforms, which converts a block of 32 SPIs from arbitrary polarity/trigger into level-high, with a separate set of config/mask/unmask/clear controls. The existing DT based driver in drivers/irqchip/irq-sni-exiu.c models this as a hierarchical domain stacked on top of the GIC's irqdomain. Since the GIC is modeled as a DT node as well, obtaining a reference to this irqdomain is easily done by going through the parent link. On ACPI systems, however, the GIC is not modeled as an object in the namespace, and so device objects cannot refer to it directly. So in order to obtain the irqdomain reference when driving the EXIU in ACPI mode, we need a helper that implicitly grabs the default domain as the parent of the hierarchy for interrupts allocated out of the global GSI pool. Reviewed-by: Mika Westerberg Reviewed-by: Lorenzo Pieralisi Signed-off-by: Ard Biesheuvel Acked-by: Rafael J. Wysocki --- drivers/acpi/irq.c | 26 ++++++++++++++++++++ include/linux/acpi.h | 7 ++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index c3b2222e2129..ce6b25a3b7a7 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -295,3 +295,29 @@ void __init acpi_set_irq_model(enum acpi_irq_model_id model, acpi_irq_model = model; acpi_gsi_domain_id = fwnode; } + +/** + * acpi_irq_create_hierarchy - Create a hierarchical IRQ domain with the default + * GSI domain as its parent. + * @flags: Irq domain flags associated with the domain + * @size: Size of the domain. + * @fwnode: Optional fwnode of the interrupt controller + * @ops: Pointer to the interrupt domain callbacks + * @host_data: Controller private data pointer + */ +struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, + unsigned int size, + struct fwnode_handle *fwnode, + const struct irq_domain_ops *ops, + void *host_data) +{ + struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id, + DOMAIN_BUS_ANY); + + if (!d) + return NULL; + + return irq_domain_create_hierarchy(d, flags, size, fwnode, ops, + host_data); +} +EXPORT_SYMBOL_GPL(acpi_irq_create_hierarchy); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 98440df7fe42..70de4bc30cea 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -23,6 +23,7 @@ #include #include /* for struct resource */ +#include #include #include #include @@ -327,6 +328,12 @@ int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); void acpi_set_irq_model(enum acpi_irq_model_id model, struct fwnode_handle *fwnode); +struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, + unsigned int size, + struct fwnode_handle *fwnode, + const struct irq_domain_ops *ops, + void *host_data); + #ifdef CONFIG_X86_IO_APIC extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); #else From patchwork Tue May 28 13:36:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10964945 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 C319A92A for ; Tue, 28 May 2019 13:37:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B05281FE8A for ; Tue, 28 May 2019 13:37:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A494626E78; Tue, 28 May 2019 13:37:44 +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=unavailable 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 3AC551FE8A for ; Tue, 28 May 2019 13:37:44 +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=i7GvPcirmEPVQ5PAto6JaP95Q9FWfPX2T5XdDCC3FBo=; b=TjmioKmdqDbzR5 UHwejh24XWx5BeNzI5WBBba1CmNql1Gk8Yyv6mwMIHi9Osr1teAGsn2BpN/RbA3+2S6iZXBK+CUOf XLhBl7zhgluGW32NNl4ZqeUzcIpNKTDtRWtS6NTTZor22HoFiPcr5ClcAKIm6doE8C5GJ81MS36do gFmqFNwnhca/ILIFvjUC6WwoF3yJytDGwg5pYwjC9s+TNDBt43O7O35r5qUdGu6oL5wT5dDQ/e4y9 3p6Yz7w8joWLbBKAHsxM9j8tjpvEPC0yZl7INdkU5R/fO6/sCryHW7lzqfQcWTbBZ7VEpYU3XLmvY oxnuZIjHcuFoEyxTemXg==; 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 1hVcIM-0008Sq-KS; Tue, 28 May 2019 13:37:38 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVcHn-0007ab-78 for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2019 13:37:09 +0000 Received: by mail-wr1-x444.google.com with SMTP id f8so20304131wrt.1 for ; Tue, 28 May 2019 06:37:00 -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=pKi5I0CJ2X5BwXo9XUNw8Vf2df15TmcuH8E+kJajjPM=; b=F8I9p3bL+LGHWYM0cDRoIfv/oll5sukRT/lGhl09pcWmcIIg4JN0g0+DsdYLJRi2bP yskq1Sp0jQ5h1tBlreOvMQ2S8ubx1qO7Rmr/FH7Yt4xkT8roE4MAlc1hqk7ak5TzxwXE tOhQye6SUer1FeoaD/NAdqeRYEleErUJj0NhkYvRmswuWizzRI0SpbwWHu+D0KaS+ate tII4sHG+2uvOvpLawOtJ3an3bKhVdBR1fs1BV/lvtEKVyVUQUPmUnsSrxD+1Us5Bqxpb Y1/0drDRdtcQq5eNKk7rC7S/uNcwwcBwpiV+i27LB2FbvGeygDTwCxh2VB4w8NNqmssC Htdw== 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=pKi5I0CJ2X5BwXo9XUNw8Vf2df15TmcuH8E+kJajjPM=; b=XWEZI+HihqtxRQhqI8aRF+SSvwBtumoA8N/GPTq8P8kUaAVOgQVuf8T/VI033OBiR4 IthN/1LtgFlKgGJsRfuRDKJB1za5FfdbCX2wzkVW/YcLN3J3rSUb/gfBWdej9lqp2hOJ nVaP3rvbEamFOpxqRvGio9OuARKl/A70J3OwxBBJ/ToEZV9ok6s5f77pwDj5WOrUNt9R 5911AsET9dqfal0kO3O+iyoDw/cgFfU06kJBg+//1RdFyq9uWlBCtbIiSBXxtzwYoyum 727Qd7AR+W9EjnR6l1kKRaneMA1H9H+fd9XTDi50GBtQ94URTt0mX61lY4CM8oksBgFj +LSA== X-Gm-Message-State: APjAAAU8LFJXU25G5ztnHAxwlzcOrw3KUUjyMVrqStNdDgIhGRu6HEVX /YmxCcF9mS22/hIm40fELtVbn8pqrfNMtw== X-Google-Smtp-Source: APXvYqwmPaw/5aVvrO07/ESg5V589aa2lSQdjDvQNt6Rzy1gIbgYVlnIWjxvFRsuKAOtEehBHTjUOw== X-Received: by 2002:adf:f00d:: with SMTP id j13mr5090883wro.178.1559050618688; Tue, 28 May 2019 06:36:58 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:c8c7:f81b:b165:1aa7]) by smtp.gmail.com with ESMTPSA id 95sm8652668wrk.70.2019.05.28.06.36.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 06:36:58 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/4] irqchip/exiu: preparatory refactor for ACPI support Date: Tue, 28 May 2019 15:36:45 +0200 Message-Id: <20190528133647.3362-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528133647.3362-1-ard.biesheuvel@linaro.org> References: <20190528133647.3362-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-20190528_063703_728476_F3B96269 X-CRM114-Status: GOOD ( 15.03 ) 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: Lorenzo Pieralisi , Graeme Gregory , Ard Biesheuvel , Marc Zyngier , Linus Walleij , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, Masahisa Kojima , Mika Westerberg , Len Brown 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 adding support for EXIU controller devices described via ACPI, 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 | 66 +++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/drivers/irqchip/irq-sni-exiu.c b/drivers/irqchip/irq-sni-exiu.c index 1927b2f36ff6..fef7c2437dfb 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,23 @@ 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 exiu_irq_data *exiu_init(const struct fwnode_handle *fwnode, + struct resource *res) { - struct irq_domain *parent_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,11 +193,44 @@ static int __init exiu_init(struct device_node *node, writel_relaxed(0xFFFFFFFF, data->base + EIREQCLR); writel_relaxed(0xFFFFFFFF, data->base + EIMASK); + return data; + +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 exiu_irq_data *data; + 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; + } + + data = exiu_init(of_node_to_fwnode(node), &res); + if (IS_ERR(data)) + return PTR_ERR(data); + domain = irq_domain_add_hierarchy(parent_domain, 0, NUM_IRQS, node, &exiu_domain_ops, data); if (!domain) { pr_err("%pOF: failed to allocate domain\n", node); - err = -ENOMEM; goto out_unmap; } @@ -220,8 +241,7 @@ static int __init exiu_init(struct device_node *node, out_unmap: iounmap(data->base); -out_free: kfree(data); - return err; + return -ENOMEM; } -IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_init); +IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_dt_init); From patchwork Tue May 28 13:36:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10964943 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 DD0306C5 for ; Tue, 28 May 2019 13:37:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC8851FE8A for ; Tue, 28 May 2019 13:37:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C08E526E78; Tue, 28 May 2019 13:37:30 +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=unavailable 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 623271FE8A for ; Tue, 28 May 2019 13:37:30 +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=3xASpbhLLLwlggLV9OIgvXy+HLeR4NxqDD6JLkF3BAQ=; b=uaz0Rohhjketkz xl5xDDkH2bv+49wYwEO5brNeuBoSvtxjR+/y9YzOGNVF3jzKG5oWkYXvGWoRENKv0Af3DWFoTPybr 0AHaVlHq4+CohWoZgZf7dufVrvKNMY+b7qClfd0VNfY3GvfaMoqLQWJ+YvNWsPqgIvwnVL/ENbxjy RnFMFW2J8BBYawVLSVMGqovAy5rSMlacdByz0BT4wFraXKcIZpHDElGfEbLJacgI1TiEUy7uG+UC3 s7PROlw3PeML1Lj4gr1EHwbM8X9NJ3ANxpMJLT9OLTqFzEWvoVFt25kgB6SHL1vdxkRDMSAiKIalw SYDomOvEdh4wGx3Vlo5A==; 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 1hVcIC-0008Bc-KI; Tue, 28 May 2019 13:37:28 +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 1hVcHm-0007bJ-WC for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2019 13:37:07 +0000 Received: by mail-wr1-x443.google.com with SMTP id f8so20304212wrt.1 for ; Tue, 28 May 2019 06:37:01 -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=ds56CQkAv670ntBJCxp4IuqDeQwQznKOl9murxD3/48=; b=xBkQ++s/BFIGDL4wQxDNtxhdWbOBqFvUU8rn7YRmvpFNqMiQ7KyWXOv+uPsPf2CR8Z IExLhc6FzLUKZFPgkNsi+Z+c/v871LUTEnnqLkU+UIyIT4JR/heJSuj/jMIO0LCzxfim 3QwjR9u4xrRYqU90W3Kjk6rG4i14VKaKT0oTWMi8FP5W1VItas8JVBaq49DYC3v1nIs4 KossB59WaMSJezPB8qllcvt1+3l4/8NwaUivh9bzbx6V3S8o7ntV1x/t68JbYl7DAKsc IUkA20CKvg/OpQkG0C8Hh0sWW+TONvGYtudSW8MxFZEorkaUojP7fSC8CoplIfYQTtCI 5MLg== 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=ds56CQkAv670ntBJCxp4IuqDeQwQznKOl9murxD3/48=; b=VqrPBDHopKJ7KTNz2gcE7hoReJmwqmRBxIme8Vs9sd1cWFeZmiCAYUeE30McUwXnyS ZifZtHRb+1lIzeq5JQxZobJ8FIBeIx9ZSBtDUk+7CRye7t/++fAE/b8gAD2yW6/fNUM8 KqO8kmNfqdMfSefZE+GTgJFlekYqSymmqYCsWmyQ44Z3xccAb6txXY06T7PKJ8bWgjk/ eBc2+GCzntrR41+emJRKxEvcoQ1CKbl6XGbOD7l1wRCkg4Jeexxskde8vB0bHBzwkNvP F0JPPLOBY5Q9KZXtJLM7TKtJHPwrULvJu78WLYL4vcdYfog48nrdh79pFH7rjUAKuB2s raZw== X-Gm-Message-State: APjAAAU384VmYhVsofQFHZ1ayeEkQvWn3zp6tsPVjAl7LaVeFz8T7vsh ZpW+DSk+NxTlLq+x9mQrp8IeIog+rrxlqw== X-Google-Smtp-Source: APXvYqzd4VklYkD2c8O7aaDf1GHCGdPU58iygopVD5DNArmfwcmrWnemCrQp6+0DGMQpCnxY5it8WA== X-Received: by 2002:adf:ef83:: with SMTP id d3mr5532806wro.253.1559050620184; Tue, 28 May 2019 06:37:00 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:c8c7:f81b:b165:1aa7]) by smtp.gmail.com with ESMTPSA id 95sm8652668wrk.70.2019.05.28.06.36.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 06:36:59 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 3/4] irqchip/exiu: implement ACPI support Date: Tue, 28 May 2019 15:36:46 +0200 Message-Id: <20190528133647.3362-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528133647.3362-1-ard.biesheuvel@linaro.org> References: <20190528133647.3362-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-20190528_063703_214577_2214F859 X-CRM114-Status: GOOD ( 16.82 ) 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: Lorenzo Pieralisi , Graeme Gregory , Ard Biesheuvel , Marc Zyngier , Linus Walleij , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, Masahisa Kojima , Mika Westerberg , Len Brown 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 Expose the existing EXIU hierarchical irqchip domain code to permit the interrupt controller to be used as the irqchip component of a GPIO controller on ACPI systems, or as the target of ordinary interrupt resources. Reviewed-by: Mika Westerberg Signed-off-by: Ard Biesheuvel --- drivers/irqchip/irq-sni-exiu.c | 76 +++++++++++++++++--- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-sni-exiu.c b/drivers/irqchip/irq-sni-exiu.c index fef7c2437dfb..30a323a2b332 100644 --- a/drivers/irqchip/irq-sni-exiu.c +++ b/drivers/irqchip/irq-sni-exiu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -134,9 +135,13 @@ static int exiu_domain_translate(struct irq_domain *domain, *hwirq = fwspec->param[1] - info->spi_base; *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK; - return 0; + } else { + if (fwspec->param_count != 2) + return -EINVAL; + *hwirq = fwspec->param[0]; + *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK; } - return -EINVAL; + return 0; } static int exiu_domain_alloc(struct irq_domain *dom, unsigned int virq, @@ -147,16 +152,21 @@ static int exiu_domain_alloc(struct irq_domain *dom, unsigned int virq, struct exiu_irq_data *info = dom->host_data; irq_hw_number_t hwirq; - if (fwspec->param_count != 3) - return -EINVAL; /* Not GIC compliant */ - if (fwspec->param[0] != GIC_SPI) - return -EINVAL; /* No PPI should point to this domain */ + parent_fwspec = *fwspec; + if (is_of_node(dom->parent->fwnode)) { + if (fwspec->param_count != 3) + return -EINVAL; /* Not GIC compliant */ + if (fwspec->param[0] != GIC_SPI) + return -EINVAL; /* No PPI should point to this domain */ + hwirq = fwspec->param[1] - info->spi_base; + } else { + hwirq = fwspec->param[0]; + parent_fwspec.param[0] = hwirq + info->spi_base + 32; + } WARN_ON(nr_irqs != 1); - hwirq = fwspec->param[1] - info->spi_base; irq_domain_set_hwirq_and_chip(dom, virq, hwirq, &exiu_irq_chip, info); - parent_fwspec = *fwspec; parent_fwspec.fwnode = dom->parent->fwnode; return irq_domain_alloc_irqs_parent(dom, virq, nr_irqs, &parent_fwspec); } @@ -245,3 +255,53 @@ static int __init exiu_dt_init(struct device_node *node, return -ENOMEM; } IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_dt_init); + +#ifdef CONFIG_ACPI +static int exiu_acpi_probe(struct platform_device *pdev) +{ + struct irq_domain *domain; + struct exiu_irq_data *data; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "failed to parse memory resource\n"); + return -ENXIO; + } + + data = exiu_init(dev_fwnode(&pdev->dev), res); + if (IS_ERR(data)) + return PTR_ERR(data); + + domain = acpi_irq_create_hierarchy(0, NUM_IRQS, dev_fwnode(&pdev->dev), + &exiu_domain_ops, data); + if (!domain) { + dev_err(&pdev->dev, "failed to create IRQ domain\n"); + goto out_unmap; + } + + dev_info(&pdev->dev, "%d interrupts forwarded\n", NUM_IRQS); + + return 0; + +out_unmap: + iounmap(data->base); + kfree(data); + return -ENOMEM; +} + +static const struct acpi_device_id exiu_acpi_ids[] = { + { "SCX0008" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(acpi, exiu_acpi_ids); + +static struct platform_driver exiu_driver = { + .driver = { + .name = "exiu", + .acpi_match_table = exiu_acpi_ids, + }, + .probe = exiu_acpi_probe, +}; +builtin_platform_driver(exiu_driver); +#endif From patchwork Tue May 28 13:36:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10964947 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 D81B492A for ; Tue, 28 May 2019 13:37:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1EAB1FE8A for ; Tue, 28 May 2019 13:37:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B071B26E78; Tue, 28 May 2019 13:37:58 +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=unavailable 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 4A8651FE8A for ; Tue, 28 May 2019 13:37:58 +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=Gvr2Di6ZGAjoZHJPvN2Vgg8WU2Xnlm+n1hr2f9fYzOs=; b=Og36vPUOw9d+fY i2g3woSZAXSb28k6NJGbDgTfmv+MRxWadfyszcBlep2tZ7BMbB3uG5VOzeTK7C5Nnc0LDj2kYeK/+ Y+YMcUruP9Yt2jWBqZHtPOtVAAi8QxtVLykLtdC4dN4ch00412Alh3iTYaK0FpNPzqgripzCsgmuK eMeTJmKyVJ5uyqSg6LZN9w9B8WUriNyYZRu3WvwBm81UXtfkqd8GdWNGM1NWaZW24TGZbY3/LXkOd pLtxxrggVpFe3eSCZzQM1yPkfvcr5+1SGFtmb71eOhdW4AaJkne0L6J1KLeKr3K6NtGN4xxvhFqvM z45jxyuoD79iNULCra7g==; 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 1hVcIY-0000GF-RT; Tue, 28 May 2019 13:37:50 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVcHp-0007cN-6B for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2019 13:37:09 +0000 Received: by mail-wm1-x344.google.com with SMTP id v22so2907639wml.1 for ; Tue, 28 May 2019 06:37:03 -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=bbidxiifh4zQbXF3+idClmgRZbbOXntRKLhQM+IruEA=; b=g9r4++eHwLh867+bZIoekdLRqjajwptL/liJwhVXgwhBPKGDq91Utht30DkTs2rLA8 6XkZmrhQcku9bdDJTCKfx17EMKG6UICuzY5+k7bio0APavWFb1UXXUtuLP23415dIlJ5 1/qnuMXVHlchnfPwtC4zFsD+ggvXQb4K49gfJ78eW6fOT59rbcBOhhFX8ApU8uOxMamh BBsA6HpW9Srs9QxHDkGywSvzGNL4W/T9PYNBhPl9B0otlG7uEaS1eNIOICTLyXVwZ1+j STdHEgUqufGyFsqmmYUwtRq+5AcF9kTkB+83hQpFzdP/ZS4VF9RRE0DEMTMpkXTkn+ab 4/mA== 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=bbidxiifh4zQbXF3+idClmgRZbbOXntRKLhQM+IruEA=; b=UHXcVcn+dgPL/br/Q7ytX/6cDLbaOOIvQdeTBTHFHhKId419BNYaB4mlb975shs7eD Rb9TEuKRbbgMEHJ+zqEAgoqzRXqpJfWTgFfeIJFNRyJCfE/D4eCt5pYIOm8fAAW2JO5g hViGkePJjp7Cxh2LtivrvVMeFXeq/798fcF2PawsWm7YZrXg6+vvk7rxLJ5VEbd2ANKr +Qn+ge9K8zpWtx+uJ2qvC675VE3DPyqeFD/w+/qJfIUJ30buceS74Oc2buHBAfEReRuu NYCGomb8lWBe/pPVsKCcCE8q/nGdlhXERRlbzVEx5QejkXjBucHkAUVTntcARO0vjA/h rrqQ== X-Gm-Message-State: APjAAAVi71sn2a/CZ8+J+9CZnRRLqQMZ/BuCaF1Ef6PrhzcA45nlYl8P 9Nb48SYcwRdlfD70JEnCM8KUB/R9F4kAjw== X-Google-Smtp-Source: APXvYqyI5qyGpNcVWlsS5O2+hF8OV81599UKPoaPWKuP93JFnxAM6YxqxifnXuT1dQl9Oboy3wZUSw== X-Received: by 2002:a7b:cbd8:: with SMTP id n24mr3221074wmi.2.1559050621491; Tue, 28 May 2019 06:37:01 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:c8c7:f81b:b165:1aa7]) by smtp.gmail.com with ESMTPSA id 95sm8652668wrk.70.2019.05.28.06.37.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 06:37:00 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 4/4] gpio: mb86s7x: enable ACPI support Date: Tue, 28 May 2019 15:36:47 +0200 Message-Id: <20190528133647.3362-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528133647.3362-1-ard.biesheuvel@linaro.org> References: <20190528133647.3362-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-20190528_063705_466190_34F917A1 X-CRM114-Status: GOOD ( 15.89 ) 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: Lorenzo Pieralisi , Graeme Gregory , Ard Biesheuvel , Marc Zyngier , Linus Walleij , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, Masahisa Kojima , Mika Westerberg , Len Brown 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 Make the mb86s7x GPIO block discoverable via ACPI. In addition, add support for ACPI GPIO interrupts routed via platform interrupts, by wiring the two together via the to_irq() gpiochip callback. Reviewed-by: Linus Walleij Signed-off-by: Ard Biesheuvel Reviewed-by: Mika Westerberg --- drivers/gpio/gpio-mb86s7x.c | 51 +++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c index 9308081e0a4a..64027f57a8aa 100644 --- a/drivers/gpio/gpio-mb86s7x.c +++ b/drivers/gpio/gpio-mb86s7x.c @@ -14,6 +14,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -27,6 +28,8 @@ #include #include +#include "gpiolib.h" + /* * Only first 8bits of a register correspond to each pin, * so there are 4 registers for 32 pins. @@ -143,6 +146,20 @@ static void mb86s70_gpio_set(struct gpio_chip *gc, unsigned gpio, int value) spin_unlock_irqrestore(&gchip->lock, flags); } +static int mb86s70_gpio_to_irq(struct gpio_chip *gc, unsigned int offset) +{ + int irq, index; + + for (index = 0;; index++) { + irq = platform_get_irq(to_platform_device(gc->parent), index); + if (irq <= 0) + break; + if (irq_get_irq_data(irq)->hwirq == offset) + return irq; + } + return -EINVAL; +} + static int mb86s70_gpio_probe(struct platform_device *pdev) { struct mb86s70_gpio_chip *gchip; @@ -158,13 +175,15 @@ static int mb86s70_gpio_probe(struct platform_device *pdev) if (IS_ERR(gchip->base)) return PTR_ERR(gchip->base); - gchip->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(gchip->clk)) - return PTR_ERR(gchip->clk); + if (!has_acpi_companion(&pdev->dev)) { + gchip->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(gchip->clk)) + return PTR_ERR(gchip->clk); - ret = clk_prepare_enable(gchip->clk); - if (ret) - return ret; + ret = clk_prepare_enable(gchip->clk); + if (ret) + return ret; + } spin_lock_init(&gchip->lock); @@ -180,19 +199,28 @@ static int mb86s70_gpio_probe(struct platform_device *pdev) gchip->gc.parent = &pdev->dev; gchip->gc.base = -1; + if (has_acpi_companion(&pdev->dev)) + gchip->gc.to_irq = mb86s70_gpio_to_irq; + ret = gpiochip_add_data(&gchip->gc, gchip); if (ret) { dev_err(&pdev->dev, "couldn't register gpio driver\n"); clk_disable_unprepare(gchip->clk); + return ret; } - return ret; + if (has_acpi_companion(&pdev->dev)) + acpi_gpiochip_request_interrupts(&gchip->gc); + + return 0; } static int mb86s70_gpio_remove(struct platform_device *pdev) { struct mb86s70_gpio_chip *gchip = platform_get_drvdata(pdev); + if (has_acpi_companion(&pdev->dev)) + acpi_gpiochip_free_interrupts(&gchip->gc); gpiochip_remove(&gchip->gc); clk_disable_unprepare(gchip->clk); @@ -205,10 +233,19 @@ static const struct of_device_id mb86s70_gpio_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, mb86s70_gpio_dt_ids); +#ifdef CONFIG_ACPI +static const struct acpi_device_id mb86s70_gpio_acpi_ids[] = { + { "SCX0007" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(acpi, mb86s70_gpio_acpi_ids); +#endif + static struct platform_driver mb86s70_gpio_driver = { .driver = { .name = "mb86s70-gpio", .of_match_table = mb86s70_gpio_dt_ids, + .acpi_match_table = ACPI_PTR(mb86s70_gpio_acpi_ids), }, .probe = mb86s70_gpio_probe, .remove = mb86s70_gpio_remove,