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 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: 165308 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp8025920oca; Tue, 28 May 2019 06:37:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYSdhreGOaek+yz6u+F1JkmqHRoj9UZO/TO1/PzzdugRRKbPMmL5IylYfRpQO5EkiJK3UY X-Received: by 2002:a17:902:ac82:: with SMTP id h2mr76144210plr.303.1559050622151; Tue, 28 May 2019 06:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559050622; cv=none; d=google.com; s=arc-20160816; b=Npl1wibwG7UTRld4Jp5DP/nIgQsSuqivRq61U4ypXmLtPGUxsZav8V1Zd885p8s4vl AnBrpoy0qWwyTiZjAfc7fFkTVRi0XaQ66PZjEuifNU2zchwMACIFGMZq61VrfmwQz++U O5bMo6pCHfHtHZHXDovxVZiFYzHEXZs4A3Xkg14uqG2fly2snTg3z3hgoiCtu4DYxrO7 MpassC4Iedgl1FdQB1Glw6ON2gqlgprBLiv7ebGEQ/ODOy6awKgq40SSs2YLDq7mrspu un5FSYFR2fzyBCTo1HTgKbWlANh7Os5rAajRMj9Hk/Yh569AFq0eqXE6hV811kMzK93r x7mA== 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=pKi5I0CJ2X5BwXo9XUNw8Vf2df15TmcuH8E+kJajjPM=; b=FB3sbGelNHB/lBNgc7Qi+4tmdxQAxkoZDSqMpF0LJR79EfJ+hUXPJckVpvaMbnr7Q6 +ojVZUWHuLwaHpxeXwofsF/StJ83tlKOKQA4WA8T4pPuFdluCeDAdnq7gqUi9VjCmg1e cdl2TQkzg72QOq5Ozqj6J6AGJKYrV97PxPPLn9+o2O+auw2ps4ZJQluBrQwrCjf2TFvz jAl697AuwTDnptVreSd69adu3Du4QgwgfA3C5TK+A4mWmppFlBX+Zu8qJqrdByZLomSy X/0zswlxUIDogigV216NTy2qm8uqxZOyYR5rmZmwVGJzOYIJYBpbupuYcaMTIOiDgwL2 bi5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F8I9p3bL; 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.01; Tue, 28 May 2019 06:37:02 -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=F8I9p3bL; 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 S1727508AbfE1NhB (ORCPT + 5 others); Tue, 28 May 2019 09:37:01 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37098 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727445AbfE1NhB (ORCPT ); Tue, 28 May 2019 09:37:01 -0400 Received: by mail-wr1-f67.google.com with SMTP id h1so6134579wro.4 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=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=BbskEotfBPKt1ND+ck1uqlDDlDsafa2PcaICY9kVL8Oj3CnL77J0ut7m9suv8/jc55 0J9mV6RKZN2uNyXpzWtPImX5SrayAboomy+cXmxBWeDqIjBbuqJY1qv3HmX6lV90RuAF VdwS2iQ3fJ+ATN8Tnu3V/t9bD0EzLdhM/8ZlXopVYn96iOnBrQChJLoGGuhTitSzJtID +rRQ9/4gx2r+wxOVAcxXoJf2r3ZMXEXgyamLJAapFFmc/6f/QlrNwPsVipZqXUpBcz6c 27Z1rwm+dd69imGfTtGpR56B5EV5XPE5Xk+qaOQU+dz2ie6cRqr0XqA7bSGJUyoVQi/L nSCA== X-Gm-Message-State: APjAAAV7xk+nUoANr41UvVl/tf/En6UfbAkKt8RcN4v1+kkQ7rx/AGyM OGWn52WRoiJawC5MFGU1J7lfXQ== 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 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 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 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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 | 66 +++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) -- 2.20.1 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: 165309 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp8025949oca; Tue, 28 May 2019 06:37:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIKRXOSZEsPwn9NPrlw1NXnM7C5kpYcKtT8JkiPtszzsNIQp0QtKT5fGhT6yhf90QE8EiP X-Received: by 2002:a17:90a:195e:: with SMTP id 30mr6257128pjh.116.1559050623621; Tue, 28 May 2019 06:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559050623; cv=none; d=google.com; s=arc-20160816; b=JNmUV6zTTdHRHUDZ3d0ERV61D2VptHoeZ7tAVmYCOggV/zqEJBINI8cFd5Cc5Uc3mD 301hBiDxfCxh+A0SztTGGIuh7fiGJcS8oAPvGIQGr5LZolweOgz+rKP7xwTvphaU0gxe cMBC7hRREr4aHFt4VJfQ0D9YMU3d47DRdrJktLIQ93T1l5TTQW0v/RTKAIF1Z3DIyaVL Ls/6HFP/rjCxM/tHaJjAXVmqDhu/QWDGlOfpKqnje96Xo6aJZpWkVGKCAHJroe2TAtiS Mep8aX8+l42GjE28aYOI60JAr/if5nI/aVj2QLa57QnhyT2pJfApqGxw1KUn4Nb+AENB qXsg== 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=ds56CQkAv670ntBJCxp4IuqDeQwQznKOl9murxD3/48=; b=vVJg56WBZw+3ZKicYypcwZ7POH18UJReB9Vd7MdIpJFvkKlV1k7u2AC5j5Vf72rf1n 029KPFWV85rAwJj2cZ2iZneX0enjfDFto/pWVLXi3xcbjDUGT/mX8Y3eHkS7lCN0ugP+ 6Xv/wDbh+i5XQWbQK/a4/SO0alFnOkaZSWP0V64Ol1jpgr/eCug5AXlISMTSKe455v3J A47TWdsrSzzE2SUuIilwpfAWyk5rroNexxyMmDbuidwaREgzxApScpqmoiw72CGHe1OH oJR45yOfZJTKRM5FhyN7DYMYyXZfEkFao/DBuMbrID+AyMPYTBPZX00cxhC7MvMoT4yK gOQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xBkQ++s/"; 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.03; Tue, 28 May 2019 06:37:03 -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="xBkQ++s/"; 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 S1727445AbfE1NhD (ORCPT + 5 others); Tue, 28 May 2019 09:37:03 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36600 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727413AbfE1NhC (ORCPT ); Tue, 28 May 2019 09:37:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id s17so20280627wru.3 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=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=kOVDV1il6dV96dtgpkskRvUrdO05lfGAO/TZL7tl6OBLlXgKI/Tx6DZjhRtEYvuBGh LQNFxEUnV+UFxLCFJRWWBQg4xG+MGUWTWkAl0GKYYpMOElTBlS7f6P0KjUFz+xACo416 70G6xO0yfI1slmGUE5Un1k5z8HRD1a/zZZGMDoksZZX6oSl3Ln6Tn11a380hIg7OCetd 4XfrNtJGLO9vxc38bZFm9Vew3RJA4tHEwgFuSNRtCR0Rf+MbH/8MTap8OOirJCigAbu3 ZvdxjWNxgvT3AwKUZU5Jlus5KX7E/Kf7yTvFqF08mqdIVAPE4oVwmjwiK0ycTPOAhYwf shDg== X-Gm-Message-State: APjAAAWivOZ7vf3ri4+mF4SPSM1LLEIAm/M3ee2qFkBY0nTjXLWRAlyk xOFN3yUg/1QnJKxaWJVkRmaMiQ== 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 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 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 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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. Reviewed-by: Mika Westerberg Signed-off-by: Ard Biesheuvel --- drivers/irqchip/irq-sni-exiu.c | 76 +++++++++++++++++--- 1 file changed, 68 insertions(+), 8 deletions(-) -- 2.20.1 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