From patchwork Tue Mar 18 09:09:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 26467 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 0E8BB202FA for ; Tue, 18 Mar 2014 09:09:19 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf16273744pdb.9 for ; Tue, 18 Mar 2014 02:09:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=aqhVLnPgDHu66j7/EniLD6F0/ICnNuDw5+EzZhCJ/Pg=; b=ftHEq77X8MHx6ZYlWY+YvibfkDuBkq7G8ml4O0mLdupDrKrU8bLtK8MnBxRbFWb9Jv bjpJ2x+wY3YDhIrIGGi8Qhg/6YFENnLJpoQrO8NRd1P0CakbWaYd5x3kHLahLRBMOiEY yfqOKwuJ+9IhrdxXgnuHN4zEcMTb1VFQ8HUGCYo9M6/yLoRqSJ155UXrzTEZTK3pl+XO yHexSGNlOoa7z3lO/ZKskdH4iiOpU12vgquGwzkqVRdhUdRJpobpBqOZBPNKvAXv55ZR he9aFvckVT2QD9L1hKnJvgv8an0zG/wCZIVENUMR2EWeoj8G870PmP7SnhLmi472ygXb BTMw== X-Gm-Message-State: ALoCoQk1ARO/KGVkMyo7ul/J6IYEoL2OcMOgGgW67hq8ZePjAbPzMGhXSU/BgHjlv30FkqKr/jWs X-Received: by 10.69.29.33 with SMTP id jt1mr11199411pbd.7.1395133759141; Tue, 18 Mar 2014 02:09:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.131 with SMTP id z3ls2029385qgd.59.gmail; Tue, 18 Mar 2014 02:09:18 -0700 (PDT) X-Received: by 10.58.225.233 with SMTP id rn9mr4414vec.53.1395133758951; Tue, 18 Mar 2014 02:09:18 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id sj4si1091724vdc.156.2014.03.18.02.09.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 02:09:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id ld13so6736503vcb.19 for ; Tue, 18 Mar 2014 02:09:18 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr10599426vei.20.1395133758862; Tue, 18 Mar 2014 02:09:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.78.9 with SMTP id i9csp189305vck; Tue, 18 Mar 2014 02:09:18 -0700 (PDT) X-Received: by 10.68.228.138 with SMTP id si10mr31443992pbc.13.1395133756323; Tue, 18 Mar 2014 02:09:16 -0700 (PDT) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx.google.com with ESMTPS id hb1si6651497pac.36.2014.03.18.02.09.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 02:09:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.44 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.220.44; Received: by mail-pa0-f44.google.com with SMTP id bj1so7006229pad.17 for ; Tue, 18 Mar 2014 02:09:15 -0700 (PDT) X-Received: by 10.66.139.169 with SMTP id qz9mr31829811pab.16.1395133755895; Tue, 18 Mar 2014 02:09:15 -0700 (PDT) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id ix2sm50592013pbc.45.2014.03.18.02.09.12 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 02:09:15 -0700 (PDT) From: Sanjay Singh Rawat To: sanjay.rawat@linaro.org Subject: [RFC PATCH] driver wakeup: wakeup property in device tree Date: Tue, 18 Mar 2014 14:39:00 +0530 Message-Id: <1395133740-11147-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sanjay.rawat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , To configure the devices as wakeup sources, currently drivers make explicit calls to device wakeup functions. This patch tries to automate the wakeup configuration with the help of device tree. In this approach, we parse the device node and if the node is having the wakeup property, the driver will be configured as wakeup source. We don't have to make explicit call to wakeup functions in the drivers init part. Also using this, to set a device as wakeup source, we just need to rebuild the device tree with wakeup property set (1) in the dt node. Signed-off-by: Sanjay Singh Rawat --- drivers/base/dd.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 0605176..df680f0 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -262,6 +263,31 @@ EXPORT_SYMBOL_GPL(device_bind_driver); static atomic_t probe_count = ATOMIC_INIT(0); static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); +void driver_configure_wakeup(struct device *dev, bool set) +{ + if(dev->of_node) { + const int *can_wakeup; + u32 val; + + can_wakeup = of_get_property(dev->of_node, "wakeup", NULL); + if(!can_wakeup) + return; + + if(set) { + val = be32_to_cpu(*can_wakeup); + if(val == 1) { + val = device_init_wakeup(dev, true); + if(val) + dev_err(dev, "failed to configure + as wakeup source\n"); + dev_dbg(dev, "configured as wakeup source\n"); + } + } + else + device_init_wakeup(dev, false); + } +} + static int really_probe(struct device *dev, struct device_driver *drv) { int ret = 0; @@ -292,6 +318,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) ret = drv->probe(dev); if (ret) goto probe_failed; + driver_configure_wakeup(dev, true); } driver_bound(dev); @@ -503,8 +530,10 @@ static void __device_release_driver(struct device *dev) if (dev->bus && dev->bus->remove) dev->bus->remove(dev); - else if (drv->remove) + else if (drv->remove) { drv->remove(dev); + driver_configure_wakeup(dev, false); + } devres_release_all(dev); dev->driver = NULL; dev_set_drvdata(dev, NULL);