From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7471C4360C for ; Sat, 12 Oct 2019 12:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A18E92196E for ; Sat, 12 Oct 2019 12:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570882749; bh=mxBCAtPZdGIhK8paaqr8HMkm4o14JXOcyY5LWDbzdF4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=ud8o1IwLsYmK2sP71Yk8s6r+pCwjsJIm8MPLdzpLSpz6gJ6Qd5iy8MV8tZ7vH/bBl 1L+LFmtqxNKQXg84R6ljh9fPAgs0nY9G2760VsAzz0nM6ce1Xp/B6XdIca5JgmGXln j+nQ7rcYXghovDporGAmTRfwjR7f04b1wiuf32Fw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729324AbfJLMTJ (ORCPT ); Sat, 12 Oct 2019 08:19:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:46482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbfJLMTI (ORCPT ); Sat, 12 Oct 2019 08:19:08 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 228692089C; Sat, 12 Oct 2019 12:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570882747; bh=mxBCAtPZdGIhK8paaqr8HMkm4o14JXOcyY5LWDbzdF4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dagGhA+5pzGTVY6qzLKppRl056MtKIGVH/O/d/vpzPhzFkxtEOMuy/uIUcfMgXIvH IrpxLDJv/bCmFbcXmiHNbnG2jKV+ngGA8KRnCAgMqprHKSMaQ5EM4J2yVGClYqtDlu h5qwospNdQcWuEAmVnLDaE//xpULAjlb7sFDfHv8= Date: Sat, 12 Oct 2019 13:19:02 +0100 From: Jonathan Cameron To: Lorenzo Bianconi Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com, rjones@gateworks.com, lorenzo.bianconi@redhat.com, devicetree@vger.kernel.org Subject: Re: [PATCH 05/13] iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings Message-ID: <20191012131902.1362063b@archlinux> In-Reply-To: <05ed5aab740bcf07ee5b32e4d3248d29b6ad31f7.1570367532.git.lorenzo@kernel.org> References: <05ed5aab740bcf07ee5b32e4d3248d29b6ad31f7.1570367532.git.lorenzo@kernel.org> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Sun, 6 Oct 2019 15:21:59 +0200 Lorenzo Bianconi wrote: > 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 Applied. Note that I'm applying this series to the togreg branch of iio.git simply to avoid the complexity of trying to unwind what should go to stable at this point and what should not. Not sure what else we can do with this driver as it is in a fairly large state of flux. You may need to do backports by hand to cover 5.4. Thanks, Jonathan > --- > 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; >