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);