Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp234664iob; Mon, 2 May 2022 18:02:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLxAEg+AW6Uhkb5JyzkByvEfzIOG/fgp45HvyLS6GyZdYH8SYgJRz5C6klTt4pk1CioKPh X-Received: by 2002:a63:87c1:0:b0:3ab:1a17:35b7 with SMTP id i184-20020a6387c1000000b003ab1a1735b7mr11938092pge.313.1651539772859; Mon, 02 May 2022 18:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651539772; cv=none; d=google.com; s=arc-20160816; b=nKHI+kAfINZUKDKY9Z2HvIBOIq9T4nf0o8bZXJ3Jm1iB51Ftk4sonujtX0gLpw4EuZ vLHxGScGERsPieBEXyne3Qj3A1N4S4DGHuRdDkwwhpHMP7IJMwlSLJCV6H1OBOhXHyJ3 XkKoKrw9rwG0CzAMr+0AQVDIuI4fd3LP0nhsDao+oDsNJbBTNJYfaAG7an6siD/+GdjE dvynzsON0R89bSAxtHVhHytlhiuAJhTFVirUQ50P0ndOoqR2PGJBKznXsZtpX4PlTiqO txIpD73lj4qk5NvUCA3S4zlLK6U6NXIwf7C5gHKyM4NjF/kZVMx+U2BdYWoBlN0otQnD Hu7w== 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=lg/7xS7sbP45U1Etk1Bj7TD4IvLYgd/PFEj7bYWsNBU=; b=wfCpugqJBCTwZ9dF/y91AIfLnf8XYpjV+sgoGe9lxs4H6g5+f7+dfsUtMMssIZYSHV FFjlqmjNcmNsCLW+3hup7a9aOB+uEjJQ7XeWVfM8aMkOBw4tb2zboSFK8XTIx99lzk7o I3lzKIMHs2K/h/O9UFAERhAU6pvJ4PSEOWyLV2cKfhPH/NR4kJ5UwnPaeVn7/5YGe2rK SZcB0ejh3fzRUp3X5Q7zRFJl9bJ9sJzvZ7l6MgEWuRNyh3KCiAfJ7MzlNqQei2/wqstp x0Prxh69xtuWN1UF14NTtGZ+Q/uMcl5mJS40eUwTrO7Us/Puvc/lVOK9lW5SfEHDxRek Fmkg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j1-20020a056a00174100b0050ad23a8d0esi16533783pfc.113.2022.05.02.18.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:02:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B2341116; Mon, 2 May 2022 17:46:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235750AbiD3I75 (ORCPT + 99 others); Sat, 30 Apr 2022 04:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbiD3I74 (ORCPT ); Sat, 30 Apr 2022 04:59:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D89A53FD9C for ; Sat, 30 Apr 2022 01:56:34 -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 72317608D5 for ; Sat, 30 Apr 2022 08:56:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A557AC385AA; Sat, 30 Apr 2022 08:56:31 +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 V11 03/10] irqchip/loongson-pch-pic: Add suspend/resume support Date: Sat, 30 Apr 2022 16:53:37 +0800 Message-Id: <20220430085344.3127346-4-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220430085344.3127346-1-chenhuacai@loongson.cn> References: <20220430085344.3127346-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 b0644d595789..5047ba96f7d7 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 @@ -41,6 +42,9 @@ struct pch_pic { struct fwnode_handle *domain_handle; u32 ht_vec_base; raw_spinlock_t pic_lock; + 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[2]; @@ -142,6 +146,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_alloc(struct irq_domain *domain, unsigned int virq, @@ -203,6 +208,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) { @@ -235,6 +280,8 @@ static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base, pch_pic_reset(priv); pch_pic_priv[nr_pics++] = priv; + register_syscore_ops(&pch_pic_syscore_ops); + return 0; iounmap_base: -- 2.27.0