Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1357683imm; Tue, 22 May 2018 02:46:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrlmXn1RnFGlbBHkbjtXihu0GfOPMMKz+mB6T3UrqZ4Ze2QpLNc2VSN0pdqe8FYE36Ieb7f X-Received: by 2002:a65:5288:: with SMTP id y8-v6mr18733758pgp.69.1526982417051; Tue, 22 May 2018 02:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526982417; cv=none; d=google.com; s=arc-20160816; b=gs/3MBasqTGS6Gx1w+3WWOOn0Ig3ETwJW2nuvDWPTMwCwKPzWNZKSVv10ZPOjlCAuc yjHf0FJ1YLpqtJrUAlxFLgj2mf3UbyUN8feENOw83W69izzA3FNET7n3nCWApTYYG1r+ LmQP3lQsE92lNO2zs5F7s7pyHpVXIzwNYln6TF+F/g//U6KgeU2e3ChkTGeyr8scJDPg 1mFBMpqbN2Rbz0jrvdVZ8GNh6MiX9YcTmHfpKo/JgkCVTTVoHPlECMY0N0q3rNC/ii6U D+Xw59cwkiVpNu2u5FKsMyn+moXr2S3XcwZfcMl4Itr348hVTqMcE073f7IQ2EAKQNo7 wcIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=yVXdsyhnvuS0aM8/w1KtRBljW6JK5RNu2qzfUnwrcXM=; b=dhnJVUUjwyEBxRG7sq1/34AHBr0o6krbSMtQrgOkfvjd9t0SYRi/XdH9r6b+6O9k/D XG5Ayj0XD6QhlhE/YG/iW7fCNMp8etwSyFuRpi+rGT9BqLFKHBd7mFeBu8EyXmLa7Kvz /KhvbApkYDSEGy3q7lzPgu4RYaHcUtC2zsBQzrRxQtb+nY1hRDuqBzcN5NpEunRQvC9p EUwsxeMoEeli7eSyusc/gTQd9smEPAwqYszkYFzFx5S+PHivMv7dl7Ep5Rpfiiz01dau W4ok0aA8CCof4nKg63rrASJ91DwVjET/vgGVWmH2BRfgvlK8mxgnGJpAUdjOp+KYGt/R mgpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n13-v6si12614527pgt.564.2018.05.22.02.46.42; Tue, 22 May 2018 02:46:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752102AbeEVJoi (ORCPT + 99 others); Tue, 22 May 2018 05:44:38 -0400 Received: from mail.bootlin.com ([62.4.15.54]:49694 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751371AbeEVJk6 (ORCPT ); Tue, 22 May 2018 05:40:58 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id A626D20737; Tue, 22 May 2018 11:40:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 1C3C720787; Tue, 22 May 2018 11:40:45 +0200 (CEST) From: Miquel Raynal To: Thomas Gleixner , Jason Cooper , Marc Zyngier , Catalin Marinas , Will Deacon , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth Cc: Rob Herring , Mark Rutland , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Antoine Tenart , Maxime Chevallier , Nadav Haklai , Haim Boot , Hanna Hawa , linux-kernel@vger.kernel.org, Miquel Raynal Subject: [PATCH v2 05/16] irqchip/irq-mvebu-icu: switch to regmap Date: Tue, 22 May 2018 11:40:31 +0200 Message-Id: <20180522094042.24770-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180522094042.24770-1-miquel.raynal@bootlin.com> References: <20180522094042.24770-1-miquel.raynal@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before splitting the code to support multiple platform devices to be probed (one for the ICU, one per interrupt group), let's switch to regmap first by creating one in the ->probe(). Signed-off-by: Miquel Raynal --- drivers/irqchip/irq-mvebu-icu.c | 45 +++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-mvebu-icu.c b/drivers/irqchip/irq-mvebu-icu.c index 0f2655d7f19e..3694c0d73c0d 100644 --- a/drivers/irqchip/irq-mvebu-icu.c +++ b/drivers/irqchip/irq-mvebu-icu.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include @@ -38,7 +40,7 @@ struct mvebu_icu { struct irq_chip irq_chip; - void __iomem *base; + struct regmap *regmap; struct irq_domain *domain; struct device *dev; atomic_t initialized; @@ -56,10 +58,10 @@ static void mvebu_icu_init(struct mvebu_icu *icu, struct msi_msg *msg) return; /* Set Clear/Set ICU SPI message address in AP */ - writel_relaxed(msg[0].address_hi, icu->base + ICU_SETSPI_NSR_AH); - writel_relaxed(msg[0].address_lo, icu->base + ICU_SETSPI_NSR_AL); - writel_relaxed(msg[1].address_hi, icu->base + ICU_CLRSPI_NSR_AH); - writel_relaxed(msg[1].address_lo, icu->base + ICU_CLRSPI_NSR_AL); + regmap_write(icu->regmap, ICU_SETSPI_NSR_AH, msg[0].address_hi); + regmap_write(icu->regmap, ICU_SETSPI_NSR_AL, msg[0].address_lo); + regmap_write(icu->regmap, ICU_CLRSPI_NSR_AH, msg[1].address_hi); + regmap_write(icu->regmap, ICU_CLRSPI_NSR_AL, msg[1].address_lo); } static void mvebu_icu_write_msg(struct msi_desc *desc, struct msi_msg *msg) @@ -82,7 +84,7 @@ static void mvebu_icu_write_msg(struct msi_desc *desc, struct msi_msg *msg) icu_int = 0; } - writel_relaxed(icu_int, icu->base + ICU_INT_CFG(d->hwirq)); + regmap_write(icu->regmap, ICU_INT_CFG(d->hwirq), icu_int); /* * The SATA unit has 2 ports, and a dedicated ICU entry per @@ -94,10 +96,10 @@ static void mvebu_icu_write_msg(struct msi_desc *desc, struct msi_msg *msg) * configured (regardless of which port is actually in use). */ if (d->hwirq == ICU_SATA0_ICU_ID || d->hwirq == ICU_SATA1_ICU_ID) { - writel_relaxed(icu_int, - icu->base + ICU_INT_CFG(ICU_SATA0_ICU_ID)); - writel_relaxed(icu_int, - icu->base + ICU_INT_CFG(ICU_SATA1_ICU_ID)); + regmap_write(icu->regmap, ICU_INT_CFG(ICU_SATA0_ICU_ID), + icu_int); + regmap_write(icu->regmap, ICU_INT_CFG(ICU_SATA1_ICU_ID), + icu_int); } } @@ -204,12 +206,20 @@ static const struct irq_domain_ops mvebu_icu_domain_ops = { .free = mvebu_icu_irq_domain_free, }; +static struct regmap_config mvebu_icu_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .name = "mvebu_icu", +}; + static int mvebu_icu_probe(struct platform_device *pdev) { struct mvebu_icu *icu; struct device_node *node = pdev->dev.of_node; struct device_node *gicp_dn; struct resource *res; + void __iomem *regs; int i; icu = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_icu), @@ -220,12 +230,17 @@ static int mvebu_icu_probe(struct platform_device *pdev) icu->dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - icu->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(icu->base)) { + regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(regs)) { dev_err(&pdev->dev, "Failed to map icu base address.\n"); - return PTR_ERR(icu->base); + return PTR_ERR(regs); } + icu->regmap = devm_regmap_init_mmio(icu->dev, regs, + &mvebu_icu_regmap_config); + if (IS_ERR(icu->regmap)) + return PTR_ERR(icu->regmap); + icu->irq_chip.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "ICU.%x", (unsigned int)res->start); @@ -260,11 +275,11 @@ static int mvebu_icu_probe(struct platform_device *pdev) for (i = 0 ; i < ICU_MAX_IRQS ; i++) { u32 icu_int, icu_grp; - icu_int = readl_relaxed(icu->base + ICU_INT_CFG(i)); + regmap_read(icu->regmap, ICU_INT_CFG(i), &icu_int); icu_grp = icu_int >> ICU_GROUP_SHIFT; if (icu_grp == ICU_GRP_NSR) - writel_relaxed(0x0, icu->base + ICU_INT_CFG(i)); + regmap_write(icu->regmap, ICU_INT_CFG(i), 0); } icu->domain = -- 2.14.1