From patchwork Tue Dec 12 14:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 177389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7770055vqy; Tue, 12 Dec 2023 06:45:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOLflI4mBIYC7wToZn1lcCB3lF1Iar++1qepXekmSkcoKU75tzp/w3mFFzANnRqaSHtxNc X-Received: by 2002:a17:902:db04:b0:1d0:81a3:4432 with SMTP id m4-20020a170902db0400b001d081a34432mr3852144plx.81.1702392350407; Tue, 12 Dec 2023 06:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702392350; cv=none; d=google.com; s=arc-20160816; b=OolZcjSLm1zvu+RToAaTr9Wez7VkbjoMpUsVAdm1kC3BcGb80zbYYiXxxLU+Pl8OKr XvOqk5oyoZJWawkbOCbIkXRPAAVl85joOZiBNg58F53sIdGntf5VV1zFPQ2wuCRyS+Yj rdm1y6XpyYmZDzZS7BQKEY0cJp5XyHMe6RMq98/un0k1nVeVfxIFHNfnS0uKEQWJDbUp d+qpqdA8dXIJqw8G/fowuLJmYl9pAg5tNUNMpyVbfHoDDgLbZSFWKGvrmzFG/T6ztdLK 6lKPmKzqFJC9WA+/XsvdJVPYo/W9Ton3EkZJ8PgwGUp/l643X9KelMJlLX1cgie0LRFe Hasw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Uw1i6E31Oq9foJm9vRTffEuxJYls4MdVg/tjhnHDdQA=; fh=I2NWj4QewUsJB8D1FIavcvdqna0ckJ8Bw6HOcWrZ4cM=; b=JwR5EbcRddfY14XWxoWVVPJUUVdSKsBiRUgJu/qBvzMHznKmH8f3e46b3lsVJNd0AT 45NkVgDB194ndWodAhH+Yw0VDFVE57F8rI0kNQ2RzkcfNgL1ZE+1Ug8VUvGQJ9dOf9Mh uEyMhZkMP8AkT9m5/yoWsCMRHkLA2PAiFzmk1IsD7AfbHgdJG8RaN+ZTFQ68eppt/RVV a0J9DNTvhfLfirKc5sYjvCYUaN7EpDSn9211n2CLe9D+hHGxCFuq/R8HoUAQCL0yUnbi edD1SuKlvs9Pfo01m5hjTe5ljNStOQfZiaED3oWN3FkS5383IizSDHNvZ8lNfdS4nNNJ UK7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=c3H7k2d7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=gd+G3bx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f12-20020a17090274cc00b001d0be32b0cfsi7931168plt.33.2023.12.12.06.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 06:45:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=c3H7k2d7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=gd+G3bx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0FFD9807E524; Tue, 12 Dec 2023 06:45:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376907AbjLLOoZ (ORCPT + 99 others); Tue, 12 Dec 2023 09:44:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376904AbjLLOoS (ORCPT ); Tue, 12 Dec 2023 09:44:18 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C890EA; Tue, 12 Dec 2023 06:44:24 -0800 (PST) Date: Tue, 12 Dec 2023 14:44:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702392262; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uw1i6E31Oq9foJm9vRTffEuxJYls4MdVg/tjhnHDdQA=; b=c3H7k2d7F6hek9v1ldMpiUXDPX/ViQj9jz2RMYbTVWbdlbmdMMmzawUMUDOwYWM1aILQHk h3SKLsk9WaGspCe6gGRrCu4NzVgTjJ0b9t9CLOvtA1j84VwwC46p+QqkXhYf2QfiDZoXYZ Hv3DOqtlEWwtwoRQAU5PM2XGnrKQdnPrnUCovCSzpwj7ThSCZxqK03s1PR/oup0WReBv4W DyAddTLMwy9J7Ssty3VXnt1MBK9d8PCWYCd31CaQwDhmhWt0iG7EaHYBlOjOZy/69a5jE4 nLIZf8hIxUXr047aGH2Y2S54+zcgGzYMBtdGcBLvPh6SESYATtiJP3qREHGWVA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702392262; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uw1i6E31Oq9foJm9vRTffEuxJYls4MdVg/tjhnHDdQA=; b=gd+G3bx3PVf/adOv0pq/FiSdn4rmS+09xloyxh8NMUyAP+D6TL2ODdyGR+3TyewyW26Ej9 yG53V+Wi2RPGz/Dg== From: "tip-bot2 for Claudiu Beznea" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/renesas-rzg2l: Add support for suspend to RAM Cc: Claudiu Beznea , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20231120111820.87398-8-claudiu.beznea.uj@bp.renesas.com> References: <20231120111820.87398-8-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Message-ID: <170239226209.398.11711507811402945428.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 06:45:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783153111839121514 X-GMAIL-MSGID: 1785087761185631405 The following commit has been merged into the irq/core branch of tip: Commit-ID: 74d2ef5f6f4b2437e6292ab2502400e8048db4aa Gitweb: https://git.kernel.org/tip/74d2ef5f6f4b2437e6292ab2502400e8048db4aa Author: Claudiu Beznea AuthorDate: Mon, 20 Nov 2023 13:18:18 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 12 Dec 2023 15:40:41 +01:00 irqchip/renesas-rzg2l: Add support for suspend to RAM The irqchip-renesas-rzg2l driver is used on RZ/G3S SoC. RZ/G3S can go into deep sleep states where power to different SoC's parts is cut off and RAM is switched to self-refresh. The resume from these states is done with the help of the bootloader. The IA55 IRQ controller needs to be reconfigured when resuming from deep sleep state. For this the IA55 registers are cached in suspend and restored in resume. The IA55 IRQ controller is connected to GPIO controller and GIC as follows: ┌──────────┐ ┌──────────┐ │ │ SPIX │ │ │ ├─────────►│ │ │ │ │ │ │ │ │ │ ┌────────┐IRQ0-7 │ IA55 │ │ GIC │ Pin0 ───────►│ ├─────────────►│ │ │ │ │ │ │ │ PPIY │ │ ... │ GPIO │ │ ├─────────►│ │ │ │GPIOINT0-127 │ │ │ │ PinN ───────►│ ├─────────────►│ │ │ │ └────────┘ └──────────┘ └──────────┘ where: - Pin0 is the first GPIO controller pin - PinN is the last GPIO controller pin - SPIX is the SPI interrupt with identifier X - PPIY is the PPI interrupt with identifier Y Implement suspend/resume functionality with syscore_ops to be able to cache/restore the registers after/before the GPIO controller suspend/resume functions are invoked. As the syscore_ops suspend/resume functions do not take any argument make the driver private data static so it can be accessed from the suspend/resume functions. The IA55 interrupt controller is resumed before the GPIO controller. As GPIO pins could be in an a state which causes spurious interrupts, the reconfiguration of the interrupt controller is restricted to restore the interrupt type and leave them disabled. An eventually required interrupt enable operation will be done as part of the GPIO controller resume function after restoring the GPIO state. [ tglx: Massaged changelog ] Signed-off-by: Claudiu Beznea Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20231120111820.87398-8-claudiu.beznea.uj@bp.renesas.com --- drivers/irqchip/irq-renesas-rzg2l.c | 68 +++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-renesas-rzg2l.c b/drivers/irqchip/irq-renesas-rzg2l.c index 34add75..9494fc2 100644 --- a/drivers/irqchip/irq-renesas-rzg2l.c +++ b/drivers/irqchip/irq-renesas-rzg2l.c @@ -18,6 +18,7 @@ #include #include #include +#include #define IRQC_IRQ_START 1 #define IRQC_IRQ_COUNT 8 @@ -56,16 +57,28 @@ #define TINT_EXTRACT_GPIOINT(x) FIELD_GET(GENMASK(31, 16), (x)) /** + * struct rzg2l_irqc_reg_cache - registers cache (necessary for suspend/resume) + * @iitsr: IITSR register + * @titsr: TITSR registers + */ +struct rzg2l_irqc_reg_cache { + u32 iitsr; + u32 titsr[2]; +}; + +/** * struct rzg2l_irqc_priv - IRQ controller private data structure * @base: Controller's base address * @fwspec: IRQ firmware specific data * @lock: Lock to serialize access to hardware registers + * @cache: Registers cache for suspend/resume */ -struct rzg2l_irqc_priv { +static struct rzg2l_irqc_priv { void __iomem *base; struct irq_fwspec fwspec[IRQC_NUM_IRQ]; raw_spinlock_t lock; -}; + struct rzg2l_irqc_reg_cache cache; +} *rzg2l_irqc_data; static struct rzg2l_irqc_priv *irq_data_to_priv(struct irq_data *data) { @@ -246,6 +259,38 @@ static int rzg2l_irqc_set_type(struct irq_data *d, unsigned int type) return irq_chip_set_type_parent(d, IRQ_TYPE_LEVEL_HIGH); } +static int rzg2l_irqc_irq_suspend(void) +{ + struct rzg2l_irqc_reg_cache *cache = &rzg2l_irqc_data->cache; + void __iomem *base = rzg2l_irqc_data->base; + + cache->iitsr = readl_relaxed(base + IITSR); + for (u8 i = 0; i < 2; i++) + cache->titsr[i] = readl_relaxed(base + TITSR(i)); + + return 0; +} + +static void rzg2l_irqc_irq_resume(void) +{ + struct rzg2l_irqc_reg_cache *cache = &rzg2l_irqc_data->cache; + void __iomem *base = rzg2l_irqc_data->base; + + /* + * Restore only interrupt type. TSSRx will be restored at the + * request of pin controller to avoid spurious interrupts due + * to invalid PIN states. + */ + for (u8 i = 0; i < 2; i++) + writel_relaxed(cache->titsr[i], base + TITSR(i)); + writel_relaxed(cache->iitsr, base + IITSR); +} + +static struct syscore_ops rzg2l_irqc_syscore_ops = { + .suspend = rzg2l_irqc_irq_suspend, + .resume = rzg2l_irqc_irq_resume, +}; + static const struct irq_chip irqc_chip = { .name = "rzg2l-irqc", .irq_eoi = rzg2l_irqc_eoi, @@ -331,7 +376,6 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) struct irq_domain *irq_domain, *parent_domain; struct platform_device *pdev; struct reset_control *resetn; - struct rzg2l_irqc_priv *priv; int ret; pdev = of_find_device_by_node(node); @@ -344,15 +388,15 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) return -ENODEV; } - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) + rzg2l_irqc_data = devm_kzalloc(&pdev->dev, sizeof(*rzg2l_irqc_data), GFP_KERNEL); + if (!rzg2l_irqc_data) return -ENOMEM; - priv->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); + rzg2l_irqc_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); + if (IS_ERR(rzg2l_irqc_data->base)) + return PTR_ERR(rzg2l_irqc_data->base); - ret = rzg2l_irqc_parse_interrupts(priv, node); + ret = rzg2l_irqc_parse_interrupts(rzg2l_irqc_data, node); if (ret) { dev_err(&pdev->dev, "cannot parse interrupts: %d\n", ret); return ret; @@ -375,17 +419,19 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) goto pm_disable; } - raw_spin_lock_init(&priv->lock); + raw_spin_lock_init(&rzg2l_irqc_data->lock); irq_domain = irq_domain_add_hierarchy(parent_domain, 0, IRQC_NUM_IRQ, node, &rzg2l_irqc_domain_ops, - priv); + rzg2l_irqc_data); if (!irq_domain) { dev_err(&pdev->dev, "failed to add irq domain\n"); ret = -ENOMEM; goto pm_put; } + register_syscore_ops(&rzg2l_irqc_syscore_ops); + return 0; pm_put: