From patchwork Thu Aug 21 16:12:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 35777 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 6ADDF2055D for ; Thu, 21 Aug 2014 16:13:22 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf76578158pad.6 for ; Thu, 21 Aug 2014 09:13:21 -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=mf8/S2jpANuJ10qQMVHmrkc+YDKu7O4UKn3xiuk48Yc=; b=I0Bqjq0Ntvdcdq1GaCWXCqxfRgus51mbhZyIRsr2kggzddDo0dZUUw+eU69u2GSMKQ iT0RiKEDRMYo2FMQS+gJZmQ8YvjbWqjsuIG/YH7kUKq4zGuGXa3XJyXlOC8oLZIgLYjg 8uDK9AHgfA1qVoVgKQZz+Ec+YDxnERku8y0JwIurVAma55BkILKmUlKi7ueoxIJgctUB 0U/lvXQc8GVNjAJVUDkFBxK6ddV5MkoH/68NRIuGEQ4yYP9OyV0NQOoIcVfjSucNUCp6 GWY8mm++6hC8gQmsjL3jq9XWCKYemhhvZXzwmeRTK2vQV8dC88Vz3roAdPKwhe3hPJ4W pmgQ== X-Gm-Message-State: ALoCoQluCwKCtUz8ZSg/HU8Px/5SplRi2vKOww8s0jN9+DyYWp0rlX0z37YcMnMHwMwu1/bn7E6T X-Received: by 10.66.141.165 with SMTP id rp5mr651020pab.47.1408637601755; Thu, 21 Aug 2014 09:13:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.34 with SMTP id d31ls8694qgf.93.gmail; Thu, 21 Aug 2014 09:13:21 -0700 (PDT) X-Received: by 10.221.21.8 with SMTP id qq8mr666665vcb.57.1408637601563; Thu, 21 Aug 2014 09:13:21 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id fg10si11804023vdc.26.2014.08.21.09.13.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Aug 2014 09:13:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so11046452vcb.34 for ; Thu, 21 Aug 2014 09:13:21 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr32210vdb.95.1408637601440; Thu, 21 Aug 2014 09:13:21 -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 uj3csp148100vcb; Thu, 21 Aug 2014 09:13:20 -0700 (PDT) X-Received: by 10.70.95.138 with SMTP id dk10mr26294573pdb.66.1408637600570; Thu, 21 Aug 2014 09:13:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qt10si36993247pbb.221.2014.08.21.09.13.19 for ; Thu, 21 Aug 2014 09:13:20 -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 S1752880AbaHUQNR (ORCPT + 26 others); Thu, 21 Aug 2014 12:13:17 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:36471 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbaHUQNO (ORCPT ); Thu, 21 Aug 2014 12:13:14 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s7LGC4J9015264; Thu, 21 Aug 2014 11:12:04 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7LGC4BT004093; Thu, 21 Aug 2014 11:12:04 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Thu, 21 Aug 2014 11:12:04 -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 s7LGC44f028617; Thu, 21 Aug 2014 11:12:04 -0500 From: Nishanth Menon To: Alessandro Zummo CC: , Tony Lindgren , , , Nishanth Menon Subject: [PATCH] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source Date: Thu, 21 Aug 2014 11:12:01 -0500 Message-ID: <1408637521-6764-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 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.175 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, SoCs such as Texas Instrument's OMAP processors 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 --- drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index f03d5ba..5feedfc 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -115,6 +117,7 @@ struct ds1307 { struct i2c_client *client; struct rtc_device *rtc; struct work_struct work; + int wakeirq; s32 (*read_block_data)(const struct i2c_client *client, u8 command, u8 length, u8 *values); s32 (*write_block_data)(const struct i2c_client *client, u8 command, @@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj, /*----------------------------------------------------------------------*/ +static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg) +{ + struct ds1307 *ds1307 = i2c_get_clientdata(client); + struct device *dev = &client->dev; + + if (!ds1307->wakeirq) + return 0; + + if (device_may_wakeup(dev)) + enable_irq(ds1307->wakeirq); + + return 0; +} + +static int ds1307_i2c_resume(struct i2c_client *client) +{ + struct ds1307 *ds1307 = i2c_get_clientdata(client); + struct device *dev = &client->dev; + + if (!ds1307->wakeirq) + return 0; + + if (device_may_wakeup(dev)) + disable_irq_nosync(ds1307->wakeirq); + + return 0; +} + static int ds1307_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1116,6 +1147,8 @@ read_rtc: } if (want_irq) { + struct device_node *node = client->dev.of_node; + err = request_irq(client->irq, ds1307_irq, IRQF_SHARED, ds1307->rtc->name, client); if (err) { @@ -1125,6 +1158,28 @@ read_rtc: set_bit(HAS_ALARM, &ds1307->flags); dev_dbg(&client->dev, "got IRQ %d\n", client->irq); + if (node) + ds1307->wakeirq = irq_of_parse_and_map(node, 1); + + if (ds1307->wakeirq <= 0) + ds1307->wakeirq = 0; + else + err = devm_request_irq(&client->dev, + ds1307->wakeirq, + ds1307_irq, + IRQF_ONESHOT, + ds1307->rtc->name, + client); + if (err) { + dev_err(&client->dev, "unable to get wakeIRQ %d\n", + err); + free_irq(client->irq, client); + goto exit; + } + + /* We enable the interrupt only during suspend path */ + if (ds1307->wakeirq) + disable_irq_nosync(ds1307->wakeirq); } } @@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = { }, .probe = ds1307_probe, .remove = ds1307_remove, + .suspend = ds1307_i2c_suspend, + .resume = ds1307_i2c_resume, .id_table = ds1307_id, };