Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1343929pxb; Thu, 16 Sep 2021 05:37:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWA84k+P0Oz+56SkQQCow39ECNT8ZzBoifn2CY+tJNxp3tajiyM3C7rHGt+Km2lopi1ZPH X-Received: by 2002:a5d:84d2:: with SMTP id z18mr2509451ior.52.1631795834524; Thu, 16 Sep 2021 05:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631795834; cv=none; d=google.com; s=arc-20160816; b=rSeyg9PKqWMw0I4/sFe1GiNm4Ir2/bIiEMuK1pihxrrP/K52LRncQHEHktprC4id1P IcgXhwGjJ/89H8292vgD91/cOKs31/smI0kDXTOoli+LCMZJ5pggGLWlpsttL3pYp35b y38+wDy2//hQRI7Oy30esrdr1D9dPvsrVYHYApAtQPbCblfLfy1QD15rKi14XJ2Drkhe oiPzE094uQxnM6qxxUhHq7S+bv+2LJHtGXCem/HSZnE/fmTo/0aZMaoNNexvXxXm3YAX 9xRk9ue+d6OVvTlYiCLA8Gktm6LEliyvkS+ncq3o2WiDS0pZWPo5dtRHOt+Hc8BSPNrK y1Bg== 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=S4ctUqnRef7SRhDpOi8VeTKU4jTaFKSyNTdyZ5WRExQ=; b=VQlbiOkO6l4tuDybZHzyvN6ho8QFcIDIrLg55u2PppQoa1PD5ZrZzZaZac3EOt065t RX03UZPRzhFgRhH/ikOVQ6sciyEAGe+8+8ouzaraPPNOULKPw4vo+mIvTjH9R47JQkQC VjcuMR5bqjmmAunHwR/roaXBkXL8n8l23gcGmEJMtb1U15vFac5UT0bSRic7CrzKNLp7 fnWfEyXGUIU2kxr5AP7D/NYYT2YkstBVQ2F8h/tpbrhkLakIrwx1/CEMr95lJSwcBvMd aoyYny1l3EcMwQUnDukFwJH5uJ/7mKOmXPxn+Wp6DFU7OfHKF3sCW9eLsxuzuUPKy77p p5bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q2si2485144jac.2.2021.09.16.05.37.01; Thu, 16 Sep 2021 05:37:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239557AbhIPMgN (ORCPT + 99 others); Thu, 16 Sep 2021 08:36:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:39682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbhIPMgN (ORCPT ); Thu, 16 Sep 2021 08:36:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09D9E60F46; Thu, 16 Sep 2021 12:34:50 +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 V5 03/10] irqchip/loongson-pch-pic: Add suspend/resume support Date: Thu, 16 Sep 2021 20:31:31 +0800 Message-Id: <20210916123138.3490474-4-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916123138.3490474-1-chenhuacai@loongson.cn> References: <20210916123138.3490474-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 6fd0c983e02a..dadc908d3a61 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]; }; 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