Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp467550rwi; Thu, 20 Oct 2022 00:43:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Od9wDYu09f3odZahmsS0KyBjYhMzth97YDFCBVtrsT05GQhDefjXuERl9wlnCjfHV6v4K X-Received: by 2002:a63:1112:0:b0:43c:7998:ac15 with SMTP id g18-20020a631112000000b0043c7998ac15mr11055989pgl.51.1666251829411; Thu, 20 Oct 2022 00:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666251829; cv=none; d=google.com; s=arc-20160816; b=CyKLA0Uipqz9zpLwuXtRh4MxEpgjCKMzTMRGR4w9SNHQsotIcrGNE4JREyN8gIEHv2 0TzWmEIHD6GC77gTAuFYmMm1TDGA/XNnSpMP4qYikN/1NdOHU/xzPBJ03hJVAq5BqzGi c8FrEsTwqXSyyZEA+Qw/H0VKY+W4dTVRBfJgR/Ud+YTgbejggVv+9c8jZGBPa463+UdO clcjRA9U4eKTIhEgiwyCSbqgACrpIX9g3ERFDLtm819YvFD1pJX8i2a8CpcuFJwPv32x O29rB1QFXD3xuHW5MsjSEB1SAh9GC+Sd+Q8ZrgI5JyFYG8dg+aPa2hAf/kRYPHgsHGfO evxQ== 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=dfzm/1tze6rwqgVt9jHOwFuqty4GFL7J2MnySzS6DBo=; b=KacRenkRwBrbuanRpTbLyg3J3f809Qu0FWm2oCNHitX27u7MwESknKpQcImNzcsUX2 U5sZb+Ac6O+TQNyr6+3/y5vschtZGxFw+dbEcFeI1mg0korCqjI6583LsHbu9I4myacm HoYQKIlMIo7PyK2UrGlqAgRGpGj2eHQ0afTHFTp5cjKvomVnjyziVN582Wb+SDcl0QhP X5ma74IRu++LZCgtkKrh9rYKy0doZ49KvOSoN9ioW5AIOhd+g+IqHKqOXehyBq2eZo7/ Ti1UpQg4uFpNarVfiUBsN9uU1KfXWa8RfHTHB++t7N645Kq+2Xt/s9cJU6HgsrZV/Gg2 IKeg== 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 k71-20020a63844a000000b00463cd99cdb5si20572063pgd.256.2022.10.20.00.43.37; Thu, 20 Oct 2022 00:43:49 -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 S229452AbiJTHir (ORCPT + 99 others); Thu, 20 Oct 2022 03:38:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbiJTHio (ORCPT ); Thu, 20 Oct 2022 03:38:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEAA6175345 for ; Thu, 20 Oct 2022 00:38:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id B2639B8265F for ; Thu, 20 Oct 2022 07:38:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84CB4C433C1; Thu, 20 Oct 2022 07:38:38 +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 3/4] irqchip/loongson-pch-pic: Add suspend/resume support Date: Thu, 20 Oct 2022 15:35:26 +0800 Message-Id: <20221020073527.541845-4-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 PCH-PIC irqchip, which is needed for upcoming suspend/hibernation. Signed-off-by: Huacai Chen --- drivers/irqchip/irq-loongson-pch-pic.c | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/irqchip/irq-loongson-pch-pic.c b/drivers/irqchip/irq-loongson-pch-pic.c index d2cf54a87bee..ef3d54e3eb72 100644 --- a/drivers/irqchip/irq-loongson-pch-pic.c +++ b/drivers/irqchip/irq-loongson-pch-pic.c @@ -15,6 +15,7 @@ #include #include #include +#include /* Registers */ #define PCH_PIC_MASK 0x20 @@ -42,6 +43,9 @@ struct pch_pic { raw_spinlock_t pic_lock; u32 vec_count; u32 gsi_base; + u32 saved_vec_en[PIC_REG_COUNT]; + u32 saved_vec_pol[PIC_REG_COUNT]; + u32 saved_vec_edge[PIC_REG_COUNT]; }; static struct pch_pic *pch_pic_priv[MAX_IO_PICS]; @@ -145,6 +149,7 @@ static struct irq_chip pch_pic_irq_chip = { .irq_ack = pch_pic_ack_irq, .irq_set_affinity = irq_chip_set_affinity_parent, .irq_set_type = pch_pic_set_type, + .flags = IRQCHIP_SKIP_SET_WAKE, }; static int pch_pic_domain_translate(struct irq_domain *d, @@ -228,6 +233,46 @@ static void pch_pic_reset(struct pch_pic *priv) } } +static int pch_pic_suspend(void) +{ + int i, j; + + for (i = 0; i < nr_pics; i++) { + for (j = 0; j < PIC_REG_COUNT; j++) { + pch_pic_priv[i]->saved_vec_pol[j] = + readl(pch_pic_priv[i]->base + PCH_PIC_POL + 4 * j); + pch_pic_priv[i]->saved_vec_edge[j] = + readl(pch_pic_priv[i]->base + PCH_PIC_EDGE + 4 * j); + pch_pic_priv[i]->saved_vec_en[j] = + readl(pch_pic_priv[i]->base + PCH_PIC_MASK + 4 * j); + } + } + + return 0; +} + +static void pch_pic_resume(void) +{ + int i, j; + + for (i = 0; i < nr_pics; i++) { + pch_pic_reset(pch_pic_priv[i]); + for (j = 0; j < PIC_REG_COUNT; j++) { + writel(pch_pic_priv[i]->saved_vec_pol[j], + pch_pic_priv[i]->base + PCH_PIC_POL + 4 * j); + writel(pch_pic_priv[i]->saved_vec_edge[j], + pch_pic_priv[i]->base + PCH_PIC_EDGE + 4 * j); + writel(pch_pic_priv[i]->saved_vec_en[j], + pch_pic_priv[i]->base + PCH_PIC_MASK + 4 * j); + } + } +} + +static struct syscore_ops pch_pic_syscore_ops = { + .suspend = pch_pic_suspend, + .resume = pch_pic_resume, +}; + static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base, struct irq_domain *parent_domain, struct fwnode_handle *domain_handle, u32 gsi_base) @@ -260,6 +305,8 @@ static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base, pch_pic_handle[nr_pics] = domain_handle; pch_pic_priv[nr_pics++] = priv; + register_syscore_ops(&pch_pic_syscore_ops); + return 0; iounmap_base: -- 2.31.1