Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4266490ybi; Mon, 15 Jul 2019 06:27:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8KQxjy6f3bd7DSjWgRzhYKhDuuq2IMcaA3Elp3QvCJUlA1MVP8JecblNtCEgjlx/mzAGA X-Received: by 2002:a17:90a:ad86:: with SMTP id s6mr29463872pjq.42.1563197232347; Mon, 15 Jul 2019 06:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563197232; cv=none; d=google.com; s=arc-20160816; b=y51iYQbuDCoM48pj+MjV1JYaoTcCyEVfOBXoiqDXJEf+STIZVtuLIPhyEEFq7+F5K3 W80YBm027MNGLKDqZ/BpdAql6l1yYot+7XyyXCF6huEk7O9iHswEZF7SGKDHLMgMdN4t lsluVgTm6AFY/N7T3kwcDr8nr4KyzZKbFR5jDtxUyfWnGHL3y5+ApBHGZYTUlAcvkgD0 rcm2I0x/lMucptaxmdWrm3IdWp2wxwn5HdO7wcPCDIHDtf1xxoQMO3+3EoF0kytlLcrl vlY/sdjOn9VOzehORJiZGllNm7Sdx6xSi33n5vxvneLeLkJA2R41lbz4FrmA5j/YOh2W 3diQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id:date :subject:cc:to:from; bh=mxRlc/1omUIfgy7bEXq9S9P9yyLQrn0PEtuWaKpVBfI=; b=cE4ux8HkEgqN3lW22YYBwI7hUgSVD1PmBjiw9D/NI1G/Lj5SqdSccPwcKzlpgRysYJ yddnDehh/teb0nTFvtRf31wYgL6JiK0kHF8LFk0Q33LlV6kVVrtFp+wL6PVENsEnWPt3 8QZJVarZZPP79gZ9ZLg/jfv5ehZeTL4tm8TCvv16yiLsyN5OyFYg6Rz6hmAmmISYQS9x nM5hBXg2VEAY00z4kcKkY8x1BtCWdDgAacxXXaWlvUCuXXcFDiRZdb7QtE38qfHmvcdd 03NDNcihAEGXmXDLy/jbklLxSi1CXeZEI4LpShXlO/U68ZACdNcX3ibI7jUigbyQolLt O9bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si15000932pls.189.2019.07.15.06.26.53; Mon, 15 Jul 2019 06:27:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730386AbfGON0K (ORCPT + 99 others); Mon, 15 Jul 2019 09:26:10 -0400 Received: from comms.puri.sm ([159.203.221.185]:53310 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730124AbfGON0J (ORCPT ); Mon, 15 Jul 2019 09:26:09 -0400 X-Greylist: delayed 354 seconds by postgrey-1.27 at vger.kernel.org; Mon, 15 Jul 2019 09:26:08 EDT Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 52D00E01EB; Mon, 15 Jul 2019 06:20:14 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NX4mBcKjbY7F; Mon, 15 Jul 2019 06:20:13 -0700 (PDT) From: Martin Kepplinger To: lorenzo.bianconi83@gmail.com, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH 1/3] iio: imu: st_lsm6sdx: move some register definitions to sensor_settings struct Date: Mon, 15 Jul 2019 15:19:17 +0200 Message-Id: <20190715131919.31938-1-martin.kepplinger@puri.sm> Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move some register definitions to the per-device array of struct st_lsm6dsx_sensor_settings in order to simplify adding new sensor devices to the driver. Also, remove completely unused register definitions. Signed-off-by: Martin Kepplinger --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 6 ++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 31 ++++++++++++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index c14bf533b66b..f072ac14f213 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -196,6 +196,9 @@ struct st_lsm6dsx_ext_dev_settings { /** * struct st_lsm6dsx_settings - ST IMU sensor settings * @wai: Sensor WhoAmI default value. + * @reg_int1_addr: Control Register address for INT1 + * @reg_int2_addr: Control Register address for INT2 + * @reg_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. * @decimator: List of decimator register info (addr + mask). @@ -206,6 +209,9 @@ struct st_lsm6dsx_ext_dev_settings { */ struct st_lsm6dsx_settings { u8 wai; + u8 reg_int1_addr; + u8 reg_int2_addr; + u8 reg_reset_addr; 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 a6702a74570e..7a4fe70a8f20 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -49,17 +49,12 @@ #include "st_lsm6dsx.h" -#define ST_LSM6DSX_REG_INT1_ADDR 0x0d -#define ST_LSM6DSX_REG_INT2_ADDR 0x0e #define ST_LSM6DSX_REG_FIFO_FTH_IRQ_MASK BIT(3) #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f -#define ST_LSM6DSX_REG_RESET_ADDR 0x12 #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) -#define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13 -#define ST_LSM6DSX_REG_INT2_ON_INT1_MASK BIT(5) #define ST_LSM6DSX_REG_ACC_OUT_X_L_ADDR 0x28 #define ST_LSM6DSX_REG_ACC_OUT_Y_L_ADDR 0x2a @@ -122,6 +117,9 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .wai = 0x69, + .reg_int1_addr = 0x0d, + .reg_int2_addr = 0x0e, + .reg_reset_addr = 0x12, .max_fifo_size = 1365, .id = { { @@ -172,6 +170,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x69, + .reg_int1_addr = 0x0d, + .reg_int2_addr = 0x0e, + .reg_reset_addr = 0x12, .max_fifo_size = 682, .id = { { @@ -222,6 +223,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6a, + .reg_int1_addr = 0x0d, + .reg_int2_addr = 0x0e, + .reg_reset_addr = 0x12, .max_fifo_size = 682, .id = { { @@ -278,6 +282,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6c, + .reg_int1_addr = 0x0d, + .reg_int2_addr = 0x0e, + .reg_reset_addr = 0x12, .max_fifo_size = 512, .id = { { @@ -349,6 +356,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6b, + .reg_int1_addr = 0x0d, + .reg_int2_addr = 0x0e, + .reg_reset_addr = 0x12, .max_fifo_size = 512, .id = { { @@ -391,6 +401,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, { .wai = 0x6b, + .reg_int1_addr = 0x0d, + .reg_int2_addr = 0x0e, + .reg_reset_addr = 0x12, .max_fifo_size = 512, .id = { { @@ -873,10 +886,10 @@ static int st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw, u8 *drdy_reg) switch (drdy_pin) { case 1: - *drdy_reg = ST_LSM6DSX_REG_INT1_ADDR; + *drdy_reg = hw->settings->reg_int1_addr; break; case 2: - *drdy_reg = ST_LSM6DSX_REG_INT2_ADDR; + *drdy_reg = hw->settings->reg_int2_addr; break; default: dev_err(hw->dev, "unsupported data ready pin\n"); @@ -976,7 +989,7 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) int err; /* device sw reset */ - err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, + err = regmap_update_bits(hw->regmap, hw->settings->reg_reset_addr, ST_LSM6DSX_REG_RESET_MASK, FIELD_PREP(ST_LSM6DSX_REG_RESET_MASK, 1)); if (err < 0) @@ -985,7 +998,7 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) msleep(50); /* reload trimming parameter */ - err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, + err = regmap_update_bits(hw->regmap, hw->settings->reg_reset_addr, ST_LSM6DSX_REG_BOOT_MASK, FIELD_PREP(ST_LSM6DSX_REG_BOOT_MASK, 1)); if (err < 0) -- 2.20.1