From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Martin Kepplinger <martin.kepplinger@puri.sm>
Cc: lorenzo.bianconi83@gmail.com, jic23@kernel.org, knaack.h@gmx.de,
lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCHv2 1/3] iio: imu: st_lsm6sdx: move register definitions to sensor_settings struct
Date: Tue, 16 Jul 2019 11:43:58 +0200 [thread overview]
Message-ID: <20190716094358.GC13440@localhost.localdomain> (raw)
In-Reply-To: <20190716093325.7683-1-martin.kepplinger@puri.sm>
[-- Attachment #1: Type: text/plain, Size: 5590 bytes --]
> 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 <martin.kepplinger@puri.sm>
> ---
>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
>
> This is already based on Lorenzo's recent changes:
> https://lore.kernel.org/linux-iio/853f216a-7814-cb79-180b-078ac5e8a359@puri.sm/T/#u
> https://lore.kernel.org/linux-iio/501b0db9-63cb-905c-c09b-682eb73f1ff3@puri.sm/T/#u
>
> revision history:
> v2: improve variable names, thanks Lorenzo
>
> thanks
> martin
>
>
>
> 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 ab1c66615d67..3c47f5d27d30 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -198,6 +198,9 @@ 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.
> * @odr_table: Hw sensors odr table (Hz + val).
> @@ -210,6 +213,9 @@ struct st_lsm6dsx_ext_dev_settings {
> */
> struct st_lsm6dsx_settings {
> u8 wai;
> + u8 int1_addr;
> + u8 int2_addr;
> + u8 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 9aa109428a52..e0d2149625cc 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
> @@ -72,6 +67,9 @@
> static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> {
> .wai = 0x69,
> + .int1_addr = 0x0d,
> + .int2_addr = 0x0e,
> + .reset_addr = 0x12,
> .max_fifo_size = 1365,
> .id = {
> {
> @@ -170,6 +168,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> {
> .wai = 0x69,
> + .int1_addr = 0x0d,
> + .int2_addr = 0x0e,
> + .reset_addr = 0x12,
> .max_fifo_size = 682,
> .id = {
> {
> @@ -268,6 +269,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> {
> .wai = 0x6a,
> + .int1_addr = 0x0d,
> + .int2_addr = 0x0e,
> + .reset_addr = 0x12,
> .max_fifo_size = 682,
> .id = {
> {
> @@ -375,6 +379,9 @@ 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 = {
> {
> @@ -494,6 +501,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> {
> .wai = 0x6b,
> + .int1_addr = 0x0d,
> + .int2_addr = 0x0e,
> + .reset_addr = 0x12,
> .max_fifo_size = 512,
> .id = {
> {
> @@ -584,6 +594,9 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> },
> {
> .wai = 0x6b,
> + .int1_addr = 0x0d,
> + .int2_addr = 0x0e,
> + .reset_addr = 0x12,
> .max_fifo_size = 512,
> .id = {
> {
> @@ -1117,10 +1130,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->int1_addr;
> break;
> case 2:
> - *drdy_reg = ST_LSM6DSX_REG_INT2_ADDR;
> + *drdy_reg = hw->settings->int2_addr;
> break;
> default:
> dev_err(hw->dev, "unsupported data ready pin\n");
> @@ -1220,7 +1233,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->reset_addr,
> ST_LSM6DSX_REG_RESET_MASK,
> FIELD_PREP(ST_LSM6DSX_REG_RESET_MASK, 1));
> if (err < 0)
> @@ -1229,7 +1242,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->reset_addr,
> ST_LSM6DSX_REG_BOOT_MASK,
> FIELD_PREP(ST_LSM6DSX_REG_BOOT_MASK, 1));
> if (err < 0)
> --
> 2.20.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2019-07-16 9:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-16 9:33 [PATCHv2 1/3] iio: imu: st_lsm6sdx: move register definitions to sensor_settings struct Martin Kepplinger
2019-07-16 9:33 ` [PATCHv2 2/3] iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9sd1 Martin Kepplinger
2019-07-16 9:48 ` Lorenzo Bianconi
2019-07-16 9:33 ` [PATCH 3/3] dt-bindings: iio: imu: st_lsm6dsx: add lsm9ds1 device bindings Martin Kepplinger
2019-07-16 9:43 ` Lorenzo Bianconi [this message]
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=20190716094358.GC13440@localhost.localdomain \
--to=lorenzo@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=martin.kepplinger@puri.sm \
--cc=pmeerw@pmeerw.net \
/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).