From patchwork Tue Sep 8 16:50:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 7142691 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 935179F1BF for ; Tue, 8 Sep 2015 16:51:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7329F20834 for ; Tue, 8 Sep 2015 16:51:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66DC2207B5 for ; Tue, 8 Sep 2015 16:51:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZM78-0000nq-2u; Tue, 08 Sep 2015 16:51:22 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZM6z-0000Wk-6E; Tue, 08 Sep 2015 16:51:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E60375; Tue, 8 Sep 2015 09:50:59 -0700 (PDT) Received: from [10.1.207.150] (e103737-lin.cambridge.arm.com [10.1.207.150]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 061D93F318; Tue, 8 Sep 2015 09:50:47 -0700 (PDT) Subject: Re: [PATCH v4] pinctrl: mediatek: Implement wake handler and suspend resume To: maoguang meng References: <1439541486-22203-1-git-send-email-maoguang.meng@mediatek.com> <55DB4609.5040904@arm.com> <1441535972.22230.5.camel@mhfsdcap03> <55EEAA24.6080706@arm.com> From: Sudeep Holla Message-ID: <55EF11E6.7030307@arm.com> Date: Tue, 8 Sep 2015 17:50:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EEAA24.6080706@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150908_095113_371598_7D5705A3 X-CRM114-Status: GOOD ( 23.83 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hongzhou Yang , Linus Walleij , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , Sudeep Holla , Matthias Brugger , Yingjoe Chen , "linux-arm-kernel@lists.infradead.org" Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 08/09/15 10:28, Sudeep Holla wrote: > > > On 06/09/15 11:39, maoguang meng wrote: >> On Wed, 2015-09-02 at 14:02 +0800, Daniel Kurtz wrote: >>> Hi maoguang, >>> >>> On Tue, Aug 25, 2015 at 12:27 AM, Sudeep Holla wrote: >>>> >>>> >>>> On 14/08/15 09:38, maoguang.meng@mediatek.com wrote: >>>>> >>>>> From: Maoguang Meng >>>>> >>>>> This patch implement irq_set_wake to get who is wakeup source and >>>>> setup on suspend resume. >>>>> >>>>> Signed-off-by: Maoguang Meng >>>>> >>> [snip] >>> >>> Can you please respond to Sudeep's questions: >>> >>>> Does this pinmux controller: >>>> >>>> 1. Support wake-up configuration ? If not, you need to use >>>> IRQCHIP_SKIP_SET_WAKE. I don't see any value in writing the >>>> mask_{set,clear} if the same registers are used for {en,dis}able >> >> YES. >> we can call enable_irq_wake(irq) to config this irq as a wake-up >> source. >> > > No that doesn't answer my question. Yes you can always call > enable_irq_wake(irq) as along as you have irq_set_wake implemented. > But my question was does this pinmux controller support wake-up > configuration. > > IMHO, by looking at the implementation I can confirm *NO*, it doesn't. > So please stop copy-pasting the implementation from other drivers. > The reason is you operate on the same mask_{set,clear} which you use > to {en,dis}able the interrupts which means you don't have to do anything > to configure an interrupt as a wakeup source other than just keeping > them enabled. Hopefully this clarifies. > >>>> >>>> 2. Is in always on domain ? If not, you need save/restore only to >>>> resume back the functionality. Generally we can set >>>> IRQCHIP_MASK_ON_SUSPEND to ensure non-wake-up interrupts are >>>> disabled during suspend and re-enabled in resume path. You just >>>> save/restore raw values without tracking the wake-up source. >> >> YES. >> > > Again *YES* for what part of my question. If it's always-on, then you > don't need this suspend/resume callbacks at all, so I assume the answer > is *NO*. > IIUC this pinmux controller, something like below should work. ---->8 From 7c26992bce047efb66a6ba8d2ffec2b272499df7 Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Tue, 8 Sep 2015 17:35:38 +0100 Subject: [PATCH] pinctrl: mediatek: Enable SKIP_SET_WAKE and MASK_ON_SUSPEND The mediatek pinmux controller doesn't provides any facility to configure the wakeup sources. So instead of providing redundant irq_set_wake functionality, SKIP_SET_WAKE could be set to it. Also there's no need to maintain 2 sets of masks. This patch enables IRQCHIP_SKIP_SET_WAKE and IRQCHIP_MASK_ON_SUSPEND and also removes wake_mask. Cc: Linus Walleij Cc: Matthias Brugger Cc: Hongzhou Yang Cc: Yingjoe Chen Cc: Maoguang Meng Cc: Chaotian Jing Cc: linux-gpio@vger.kernel.org Cc: linux-mediatek@lists.infradead.org Signed-off-by: Sudeep Holla --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 24 +----------------------- drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 1 - 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 7726c6caaf83..d8e194a5bb31 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -1063,20 +1063,6 @@ static int mtk_eint_set_type(struct irq_data *d, return 0; } -static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on) -{ - struct mtk_pinctrl *pctl = irq_data_get_irq_chip_data(d); - int shift = d->hwirq & 0x1f; - int reg = d->hwirq >> 5; - - if (on) - pctl->wake_mask[reg] |= BIT(shift); - else - pctl->wake_mask[reg] &= ~BIT(shift); - - return 0; -} - static void mtk_eint_chip_write_mask(const struct mtk_eint_offsets *chip, void __iomem *eint_reg_base, u32 *buf) { @@ -1112,7 +1098,6 @@ static int mtk_eint_suspend(struct device *device) reg = pctl->eint_reg_base; mtk_eint_chip_read_mask(eint_offsets, reg, pctl->cur_mask); - mtk_eint_chip_write_mask(eint_offsets, reg, pctl->wake_mask); return 0; } @@ -1153,9 +1138,9 @@ static struct irq_chip mtk_pinctrl_irq_chip = { .irq_unmask = mtk_eint_unmask, .irq_ack = mtk_eint_ack, .irq_set_type = mtk_eint_set_type, - .irq_set_wake = mtk_eint_irq_set_wake, .irq_request_resources = mtk_pinctrl_irq_request_resources, .irq_release_resources = mtk_pinctrl_irq_release_resources, + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND, }; static unsigned int mtk_eint_init(struct mtk_pinctrl *pctl) @@ -1393,13 +1378,6 @@ int mtk_pctrl_init(struct platform_device *pdev, } ports_buf = pctl->devdata->eint_offsets.ports; - pctl->wake_mask = devm_kcalloc(&pdev->dev, ports_buf, - sizeof(*pctl->wake_mask), GFP_KERNEL); - if (!pctl->wake_mask) { - ret = -ENOMEM; - goto chip_error; - } - pctl->cur_mask = devm_kcalloc(&pdev->dev, ports_buf, sizeof(*pctl->cur_mask), GFP_KERNEL); if (!pctl->cur_mask) { diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h index 55a534338931..acd804a945d8 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h @@ -267,7 +267,6 @@ struct mtk_pinctrl { void __iomem *eint_reg_base; struct irq_domain *domain; int *eint_dual_edges; - u32 *wake_mask; u32 *cur_mask; };