From patchwork Mon Apr 29 13:12:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 163016 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1866255ill; Mon, 29 Apr 2019 06:12:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHVhreFnEqMquKkXHcks5si7uHc0nGsrIL/sPgXZ889lTXdXuvVlLaJAJ994m9Eu2la3jZ X-Received: by 2002:a63:a849:: with SMTP id i9mr13987993pgp.205.1556543536387; Mon, 29 Apr 2019 06:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556543536; cv=none; d=google.com; s=arc-20160816; b=ixrH0p02vN3C3/aF0Oc7eHHn36v6TlaEFwkT/vqHIxxV+7zq/XdQK9D8iLyzAeCFjs 5eG6tbXjso0X0CsovoQ0fGi0RjKwbSnUTYVqeNLfDEmU+M/Yv6/92nP3uJJemAKKlmvk qhO10TiiEI9ybDWHQOWCRsYORssj+wD+5deb2+9W4GOUopwhXxtVjXXLTPTH9Z6tgNzJ bmBAKZykrhkcYojFuXihY3RTpkFAlYua1vVXLnVVQsMkELxQrNkdgKRLjbPCfH90hF2w 9Qf/XwYzwXCAb6rObemttGqTqVq5PLBC1R0hcE5nMfc7zuzL9BOKH6qEObZgT0gzTQOx Yhqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zgLkZH7fvnn9ow85IxLoErjzNeQPt/Y/6sGtcm5H+QY=; b=jLAkcWqRLqEieh1YrRVeZGnzri042BKwj0NGP1ytmZ3MRO6CgyOxu3spaFA5xQFpgz 9P2q/MwRxhaZf/qytsXsdnLm9IzCfwzNdzoX55IsBcNe76vX03oVd75/h+XJMcJO4+Sv ecY7nV0rAnt5l4ub73GwtEUbyL6q9+lPYJuc71X5Osg7YPqozK8540BE7UC615ISSw1M IeAUV49URJjSJSKLhNiU/+Q8CcwTNXv9EyoYFIGOtsNqdpqPDuZc1CrBC60hAIuf2rp7 A5UEBWlqH5svNNFe7BKjxxUi1PycjRJk3bO2aHLCtnUsB3VrCHVI4i6t14p3ag27r4qV iTvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JUEtyqTf; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si7550503plq.83.2019.04.29.06.12.16; Mon, 29 Apr 2019 06:12:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JUEtyqTf; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbfD2NMP (ORCPT + 9 others); Mon, 29 Apr 2019 09:12:15 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35308 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728006AbfD2NMP (ORCPT ); Mon, 29 Apr 2019 09:12:15 -0400 Received: by mail-wr1-f66.google.com with SMTP id f7so7470888wrs.2 for ; Mon, 29 Apr 2019 06:12:14 -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=zgLkZH7fvnn9ow85IxLoErjzNeQPt/Y/6sGtcm5H+QY=; b=JUEtyqTfzgq+eI8JsoNhV2vJVtHVdvLJneMkfVrhS7zClvtLa1COifGGYGf1vqxZsY oL/ChqJVd/RBTwXD5iru8C/LUzLz6jjirc+ok6uL3d+L3bwJYu6ptGzutMt9T9KnKne6 JjCEp7UjWOIjrNKdA6HCoA0ACG6hThLrFTo5rEPUiLMjowlnHb1g2ms6t4iLrT3Pj582 pItzXWpE2Pg2Qu19ZOF3VQAlYYMPATGQHxZ1N1kSRBpsu5eCmxmGSrK9q2Y7Be12UFYs THtw+p6BHyz2Yfrunab4WyoE55JWezpVm8bxfQ8q291n2vU76uMm/3m/XqzF5Bs2NAMt oZig== 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=zgLkZH7fvnn9ow85IxLoErjzNeQPt/Y/6sGtcm5H+QY=; b=carT6nfnUeoxHOoeozoX/f7zJfkWKlerMu9egW6RK8XKu5uA/Hm2DODoUduBwNsAzY f+n4QWUyTGSrl9zRFx1LL38u2AXob+1Ep3h/k2zvYyvQiyPMK95ms6ip+l8KEZ8ENUu4 mHqA9vQE2KNwJcVKlOodmfv4yxp93M7HwJqjGT4Xv6Mwgr5AoMmBoOK+XxYNyZhFx2VD z1tM6E3aUlqWLlxW1RT6ThcfG/lVE7znJjW14EeaoKHWWG7H3X/99Xw6bHZSi1gwk4re KRSXAfRZNb4nCSoYoVvi3wgD1gpk9nzzja3rQ0e/ZyyTlpofVeqIQnHPO+d5G+bDc4Ab LCxw== X-Gm-Message-State: APjAAAWWCcI17mc+v1jzHZ6LgAa7UZNeTcrG3mzCPP23Lk93UA8V3iei s08yLbZP6OAzBBRu9tcZo8puaQ== X-Received: by 2002:a5d:464f:: with SMTP id j15mr19107653wrs.265.1556543533485; Mon, 29 Apr 2019 06:12:13 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:f9fc:88:6502:8fa7]) by smtp.gmail.com with ESMTPSA id s16sm5410282wrg.71.2019.04.29.06.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 06:12:12 -0700 (PDT) From: Ard Biesheuvel To: linux-gpio@vger.kernel.org Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Masahisa Kojima , Linus Walleij , Marc Zyngier , Graeme Gregory , Lorenzo Pieralisi , Mika Westerberg , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 1/4] acpi/irq: implement getter for GSI irqdomain Date: Mon, 29 Apr 2019 15:12:05 +0200 Message-Id: <20190429131208.3620-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429131208.3620-1-ard.biesheuvel@linaro.org> References: <20190429131208.3620-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 returns the default domain for unqualified interrupts. This is essentially what the ACPI GSI domain provides, so add a helper that returns a reference to this domain. Signed-off-by: Ard Biesheuvel --- drivers/acpi/irq.c | 14 ++++++++++---- include/linux/acpi.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index c3b2222e2129..d47bbd54d4aa 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -17,6 +17,14 @@ enum acpi_irq_model_id acpi_irq_model; static struct fwnode_handle *acpi_gsi_domain_id; +/** + * acpi_get_gsi_irqdomain - Retrieve the irqdomain that owns the GSI space. + */ +struct irq_domain *acpi_get_gsi_irqdomain(void) +{ + return irq_find_matching_fwnode(acpi_gsi_domain_id, DOMAIN_BUS_ANY); +} + /** * acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI * @gsi: GSI IRQ number to map @@ -29,8 +37,7 @@ static struct fwnode_handle *acpi_gsi_domain_id; */ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) { - struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id, - DOMAIN_BUS_ANY); + struct irq_domain *d = acpi_get_gsi_irqdomain(); *irq = irq_find_mapping(d, gsi); /* @@ -76,8 +83,7 @@ EXPORT_SYMBOL_GPL(acpi_register_gsi); */ void acpi_unregister_gsi(u32 gsi) { - struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id, - DOMAIN_BUS_ANY); + struct irq_domain *d = acpi_get_gsi_irqdomain(); int irq = irq_find_mapping(d, gsi); irq_dispose_mapping(irq); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d5dcebd7aad3..1016027dd626 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -316,6 +316,7 @@ static inline bool acpi_sci_irq_valid(void) extern int sbf_port; extern unsigned long acpi_realmode_flags; +struct irq_domain *acpi_get_gsi_irqdomain(void); int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity); int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); From patchwork Mon Apr 29 13:12:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 163017 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1866348ill; Mon, 29 Apr 2019 06:12:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqywimhNN64XS+8Q3u97ya0mu5XK2KUEhXbwwskP0SYWr+lyM6MSdDHN9l4vL35Ert1PoMO7 X-Received: by 2002:a17:902:e01:: with SMTP id 1mr63257906plw.128.1556543539444; Mon, 29 Apr 2019 06:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556543539; cv=none; d=google.com; s=arc-20160816; b=fHAHNhGg8rl6ECbPygq3fzff9xomIxjllekKLj86Jk66xN97/1XJMUeO+naGB/9H0J RiLPgIFn7ndsii2OAfNrI01K3Miw6k5KHrT9hnwSf465+5oKSio7Dd6DDqN49yADhA/z 6ud3mJ6liDEW1Jp4OyxG5MDP5czN3nTcZLRzy1eH1Om8m9OGrk98dhGBF9T7Je4kWSJv JY1ce1fK91zLIkW8Qsw+p/AVzQz2FA9WXpwVtRkqo/u05YDC8rnUg6jYdZljDyTvg49/ 9Wu0SbB4PRtXf7+E5vu3gOrRSbP0G9vKbbYNiIO/Vh9cSzylU8uV+V5zOB4osvZ0BflK AAnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LflG0JOcbN8VcRqNOvuJxlldgCtsVbbH4h32KwiCqss=; b=Xhgkq4+nEFyIpkjFyDrfWywkGsISYmtPGuytkJXvnIKROyoQCDBw/lSQKZYL91mdPk BhUwxw25RNWuMl1dmURor23YIDXKlazoiC5K7wozdiqOlcZRdftn6AurUOYz47VryQEs W4tkbPzSXP7hZWZJLPVheMq2l4Vqnmx9IC5LjzCyu62Pc59wEOLZyf9kqFFmrnGdODEi EUuQjBd5m3pmLZQb3KWteF6jAdsTWpxeD16uYUTVynHzseOtjYskBYs86NAr3YF+nrur Fvf2zMZqq57Kcv85YveBXwWacUk+QsyAhgrQJ6uUqHuS4IpmRU13oRh8RIVcNy7071GT e4yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ElwC/dqy"; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si7550503plq.83.2019.04.29.06.12.19; Mon, 29 Apr 2019 06:12:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ElwC/dqy"; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbfD2NMS (ORCPT + 9 others); Mon, 29 Apr 2019 09:12:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42211 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbfD2NMS (ORCPT ); Mon, 29 Apr 2019 09:12:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id l2so312378wrb.9 for ; Mon, 29 Apr 2019 06:12:16 -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=LflG0JOcbN8VcRqNOvuJxlldgCtsVbbH4h32KwiCqss=; b=ElwC/dqyvPGkd7e4295vczNFShOirzGuBqdcY0+km+H5WkenpoB7C4k4h9TYj6Ak1D RWL/xEmSkeCmKYBXiSL0WLzeOy4M7otJdu9ogPADkHyARgiuArqGpY5gkcYUAPOALtLF j6VaYECxgPkQmOv1TnNU4v9DH0UaSQ3ARXKhBWY5RPyBzw8spXWuksnol/xZWpe/sMn+ +O5AeEc3sWJS/Syv+gDpLOBOrNFCRXRp9tHhKaAQE1SXfsZ5otjL985N0wwA3wxLpe3I wjlgFMNyQ7r7VcwTUecaBbDbq3NNFRivwhM/pUAfPSvl0tf+tpkQRCq/I+2ERcqGUPnt o71g== 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=LflG0JOcbN8VcRqNOvuJxlldgCtsVbbH4h32KwiCqss=; b=lfTnxVz6+mEiGNBbzD4wQJGd0B9xwbyTrYZAzcx0oDtliYq5lQku8Wk/3xbDStKAkS oQPVl2Uy6dfPDFMPe5HywGf2b6vTBdPCi90uLFXsyINZppaJxbOyKb6hGP7ge88CcXu7 SsGAZ4Lumb//UMScrsP0F90UjB3/faKxauwDcpI40vj0NWK++x+K6R3oPUz3fNHI1i+p MNfkSBz1ShZG4BumbyrL3sNVk4E48rmCd6rSKevT5AjdL6k83et52FV3BNjZn+2Sx56V mqsht5zcMlx/5F0aAFDGokg882XqRkx5cLLYoPZolMT6r/sMxiZnivXZ00HI9uaSJoLc tiPg== X-Gm-Message-State: APjAAAWy8rAPxDHjtP3a1RSiEklQH1pRClYw6o2CcTMcNf6Cx/9UJDKO QcT6VzomadLxXMutKFCHWdUvrQ== X-Received: by 2002:a05:6000:12c1:: with SMTP id l1mr4895866wrx.152.1556543536105; Mon, 29 Apr 2019 06:12:16 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:f9fc:88:6502:8fa7]) by smtp.gmail.com with ESMTPSA id s16sm5410282wrg.71.2019.04.29.06.12.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 06:12:15 -0700 (PDT) From: Ard Biesheuvel To: linux-gpio@vger.kernel.org Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Masahisa Kojima , Linus Walleij , Marc Zyngier , Graeme Gregory , Lorenzo Pieralisi , Mika Westerberg , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 2/4] irqchip/exiu: preparatory refactor for ACPI support Date: Mon, 29 Apr 2019 15:12:06 +0200 Message-Id: <20190429131208.3620-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429131208.3620-1-ard.biesheuvel@linaro.org> References: <20190429131208.3620-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 | 77 ++++++++++++-------- 1 file changed, 48 insertions(+), 29 deletions(-) -- 2.20.1 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); From patchwork Mon Apr 29 13:12:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 163018 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1866399ill; Mon, 29 Apr 2019 06:12:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfoEFG/ZGxC6lk0Ye3C+WwJiTESDPsJTKbG8SN8u7tKVC9vTHz3zOPoSARVqnyTbHmZAgq X-Received: by 2002:a62:1690:: with SMTP id 138mr61041788pfw.28.1556543540921; Mon, 29 Apr 2019 06:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556543540; cv=none; d=google.com; s=arc-20160816; b=JYS+FBPinw7b1ipKBoIdJOhVT6+DDGwtC6gxc889+LRrB99jZZu+qS12CYbJkzJluj 2za2KDHZ9UKR6//j6lw4jAagosLv7DPQp1hxtuOqf9hTbDbun5WgIUYX31SV4C9V+yrm Pr+gRpS3I3jEyTR9g+BCps2ve7GHq36sA0JYM46OnJxfr5YIL4R0fIu87L4Q8MAYtli5 t9/BpgXvT1c/YdrfeKXwK9Ys4eaV0nGlxp4olHKXubpCKYNBjyPUnjHoLR1IlqycNJRb A3vawlAjQnbiVVSTdYQWFyMQSDZdWCvJAcof0FvW7Ta1s/iZ8BGkM19Cg24oxLH33Elu XXDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aF6l04CaNOxatTezE3P0EG9tcSof6ocX8T/Hj4rb3rU=; b=EgVJ9nixsfxqWzxrbulS4X+8jtzyzvfHlAHO/49ML2ObKlXxCouFxJN9qgGqBO0t0Y msNiX73gtyf15srZqsEQan3RZOwSeyvIYPUj1rwb8hjJ0NAZhEOlHlZCIBK95gNPqmpA 3CbdoLf+tEkrdSCKu8kvx56j/ingkIRgesHApcnixrS8ZRK4wU/wBK1qkXA3t1CCOQKM bw4e7V2xXvlQLpXkp5WsYRUGZH8/tPp9sfN7wXPuFym/e5qhyOws7DnOH+8oSSlNgP13 4Whal5vDZu11iouJwNboV3vBDFJJIn4CYn2T7J3jnkg6YDa5xYzajiAfZYvOlnEoaalQ xABQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y0PxrwNP; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si7550503plq.83.2019.04.29.06.12.20; Mon, 29 Apr 2019 06:12:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y0PxrwNP; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728126AbfD2NMU (ORCPT + 9 others); Mon, 29 Apr 2019 09:12:20 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37546 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbfD2NMT (ORCPT ); Mon, 29 Apr 2019 09:12:19 -0400 Received: by mail-wr1-f65.google.com with SMTP id r6so15992207wrm.4 for ; Mon, 29 Apr 2019 06:12:18 -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=aF6l04CaNOxatTezE3P0EG9tcSof6ocX8T/Hj4rb3rU=; b=y0PxrwNPQ79uhV6F0ybWo2y4mgV33xEuUKcozXD+KpG6GxZrXk1fuDWAPysrJQZHyI CD8sIHT+o/3j5xs34dVnc22/2G3BezaxpH644dAfpu8PSvn+f8mRbk8EZG5BJx/a/NCS gOzxfhBaH3/PD35lPKdTkOvKtvYYw3z6wzIu6QPI75/aeXJZ9Q0FJqs/C6gHjhwoUzHB AcvmR0t4UzCwwbJueeInjlaTCj9Xn0QPipqK9Pbd9A4EZ3gXNHIW5Y/Ahh/ibqpGw88w 67TDidPn6WnHOnBDH09QWbfmhKYTyGj13+c3zwLEnFiuEp6GuE2kF3VaeSO7Wgo26XyA LOPQ== 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=aF6l04CaNOxatTezE3P0EG9tcSof6ocX8T/Hj4rb3rU=; b=f4QwXFiniiEPRhSBZfAtK1o9S45IbnZBaG+jf02uvXk4Om23d/T0IyKRUE/BgJzpBs hed7U0lvX8Z49+jotMCF68fiMtSHiBX1etnwEenY/8v+aTlbUeHVxhT5BE3899CUHsrG cmwWQ9A2ysGxFmOP6Z3WT1SKVSkJCVQn1bURRzT4+JC2fEH/f9lNEruoUhtvfUmkZbUL sFgiG1mSepvCQYlxlIDFOXNQdoRkk7kkL7EfHPHU2xXroZ16ORv7FDIYvdi/ketHMkV6 47/NYQNbbO0KB2y4ygDwk65h+2QQyLA02f6mpXbou3ctg4FsReYyKOvwyoL17LWMWqZJ gbmw== X-Gm-Message-State: APjAAAWQcQFLa8+7qFdpPBCTiHCt4rVH/6R99oxpZjJvvzj368Tll0tX u0HozgaZ32MEdzp6VwhAq9094w== X-Received: by 2002:a5d:674f:: with SMTP id l15mr16932208wrw.41.1556543537573; Mon, 29 Apr 2019 06:12:17 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:f9fc:88:6502:8fa7]) by smtp.gmail.com with ESMTPSA id s16sm5410282wrg.71.2019.04.29.06.12.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 06:12:16 -0700 (PDT) From: Ard Biesheuvel To: linux-gpio@vger.kernel.org Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Masahisa Kojima , Linus Walleij , Marc Zyngier , Graeme Gregory , Lorenzo Pieralisi , Mika Westerberg , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 3/4] irqchip/exiu: implement ACPI support Date: Mon, 29 Apr 2019 15:12:07 +0200 Message-Id: <20190429131208.3620-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429131208.3620-1-ard.biesheuvel@linaro.org> References: <20190429131208.3620-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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. Signed-off-by: Ard Biesheuvel --- drivers/irqchip/irq-sni-exiu.c | 72 +++++++++++++++++--- 1 file changed, 64 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/irqchip/irq-sni-exiu.c b/drivers/irqchip/irq-sni-exiu.c index 52ce662334d4..68394f804af1 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); } @@ -244,3 +254,49 @@ static int __init exiu_dt_init(struct device_node *node, return 0; } IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_dt_init); + +#ifdef CONFIG_ACPI +static int exiu_acpi_probe(struct platform_device *pdev) +{ + struct irq_domain *parent_domain, *domain; + struct resource *res; + + parent_domain = acpi_get_gsi_irqdomain(); + if (!parent_domain) { + dev_err(&pdev->dev, "unable to obtain parent domain\n"); + return -ENODEV; + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "failed to parse memory resource\n"); + return -ENXIO; + } + + domain = exiu_init(parent_domain, dev_fwnode(&pdev->dev), res); + if (IS_ERR(domain)) { + dev_err(&pdev->dev, "failed to create IRQ domain (%ld)\n", + PTR_ERR(domain)); + return PTR_ERR(domain); + } + + dev_info(&pdev->dev, "%d interrupts forwarded\n", NUM_IRQS); + + return 0; +} + +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 Mon Apr 29 13:12:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 163019 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1866458ill; Mon, 29 Apr 2019 06:12:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXZzTLDMk59wH8iPHjS0QAtBa9x41YgFr2T3Av30QJvz8a0xAsenWmA4McbMXKuQ/beFfh X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr62178746plb.319.1556543542614; Mon, 29 Apr 2019 06:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556543542; cv=none; d=google.com; s=arc-20160816; b=WCvtBJd99rR4QwaK5AXTLDak/ut2KsnD/23xxvcMTDBQHu2YGZO0/MXc03gUfsvwVf uRTWKj3iwDZOP18B72yoPFvmfYAdcPADMLm3W6oI3FLtGLRawJHFqhnqieYN50dgJg+y MHufsfzgi010Ib3iwHccY0n3LeTRi7hzUcYHTgxmjMghzHMraExP+IBzmnzriUjgZL9V x+7r72r5X5xESGDwQHz3EjnndWlE6e+0EepA36J7wxLqFH1OfEwj6cpWwpXm7JTJMnKh P+iGPstiVbE0FnNbIp90JM+WiG9QK6po8f0H45TbyadcD+cnWUhvUqsJpN8DVgPNFs4l Ghxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EWtkEswA/ppJKsau0ucZOXQ0FjybdP/7oMBp2mQhOUw=; b=m/xguVLvC/52JRpwy/0zgBXdjqxAFnxyteMVvZ4FxXYDn5Pj0k2Wc+Wdbu6Jh9VjlC sICgO1+kMVJC0f4bnq5Rdrw3AFUj9r/BohWwXWeVoKwlODeUJHrk6QoaYFYkrEjr55ZO LrfvPu5QWjh1Y6+ld9UYZNMAI5CUyOHhet1mzROh426C1bLjSVAUAoG5NVtkF/BAetNd 7yRLZbl0RmjKkZQZ3jHWLSjaR3yUi80eGytO4DbfY2UG9BnEcZ1NjIQpvvyhv35wPruT zSRw/WvR45hcbnrsfU+g+IJCXzBhCy2CyMN9RlDDwzi34X+CEQwpLus2cejvc3yqoeAn fa2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=avQNkrkD; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si7550503plq.83.2019.04.29.06.12.22; Mon, 29 Apr 2019 06:12:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=avQNkrkD; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728006AbfD2NMV (ORCPT + 9 others); Mon, 29 Apr 2019 09:12:21 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40503 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726403AbfD2NMV (ORCPT ); Mon, 29 Apr 2019 09:12:21 -0400 Received: by mail-wm1-f68.google.com with SMTP id h11so15698034wmb.5 for ; Mon, 29 Apr 2019 06:12:19 -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=EWtkEswA/ppJKsau0ucZOXQ0FjybdP/7oMBp2mQhOUw=; b=avQNkrkDuUX/SIDLB2Sk61f/7WpPyXBxDA6gZqFxCDXCdzxT6U+W+gX9DxRmUClSwO sFUfh3j/XDAXHED0K0TkLdlz5zpmUr+MQtD4d73Q7NmxxUGAGPzu6wmYbItwxaELDhGI OChUm+KddPrwSKDBRDn2jP9Cmz8sMGNiRrM7TwxiRFa698s7flVazpEeC+9soz5p6eQZ VPyCTtMGWyHurppOIuI6fVfW5s3dN63XNlBUbJ+CBR2eLVlMDI8qaGUBJDPICuQyb9xf fwqFaWw4548vRi704SVGxALKRQtt5TRkeXVzVc98B2g7s3MjZ9Cm3eMWQ8nlT+5+uYil TRcg== 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=EWtkEswA/ppJKsau0ucZOXQ0FjybdP/7oMBp2mQhOUw=; b=t6ogQ+arA6AHq8qn/DsMpeK4aerrtrRaKgQTOxhjUR8Q3uRLGsLw4ARrR3Yk+bi1tl zrA9NOd4xmfRJnjZT1bUoELe6XcW0eupdDl+B1sfIF7h8U3vcvtiIvILMBYbM06NEzhz HPwpVMKRyKuwVzzQoPL9bee8Eu8jQyiCN7AsN+2YDdzGKjrVxwG2N9HVfW0hYbYUjpJM cAwkR6U9SzP03RvU9g0YnvVVE7zAqkSFN1EaheQnR1SKLTUxfRqnwrfySLlt6HrIbNA+ Z98AA8Wor3xSekNkOke3Ta5rgOGHUxDuu5HIH0WLYE04RIgjsXPb6Q6IhVZvcbp6wbS+ 8esA== X-Gm-Message-State: APjAAAWkSB8rwztIK2LkvTUeQICVQwQ4aOVhjV3OpACFQiyjURS726NU 9WDkzBzyGk5tZDG3PesFTHqMDA== X-Received: by 2002:a1c:2d0e:: with SMTP id t14mr17354279wmt.33.1556543539028; Mon, 29 Apr 2019 06:12:19 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:f9fc:88:6502:8fa7]) by smtp.gmail.com with ESMTPSA id s16sm5410282wrg.71.2019.04.29.06.12.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 06:12:18 -0700 (PDT) From: Ard Biesheuvel To: linux-gpio@vger.kernel.org Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Masahisa Kojima , Linus Walleij , Marc Zyngier , Graeme Gregory , Lorenzo Pieralisi , Mika Westerberg , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 4/4] gpio: mb86s7x: enable ACPI support Date: Mon, 29 Apr 2019 15:12:08 +0200 Message-Id: <20190429131208.3620-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429131208.3620-1-ard.biesheuvel@linaro.org> References: <20190429131208.3620-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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. Signed-off-by: Ard Biesheuvel --- drivers/gpio/gpio-mb86s7x.c | 57 ++++++++++++++++---- 1 file changed, 48 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c index 3134c0d2bfe4..61ad95c3e3d2 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; @@ -160,13 +177,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 (!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); @@ -182,21 +201,32 @@ static int mb86s70_gpio_probe(struct platform_device *pdev) gchip->gc.parent = &pdev->dev; gchip->gc.base = -1; + if (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); + if (gchip->clk) + clk_disable_unprepare(gchip->clk); + return ret; } - return ret; + if (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 (ACPI_COMPANION(&pdev->dev)) + acpi_gpiochip_free_interrupts(&gchip->gc); gpiochip_remove(&gchip->gc); - clk_disable_unprepare(gchip->clk); + if (gchip->clk) + clk_disable_unprepare(gchip->clk); return 0; } @@ -207,10 +237,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,