From patchwork Tue Aug 19 14:06:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 35600 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9341B201EF for ; Tue, 19 Aug 2014 14:07:31 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf53189379pdb.1 for ; Tue, 19 Aug 2014 07:07:30 -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 :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=H2ohBESTZ+qbpqaaNazO8gmmG4+h1N2OJzRj6B0m1HI=; b=lXwtXIcoYHgEWMUq++WjbxM6cUdfu8GFhp7tcHlNpxwhOOlUsPEEzfi3l/QLlkBksa qsAM/dFmOXBt7iOjivPcY4gpvQmA98OA5tnyZXfwPSTwDqOs57oBvsUu0fkE0PSIq8HT dEMXh2HMBsTPnoPVF4d3tf6r1vJm99f+lDw1alcirEUW2iH3VNulok6e/sOmJXef5dLm yUP1/kge00RXwhpSLcaV2Y5o5DFtJdp0EwvXfTTi0RouqUfpW5TGYZSVz8QCkXzmkFq8 dz/xkVJ6tbLocVUsJ4qtgpGTR7vC7gIHQSej+io6rLsQ8y+jE5r9M4RngZz1mFO2C3bZ 7bMg== X-Gm-Message-State: ALoCoQlFhcc63fQUuxX4/W9pHONgL8EPkC6MIZOG7h6WDpQb+/y56Hn3eVb2NmPgm8oVNdPvBoGF X-Received: by 10.66.147.227 with SMTP id tn3mr22822728pab.4.1408457249242; Tue, 19 Aug 2014 07:07:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.182 with SMTP id h51ls2204016qgf.80.gmail; Tue, 19 Aug 2014 07:07:29 -0700 (PDT) X-Received: by 10.220.130.131 with SMTP id t3mr30508336vcs.30.1408457249129; Tue, 19 Aug 2014 07:07:29 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id fd7si8745616vdc.0.2014.08.19.07.07.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 07:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so7469914vcb.16 for ; Tue, 19 Aug 2014 07:07:29 -0700 (PDT) X-Received: by 10.220.118.136 with SMTP id v8mr592836vcq.50.1408457249004; Tue, 19 Aug 2014 07:07:29 -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.37.5 with SMTP id tc5csp241656vcb; Tue, 19 Aug 2014 07:07:28 -0700 (PDT) X-Received: by 10.70.91.73 with SMTP id cc9mr51095445pdb.138.1408457247882; Tue, 19 Aug 2014 07:07:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qs6si27026097pbc.21.2014.08.19.07.07.18 for ; Tue, 19 Aug 2014 07:07:19 -0700 (PDT) Received-SPF: none (google.com: devicetree-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 S1752737AbaHSOHK (ORCPT + 6 others); Tue, 19 Aug 2014 10:07:10 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:44901 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbaHSOHJ (ORCPT ); Tue, 19 Aug 2014 10:07:09 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s7JE6inM017742; Tue, 19 Aug 2014 09:06:44 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7JE6hLH016918; Tue, 19 Aug 2014 09:06:43 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 19 Aug 2014 09:06:43 -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 s7JE6hdh017345; Tue, 19 Aug 2014 09:06:43 -0500 From: Nishanth Menon To: Samuel Ortiz , Lee Jones , Mark Brown , Tony Lindgren CC: Keerthy , , , , , Nishanth Menon Subject: [PATCH] mfd: palmas: Add support for optional wakeup Date: Tue, 19 Aug 2014 09:06:37 -0500 Message-ID: <1408457197-30487-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.171 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 idle states as interrupts. 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. Finally, to pass the wake-up interrupt in the dts file, interrupts-extended property needs to be passed. This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add support for optional wake-up") Signed-off-by: Nishanth Menon --- Documentation/devicetree/bindings/mfd/palmas.txt | 20 ++++++++ drivers/mfd/palmas.c | 59 ++++++++++++++++++++++ include/linux/mfd/palmas.h | 2 + 3 files changed, 81 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/palmas.txt b/Documentation/devicetree/bindings/mfd/palmas.txt index eda8989..2627842 100644 --- a/Documentation/devicetree/bindings/mfd/palmas.txt +++ b/Documentation/devicetree/bindings/mfd/palmas.txt @@ -51,3 +51,23 @@ palmas { .... }; } + +Example: with interrupts extended + See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt + Use pinmux 0x418 as wakeup interrupt and gpio1_0 as interrupt source + +palmas { + compatible = "ti,twl6035", "ti,palmas"; + reg = <0x48> + interrupt-parent = <&intc>; + interrupt-controller; + #interrupt-cells = <2>; + #address-cells = <1>; + #size-cells = <0>; + interrupts-extended = <&gpio1 0 IRQ_TYPE_LEVEL_HIGH + &pinmux 0x418>; + pmic { + compatible = "ti,twl6035-pmic", "ti,palmas-pmic"; + .... + }; +} 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 */