From patchwork Fri Sep 5 20:51:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 36894 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1EE30202A1 for ; Fri, 5 Sep 2014 20:53:13 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf106827623pad.6 for ; Fri, 05 Sep 2014 13:53:12 -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:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=ndkkdxULbj3OjYSSAPqIjuFpi+bJCc8T1CkSWVFS6WU=; b=WaimTJMDefTKXVTN1T8DyyZv02pd7N61p/GE/im8eJkEfXz+ntdK0rjOmu1EcwxXHF PWOBXww0d3HQmLNywDcM3XRRP4Mfi2gs5mZd5w6AmcW2bq/8+mZqb3e0XAAI5ScPfBbg Lo6wNrZihwa9FyxbDJdefr/OYHiDqHwdGKXIQZkSzdV7S7Rtss1qGsLH/x7i4FHEcU3P CYtNOEZMejistj/qZ2Arx4si9Lhu2g7kud+ZzGoTDPtc8HrACIOXuFS2Oj8NCdxktoPT wX/Td+3RtLuXtXhPNW1kfvSN3yQWVv6Y9DPU6wWq4j6Y/1rFlnYpZjXbivpQO4ut10RC JdPA== X-Gm-Message-State: ALoCoQmIyFoOnVaACUZnJqaAPJHNGkTKH87hv0dbuRNOo9fNCCDOvcmx3fgP1jJnW9b0QtykAXP/ X-Received: by 10.66.141.70 with SMTP id rm6mr8505099pab.37.1409950392452; Fri, 05 Sep 2014 13:53:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.231 with SMTP id v94ls936939qgv.16.gmail; Fri, 05 Sep 2014 13:53:12 -0700 (PDT) X-Received: by 10.220.167.9 with SMTP id o9mr12571744vcy.8.1409950392340; Fri, 05 Sep 2014 13:53:12 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id ev4si2072085vdb.15.2014.09.05.13.53.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 13:53:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hq11so12978925vcb.36 for ; Fri, 05 Sep 2014 13:53:12 -0700 (PDT) X-Received: by 10.220.169.72 with SMTP id x8mr2897847vcy.45.1409950392191; Fri, 05 Sep 2014 13:53:12 -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 uj3csp137148vcb; Fri, 5 Sep 2014 13:53:11 -0700 (PDT) X-Received: by 10.66.138.46 with SMTP id qn14mr25053198pab.77.1409950391157; Fri, 05 Sep 2014 13:53:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yr4si6050617pab.80.2014.09.05.13.53.10 for ; Fri, 05 Sep 2014 13:53:11 -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 S1752234AbaIEUwj (ORCPT + 26 others); Fri, 5 Sep 2014 16:52:39 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:54097 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751144AbaIEUwf (ORCPT ); Fri, 5 Sep 2014 16:52:35 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s85KqCcV001805; Fri, 5 Sep 2014 15:52:12 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s85KqBbJ000946; Fri, 5 Sep 2014 15:52:11 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Fri, 5 Sep 2014 15:52:11 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s85KqBLx020771; Fri, 5 Sep 2014 15:52:11 -0500 From: Nishanth Menon To: Lee Jones CC: , , Keerthy , Mark Brown , Nishanth Menon , Samuel Ortiz , , Tony Lindgren , Subject: [PATCH V2 3/3] mfd: palmas: Add support for optional wakeup Date: Fri, 5 Sep 2014 15:51:51 -0500 Message-ID: <1409950311-25236-4-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409950311-25236-1-git-send-email-nm@ti.com> References: <1409950311-25236-1-git-send-email-nm@ti.com> MIME-Version: 1.0 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.177 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: , 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 | 59 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/palmas.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index 28cb048..11186ab 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,22 @@ 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, + IRQF_ONESHOT | pdata->irq_flags, + dev_name(palmas->dev), + &palmas); + if (ret < 0) + goto err_i2c; + + /* 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 +735,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 +778,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 */