From patchwork Mon Oct 17 03:39:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 3202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1253961wrs; Sun, 16 Oct 2022 20:44:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM445fpTQmuR7UlAD03Xh1VSsjvBkBTnHYLtC8NcCMO8L69Dj5RPMaCcYAWbji1vzQWBLF0k X-Received: by 2002:a05:6402:414d:b0:451:73f0:e113 with SMTP id x13-20020a056402414d00b0045173f0e113mr8435396eda.207.1665978250074; Sun, 16 Oct 2022 20:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665978250; cv=none; d=google.com; s=arc-20160816; b=QGM8YAYyLlKg/yHlFpsPghUpPA4u9ruXafcC9VBG+3HK2wvajnPjcSnJZgs0uaPyzM FFZK8FS1D438Ft5qFCpnexj2OHMQnCnz5QP4MzZMLw8Cf82UC/sNYep7Fy1H6OiTmdZ5 1ziak1KT8PGbyRXRRAu3oib7yW8X1/r2XJN4AupBtfuIAGBPzGu2aRxjp/Xz3O9xR4fR WsDQpjH6g+GWm2XOL9DUhnd7rjnWEyrXOoiZdPAn08pMSxBBduTIc3Xghw4HnVFY+q22 veTqSDNNtRaoOXh4g0w07WK6U36f8omMKUIx/Kf274ZGbs8YTAierpQJLPM1PHuNW8Ck AKGA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc11-20020a170907168b00b007269ef1872esi9594933ejc.897.2022.10.16.20.43.45; Sun, 16 Oct 2022 20:44:10 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746904809425508649?= X-GMAIL-MSGID: =?utf-8?q?1746904809425508649?= 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: