Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3892421rwi; Sun, 16 Oct 2022 20:59:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61hnO73wm1vhJfBCRF8v7sloMyAFKfcYi50PBTwn48TN7tF3DvyaAMghfykgCQ2ralfq5R X-Received: by 2002:a05:6a00:1ca4:b0:562:daf9:6162 with SMTP id y36-20020a056a001ca400b00562daf96162mr10405128pfw.40.1665979162904; Sun, 16 Oct 2022 20:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665979162; cv=none; d=google.com; s=arc-20160816; b=yPJDtDmubvLrdav4aLq2dNSeBurKsJRQfmzlPjaFd33X5k30Iuo9b79IRrIH1p3qv0 BkRtTTEc2gfCSGZxeEjJWNkZftUtBmPhxR6nJw1QXHb7P+rktY5sa1TrZeJHsXAKyfqW Js/pqrcepA9VUuvzc7Mk+tREWhHVvpUAb4CXQX0gq2MMzbzj6eGw1mIOM7w7KGgz4WKd KH+A1W8nyt+Sz+42RtTKLzs/p+5pvGKOTmc9DFKoY+GxYDIno62Q6vN6xmr0QChDCvwH /CHPSb5qgu9np3tbGtQLWTtI6hX1nP9OUKtS7Iyn1QZ2rmMTjyNP46qaiylRWHzeYvLM w7Yg== 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=6XifCLeTLId+XvzcE54Os8NYWc1ajxnAOQrjmExoOyg=; b=Dh579BIIWeonP3fyKhzqMkfHSNnKdAS32tgTDoWuLoTVTzV/LXVwpyY8BCUgXFG8gG y7WB1XvBK1JDuSVOLZCMvxHO8EycOqO4pf1j6rIfsAJkObKZAX4q5VGqeVxS/c541ePW r+zzBjqek8Qzt6/LmglqRVewZsSWm4JLXdei4gquNQsBxtVPqPi8gcBQ4/fdRDaiJ06v hJHUOO3kjaVBrgBi8KUdvTOLvT0dPZYRzGv+40wW8pU9ow3xiDqpj+fKyOYEaV+0rNUW DMUnvjIGM9ZlZ1ji5x2F9PeO3rmIagYcawoye4wfAXQKKajFjOE9vfJIIp5qea/UHWml lJhA== 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 u9-20020a056a00098900b0052e4de9b806si11459849pfg.342.2022.10.16.20.59.10; Sun, 16 Oct 2022 20:59:22 -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 S232642AbiJQDnv (ORCPT + 99 others); Sun, 16 Oct 2022 23:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232627AbiJQDnl (ORCPT ); Sun, 16 Oct 2022 23:43:41 -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 8F8E95050F for ; Sun, 16 Oct 2022 20:43:40 -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 45042B80CC2 for ; Mon, 17 Oct 2022 03:43:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26BEAC433B5; Mon, 17 Oct 2022 03:43:35 +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 4/4] irqchip/loongson-pch-lpc: Add suspend/resume support Date: Mon, 17 Oct 2022 11:39:04 +0800 Message-Id: <20221017033904.2421723-5-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-LPC irqchip, which is needed for upcoming suspend/hibernation. Signed-off-by: Huacai Chen --- drivers/irqchip/irq-loongson-pch-lpc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/irqchip/irq-loongson-pch-lpc.c b/drivers/irqchip/irq-loongson-pch-lpc.c index bf2324910a75..9b35492fb6be 100644 --- a/drivers/irqchip/irq-loongson-pch-lpc.c +++ b/drivers/irqchip/irq-loongson-pch-lpc.c @@ -13,6 +13,7 @@ #include #include #include +#include /* Registers */ #define LPC_INT_CTL 0x00 @@ -34,6 +35,7 @@ struct pch_lpc { u32 saved_reg_pol; }; +static struct pch_lpc *pch_lpc_priv; struct fwnode_handle *pch_lpc_handle; static void lpc_irq_ack(struct irq_data *d) @@ -147,6 +149,26 @@ static int pch_lpc_disabled(struct pch_lpc *priv) (readl(priv->base + LPC_INT_STS) == 0xffffffff); } +static int pch_lpc_suspend(void) +{ + pch_lpc_priv->saved_reg_ctl = readl(pch_lpc_priv->base + LPC_INT_CTL); + pch_lpc_priv->saved_reg_ena = readl(pch_lpc_priv->base + LPC_INT_ENA); + pch_lpc_priv->saved_reg_pol = readl(pch_lpc_priv->base + LPC_INT_POL); + return 0; +} + +static void pch_lpc_resume(void) +{ + writel(pch_lpc_priv->saved_reg_ctl, pch_lpc_priv->base + LPC_INT_CTL); + writel(pch_lpc_priv->saved_reg_ena, pch_lpc_priv->base + LPC_INT_ENA); + writel(pch_lpc_priv->saved_reg_pol, pch_lpc_priv->base + LPC_INT_POL); +} + +static struct syscore_ops pch_lpc_syscore_ops = { + .suspend = pch_lpc_suspend, + .resume = pch_lpc_resume, +}; + int __init pch_lpc_acpi_init(struct irq_domain *parent, struct acpi_madt_lpc_pic *acpi_pchlpc) { @@ -191,7 +213,10 @@ int __init pch_lpc_acpi_init(struct irq_domain *parent, parent_irq = irq_create_fwspec_mapping(&fwspec); irq_set_chained_handler_and_data(parent_irq, lpc_irq_dispatch, priv); + pch_lpc_priv = priv; pch_lpc_handle = irq_handle; + register_syscore_ops(&pch_lpc_syscore_ops); + return 0; free_irq_handle: -- 2.31.1