Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp465426rwi; Thu, 20 Oct 2022 00:41:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HmyPBDQ9J5tcyzcKvvPw5BVYTxHjzb5GaKK6/sft5JifPoEmMppRjz81D2N5RpTkv+NGh X-Received: by 2002:a17:902:6bcc:b0:182:df88:e6c8 with SMTP id m12-20020a1709026bcc00b00182df88e6c8mr12740591plt.117.1666251690292; Thu, 20 Oct 2022 00:41:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666251690; cv=none; d=google.com; s=arc-20160816; b=ACmSGFMENZfdVRRgYkzaXGBOZxHKqVhuiXgNPafemMjVZQhq/tV03rjDgG8bMFbZx5 KIQnUmN9PH5XcUpu99eWO175UdmzGHncnR0qUsXW64uUE8h9hjoFaVgEwUmNkvlqlmGj 2lCLUuh2hXQfKoZdRYRrHmsHqOmbbk0DubbhC2fmZWNASv8RxrmaTu5S+tp009eD2bV3 CwNM3eC1TViyUs7p06Wysgq/D2sysl9WXVlnV2d6msxWHGyPHXG6z/3mDJ6CcBOm83gf 0OOpcMn9XCdF/gh/4V4Si5pwx6VzPcbK9/MtBXS5w3kyGrDCyuw8+6U7YQPLCXnukMcW uYDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VmDUfwRl6pZb2Hk6jbdKw99hJuBQjS3mJMrKKrYPThE=; b=vJe+XLasomrurtFmzhFg8LVydM3Ew80+Ef4O1LJ+yQkFnj1JbIHzNsAGBusf3UofT4 /pdQ8LfSQaJDewT2bVcF7LoKA8IuY3ev1Qc17HihlYmZ4BsPQK5gI50ZOr4N3ON14Rh1 BMBgJEl5Lucbl2d9CM+Uzrk0HxszPR6I2AuRu8DnkIxCd3sldyRwJVk9FA3PXgv+y/zv kSQC4uQ/ATLp2qOBy82bCFy+AJ5hMXXmCVlueWZ1b4wVyPKRZxVrrSU5hmPWoTvheX/C bZce6y4EowKe+hDknHB+iK8R3yB2Fm1Ua+zLsfZ0FS1SI1Xl1nCrfvc0Lt8/RSI7x9pK Sj6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a170902854400b0017dafc02313si20776767plo.92.2022.10.20.00.41.18; Thu, 20 Oct 2022 00:41:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbiJTHiG (ORCPT + 99 others); Thu, 20 Oct 2022 03:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiJTHiF (ORCPT ); Thu, 20 Oct 2022 03:38:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 728F2170DF8 for ; Thu, 20 Oct 2022 00:38:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 058E1619E1 for ; Thu, 20 Oct 2022 07:38:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E3A9C433C1; Thu, 20 Oct 2022 07:38:01 +0000 (UTC) From: Huacai Chen To: Thomas Gleixner , Marc Zyngier Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Xuefeng Li , Huacai Chen , Jiaxun Yang , Huacai Chen Subject: [PATCH V2 1/4] irqchip/loongson-htvec: Add suspend/resume support Date: Thu, 20 Oct 2022 15:35:24 +0800 Message-Id: <20221020073527.541845-2-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221020073527.541845-1-chenhuacai@loongson.cn> References: <20221020073527.541845-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add suspend/resume support for HTVEC irqchip, which is needed for upcoming suspend/hibernation. Signed-off-by: Huacai Chen --- drivers/irqchip/irq-loongson-htvec.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/irqchip/irq-loongson-htvec.c b/drivers/irqchip/irq-loongson-htvec.c index 1f72bde2fff5..11289ffa07e4 100644 --- a/drivers/irqchip/irq-loongson-htvec.c +++ b/drivers/irqchip/irq-loongson-htvec.c @@ -16,6 +16,7 @@ #include #include #include +#include /* Registers */ #define HTVEC_EN_OFF 0x20 @@ -29,6 +30,7 @@ struct htvec { void __iomem *base; struct irq_domain *htvec_domain; raw_spinlock_t htvec_lock; + u32 saved_vec_en[HTVEC_MAX_PARENT_IRQ]; }; static struct htvec *htvec_priv; @@ -156,6 +158,29 @@ static void htvec_reset(struct htvec *priv) } } +static int htvec_suspend(void) +{ + int i; + + for (i = 0; i < htvec_priv->num_parents; i++) + htvec_priv->saved_vec_en[i] = readl(htvec_priv->base + HTVEC_EN_OFF + 4 * i); + + return 0; +} + +static void htvec_resume(void) +{ + int i; + + for (i = 0; i < htvec_priv->num_parents; i++) + writel(htvec_priv->saved_vec_en[i], htvec_priv->base + HTVEC_EN_OFF + 4 * i); +} + +static struct syscore_ops htvec_syscore_ops = { + .suspend = htvec_suspend, + .resume = htvec_resume, +}; + static int htvec_init(phys_addr_t addr, unsigned long size, int num_parents, int parent_irq[], struct fwnode_handle *domain_handle) { @@ -188,6 +213,8 @@ static int htvec_init(phys_addr_t addr, unsigned long size, htvec_priv = priv; + register_syscore_ops(&htvec_syscore_ops); + return 0; iounmap_base: -- 2.31.1