From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB154C433E0 for ; Thu, 14 Jan 2021 21:46:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77DD523A5C for ; Thu, 14 Jan 2021 21:46:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77DD523A5C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=z2ED/Cf/9FLKCFsBWTfCZuSR2NbQdT5L4XW7egwrMLw=; b=fsDS59e8JDB4Y5Fxxkh3Tg8Zf SEMDGqNHlpP7yXmJjRqEpT90jR2bY2dvqqaS/qyLcq4huaBo2/DTxAyNq+ySd1Wcyu+iAIWlFLl6x v+BHwj3g6quIwScgz8QNDjsjlDeyk4YENFZGcpPtwUzTpx8CBnd3ro+E9E6IgyfoO+W7b3m1JjzkR 5LmDp30sWSr8kVyH/FlgG7McwEBx/H85/2Z/f7SJ3tdAuSfnPeiLLdgqwI4EyB6YFlxyhe1MOCdzP 03uwWvBRswWci4wx8F6t9VHM5wg8LFDb3IrFSXIWVu+PJvIKo+EJ3W10bkXBhXd4hEJkOrHOf07WB h5fkK4Y+A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0AQB-0007xc-BK; Thu, 14 Jan 2021 21:44:47 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0AQ8-0007xF-JQ for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2021 21:44:45 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9708722BEA; Thu, 14 Jan 2021 21:44:43 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1l0AQ5-007bs8-7D; Thu, 14 Jan 2021 21:44:41 +0000 Date: Thu, 14 Jan 2021 21:44:40 +0000 Message-ID: <87sg73jirb.wl-maz@kernel.org> From: Marc Zyngier To: Samuel Holland Subject: Re: [PATCH v4 04/10] irqchip/sun6i-r: Add wakeup support In-Reply-To: <20210112055950.21209-5-samuel@sholland.org> References: <20210112055950.21209-1-samuel@sholland.org> <20210112055950.21209-5-samuel@sholland.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: samuel@sholland.org, tglx@linutronix.de, robh+dt@kernel.org, mripard@kernel.org, wens@csie.org, jernej.skrabec@siol.net, megous@megous.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210114_164445_113362_47C73BF0 X-CRM114-Status: GOOD ( 31.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ondrej Jirman , devicetree@vger.kernel.org, Jernej Skrabec , linux-kernel@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , Rob Herring , Thomas Gleixner , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 12 Jan 2021 05:59:44 +0000, Samuel Holland wrote: > > Maintain bitmaps of wake-enabled IRQs and mux inputs, and program them > to the hardware during the syscore phase of suspend and shutdown. Then > restore the original set of enabled IRQs (only the NMI) during resume. > > This serves two purposes. First, it lets power management firmware > running on the ARISC coprocessor know which wakeup sources Linux wants > to have enabled. That way, it can avoid turning them off when it shuts > down the remainder of the clock tree. Second, it preconfigures the > coprocessor's interrupt controller, so the firmware's wakeup logic > is as simple as waiting for an interrupt to arrive. > > The suspend/resume logic is not conditional on PM_SLEEP because it is > identical to the init/shutdown logic. Wake IRQs may be enabled during > shutdown to allow powering the board back on. As an example, see > commit a5c5e50cce9d ("Input: gpio-keys - add shutdown callback"). > > Signed-off-by: Samuel Holland > --- > drivers/irqchip/irq-sun6i-r.c | 107 ++++++++++++++++++++++++++++++++-- > 1 file changed, 101 insertions(+), 6 deletions(-) > > diff --git a/drivers/irqchip/irq-sun6i-r.c b/drivers/irqchip/irq-sun6i-r.c > index d04d067423f4..a1b58c98d6ca 100644 > --- a/drivers/irqchip/irq-sun6i-r.c > +++ b/drivers/irqchip/irq-sun6i-r.c > @@ -39,6 +39,7 @@ > * set of 128 mux bits. This requires a second set of top-level registers. > */ > > +#include > #include > #include > #include > @@ -46,6 +47,7 @@ > #include > #include > #include > +#include > > #include > > @@ -67,8 +69,17 @@ > #define SUN6I_NR_DIRECT_IRQS 16 > #define SUN6I_NR_MUX_BITS 128 > > +struct sun6i_r_intc_variant { > + u32 first_mux_irq; > + u32 nr_mux_irqs; > + u32 mux_valid[BITS_TO_U32(SUN6I_NR_MUX_BITS)]; > +}; > + > static void __iomem *base; > static irq_hw_number_t nmi_hwirq; > +static DECLARE_BITMAP(wake_irq_enabled, SUN6I_NR_TOP_LEVEL_IRQS); > +static DECLARE_BITMAP(wake_mux_enabled, SUN6I_NR_MUX_BITS); > +static DECLARE_BITMAP(wake_mux_valid, SUN6I_NR_MUX_BITS); > > static void sun6i_r_intc_ack_nmi(void) > { > @@ -145,6 +156,21 @@ static int sun6i_r_intc_nmi_set_irqchip_state(struct irq_data *data, > return irq_chip_set_parent_state(data, which, state); > } > > +static int sun6i_r_intc_irq_set_wake(struct irq_data *data, unsigned int on) > +{ > + unsigned long offset_from_nmi = data->hwirq - nmi_hwirq; > + > + if (offset_from_nmi < SUN6I_NR_DIRECT_IRQS) > + assign_bit(offset_from_nmi, wake_irq_enabled, on); > + else if (test_bit(data->hwirq, wake_mux_valid)) > + assign_bit(data->hwirq, wake_mux_enabled, on); > + else > + /* Not wakeup capable. */ > + return -EPERM; > + > + return 0; > +} > + > static struct irq_chip sun6i_r_intc_nmi_chip = { > .name = "sun6i-r-intc", > .irq_ack = sun6i_r_intc_nmi_ack, > @@ -154,8 +180,19 @@ static struct irq_chip sun6i_r_intc_nmi_chip = { > .irq_set_affinity = irq_chip_set_affinity_parent, > .irq_set_type = sun6i_r_intc_nmi_set_type, > .irq_set_irqchip_state = sun6i_r_intc_nmi_set_irqchip_state, > - .flags = IRQCHIP_SET_TYPE_MASKED | > - IRQCHIP_SKIP_SET_WAKE, > + .irq_set_wake = sun6i_r_intc_irq_set_wake, > + .flags = IRQCHIP_SET_TYPE_MASKED, > +}; > + > +static struct irq_chip sun6i_r_intc_wakeup_chip = { > + .name = "sun6i-r-intc", > + .irq_mask = irq_chip_mask_parent, > + .irq_unmask = irq_chip_unmask_parent, > + .irq_eoi = irq_chip_eoi_parent, > + .irq_set_affinity = irq_chip_set_affinity_parent, > + .irq_set_type = irq_chip_set_type_parent, > + .irq_set_wake = sun6i_r_intc_irq_set_wake, > + .flags = IRQCHIP_SET_TYPE_MASKED, Worth implementing irq_get/set_irqchip_state() using the _parent helper, I guess. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel