From patchwork Mon Jul 15 08:15:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 11043479 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 085C613B1 for ; Mon, 15 Jul 2019 08:15:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEE3126E51 for ; Mon, 15 Jul 2019 08:15:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E37AC26E7B; Mon, 15 Jul 2019 08:15:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 8A56E26E78 for ; Mon, 15 Jul 2019 08:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729384AbfGOIP1 (ORCPT ); Mon, 15 Jul 2019 04:15:27 -0400 Received: from first.geanix.com ([116.203.34.67]:55302 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbfGOIP1 (ORCPT ); Mon, 15 Jul 2019 04:15:27 -0400 Received: from zen.localdomain (unknown [85.184.140.241]) by first.geanix.com (Postfix) with ESMTPSA id B81394361D; Mon, 15 Jul 2019 08:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1563178502; bh=ImJrCnp61KHcPzIUn7tTxAsJTCx0JL12z5dzII4tKAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NKztfCHNcrd9R8i2polMzIOI/vXToTwu1lP+MxCpACy7BMjr0hGC8iNZdf0xn2IJD TFgQIazblWfB7/4QXd3DZ4HldhRijTw8y+lYUwZ3oC626JPKpl/KN2GV47IWdR8brj mRhjEXf/4oiDxq0pyYgHPugEFsThBaLFfOizB0qCo2RaGNteR/Spbv7oQwWCDss+QS RY9dJCWMe4olcQ48ne8i9cRtHIb7C3y1OyPCaX5sGdOkghYUYrV5RHStPFlEiE60++ oj4U4obZ7P5zjnBEd8nFVI5heZ0awTXWZow2gwpgC69tnfg29rd/w4O2c6DqO9wgs9 ZL2JoZrQr6v9g== From: Sean Nyekjaer To: linux-iio@vger.kernel.org, jic23@kernel.org Cc: Sean Nyekjaer , lorenzo.bianconi83@gmail.com, martin@geanix.com Subject: [PATCH v2 4/6] iio: imu: st_lsm6dsx: add wakeup-source option Date: Mon, 15 Jul 2019 10:15:12 +0200 Message-Id: <20190715081514.81129-4-sean@geanix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190715081514.81129-1-sean@geanix.com> References: <20190715081514.81129-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 --- Changes since v1: * none, as the call to st_lsm6dsx_flush_fifo will put the fifo in bypass mode. 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 6decb0846f1a..fc450eeb9870 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1358,6 +1358,10 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, 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); @@ -1372,6 +1376,12 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) if (!hw->iio_devs[i]) continue; + 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; @@ -1404,6 +1414,11 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) if (!hw->iio_devs[i]) continue; + 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->suspend_mask & BIT(sensor->id))) continue;