From patchwork Tue Jun 18 12:59:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 11001583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2A5F13AF for ; Tue, 18 Jun 2019 12:59:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4B8528A7C for ; Tue, 18 Jun 2019 12:59:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C706128A8E; Tue, 18 Jun 2019 12:59:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75DA528A7C for ; Tue, 18 Jun 2019 12:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbfFRM76 (ORCPT ); Tue, 18 Jun 2019 08:59:58 -0400 Received: from first.geanix.com ([116.203.34.67]:37326 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbfFRM75 (ORCPT ); Tue, 18 Jun 2019 08:59:57 -0400 Received: from zen.localdomain (unknown [85.184.140.241]) by first.geanix.com (Postfix) with ESMTPSA id 6325EB0E; Tue, 18 Jun 2019 12:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1560862789; bh=XvLp6MObahEArU1VuFlBiaL0pBUWQvqL0S1HHeUDYpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NB/gH0lTMmbM9H+O6VnI+AP3T31PBv6uOCsEIX2aJg9Ac8LWiQht+EvDpZYXIaA4m ZOuM6xAXiJJapUSyHQoqsyg6rzEjCybvcxn0mUkuNzQfd+OynihOCDUgpy+MSY1wqM HsxxIqkDFawzAAfemZlGBEsdOLa6QCd21Zin/nxvZvbWyiDf7TwsssNlDiouixOSG1 hEp7ZafvROx+UpbGIpUzYULzfQSreFeTM2BC2kCUgGfKqiM03JqjNCwVUB/163yjS4 w+SdNGgsMkRNig5k9o7hVGp/a/D5UJ04taEAqXwNu0rZnlWcQqLys8FpvMo1aPvA0X 9F8xeyA2b6PEw== From: Sean Nyekjaer To: linux-iio@vger.kernel.org, jic23@kernel.org Cc: Sean Nyekjaer , lorenzo.bianconi83@gmail.com, martin@geanix.com Subject: [PATCH 3/5] iio: imu: st_lsm6dsx: add wakeup-source option Date: Tue, 18 Jun 2019 14:59:37 +0200 Message-Id: <20190618125939.105903-4-sean@geanix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190618125939.105903-1-sean@geanix.com> References: <20190618125939.105903-1-sean@geanix.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP this add ways for the SoC to wake from accelerometer wake events. In the suspend function we skip disabling the sensor if wakeup-source and events are activated. Signed-off-by: Sean Nyekjaer --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 351c46f01662..59a34894e495 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1076,6 +1076,10 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, return err; } + if (dev->of_node) + if (of_property_read_bool(dev->of_node, "wakeup-source")) + device_init_wakeup(dev, true); + return 0; } EXPORT_SYMBOL(st_lsm6dsx_probe); @@ -1088,6 +1092,12 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) int i, err = 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (device_may_wakeup(dev) && (i == ST_LSM6DSX_ID_ACC)) { + /* Enable wake from IRQ */ + enable_irq_wake(hw->irq); + continue; + } + sensor = iio_priv(hw->iio_devs[i]); if (!(hw->enable_mask & BIT(sensor->id))) continue; @@ -1112,6 +1122,11 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) int i, err = 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (device_may_wakeup(dev) && (i == ST_LSM6DSX_ID_ACC)) { + disable_irq_wake(hw->irq); + continue; + } + sensor = iio_priv(hw->iio_devs[i]); if (!(hw->enable_mask & BIT(sensor->id))) continue;