From patchwork Sun Oct 6 13:21:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176319 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BA9213BD for ; Sun, 6 Oct 2019 13:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A4EE20867 for ; Sun, 6 Oct 2019 13:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368144; bh=sGBTyWy/S9tZ1AyR58GqQiuHQqD7gC5cLUeyfanM5tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tTM5CEk2BdsZdBPfDhi2fN6vzbtybVQTZI+u4+pvHhHPdMpjkSVgAzUJqm3QmkDt/ m6284AW1QEebGuzlVViDRDAn/Yx/9BsHVvgVjAQYu/+7Tr3P7hEV/OZHMg+jdPE2Hu Oxx8ycKsqmWJ1qw9wEk01wTN2+qhxcy05oYP/8QI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbfJFNWX (ORCPT ); Sun, 6 Oct 2019 09:22:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:38302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWX (ORCPT ); Sun, 6 Oct 2019 09:22:23 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3837C20684; Sun, 6 Oct 2019 13:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368142; bh=sGBTyWy/S9tZ1AyR58GqQiuHQqD7gC5cLUeyfanM5tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SB1tHp8GbhLtNXycY3NCLFrKLVY+J8mdbjAtKbaNYRpwoPvQZmK6Aw6C6d9iZ4ub1 WJ9aTlb4dyLU4eMjW0S3Cfb2kGXEwW/MWruzFmdQW+6q9mBL/maPe3pFvSZ0R71RUv hqDSnTzbA0Bijk0eBqaZUAd3xkEdPG0fgAgZ3398= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 01/13] iio: imu: st_lsm6dsx: use st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event Date: Sun, 6 Oct 2019 15:21:55 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Rely on st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event since it can run concurrently with sensor hub configuration. Move event related code in st_lsm6dsx_report_motion_event Fixes: 1aabad1fb5e9 ("iio: imu: st_lsm6dsx: add motion report function and call from interrupt") Signed-off-by: Lorenzo Bianconi Tested-by: Sean Nyekjaer --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 34 ++++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 8a813ddba19c..df270905f21d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1757,10 +1757,23 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, return iio_dev; } -static void st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw, int data) +static bool +st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw) { - s64 timestamp = iio_get_time_ns(hw->iio_devs[ST_LSM6DSX_ID_ACC]); + const struct st_lsm6dsx_event_settings *event_settings; + int err, data; + s64 timestamp; + if (!hw->enable_event) + return false; + + event_settings = &hw->settings->event_settings; + err = st_lsm6dsx_read_locked(hw, event_settings->wakeup_src_reg, + &data, sizeof(data)); + if (err < 0) + return false; + + timestamp = iio_get_time_ns(hw->iio_devs[ST_LSM6DSX_ID_ACC]); if ((data & hw->settings->event_settings.wakeup_src_z_mask) && (hw->enable_event & BIT(IIO_MOD_Z))) iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC], @@ -1790,30 +1803,23 @@ static void st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw, int data) IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), timestamp); + + return data & event_settings->wakeup_src_status_mask; } static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) { struct st_lsm6dsx_hw *hw = private; + bool event; int count; - int data, err; - - if (hw->enable_event) { - err = regmap_read(hw->regmap, - hw->settings->event_settings.wakeup_src_reg, - &data); - if (err < 0) - return IRQ_NONE; - if (data & hw->settings->event_settings.wakeup_src_status_mask) - st_lsm6dsx_report_motion_event(hw, data); - } + event = st_lsm6dsx_report_motion_event(hw); mutex_lock(&hw->fifo_lock); count = hw->settings->fifo_ops.read_fifo(hw); mutex_unlock(&hw->fifo_lock); - return count ? IRQ_HANDLED : IRQ_NONE; + return count || event ? IRQ_HANDLED : IRQ_NONE; } static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) From patchwork Sun Oct 6 13:21:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 820D213BD for ; Sun, 6 Oct 2019 13:22:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6061B2133F for ; Sun, 6 Oct 2019 13:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368150; bh=7a8g0Wg9KKe50FX8PkqjA04Asujhl6+waWSf+7x6Oxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=unNU1A2JoojuXUX/5T8xcL3Dc3M04KhJZxDMcH/RerZ4qZ8eIYqBj3BTTbZ4McMuh X2N9somfifNauNKX+NITHlQALdO2yFN+eO39xoz3CuWXns52BtHhdjEHEdzCobQlJz /usg+VFHrllqPQHPHjEHHqXe7RpxGIj/UnMnBiL8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbfJFNW3 (ORCPT ); Sun, 6 Oct 2019 09:22:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNW3 (ORCPT ); Sun, 6 Oct 2019 09:22:29 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B4D7220684; Sun, 6 Oct 2019 13:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368148; bh=7a8g0Wg9KKe50FX8PkqjA04Asujhl6+waWSf+7x6Oxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S8ewJxc4gYI09FzbGWQSst0nF5K6MKwEQAO1N/CirBwUqxmrktYPmolEWG29QDF4Y v8Dy1nwtWn7M9WiGgcNN18gaPLyJO/Fz1SibjSvS1e/BA1IhE4vMte8SaPha/YoMys lgSCOcuebNIsWof84BhhiGIYbO9WBABFZ4iSrjFc= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 02/13] iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer Date: Sun, 6 Oct 2019 15:21:56 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Check read_fifo pointer before using it since we can't assume it is always set adding new sensors. This patch fixes the following crash: irq 277: nobody cared (try booting with the "irqpoll" option) CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-rc5-00322-g792b824-dirty #7 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0xd8/0x10c) [] (dump_stack) from [] (__report_bad_irq+0x24/0xc0) [] (__report_bad_irq) from [] (note_interrupt+0x27c/0x2dc) [] (note_interrupt) from [] (handle_irq_event_percpu+0x54/0x7c) [] (handle_irq_event_percpu) from [] (handle_irq_event+0x38/0x5c) [] (handle_irq_event) from [] (handle_level_irq+0xc8/0x154) [] (handle_level_irq) from [] (generic_handle_irq+0x20/0x34) [] (generic_handle_irq) from [] (mxc_gpio_irq_handler+0xc4/0xf8) [] (mxc_gpio_irq_handler) from [] (mx3_gpio_irq_handler+0x64/0xb8) [] (mx3_gpio_irq_handler) from [] (generic_handle_irq+0x20/0x34) [] (generic_handle_irq) from [] (__handle_domain_irq+0x64/0xe0) [] (__handle_domain_irq) from [] (gic_handle_irq+0x4c/0xa0) [] (gic_handle_irq) from [] (__irq_svc+0x70/0x98) Exception stack(0xc1301f10 to 0xc1301f58 1f00: 00000001 00000006 00000000 c130c340 1f20: c1300000 c1308928 00000001 c1308960 00000000 c12b9db0 c1308908 00000000 1f40: 00000000 c1301f60 c0182010 c0109508 20000013 ffffffff [] (__irq_svc) from [] (arch_cpu_idle+0x20/0x3c) [] (arch_cpu_idle) from [] (do_idle+0x1bc/0x2bc) [] (do_idle) from [] (cpu_startup_entry+0x18/0x1c) [] (cpu_startup_entry) from [] (start_kernel+0x440/0x504) [] (start_kernel) from [<00000000>] (0x0) handlers: [<62052c0d>] st_lsm6dsx_handler_irq threaded [] st_lsm6dsx_handler_thread Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Tested-by: Bobby Jones Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 3 +++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index ef579650fd52..cabd4bfeab17 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -586,6 +586,9 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) { int err; + if (!hw->settings->fifo_ops.read_fifo) + return -ENOTSUPP; + mutex_lock(&hw->fifo_lock); hw->settings->fifo_ops.read_fifo(hw); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index df270905f21d..eac695663b6f 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1815,6 +1815,9 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) event = st_lsm6dsx_report_motion_event(hw); + if (!hw->settings->fifo_ops.read_fifo) + return event ? IRQ_HANDLED : IRQ_NONE; + mutex_lock(&hw->fifo_lock); count = hw->settings->fifo_ops.read_fifo(hw); mutex_unlock(&hw->fifo_lock); From patchwork Sun Oct 6 13:21:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1024013BD for ; Sun, 6 Oct 2019 13:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB1C92087E for ; Sun, 6 Oct 2019 13:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368152; bh=qTEwSD5xhvujACEv3T9bUUzzwJf9LeeTjpnpHxmfh1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2v/LH0QcGQsjJ23Vni3muLqfI6dun1RmNa0bDw1kOSwN1p71kvgplPfpFAVDkWyDZ lXmC77hO67HQum1ATE5PK8D5XP0U8G2yvgS+McRn59cSfUUW2RMuU9GxOQHehvZn2B 1dKRhGIDv8Q7yroH5yeKBCuuDHEBgslZyi/JcN10= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726404AbfJFNWc (ORCPT ); Sun, 6 Oct 2019 09:22:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:38380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWc (ORCPT ); Sun, 6 Oct 2019 09:22:32 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6E7B20867; Sun, 6 Oct 2019 13:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368150; bh=qTEwSD5xhvujACEv3T9bUUzzwJf9LeeTjpnpHxmfh1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQSbzUPgyf8d9ShFUx9Ae/+DJBBgFppGLLIT5PBmeGDjSMoBA7HhKIH2tV9+EHg0Y 9gGmq6PmB094E2mpU78nwnm/PtyuCtvn7xBS0F2rMVK+9BnXYLZTPC7vlr0agz08YY lX3got+Pm6JW+wGSBujS9YYw9m+UfX4SFceuVIUE= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 03/13] iio: imu: st_lsm6dsx: move irq related definitions in irq_config Date: Sun, 6 Oct 2019 15:21:57 +0200 Message-Id: <873559493f99be2a659f27da293f66a546598c2b.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Group irq related definition in irq_config structure in st_lsm6dsx_settings. This is a preliminary patch to move OpenDrain/Active low registers in st_lsm6dsx_settings. Signed-off-by: Lorenzo Bianconi Tested-by: Sean Nyekjaer --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 22 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 265 ++++++++++++------- 2 files changed, 179 insertions(+), 108 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index fd02d0e184f3..873ec3b8fd69 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -236,29 +236,21 @@ struct st_lsm6dsx_ext_dev_settings { /** * struct st_lsm6dsx_settings - ST IMU sensor settings * @wai: Sensor WhoAmI default value. - * @int1_addr: Control Register address for INT1 - * @int2_addr: Control Register address for INT2 * @reset_addr: register address for reset/reboot * @max_fifo_size: Sensor max fifo length in FIFO words. * @id: List of hw id/device name supported by the driver configuration. * @channels: IIO channels supported by the device. + * @irq_config: interrupts related registers. * @odr_table: Hw sensors odr table (Hz + val). * @fs_table: Hw sensors gain table (gain + val). * @decimator: List of decimator register info (addr + mask). * @batch: List of FIFO batching register info (addr + mask). - * @lir: Latched interrupt register info (addr + mask). - * @clear_on_read: Clear on read register info (addr + mask). * @fifo_ops: Sensor hw FIFO parameters. * @ts_settings: Hw timer related settings. * @shub_settings: i2c controller related settings. */ struct st_lsm6dsx_settings { u8 wai; - u8 int1_addr; - u8 int2_addr; - u8 int1_func_addr; - u8 int2_func_addr; - u8 int_func_mask; u8 reset_addr; u16 max_fifo_size; struct { @@ -269,12 +261,18 @@ struct st_lsm6dsx_settings { const struct iio_chan_spec *chan; int len; } channels[2]; + struct { + struct st_lsm6dsx_reg irq1; + struct st_lsm6dsx_reg irq2; + struct st_lsm6dsx_reg irq1_func; + struct st_lsm6dsx_reg irq2_func; + struct st_lsm6dsx_reg lir; + struct st_lsm6dsx_reg clear_on_read; + } irq_config; struct st_lsm6dsx_odr_table_entry odr_table[2]; struct st_lsm6dsx_fs_table_entry fs_table[2]; struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID]; struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID]; - struct st_lsm6dsx_reg lir; - struct st_lsm6dsx_reg clear_on_read; struct st_lsm6dsx_fifo_ops fifo_ops; struct st_lsm6dsx_hw_ts_settings ts_settings; struct st_lsm6dsx_shub_settings shub_settings; @@ -359,9 +357,9 @@ struct st_lsm6dsx_hw { u8 ts_sip; u8 sip; + const struct st_lsm6dsx_reg *irq_routing; u8 event_threshold; u8 enable_event; - struct st_lsm6dsx_reg irq_routing; u8 *buff; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index eac695663b6f..23d67caa24ed 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -61,7 +61,6 @@ #include "st_lsm6dsx.h" -#define ST_LSM6DSX_REG_FIFO_FTH_IRQ_MASK BIT(3) #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f #define ST_LSM6DSX_REG_RESET_MASK BIT(0) #define ST_LSM6DSX_REG_BOOT_MASK BIT(7) @@ -97,8 +96,6 @@ static const struct iio_chan_spec st_lsm6ds0_gyro_channels[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .wai = 0x68, - .int1_addr = 0x0c, - .int2_addr = 0x0d, .reset_addr = 0x22, .max_fifo_size = 32, .id = { @@ -164,14 +161,19 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[2] = { IIO_DEGREE_TO_RAD(2000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0c, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0d, + .mask = BIT(3), + }, + }, }, { .wai = 0x69, - .int1_addr = 0x0d, - .int2_addr = 0x0e, - .int1_func_addr = 0x5e, - .int2_func_addr = 0x5f, - .int_func_mask = BIT(5), .reset_addr = 0x12, .max_fifo_size = 1365, .id = { @@ -238,6 +240,28 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x58, + .mask = BIT(0), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + }, .decimator = { [ST_LSM6DSX_ID_ACC] = { .addr = 0x08, @@ -248,10 +272,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(5, 3), }, }, - .lir = { - .addr = 0x58, - .mask = BIT(0), - }, .fifo_ops = { .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_fifo, @@ -297,11 +317,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x69, - .int1_addr = 0x0d, - .int2_addr = 0x0e, - .int1_func_addr = 0x5e, - .int2_func_addr = 0x5f, - .int_func_mask = BIT(5), .reset_addr = 0x12, .max_fifo_size = 682, .id = { @@ -368,6 +383,28 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x58, + .mask = BIT(0), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + }, .decimator = { [ST_LSM6DSX_ID_ACC] = { .addr = 0x08, @@ -378,10 +415,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(5, 3), }, }, - .lir = { - .addr = 0x58, - .mask = BIT(0), - }, .fifo_ops = { .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_fifo, @@ -427,11 +460,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6a, - .int1_addr = 0x0d, - .int2_addr = 0x0e, - .int1_func_addr = 0x5e, - .int2_func_addr = 0x5f, - .int_func_mask = BIT(5), .reset_addr = 0x12, .max_fifo_size = 682, .id = { @@ -507,6 +535,28 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x58, + .mask = BIT(0), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + }, .decimator = { [ST_LSM6DSX_ID_ACC] = { .addr = 0x08, @@ -517,10 +567,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(5, 3), }, }, - .lir = { - .addr = 0x58, - .mask = BIT(0), - }, .fifo_ops = { .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_fifo, @@ -570,8 +616,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6c, - .int1_addr = 0x0d, - .int2_addr = 0x0e, .reset_addr = 0x12, .max_fifo_size = 512, .id = { @@ -641,6 +685,24 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x56, + .mask = BIT(0), + }, + .clear_on_read = { + .addr = 0x56, + .mask = BIT(6), + }, + }, .batch = { [ST_LSM6DSX_ID_ACC] = { .addr = 0x09, @@ -651,14 +713,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(7, 4), }, }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, .fifo_ops = { .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_tagged_fifo, @@ -711,11 +765,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6b, - .int1_addr = 0x0d, - .int2_addr = 0x0e, - .int1_func_addr = 0x5e, - .int2_func_addr = 0x5f, - .int_func_mask = BIT(5), .reset_addr = 0x12, .max_fifo_size = 512, .id = { @@ -782,6 +831,32 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x56, + .mask = BIT(0), + }, + .clear_on_read = { + .addr = 0x56, + .mask = BIT(6), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + }, .batch = { [ST_LSM6DSX_ID_ACC] = { .addr = 0x09, @@ -792,14 +867,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(7, 4), }, }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, .fifo_ops = { .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_tagged_fifo, @@ -841,11 +908,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6b, - .int1_addr = 0x0d, - .int2_addr = 0x0e, - .int1_func_addr = 0x5e, - .int2_func_addr = 0x5f, - .int_func_mask = BIT(5), .reset_addr = 0x12, .max_fifo_size = 512, .id = { @@ -915,6 +977,32 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000), 0x3 }, }, }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x56, + .mask = BIT(0), + }, + .clear_on_read = { + .addr = 0x56, + .mask = BIT(6), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + }, .batch = { [ST_LSM6DSX_ID_ACC] = { .addr = 0x09, @@ -925,14 +1013,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(7, 4), }, }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, .fifo_ops = { .update_fifo = st_lsm6dsx_update_fifo, .read_fifo = st_lsm6dsx_read_tagged_fifo, @@ -1281,7 +1361,7 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) int err; u8 enable = 0; - if (!hw->settings->int1_func_addr) + if (!hw->settings->irq_config.irq1_func.addr) return -ENOTSUPP; enable = state ? hw->settings->event_settings.enable_reg.mask : 0; @@ -1293,12 +1373,11 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) if (err < 0) return err; - enable = state ? hw->irq_routing.mask : 0; + enable = state ? hw->irq_routing->mask : 0; /* Enable wakeup interrupt */ - return regmap_update_bits(hw->regmap, hw->irq_routing.addr, - hw->irq_routing.mask, - enable); + return regmap_update_bits(hw->regmap, hw->irq_routing->addr, + hw->irq_routing->mask, enable); } static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, @@ -1527,7 +1606,9 @@ static int st_lsm6dsx_of_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin) return of_property_read_u32(np, "st,drdy-int-pin", drdy_pin); } -static int st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw, u8 *drdy_reg) +static int +st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw, + const struct st_lsm6dsx_reg **drdy_reg) { int err = 0, drdy_pin; @@ -1541,14 +1622,12 @@ static int st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw, u8 *drdy_reg) switch (drdy_pin) { case 1: - *drdy_reg = hw->settings->int1_addr; - hw->irq_routing.addr = hw->settings->int1_func_addr; - hw->irq_routing.mask = hw->settings->int_func_mask; + hw->irq_routing = &hw->settings->irq_config.irq1_func; + *drdy_reg = &hw->settings->irq_config.irq1; break; case 2: - *drdy_reg = hw->settings->int2_addr; - hw->irq_routing.addr = hw->settings->int2_func_addr; - hw->irq_routing.mask = hw->settings->int_func_mask; + hw->irq_routing = &hw->settings->irq_config.irq2_func; + *drdy_reg = &hw->settings->irq_config.irq2; break; default: dev_err(hw->dev, "unsupported data ready pin\n"); @@ -1644,7 +1723,7 @@ static int st_lsm6dsx_init_hw_timer(struct st_lsm6dsx_hw *hw) static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) { - u8 drdy_int_reg; + const struct st_lsm6dsx_reg *reg; int err; /* device sw reset */ @@ -1673,35 +1752,29 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) return err; /* enable FIFO watermak interrupt */ - err = st_lsm6dsx_get_drdy_reg(hw, &drdy_int_reg); + err = st_lsm6dsx_get_drdy_reg(hw, ®); if (err < 0) return err; - err = regmap_update_bits(hw->regmap, drdy_int_reg, - ST_LSM6DSX_REG_FIFO_FTH_IRQ_MASK, - FIELD_PREP(ST_LSM6DSX_REG_FIFO_FTH_IRQ_MASK, - 1)); + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; /* enable Latched interrupts for device events */ - if (hw->settings->lir.addr) { - unsigned int data; - - data = ST_LSM6DSX_SHIFT_VAL(1, hw->settings->lir.mask); - err = regmap_update_bits(hw->regmap, hw->settings->lir.addr, - hw->settings->lir.mask, data); + if (hw->settings->irq_config.lir.addr) { + reg = &hw->settings->irq_config.lir; + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; /* enable clear on read for latched interrupts */ - if (hw->settings->clear_on_read.addr) { - data = ST_LSM6DSX_SHIFT_VAL(1, - hw->settings->clear_on_read.mask); + if (hw->settings->irq_config.clear_on_read.addr) { + reg = &hw->settings->irq_config.clear_on_read; err = regmap_update_bits(hw->regmap, - hw->settings->clear_on_read.addr, - hw->settings->clear_on_read.mask, - data); + reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; } From patchwork Sun Oct 6 13:21:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A7BB13BD for ; Sun, 6 Oct 2019 13:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 780E420867 for ; Sun, 6 Oct 2019 13:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368154; bh=b4uVfeTKNSxGsaAGqAUEO5pMHiL+u9bjLP3wHVv8vIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CE8yY3NWUXxmrpaLmbOAFxoAfPD3/f488vqy0fip5oG2A4O9g6OoZeC3Ql259Wbq2 3naKX17rn+BTCAw7wYeUt8ROM9sxB5gFIgYqMf6JnQlQCczwExZRHycSzyfXlH1all EwLtIeJyvBVapjfhq8+/MRHrZmz1YaNZkKpKNnF8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726436AbfJFNWe (ORCPT ); Sun, 6 Oct 2019 09:22:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:38394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWd (ORCPT ); Sun, 6 Oct 2019 09:22:33 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0FDB120684; Sun, 6 Oct 2019 13:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368152; bh=b4uVfeTKNSxGsaAGqAUEO5pMHiL+u9bjLP3wHVv8vIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zk24TjL1hQwUgNvcQo2kV114KbGlDrxx0co0Ch2G+SJjQMVDQUfYhAV2xA0NSzB6K eGuEvf5r6WAvoUg6vmTIQik2rZ/PUqaRpwKCEouwdudWYrZ1kwmi5f9/PuuPTAZZY1 sjRf0d+ZCaBW/6E2wLANodZi0Pe3tbnvQDa8Wxy4= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 04/13] iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supported Date: Sun, 6 Oct 2019 15:21:58 +0200 Message-Id: <7db02b38f42c3ca784e463aac2df98cd0d15d21c.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Move active low and open drain register definitions in hw_settings register map since not all supported sensors (e.g lsm9ds1) rely on the same definitions Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 + drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 79 ++++++++++++++++---- 2 files changed, 67 insertions(+), 14 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 873ec3b8fd69..8e002a51595e 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -268,6 +268,8 @@ struct st_lsm6dsx_settings { struct st_lsm6dsx_reg irq2_func; struct st_lsm6dsx_reg lir; struct st_lsm6dsx_reg clear_on_read; + struct st_lsm6dsx_reg hla; + struct st_lsm6dsx_reg od; } irq_config; struct st_lsm6dsx_odr_table_entry odr_table[2]; struct st_lsm6dsx_fs_table_entry fs_table[2]; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 23d67caa24ed..a598cc8e9343 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -67,11 +67,6 @@ #define ST_LSM6DSX_REG_BDU_ADDR 0x12 #define ST_LSM6DSX_REG_BDU_MASK BIT(6) -#define ST_LSM6DSX_REG_HLACTIVE_ADDR 0x12 -#define ST_LSM6DSX_REG_HLACTIVE_MASK BIT(5) -#define ST_LSM6DSX_REG_PP_OD_ADDR 0x12 -#define ST_LSM6DSX_REG_PP_OD_MASK BIT(4) - static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = { ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0), ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x2a, IIO_MOD_Y, 1), @@ -170,6 +165,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x0d, .mask = BIT(3), }, + .hla = { + .addr = 0x22, + .mask = BIT(5), + }, + .od = { + .addr = 0x22, + .mask = BIT(4), + }, }, }, { @@ -261,6 +264,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x5f, .mask = BIT(5), }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, }, .decimator = { [ST_LSM6DSX_ID_ACC] = { @@ -404,6 +415,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x5f, .mask = BIT(5), }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, }, .decimator = { [ST_LSM6DSX_ID_ACC] = { @@ -556,6 +575,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x5f, .mask = BIT(5), }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, }, .decimator = { [ST_LSM6DSX_ID_ACC] = { @@ -702,6 +729,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x56, .mask = BIT(6), }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, }, .batch = { [ST_LSM6DSX_ID_ACC] = { @@ -856,6 +891,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x5f, .mask = BIT(5), }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, }, .batch = { [ST_LSM6DSX_ID_ACC] = { @@ -1002,6 +1045,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x5f, .mask = BIT(5), }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, }, .batch = { [ST_LSM6DSX_ID_ACC] = { @@ -1900,8 +1951,9 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) { - struct st_sensors_platform_data *pdata; struct device_node *np = hw->dev->of_node; + struct st_sensors_platform_data *pdata; + const struct st_lsm6dsx_reg *reg; unsigned long irq_type; bool irq_active_low; int err; @@ -1922,20 +1974,19 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) return -EINVAL; } - err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_HLACTIVE_ADDR, - ST_LSM6DSX_REG_HLACTIVE_MASK, - FIELD_PREP(ST_LSM6DSX_REG_HLACTIVE_MASK, - irq_active_low)); + reg = &hw->settings->irq_config.hla; + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(irq_active_low, + reg->mask)); if (err < 0) return err; pdata = (struct st_sensors_platform_data *)hw->dev->platform_data; if ((np && of_property_read_bool(np, "drive-open-drain")) || (pdata && pdata->open_drain)) { - err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_PP_OD_ADDR, - ST_LSM6DSX_REG_PP_OD_MASK, - FIELD_PREP(ST_LSM6DSX_REG_PP_OD_MASK, - 1)); + reg = &hw->settings->irq_config.od; + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; From patchwork Sun Oct 6 13:21:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B21201747 for ; Sun, 6 Oct 2019 13:22:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 910492080F for ; Sun, 6 Oct 2019 13:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368156; bh=ZInNTo0B0GFPLzASupH5y0zb+HGFmLKUn4+Wc0CNYSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lphHELC9l19tpbwDpeRaVAavsGx8vDmo/mQHy43e/uhlc2tuiGChIqWVwmoS2u5FA E2drHmC3RtAxnqc5BWV7eqhgRQ9wvjjqBJu7+5yuqXPFP6BzdeE/cxIfZGh0OvYTn7 tjd6VoVfHnSzDZnN38ngIIqcn3+V2KQzHKrjuQ/g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbfJFNWg (ORCPT ); Sun, 6 Oct 2019 09:22:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:38438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWg (ORCPT ); Sun, 6 Oct 2019 09:22:36 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 26BAA2133F; Sun, 6 Oct 2019 13:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368154; bh=ZInNTo0B0GFPLzASupH5y0zb+HGFmLKUn4+Wc0CNYSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0a8YYtKodU+hqaZUXBnmXwDI/5cHwRz33WRh9sUlkT+8iVnOpTlCotGbweqUOiTlT ZzOIZ6qFo5KJpWKN33TUV4TE3JgFk/OtB24noVbG9n0SqsaSsjFS3iHdNnJ3JxFs4p f5yPvnfd40Ss5NQHdHkHCqm9VyjRWvYmlryPKTKE= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 05/13] iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings Date: Sun, 6 Oct 2019 15:21:59 +0200 Message-Id: <05ed5aab740bcf07ee5b32e4d3248d29b6ad31f7.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Move bdu, boot and reset register definitions in hw_settings register map since not all supported sensors (e.g lsm9ds1) rely on the same definitions Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 8 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 113 +++++++++++++++---- 2 files changed, 99 insertions(+), 22 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 8e002a51595e..5692ea695f04 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -236,7 +236,9 @@ struct st_lsm6dsx_ext_dev_settings { /** * struct st_lsm6dsx_settings - ST IMU sensor settings * @wai: Sensor WhoAmI default value. - * @reset_addr: register address for reset/reboot + * @reset: register address for reset. + * @boot: register address for boot. + * @bdu: register address for Block Data Update. * @max_fifo_size: Sensor max fifo length in FIFO words. * @id: List of hw id/device name supported by the driver configuration. * @channels: IIO channels supported by the device. @@ -251,7 +253,9 @@ struct st_lsm6dsx_ext_dev_settings { */ struct st_lsm6dsx_settings { u8 wai; - u8 reset_addr; + struct st_lsm6dsx_reg reset; + struct st_lsm6dsx_reg boot; + struct st_lsm6dsx_reg bdu; u16 max_fifo_size; struct { enum st_lsm6dsx_hw_id hw_id; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index a598cc8e9343..5df382b9d8f9 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -62,10 +62,6 @@ #include "st_lsm6dsx.h" #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f -#define ST_LSM6DSX_REG_RESET_MASK BIT(0) -#define ST_LSM6DSX_REG_BOOT_MASK BIT(7) -#define ST_LSM6DSX_REG_BDU_ADDR 0x12 -#define ST_LSM6DSX_REG_BDU_MASK BIT(6) static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = { ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0), @@ -91,7 +87,18 @@ static const struct iio_chan_spec st_lsm6ds0_gyro_channels[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .wai = 0x68, - .reset_addr = 0x22, + .reset = { + .addr = 0x22, + .mask = BIT(0), + }, + .boot = { + .addr = 0x22, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x22, + .mask = BIT(6), + }, .max_fifo_size = 32, .id = { { @@ -177,7 +184,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x69, - .reset_addr = 0x12, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, .max_fifo_size = 1365, .id = { { @@ -328,7 +346,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x69, - .reset_addr = 0x12, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, .max_fifo_size = 682, .id = { { @@ -479,7 +508,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6a, - .reset_addr = 0x12, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, .max_fifo_size = 682, .id = { { @@ -643,7 +683,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6c, - .reset_addr = 0x12, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, .max_fifo_size = 512, .id = { { @@ -800,7 +851,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6b, - .reset_addr = 0x12, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, .max_fifo_size = 512, .id = { { @@ -951,7 +1013,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6b, - .reset_addr = 0x12, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, .max_fifo_size = 512, .id = { { @@ -1778,27 +1851,27 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) int err; /* device sw reset */ - err = regmap_update_bits(hw->regmap, hw->settings->reset_addr, - ST_LSM6DSX_REG_RESET_MASK, - FIELD_PREP(ST_LSM6DSX_REG_RESET_MASK, 1)); + reg = &hw->settings->reset; + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; msleep(50); /* reload trimming parameter */ - err = regmap_update_bits(hw->regmap, hw->settings->reset_addr, - ST_LSM6DSX_REG_BOOT_MASK, - FIELD_PREP(ST_LSM6DSX_REG_BOOT_MASK, 1)); + reg = &hw->settings->boot; + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; msleep(50); /* enable Block Data Update */ - err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_BDU_ADDR, - ST_LSM6DSX_REG_BDU_MASK, - FIELD_PREP(ST_LSM6DSX_REG_BDU_MASK, 1)); + reg = &hw->settings->bdu; + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(1, reg->mask)); if (err < 0) return err; From patchwork Sun Oct 6 13:22:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D62A1747 for ; Sun, 6 Oct 2019 13:22:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21E482133F for ; Sun, 6 Oct 2019 13:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368158; bh=x4JU9PoYK88zVApCo9zd7hj9YzT1ehWfIDDSXB28k4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SSz5+jKgAPMLutdO6CAtyaVcYfZMsLZgSNM7GFJsiPGXIJg+8AGAcna9t3HCxgbuU NpO5jTNkKEULBQeqkF82/2/M6IJyFk3k+kg4PAFGAD2/V1RCZk+7Ga48Rbd2iISmxg eM2NUiNFmwlDOhjFx8qjASp7OoYGnYwP9vY4eyJc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726474AbfJFNWh (ORCPT ); Sun, 6 Oct 2019 09:22:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:38462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWh (ORCPT ); Sun, 6 Oct 2019 09:22:37 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F0B72087E; Sun, 6 Oct 2019 13:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368156; bh=x4JU9PoYK88zVApCo9zd7hj9YzT1ehWfIDDSXB28k4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZ+5XzuxpWveb5HqMjAAcbxmIDSOR1xtkHEaqbVy9akWbKT9jH6BdWA6SZ6WmwLBb rXbJ/DH5Uo+lat1oKNQXBgPEuKjU/KK0J/NPx2lImiylMP9WZj4HIPizbNEw4UtSgj PtgAkNByNNgGES5bWjo5a8rRiEVnyKZ6L5RAoYwA= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 06/13] iio: imu: st_lsm6dsx: always check enable_reg in st_lsm6dsx_event_setup Date: Sun, 6 Oct 2019 15:22:00 +0200 Message-Id: <837ea533a4094d6da572999e8f863687fa4cae1b.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Check if enable_reg of event_settings data structure is defined before writing on it Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events") Signed-off-by: Lorenzo Bianconi Tested-by: Sean Nyekjaer --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 5df382b9d8f9..7e9e1ef81742 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1482,26 +1482,25 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev, static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) { + const struct st_lsm6dsx_reg *reg; int err; - u8 enable = 0; if (!hw->settings->irq_config.irq1_func.addr) return -ENOTSUPP; - enable = state ? hw->settings->event_settings.enable_reg.mask : 0; - - err = regmap_update_bits(hw->regmap, - hw->settings->event_settings.enable_reg.addr, - hw->settings->event_settings.enable_reg.mask, - enable); - if (err < 0) - return err; - - enable = state ? hw->irq_routing->mask : 0; + reg = &hw->settings->event_settings.enable_reg; + if (reg->addr) { + err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, + ST_LSM6DSX_SHIFT_VAL(state, reg->mask)); + if (err < 0) + return err; + } /* Enable wakeup interrupt */ return regmap_update_bits(hw->regmap, hw->irq_routing->addr, - hw->irq_routing->mask, enable); + hw->irq_routing->mask, + ST_LSM6DSX_SHIFT_VAL(state, + hw->irq_routing->mask)); } static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, From patchwork Sun Oct 6 13:22:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C11D13BD for ; Sun, 6 Oct 2019 13:22:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B3982133F for ; Sun, 6 Oct 2019 13:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368160; bh=4K9yshLJ6nsCgdbzwOhPEwWXE3AxMJgFLFT4CWr9oAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bEBppkvhsw5uLgDNaN5eBVp5HoUGFekE1BvTnQjOgbqM8dC8IeEJYZciBYPmnTgOr 8V+lEYRUEKZncBKNUmK3/j5JdM3icHAlej7i56MB0ZlUcLL4ClmSZMiNbmhX5viA4d HdmIJDMluVJqYGVBl+jy1aqjtaOuMurYsZL3tkZU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726481AbfJFNWj (ORCPT ); Sun, 6 Oct 2019 09:22:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:38486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWj (ORCPT ); Sun, 6 Oct 2019 09:22:39 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52B3D2080F; Sun, 6 Oct 2019 13:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368158; bh=4K9yshLJ6nsCgdbzwOhPEwWXE3AxMJgFLFT4CWr9oAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FyxEwnCOP3fm8SreM3Icz5xg01OrirspNuXA4l5kcyh2RCzU0i6Hq/ABDCpMmgh0l 6i9MhNXdHVbgRkd0SxtpigdvFNZMoMoeIwswqw7DFSwi4wpJEZXyEMd7hBhJklU09/ tqD0dHnV8w/fJqYMpMvpDIuLFAOmoLimIGBFbgPY= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 07/13] iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events Date: Sun, 6 Oct 2019 15:22:01 +0200 Message-Id: <903ebb1b14412abdee3029417ae146515e49c685.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Rely on st_lsm6dsx_update_bits_locked in st_lsm6dsx_write_event and st_lsm6dsx_event_setup routines since they can run concurrently with sensor hub configuration Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events") Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 7e9e1ef81742..023646762b4a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1483,6 +1483,7 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev, static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) { const struct st_lsm6dsx_reg *reg; + unsigned int data; int err; if (!hw->settings->irq_config.irq1_func.addr) @@ -1490,17 +1491,17 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) reg = &hw->settings->event_settings.enable_reg; if (reg->addr) { - err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, - ST_LSM6DSX_SHIFT_VAL(state, reg->mask)); + data = ST_LSM6DSX_SHIFT_VAL(state, reg->mask); + err = st_lsm6dsx_update_bits_locked(hw, reg->addr, + reg->mask, data); if (err < 0) return err; } /* Enable wakeup interrupt */ - return regmap_update_bits(hw->regmap, hw->irq_routing->addr, - hw->irq_routing->mask, - ST_LSM6DSX_SHIFT_VAL(state, - hw->irq_routing->mask)); + data = ST_LSM6DSX_SHIFT_VAL(state, hw->irq_routing->mask); + return st_lsm6dsx_update_bits_locked(hw, hw->irq_routing->addr, + hw->irq_routing->mask, data); } static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, @@ -1531,6 +1532,8 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_hw *hw = sensor->hw; + const struct st_lsm6dsx_reg *reg; + unsigned int data; int err; if (type != IIO_EV_TYPE_THRESH) @@ -1539,11 +1542,11 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, if (val < 0 || val > 31) return -EINVAL; - err = regmap_update_bits(hw->regmap, - hw->settings->event_settings.wakeup_reg.addr, - hw->settings->event_settings.wakeup_reg.mask, - val); - if (err) + reg = &hw->settings->event_settings.wakeup_reg; + data = ST_LSM6DSX_SHIFT_VAL(val, reg->mask); + err = st_lsm6dsx_update_bits_locked(hw, reg->addr, + reg->mask, data); + if (err < 0) return -EINVAL; hw->event_threshold = val; From patchwork Sun Oct 6 13:22:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3043A1747 for ; Sun, 6 Oct 2019 13:22:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0592F20867 for ; Sun, 6 Oct 2019 13:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368162; bh=hFXi24clnV9HB2ZmxckPQEhdsBtRWGbh//3lUs7nsxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=VRL5E7kI5hKDaL14I2XPaixFUg/DpKKoHjg8xSw/5vswys1X3rT5vgvCGLFYlQDUs 98vvZsDSTKWg2B25osIYTRG5TDrJRPAdDjtFqpjrHQ1OBk9f9iKpdkgA+FrM5L7GQi DSQ8ZVarB7aAot3uZm2ofX6Oc00rqsPodNAUA8S4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbfJFNWl (ORCPT ); Sun, 6 Oct 2019 09:22:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:38510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWl (ORCPT ); Sun, 6 Oct 2019 09:22:41 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 613B52087E; Sun, 6 Oct 2019 13:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368161; bh=hFXi24clnV9HB2ZmxckPQEhdsBtRWGbh//3lUs7nsxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8knE7R+dRnB66qBUYAOOOCyQGtEGNS3wAeeSBBcXY3JEaSCl4pVdEAxkNlkSRp3E ZkGk2Np8lBkOGaNweLuW6Lmsogow5aRemm3JHlKB79v1ovTliE4qApAUuGnAqR7cwN Jz6DMSKsmh4924Jjy0fEdSN5CIdC77+RkLCRkYc4= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 08/13] iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config Date: Sun, 6 Oct 2019 15:22:02 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Always grub conf mutex in st_lsm6dsx_write_event_config since it can run concurrently with FIFO configuration Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events") Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 023646762b4a..04231710ab9c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1604,7 +1604,9 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, if (err < 0) return err; + mutex_lock(&hw->conf_lock); err = st_lsm6dsx_sensor_set_enable(sensor, state); + mutex_unlock(&hw->conf_lock); if (err < 0) return err; From patchwork Sun Oct 6 13:22:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 169E51747 for ; Sun, 6 Oct 2019 13:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E93B320684 for ; Sun, 6 Oct 2019 13:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368165; bh=MNWJLwxyI7zRash2vbBuM0IL8Rhccb10ChtBsE6owvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wvPVcDAZjV+Sr8kLmwjsnsJtrNtbu8mPM3ju4b8vKFTyfvUOnmz31DjSoMlG6c+Ve FQX7ds494tNVNIqi/2KcH+G+5o2lNY8blcnirRoOBVvnSsTGaYa/W46T+fvVxwFfwZ GBz6+pXDjY1dpSCPO6Jl1Th+XNJfyTCpUmYS3KY8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726508AbfJFNWo (ORCPT ); Sun, 6 Oct 2019 09:22:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:38534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWo (ORCPT ); Sun, 6 Oct 2019 09:22:44 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 70DCE2080F; Sun, 6 Oct 2019 13:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368163; bh=MNWJLwxyI7zRash2vbBuM0IL8Rhccb10ChtBsE6owvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToFsD2b2QpUPT/YfcGpqYtuFB+p6gkF4E877uQs9/dUskRNm/stQe14oLdnPwDYsS zZ3EaAk9nBrRbsvPh33Ld+6y83AEadrlSdKzRKq+Ins95JNaNZhW0aBGrBmOaLNjBy g4ybbhW1hkEPSMWeRQFh0Pb7wfekdWrzxhhPy+qE= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 09/13] iio: imu: st_lsm6dsx: fix checkpatch warning Date: Sun, 6 Oct 2019 15:22:03 +0200 Message-Id: <7c8a7e5f17befae7ac541cfb155ec7fefa78b10e.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Fix following checkpatch warnings: CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_read_event_config(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, WARNING: line over 80 characters + if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 35 +++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 04231710ab9c..b0623b837abd 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1523,12 +1523,13 @@ static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, return IIO_VAL_INT; } -static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir, - enum iio_event_info info, - int val, int val2) +static int +st_lsm6dsx_write_event(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int val, int val2) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_hw *hw = sensor->hw; @@ -1554,10 +1555,11 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, return 0; } -static int st_lsm6dsx_read_event_config(struct iio_dev *iio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir) +static int +st_lsm6dsx_read_event_config(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_hw *hw = sensor->hw; @@ -1568,11 +1570,11 @@ static int st_lsm6dsx_read_event_config(struct iio_dev *iio_dev, return !!(hw->enable_event & BIT(chan->channel2)); } -static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir, - int state) +static int +st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, int state) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_hw *hw = sensor->hw; @@ -2150,7 +2152,8 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, return err; } - if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) + if (dev->of_node && + of_property_read_bool(dev->of_node, "wakeup-source")) device_init_wakeup(dev, true); return 0; From patchwork Sun Oct 6 13:22:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87EDC13BD for ; Sun, 6 Oct 2019 13:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6785020867 for ; Sun, 6 Oct 2019 13:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368166; bh=HWiROyqVHj52scWeZCx9IuF0DfAJWdxDz8Yg11/KS8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vYBZNcgPnd/nJtAccVZkUhpUnh2LYbx5Y7aTmGyG1RlsLf2M1w6xl0C+I1kDDqMRb V/bTiexWI5zmotqWUmM3hQCmWQEB2bRMJ39U5Zl5SJ6/F0ZfZOqnK/Mu1LRlJx+o/O fSkjETog2QaLP8Szx/qWq5wfjpu0yQmTAPonU4iM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726516AbfJFNWq (ORCPT ); Sun, 6 Oct 2019 09:22:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:38556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWp (ORCPT ); Sun, 6 Oct 2019 09:22:45 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 80A922087E; Sun, 6 Oct 2019 13:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368165; bh=HWiROyqVHj52scWeZCx9IuF0DfAJWdxDz8Yg11/KS8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M5SNEgu2FEUWbFEvARi3G+1Oz4EVcQRjXkbSFSsvnAo/XczF8NFuCkKniMSEbV28F DZ5yYcjhVZTm4cS6QKUpDJXEaOTUf45fa+C2yBmDg7QulGdyNCadms4qXmNSPg9d6a HGEBNf/EQpy0f3w0GNN8BUNjvswFWAp9fJFys3gw= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 10/13] iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data Date: Sun, 6 Oct 2019 15:22:04 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add the possibility to enable/disable wakeup source through st_sensors_platform_data and not only through device tree Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 ++++-- include/linux/platform_data/st_sensors_pdata.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index b0623b837abd..a2a0ac81e3d3 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2089,7 +2089,9 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap) { + struct st_sensors_platform_data *pdata = dev->platform_data; const struct st_lsm6dsx_shub_settings *hub_settings; + struct device_node *np = dev->of_node; struct st_lsm6dsx_hw *hw; const char *name = NULL; int i, err; @@ -2152,8 +2154,8 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, return err; } - if (dev->of_node && - of_property_read_bool(dev->of_node, "wakeup-source")) + if ((np && of_property_read_bool(np, "wakeup-source")) || + (pdata && pdata->wakeup_source)) device_init_wakeup(dev, true); return 0; diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h index 30929c22227d..e40b28ca892e 100644 --- a/include/linux/platform_data/st_sensors_pdata.h +++ b/include/linux/platform_data/st_sensors_pdata.h @@ -18,12 +18,14 @@ * @open_drain: set the interrupt line to be open drain if possible. * @spi_3wire: enable spi-3wire mode. * @pullups: enable/disable i2c controller pullup resistors. + * @wakeup_source: enable/disable device as wakeup generator. */ struct st_sensors_platform_data { u8 drdy_int_pin; bool open_drain; bool spi_3wire; bool pullups; + bool wakeup_source; }; #endif /* ST_SENSORS_PDATA_H */ From patchwork Sun Oct 6 13:22:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 473DC13BD for ; Sun, 6 Oct 2019 13:22:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 25B732133F for ; Sun, 6 Oct 2019 13:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368168; bh=ToihDePn9t+T//wYe2kgzJ0PK3Wvt/BsjHbN9WgnTVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wNrNzUZqia4oldneQKXhdmQ7gdtyhVedZ11Qtm/EJbQ6Rrvjmu2AtosQ8JVdnfE9g WRziA11Mld5fuPbtc43uMrr7aWLW9ehU2VCKapVkulHb7S/75FAYkJkA4Q/fdW42WO 2wWinYx+hHdQwG93eeWymyFbO7VQqRpxrzYnA2Wg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726529AbfJFNWr (ORCPT ); Sun, 6 Oct 2019 09:22:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:38590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWr (ORCPT ); Sun, 6 Oct 2019 09:22:47 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 93B9920684; Sun, 6 Oct 2019 13:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368167; bh=ToihDePn9t+T//wYe2kgzJ0PK3Wvt/BsjHbN9WgnTVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nk5QbgL6lri1jbeFq6AmI6u2vePq+ZiIjy/XfKqe/H34CrFN1Q7moFQNxlcA4mYHH 28fcYoqDrD9isioYYSopLZpykLYj6kOhWLPCQrKDegO1q3dIp7+/IT+RGajaJldYSq 4LTVygZcVLxuyQGjPa5XiGG6QTguMoE2fFLthtOo= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 11/13] iio: imu: st_lsm6dsx: add missing kernel documenation Date: Sun, 6 Oct 2019 15:22:05 +0200 Message-Id: <08d98185ff40de1b2183446d6da61fffcafb9b7f.1570367532.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add missing kernel doc for st_lsm6dsx_hw data structure Signed-off-by: Lorenzo Bianconi Reviewed-by: Sean Nyekjaer --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 5692ea695f04..40532f99ba4b 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -345,6 +345,9 @@ struct st_lsm6dsx_sensor { * @ts_sip: Total number of timestamp samples in a given pattern. * @sip: Total number of samples (acc/gyro/ts) in a given pattern. * @buff: Device read buffer. + * @irq_routing: pointer to interrupt routing configuration. + * @event_threshold: wakeup event threshold. + * @enable_event: enabled event bitmask. * @iio_devs: Pointers to acc/gyro iio_dev instances. * @settings: Pointer to the specific sensor settings in use. */ From patchwork Sun Oct 6 13:22:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90A6C1862 for ; Sun, 6 Oct 2019 13:22:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DD2B2133F for ; Sun, 6 Oct 2019 13:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368170; bh=du4I8ZEf1/8MRPe0eby4NOeQjZy7ujhUdHMW15Gi6eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AFIiDRfHL3y0YrEjaztZHbdWorQf9IzO2Wf4GAqdoajevxnM0RyrD20DbAIHIrGwB 9WSEIVyGxRoVVApnm7+/vSrvxecU5rhsRYKt5y7TFjEMUcZLJGU2xBRFUKuhEWe5GL IIDPjevf8O0h0u9rEkia789ahTFY89NpmN4cdrF8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbfJFNWu (ORCPT ); Sun, 6 Oct 2019 09:22:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:38610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWt (ORCPT ); Sun, 6 Oct 2019 09:22:49 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A44B320867; Sun, 6 Oct 2019 13:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368169; bh=du4I8ZEf1/8MRPe0eby4NOeQjZy7ujhUdHMW15Gi6eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cml3DfjKEkjzJQtQwfTr4QyeI9hy+Ft45RFwUCBXgflRgqpTjS1XkGqrtcyWCpJSf Gz6l2AW6V5DgtNNlVC46BnVAIm7AwK4V52TEw4nib6kGHQkO7DC1yjK29wI6D3BRD7 3JP+InAjWrS/+cu+jxsn+iIgNu/B2HVHq3NA4KGg= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 12/13] dt-bindings: iio: imu: st_lsm6dsx: document missing wakeup-source property Date: Sun, 6 Oct 2019 15:22:06 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Signed-off-by: Lorenzo Bianconi Reviewed-by: Sean Nyekjaer Acked-by: Rob Herring --- Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt index 6d0c050d89fe..1a07d38c813f 100644 --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt @@ -31,6 +31,7 @@ Optional properties: - interrupts: interrupt mapping for IRQ. It should be configured with flags IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING. +- wakeup-source: Enables wake up of host system on event. Refer to interrupt-controller/interrupts.txt for generic interrupt client node bindings. From patchwork Sun Oct 6 13:22:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 11176343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D09701747 for ; Sun, 6 Oct 2019 13:22:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFD4C2087E for ; Sun, 6 Oct 2019 13:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368172; bh=lF4U+388Up8x8NgLcxcAHnQARZqRdLj5ly/E56lPHhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ES313OTfWzy23RaFTgYhQun5mCANiEMGWvNbUeTHThQlFNlVxAHn/lI9mPD7huXYe JwgpsXDTHjnX+ySK4FGXMaEhmKmhb54YsUV0YJhufDBcNRwaV0TX+iXY3MGJHAUhZm b4iQSHAA6ApYtVBHPNlhwsCtm9gqaxK90Pvh0V5E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726554AbfJFNWw (ORCPT ); Sun, 6 Oct 2019 09:22:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:38640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfJFNWw (ORCPT ); Sun, 6 Oct 2019 09:22:52 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.37.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE46420684; Sun, 6 Oct 2019 13:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570368171; bh=lF4U+388Up8x8NgLcxcAHnQARZqRdLj5ly/E56lPHhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gnltqg8Qk8XyDJ0K3hgDwFxoKddPM2+XkP8PlzK8EdE8MS/0TMLjp132Z/W+si6bu vrGgW+nzo5oRltocFn+pC1xRi41VoJcDKPMl7/K2VknL9MgQ1uN33/0jsMgKgogiQw W1zKolNmoaPCmw1jMhpwLMt1qC2vyFEACPXjKn8k= From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: [PATCH 13/13] iio: imu: st_lsm6dsx: enable wake-up event for LSM6DSO Date: Sun, 6 Oct 2019 15:22:07 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add missing wake-up register info for LSM6DSO/LSM6DSOX sensor Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index a2a0ac81e3d3..876f59cedc8b 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -780,6 +780,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x56, .mask = BIT(6), }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, .hla = { .addr = 0x12, .mask = BIT(5), @@ -847,7 +855,22 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .slv0_addr = 0x15, .dw_slv0_addr = 0x21, .batch_en = BIT(3), - } + }, + .event_settings = { + .enable_reg = { + .addr = 0x58, + .mask = BIT(7), + }, + .wakeup_reg = { + .addr = 0x5b, + .mask = GENMASK(5, 0), + }, + .wakeup_src_reg = 0x1b, + .wakeup_src_status_mask = BIT(3), + .wakeup_src_z_mask = BIT(0), + .wakeup_src_y_mask = BIT(1), + .wakeup_src_x_mask = BIT(2), + }, }, { .wai = 0x6b,