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: 165307 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp8025889oca; Tue, 28 May 2019 06:37:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4xIaWvCAdH/MvRF5ssw6Np9QYAkQRgOy2k8Z7/pBrsvpEduL4tacmBwxL605tq06/hS/C X-Received: by 2002:a17:90a:350d:: with SMTP id q13mr6194195pjb.20.1559050620588; Tue, 28 May 2019 06:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559050620; cv=none; d=google.com; s=arc-20160816; b=CT0DJVi302algbvjeLTNj4hJ8InFS1TPpbaIcsWeMiV/OTv18FEDiIMdxLlZo0QPfh CK4/pe1OgRE8M8pg/reb8gkn5ciny7hDPIgFS/83hkX28AFptexZpGTHQCQH29eYHiyt OS5wh6eBf0U04yRKSY+SqYF6hr1Ypc+4YaRkcVXMTgL0bJ+wrQx4BbuxCBpsIlwJ4Ymq aoBLB5VNVKmJrH/u6R9T3EduzdqudW++WwR+wLVA7RdkU45c4ne1ZJkKUSlNGuGXXEEa sNruD+hle1MxlB3TZvxBzlN0/eZA7d4IR7ah6jqh0ExA/+kwyeTHXe0EsOLT+KtuOPdX ipjQ== 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=Ce8JB4XUI/WvY+NITbCG46XF1cnECw0qEl06Q1Mp/6Q=; b=mVsGg12vCjpXjct3tTWsHxs1aSwLVjuoi9uOU7mJIwpx/S6gBEBEUJGWLXhfSvYnrq gmidiIrRhZTHgDPHA1poeUBbDZZTrX1N0/NQ9ny5ui3QSwaPqA4MLeg5QuZXxL28pdbO sZ4MnO28ElZsghJr7x4NgdLFBVM7qgQQupH0I+R5Tcv+gff3MIfYD+7zpw5M/AR7djnp LU3n+GiXdzTv4mqpWFyB9Pe9ZN74qC0wAgUI1lDhkNeYQV/JYEfPF2ScsY2HUQWeyjve bPKLFmve/0uqG6/Ya2hEyUZpaMYHFf+of9wBu2kbfZSaFI/GZe3Y3tn9lxbFPd9UxuZt xmTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P/jGceWx"; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-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 h3si3433642pjs.104.2019.05.28.06.37.00; Tue, 28 May 2019 06:37:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-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="P/jGceWx"; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-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 S1727457AbfE1NhA (ORCPT + 5 others); Tue, 28 May 2019 09:37:00 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43377 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726924AbfE1Ng7 (ORCPT ); Tue, 28 May 2019 09:36:59 -0400 Received: by mail-wr1-f68.google.com with SMTP id l17so11871124wrm.10 for ; Tue, 28 May 2019 06:36:58 -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=COejofU+23kSqYDwk74t2eApleSczQJK5SyqTZwZA+Kk6+AAS1VLm6Fnz16/ZXNfVJ JWr/KInk5cHc3l0O2WLus1+lTRkog0hyNgq7WHvRCPAOrInk8zGFz57QSQa17EM89NEQ WP1ZMDQTwQGBTsSnYTNnGjlNR2Xn/MVmxOLCnnekfAJsqvHjVaNse/dD3b2jCMmE4xzR G0TyfYCBn+b/sP/raElCDyd5HwA/nB+Siw3RVHQhULbVm0HPR/sUnQiWsvlzivFgS4+Q 2TysVZgikGdyVCP7NRwWDN07Pxn7MudYUmwRCcek0gbda9eTMD68cUJo96rN2yRoAHxa urDw== X-Gm-Message-State: APjAAAW8/e7HAtbmnQpZj5wIj435RWZbThmAlS/uyhCYAe/ALr1OCNVU ZS7yShObfQxgl1+WLcuhS+cQog== 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 Cc: linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, Ard Biesheuvel , Masahisa Kojima , Linus Walleij , Marc Zyngier , Graeme Gregory , Lorenzo Pieralisi , Mika Westerberg , "Rafael J. Wysocki" , Len Brown 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 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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 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 --- drivers/acpi/irq.c | 26 ++++++++++++++++++++ include/linux/acpi.h | 7 ++++++ 2 files changed, 33 insertions(+) -- 2.20.1 Acked-by: Rafael J. Wysocki 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