From patchwork Tue Mar 18 09:12:21 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: 26468 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CF607202FA for ; Tue, 18 Mar 2014 09:12:47 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf26315925obb.7 for ; Tue, 18 Mar 2014 02:12:47 -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:cc: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=fF/rtMqVqSXAbPRqmENb6gQWy9KgarA2OcXMyvca7uit0NtBz3gZF4h5znG22ZfLua AsblModHX54HG2mqsiTbLM4PxEsmtYrZ75MUywE1gT/WMYIYiDEj6/dHIxqDIyo0lk7O /yQTtnLD2zJPu1GCoNQOgH35pTWa9ira32U7BHYTCosuZaLcGtL6dMF9Zv2weCpvbhi0 Y9C2VEZSOEwkuJjW0MT6JqDnUBBjaId3Ak/6bqhPCsCLr832sTbribxMuOuwLNDcy2Vw DvVpjONM99URfDmbIbrEho70DU+tbbcZYdTqLMb8E4IdDErPwOZoX+uIm3mb9SQa4lW/ hNwg== X-Gm-Message-State: ALoCoQl/PuKc23gC0Brf6GaxtNCnkKeBtyb0VTrjWxJL5DMYdcglKyw19rBbLHswsZ5DOS+eGtuY X-Received: by 10.43.92.73 with SMTP id bp9mr10573552icc.26.1395133967329; Tue, 18 Mar 2014 02:12:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.66 with SMTP id h60ls562366qge.54.gmail; Tue, 18 Mar 2014 02:12:47 -0700 (PDT) X-Received: by 10.220.11.141 with SMTP id t13mr2770358vct.30.1395133967201; Tue, 18 Mar 2014 02:12:47 -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 sa10si2485727vdc.193.2014.03.18.02.12.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 02:12:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 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.172; Received: by mail-vc0-f172.google.com with SMTP id la4so6913463vcb.31 for ; Tue, 18 Mar 2014 02:12:47 -0700 (PDT) X-Received: by 10.52.163.145 with SMTP id yi17mr276672vdb.46.1395133967122; Tue, 18 Mar 2014 02:12:47 -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 i9csp189498vck; Tue, 18 Mar 2014 02:12:46 -0700 (PDT) X-Received: by 10.68.181.165 with SMTP id dx5mr32812891pbc.38.1395133966100; Tue, 18 Mar 2014 02:12:46 -0700 (PDT) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by mx.google.com with ESMTPS id xn1si9595087pbc.218.2014.03.18.02.12.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 02:12:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.177 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.192.177; Received: by mail-pd0-f177.google.com with SMTP id y10so6800441pdj.36 for ; Tue, 18 Mar 2014 02:12:45 -0700 (PDT) X-Received: by 10.68.96.99 with SMTP id dr3mr31625764pbb.40.1395133965646; Tue, 18 Mar 2014 02:12:45 -0700 (PDT) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id fk4sm84728762pab.23.2014.03.18.02.12.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 02:12:45 -0700 (PDT) From: Sanjay Singh Rawat To: linaro-kernel@lists.linaro.org Cc: grant.likely@linaro.org, robh+dt@kernel.org, Sanjay Singh Rawat Subject: [RFC PATCH] driver wakeup: wakeup property in device tree Date: Tue, 18 Mar 2014 14:42:21 +0530 Message-Id: <1395133941-11196-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.172 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);