Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3892681rwi; Sun, 16 Oct 2022 20:59:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TyeMfkHHlUphap6tqwLgdXR0apkChxvVEgyzhfY3DJNDLSshl2uTA18VBrRcYjRzaYluF X-Received: by 2002:a17:903:2285:b0:185:44df:d911 with SMTP id b5-20020a170903228500b0018544dfd911mr9968270plh.71.1665979186251; Sun, 16 Oct 2022 20:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665979186; cv=none; d=google.com; s=arc-20160816; b=aCRvNLHUcF+PqrQnlsU40pfPR4a1qXHuLudTRC2OjIqGedxmC/Z4DvclBqcQaumA9F eSA9fEcIB8X4VEWWAZ4nZfjhkKoTZ4z0dpizOGnAH0FyLoyBHsd5K/rRqcoLr+DaxpIn GJRNVSzWx0pTgU7FblaOR1qYTEZn+V4aKjQa7jv0pVSd5sOeKGWxWfwaNyZ/0Zv4AXmT N9554/kX1iC5UnykcVYDz1o1ZHstn9K/YyRvEte3XJt1kKgfTGqto/Gx3JvLt3qJ7bpX P0q3Mmu2pYNuZKtnvfKLZSS7OlCz+4G96BjXSOYQRkmxn0SIIA4fuXaQAf9i8LA6eSO6 VYVA== 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=P6Y6Xz85wIVC+DGN6M/r4suVX8AkX4m/jnV2wIgF4uU=; b=FCxrMGi2XhCUGzFIt6rN5zVc2Eu38Rm89gcUh+JbiJ3LKjlIaPVbwlP2Wkq1FmVn2N O83082cyYE7xPDD/Bwl/XS7DltsbPz9nIEdQY8Wc/TsOLWDIAY+ILmrTs4FUGXgN9+YN +F/IKsU737D26ObNMTmY1zJdXl8vUV0SDBGpJPhXtPGLiEqXKYIhCamUzSHfw4ZcZwmC 3CMQclctNLW5QTcZ1L++sznDMKj3KjxpEcJaXuaHmoQP6QVqUtImnOdi9nwTFpaEXzju pGcaPUYct0CwaEtFIEfKqRTHYIlAx9csOmBsbqi7wCiaRl1jChHO12JtMFkjh5qOqSQE cw6A== 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 n34-20020a17090a5aa500b00203917479dcsi15154610pji.107.2022.10.16.20.59.34; Sun, 16 Oct 2022 20:59:46 -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 S232619AbiJQDnL (ORCPT + 99 others); Sun, 16 Oct 2022 23:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232615AbiJQDnJ (ORCPT ); Sun, 16 Oct 2022 23:43:09 -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 D7D5850197 for ; Sun, 16 Oct 2022 20:43:07 -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 94066B80CC2 for ; Mon, 17 Oct 2022 03:43:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86C06C433C1; Mon, 17 Oct 2022 03:43:03 +0000 (UTC) From: Huacai Chen To: Thomas Gleixner , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Xuefeng Li , Huacai Chen , Jiaxun Yang , Huacai Chen Subject: [PATCH 3/4] irqchip/loongson-pch-pic: Add suspend/resume support Date: Mon, 17 Oct 2022 11:39:03 +0800 Message-Id: <20221017033904.2421723-4-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221017033904.2421723-1-chenhuacai@loongson.cn> References: <20221017033904.2421723-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 c01b9c257005..217513d74664 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