linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo@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: Re: [PATCH 05/13] iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings
Date: Sat, 12 Oct 2019 13:19:02 +0100	[thread overview]
Message-ID: <20191012131902.1362063b@archlinux> (raw)
In-Reply-To: <05ed5aab740bcf07ee5b32e4d3248d29b6ad31f7.1570367532.git.lorenzo@kernel.org>

On Sun,  6 Oct 2019 15:21:59 +0200
Lorenzo Bianconi <lorenzo@kernel.org> 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 <lorenzo@kernel.org>
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;
>  


  reply	other threads:[~2019-10-12 12:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-06 13:21 [PATCH 00/13] various st_lsm6dsx fixes and missing bits Lorenzo Bianconi
2019-10-06 13:21 ` [PATCH 01/13] iio: imu: st_lsm6dsx: use st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event Lorenzo Bianconi
2019-10-07  7:54   ` Sean Nyekjaer
2019-10-12 12:08   ` Jonathan Cameron
2019-10-06 13:21 ` [PATCH 02/13] iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer Lorenzo Bianconi
2019-10-06 13:21 ` [PATCH 03/13] iio: imu: st_lsm6dsx: move irq related definitions in irq_config Lorenzo Bianconi
2019-10-07  7:54   ` Sean Nyekjaer
2019-10-12 12:13     ` Jonathan Cameron
2019-10-06 13:21 ` [PATCH 04/13] iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supported Lorenzo Bianconi
2019-10-12 12:14   ` Jonathan Cameron
2019-10-06 13:21 ` [PATCH 05/13] iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings Lorenzo Bianconi
2019-10-12 12:19   ` Jonathan Cameron [this message]
2019-10-06 13:22 ` [PATCH 06/13] iio: imu: st_lsm6dsx: always check enable_reg in st_lsm6dsx_event_setup Lorenzo Bianconi
2019-10-07  7:55   ` Sean Nyekjaer
2019-10-12 12:21     ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 07/13] iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events Lorenzo Bianconi
2019-10-12 12:22   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 08/13] iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config Lorenzo Bianconi
2019-10-12 12:23   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 09/13] iio: imu: st_lsm6dsx: fix checkpatch warning Lorenzo Bianconi
2019-10-12 12:24   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 10/13] iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data Lorenzo Bianconi
2019-10-12 12:25   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 11/13] iio: imu: st_lsm6dsx: add missing kernel documenation Lorenzo Bianconi
2019-10-07  7:56   ` Sean Nyekjaer
2019-10-12 12:26     ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 12/13] dt-bindings: iio: imu: st_lsm6dsx: document missing wakeup-source property Lorenzo Bianconi
2019-10-07  7:56   ` Sean Nyekjaer
2019-10-15 20:34   ` Rob Herring
2019-10-06 13:22 ` [PATCH 13/13] iio: imu: st_lsm6dsx: enable wake-up event for LSM6DSO Lorenzo Bianconi
2019-10-12 12:28   ` Jonathan Cameron
2019-10-12 12:20 ` [PATCH 00/13] various st_lsm6dsx fixes and missing bits Jonathan Cameron
2019-10-12 12:26   ` Lorenzo Bianconi
2019-10-12 13:26     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191012131902.1362063b@archlinux \
    --to=jic23@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=martin@geanix.com \
    --cc=rjones@gateworks.com \
    --cc=sean@geanix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).