From patchwork Mon Sep 8 15:41:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 37008 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD3B320491 for ; Mon, 8 Sep 2014 15:41:52 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id tp5sf7025952ieb.9 for ; Mon, 08 Sep 2014 08:41:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-disposition; bh=DkyI6Dz0ACNieL5Te29d2FffR1XSEGYUesc7RYPY79Q=; b=dafAfIdyei79CukkW8S8WWxxNLZhf/yWiNGOKvrVItnXMsZnpVUz+C433YHxc4LD77 NuRlqkgM6h+oyazJcSETMzUe6z1s0A1jFB4XUtWKpE0w73E7XFW5l4p9Ao+QDp8c6aBy UJrpPdPSzg4LzWaJtEwQ3RBcgQccgkcVasc7xFt60YE16EiuNnqWveSYrtw6LcJmnaZL raRbjUTYdXs04nWTrkDHg+aZDOw5nP2YQTxPdVAd7O3WJXRFM2+ezkpU6EHuSCm8ez+r 4dlUhyG0LVcI6X7g1oBNwYsaqSoVRvqD9Q4bfcT4tZ2eEs8YvrJLOw8FIm+c2nw+kHQ5 x0pw== X-Gm-Message-State: ALoCoQl8CgQ8ncAbB3kJNKrlCGeyIdGiq6ovPjCLayAAtWF+PDK3lbPoWW86LLLVX2WEAAWFp7rK X-Received: by 10.42.188.72 with SMTP id cz8mr12867639icb.21.1410190912146; Mon, 08 Sep 2014 08:41:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.102 with SMTP id a93ls1697725qge.15.gmail; Mon, 08 Sep 2014 08:41:52 -0700 (PDT) X-Received: by 10.52.255.232 with SMTP id at8mr21654027vdd.4.1410190912044; Mon, 08 Sep 2014 08:41:52 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id ut5si4073166vcb.26.2014.09.08.08.41.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Sep 2014 08:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hy10so1950641vcb.3 for ; Mon, 08 Sep 2014 08:41:51 -0700 (PDT) X-Received: by 10.52.129.165 with SMTP id nx5mr20779982vdb.25.1410190911865; Mon, 08 Sep 2014 08:41:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp152875vcb; Mon, 8 Sep 2014 08:41:51 -0700 (PDT) X-Received: by 10.70.52.74 with SMTP id r10mr1154619pdo.12.1410190910828; Mon, 08 Sep 2014 08:41:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g14si18556673pdm.118.2014.09.08.08.41.50 for ; Mon, 08 Sep 2014 08:41:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932065AbaIHPls (ORCPT + 26 others); Mon, 8 Sep 2014 11:41:48 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:59443 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754784AbaIHPlq (ORCPT ); Mon, 8 Sep 2014 11:41:46 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s88Ff9le013573; Mon, 8 Sep 2014 10:41:09 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s88Ff9Mw027975; Mon, 8 Sep 2014 10:41:09 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Mon, 8 Sep 2014 10:41:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s88Ff9GR005681; Mon, 8 Sep 2014 10:41:09 -0500 Date: Mon, 8 Sep 2014 10:41:09 -0500 From: Nishanth Menon To: Thomas Gleixner CC: Lee Jones , , , Keerthy , Mark Brown , Samuel Ortiz , , Tony Lindgren , Subject: Re: [PATCH V2 3/3] mfd: palmas: Add support for optional wakeup Message-ID: <20140908154109.GA12336@kahuna> References: <1409950311-25236-1-git-send-email-nm@ti.com> <1409950311-25236-4-git-send-email-nm@ti.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: nm@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline On 23:13-20140905, Thomas Gleixner wrote: > On Fri, 5 Sep 2014, Nishanth Menon wrote: > > + if (!palmas->wakeirq) > > + goto no_wake_irq; > > + > > + ret = devm_request_irq(palmas->dev, palmas->wakeirq, > > + palmas_wake_irq, > > + IRQF_ONESHOT | pdata->irq_flags, > > Why is this marked IRQF_ONESHOT? Uggh.. should have dropped it. my bad.. removed in the revision below. Thanks for catching it. > > > + dev_name(palmas->dev), > > + &palmas); > > + if (ret < 0) > > + goto err_i2c; > > Why err and not doing the obvious clearing of palmas->wakeirq and > keep at least the i2c functional? Hmmm.. true.. we can stay alive even though without wakeup capability if someone messes up configuration.. Fixed version below. Let me know if you are ok with the following. ----8<---- >From 6da58ac66eedea46cf7282c6644c76c8f328f5ee Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Tue, 12 Aug 2014 12:00:52 -0500 Subject: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup With the recent pinctrl-single changes, omaps can treat wake-up events from deeper power states as interrupts. This is to handle the case where the system needs two interrupt sources when SoC is in deep sleep(1 to exit from deep power mode such as sleep, and other from the module handling the actual event during system active state). This is not the same as threaded interrupts as the wakeup interrupt source is used only as part of deeper power saving mode. Let's add support for the optional second interrupt for wake-up events. And then SoC can wakeup and handle the event using it's regular handler. This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add support for optional wake-up") Signed-off-by: Nishanth Menon --- drivers/mfd/palmas.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/palmas.h | 2 ++ 2 files changed, 64 insertions(+) diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index 28cb048..de7d204 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c @@ -24,6 +24,7 @@ #include #include #include +#include static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = { { @@ -326,6 +327,16 @@ static struct regmap_irq_chip tps65917_irq_chip = { PALMAS_INT1_MASK), }; +static irqreturn_t palmas_wake_irq(int irq, void *_palmas) +{ + /* + * Return Not handled so that interrupt is disabled. + * Level event ensures that the event is eventually handled + * by the appropriate chip handler already registered + */ + return IRQ_NONE; +} + int palmas_ext_control_req_config(struct palmas *palmas, enum palmas_external_requestor_id id, int ext_ctrl, bool enable) { @@ -409,6 +420,7 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c, pdata->mux_from_pdata = 1; pdata->pad2 = prop; } + pdata->wakeirq = irq_of_parse_and_map(node, 1); /* The default for this register is all masked */ ret = of_property_read_u32(node, "ti,power-ctrl", &prop); @@ -521,6 +533,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, palmas); palmas->dev = &i2c->dev; palmas->irq = i2c->irq; + palmas->wakeirq = pdata->wakeirq; match = of_match_device(of_palmas_match_tbl, &i2c->dev); @@ -587,6 +600,25 @@ static int palmas_i2c_probe(struct i2c_client *i2c, if (ret < 0) goto err_i2c; + if (!palmas->wakeirq) + goto no_wake_irq; + + ret = devm_request_irq(palmas->dev, palmas->wakeirq, + palmas_wake_irq, + pdata->irq_flags, + dev_name(palmas->dev), + &palmas); + if (ret < 0) { + dev_err(palmas->dev, "Invalid wakeirq(%d) (res: %d), skiping\n", + palmas->wakeirq, ret); + palmas->wakeirq = 0; + } else { + /* We use wakeirq only during suspend-resume path */ + device_set_wakeup_capable(palmas->dev, true); + disable_irq_nosync(palmas->wakeirq); + } + +no_wake_irq: no_irq: slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE); addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE, @@ -706,6 +738,34 @@ static int palmas_i2c_remove(struct i2c_client *i2c) return 0; } +static int palmas_i2c_suspend(struct i2c_client *i2c, pm_message_t mesg) +{ + struct palmas *palmas = i2c_get_clientdata(i2c); + struct device *dev = &i2c->dev; + + if (!palmas->wakeirq) + return 0; + + if (device_may_wakeup(dev)) + enable_irq(palmas->wakeirq); + + return 0; +} + +static int palmas_i2c_resume(struct i2c_client *i2c) +{ + struct palmas *palmas = i2c_get_clientdata(i2c); + struct device *dev = &i2c->dev; + + if (!palmas->wakeirq) + return 0; + + if (device_may_wakeup(dev)) + disable_irq_nosync(palmas->wakeirq); + + return 0; +} + static const struct i2c_device_id palmas_i2c_id[] = { { "palmas", }, { "twl6035", }, @@ -721,6 +781,8 @@ static struct i2c_driver palmas_i2c_driver = { .of_match_table = of_palmas_match_tbl, .owner = THIS_MODULE, }, + .suspend = palmas_i2c_suspend, + .resume = palmas_i2c_resume, .probe = palmas_i2c_probe, .remove = palmas_i2c_remove, .id_table = palmas_i2c_id, diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index fb0390a..e8cf4c2 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -75,6 +75,7 @@ struct palmas { /* IRQ Data */ int irq; u32 irq_mask; + int wakeirq; struct mutex irq_lock; struct regmap_irq_chip_data *irq_data; @@ -377,6 +378,7 @@ struct palmas_clk_platform_data { struct palmas_platform_data { int irq_flags; + int wakeirq; int gpio_base; /* bit value to be loaded to the POWER_CTRL register */