From patchwork Fri Feb 14 07:57:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 3651451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5CFB3BF13A for ; Fri, 14 Feb 2014 09:11:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5929A20212 for ; Fri, 14 Feb 2014 09:11:35 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B78B20179 for ; Fri, 14 Feb 2014 09:11:30 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEEDT-0005a1-1h; Fri, 14 Feb 2014 08:33:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEED5-0001Rw-Ea; Fri, 14 Feb 2014 08:33:23 +0000 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEECx-0001Qm-L4 for linux-arm-kernel@lists.infradead.org; Fri, 14 Feb 2014 08:33:21 +0000 Received: by mail-pb0-f52.google.com with SMTP id jt11so12001509pbb.25 for ; Fri, 14 Feb 2014 00:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=NoknKCSrD6r60ZWf6P4QrDNGLKScvfeTiNkmxsz11uE=; b=JucOc3XKUc6h0BWLnc7ZgTU0r3ccM9pjn5Ba9wfVFux7u6TA85o1QHZIU2aqxVC9Z9 F9sXwt368BIsD11Ir1kj3ctm4QCviPoOJlJQ6CH3EBbTS3qUEII9BQH7m9HHh/MQWMJ/ 7LDECu8pA5rmaY8Zhov1sazO5eaBfiSAzqyZS6+rD+39gHuZlHk/fExsmG0hXorUl8Iq AjhE4AW5q+cI9wl6RxivSlX8s7pnnIkUhPedi82WbtPZJmpoEEf2q3Q74o1wRuPduxCS IiUYtUt8ZqbIQnSsWYZDukQT67qYg8N1nJN9KxhxcHCvn+fF790RBp5DT0URGS3Hllqr c7pQ== X-Received: by 10.66.233.71 with SMTP id tu7mr7592639pac.22.1392366349885; Fri, 14 Feb 2014 00:25:49 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-67-188-112-76.hsd1.ca.comcast.net. [67.188.112.76]) by mx.google.com with ESMTPSA id cz3sm14557375pbc.9.2014.02.14.00.25.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 14 Feb 2014 00:25:49 -0800 (PST) Date: Thu, 13 Feb 2014 23:57:17 -0800 From: Dmitry Torokhov To: Barry Song <21cnbao@gmail.com> Subject: Re: [PATCH v3] input: sirfsoc-onkey - report onkey untouch event by detecting pin status Message-ID: <20140214075717.GA14682@core.coreip.homeip.net> References: <1392348001-4950-1-git-send-email-21cnbao@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1392348001-4950-1-git-send-email-21cnbao@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140214_033315_808349_54302354 X-CRM114-Status: GOOD ( 20.95 ) X-Spam-Score: -2.0 (--) Cc: Xianglong Du , linux-input@vger.kernel.org, workgroup.linux@csr.com, Rongjun Ying , Barry Song , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Hi Barry, On Fri, Feb 14, 2014 at 11:20:01AM +0800, Barry Song wrote: > From: Xianglong Du > > this patch adds a delayed_work to detect the untouch of onkey since HW will > not generate interrupt for it. > > at the same time, we move the KEY event to POWER instead of SUSPEND, which > will be suitable for both Android and Linux. Userspace PowerManager Daemon > will decide to suspend or shutdown based on how long we have touched onkey > > Signed-off-by: Xianglong Du > Signed-off-by: Rongjun Ying > Signed-off-by: Barry Song > --- > -v3: move to use custom devres action Thank you for making the changes, however it seems that we can control whether the device generates interrupts or not and so we can implement open and close methods. If patch below works then your cancel_delayed_work() call should go into sirfosc_pwrc_close() and we do not need to use devm_free_irq() not custom action. Thanks. diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c index e8897c3..dc7db65 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c @@ -49,6 +49,35 @@ static irqreturn_t sirfsoc_pwrc_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static void sirfsoc_pwrc_toggle_interrupts(struct sirfsoc_pwrc_drvdata *pwrcdrv, + bool enable) +{ + u32 int_mask; + + int_mask = sirfsoc_rtc_iobrg_readl(pwrcdrv->pwrc_base + PWRC_INT_MASK); + if (enable) + int_mask |= PWRC_ON_KEY_BIT; + else + int_mask &= ~PWRC_ON_KEY_BIT; + sirfsoc_rtc_iobrg_writel(int_mask, pwrcdrv->pwrc_base + PWRC_INT_MASK); +} + +static int sirfsoc_pwrc_open(struct input_dev *input) +{ + struct sirfsoc_pwrc_drvdata *pwrcdrv = input_get_drvdata(input); + + sirfsoc_pwrc_toggle_interrupts(pwrcdrv, true); + + return 0; +} + +static void sirfsoc_pwrc_close(struct input_dev *input) +{ + struct sirfsoc_pwrc_drvdata *pwrcdrv = input_get_drvdata(input); + + sirfsoc_pwrc_toggle_interrupts(pwrcdrv, false); +} + static const struct of_device_id sirfsoc_pwrc_of_match[] = { { .compatible = "sirf,prima2-pwrc" }, {}, @@ -70,7 +99,7 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) } /* - * we can't use of_iomap because pwrc is not mapped in memory, + * We can't use of_iomap because pwrc is not mapped in memory, * the so-called base address is only offset in rtciobrg */ error = of_property_read_u32(np, "reg", &pwrcdrv->pwrc_base); @@ -88,6 +117,11 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) pwrcdrv->input->phys = "pwrc/input0"; pwrcdrv->input->evbit[0] = BIT_MASK(EV_PWR); + pwrcdrv->input->open = sirfsoc_pwrc_open; + pwrcdrv->input->close = sirfsoc_pwrc_close; + + input_set_drvdata(pwrcdrv->input, pwrcdrv); + irq = platform_get_irq(pdev, 0); error = devm_request_irq(&pdev->dev, irq, sirfsoc_pwrc_isr, IRQF_SHARED, @@ -98,11 +132,6 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) return error; } - sirfsoc_rtc_iobrg_writel( - sirfsoc_rtc_iobrg_readl(pwrcdrv->pwrc_base + PWRC_INT_MASK) | - PWRC_ON_KEY_BIT, - pwrcdrv->pwrc_base + PWRC_INT_MASK); - error = input_register_device(pwrcdrv->input); if (error) { dev_err(&pdev->dev, @@ -129,15 +158,16 @@ static int pwrc_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct sirfsoc_pwrc_drvdata *pwrcdrv = platform_get_drvdata(pdev); + struct input_dev *input = pwrcdrv->input; /* * Do not mask pwrc interrupt as we want pwrc work as a wakeup source * if users touch X_ONKEY_B, see arch/arm/mach-prima2/pm.c */ - sirfsoc_rtc_iobrg_writel( - sirfsoc_rtc_iobrg_readl( - pwrcdrv->pwrc_base + PWRC_INT_MASK) | PWRC_ON_KEY_BIT, - pwrcdrv->pwrc_base + PWRC_INT_MASK); + mutex_lock(&input->mutex); + if (input->users) + sirfsoc_pwrc_toggle_interrupts(pwrcdrv, true); + mutex_unlock(&input->mutex); return 0; }