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