From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 6/6] iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm
Date: Mon, 23 Dec 2019 18:25:39 +0100 [thread overview]
Message-ID: <20191223172539.GE6274@localhost.localdomain> (raw)
In-Reply-To: <20191223164917.6bcb72cf@archlinux>
[-- Attachment #1: Type: text/plain, Size: 7652 bytes --]
> On Sat, 14 Dec 2019 17:52:59 +0100
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > Enabled i2c master controller support for LSM6DSM sensor. Enable
> > ext_sensor0 for lsm6dsm. This series has been tested using LIS2MDL as
> > slave device connected to the i2c controller of the LSM6DSM
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> One question inline. However I'm happy enough to take it with that
> outstanding on basis I am not going to push out as non rebasing for
> a while yet.
>
> Applied to the togreg branch of iio.git and pushed out as testing for
> the autobuilders to play with it.
>
> Thanks,
>
> Jonathan
>
> > ---
[...]
> > iio_push_to_buffers_with_timestamp(
> > hw->iio_devs[ST_LSM6DSX_ID_ACC],
> > acc_buff, acc_sensor->ts_ref + ts);
> > + if (ext_sip-- > 0)
> > + iio_push_to_buffers_with_timestamp(
> > + hw->iio_devs[ST_LSM6DSX_ID_EXT0],
> > + ext_buff, ext_sensor->ts_ref + ts);
> > }
> > }
> >
> > @@ -628,12 +641,12 @@ int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
> > err = st_lsm6dsx_sensor_set_enable(sensor, enable);
> > if (err < 0)
> > goto out;
> > -
> > - err = st_lsm6dsx_set_fifo_odr(sensor, enable);
> > - if (err < 0)
> > - goto out;
> > }
> >
>
> Why this change? I'm not sure what the original logic was so hard to follow ;)
Hi Jonathan,
we need to set FIFO odr to 1.66KHz for LSM6DSM even if we enable just the sensor hub
(and not other sensors).
Regards,
Lorenzo
>
> > + err = st_lsm6dsx_set_fifo_odr(sensor, enable);
> > + if (err < 0)
> > + goto out;
> > +
> > err = st_lsm6dsx_update_decimators(hw);
> > if (err < 0)
> > goto out;
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > index 679831d84d78..1f00b0d74b25 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > @@ -655,6 +655,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > .addr = 0x08,
> > .mask = GENMASK(5, 3),
> > },
> > + [ST_LSM6DSX_ID_EXT0] = {
> > + .addr = 0x09,
> > + .mask = GENMASK(2, 0),
> > + },
> > },
> > .fifo_ops = {
> > .update_fifo = st_lsm6dsx_update_fifo,
> > @@ -687,6 +691,39 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > .mask = GENMASK(5, 3),
> > },
> > },
> > + .shub_settings = {
> > + .page_mux = {
> > + .addr = 0x01,
> > + .mask = BIT(7),
> > + },
> > + .master_en = {
> > + .addr = 0x1a,
> > + .mask = BIT(0),
> > + },
> > + .pullup_en = {
> > + .addr = 0x1a,
> > + .mask = BIT(3),
> > + },
> > + .aux_sens = {
> > + .addr = 0x04,
> > + .mask = GENMASK(5, 4),
> > + },
> > + .wr_once = {
> > + .addr = 0x07,
> > + .mask = BIT(5),
> > + },
> > + .emb_func = {
> > + .addr = 0x19,
> > + .mask = BIT(2),
> > + },
> > + .num_ext_dev = 1,
> > + .shub_out = {
> > + .addr = 0x2e,
> > + },
> > + .slv0_addr = 0x02,
> > + .dw_slv0_addr = 0x0e,
> > + .pause = 0x7,
> > + },
> > .event_settings = {
> > .enable_reg = {
> > .addr = 0x58,
> > @@ -1901,6 +1938,16 @@ static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw)
> > hub_settings->aux_sens.mask, data);
> >
> > st_lsm6dsx_set_page(hw, false);
> > +
> > + if (err < 0)
> > + return err;
> > + }
> > +
> > + if (hub_settings->emb_func.addr) {
> > + data = ST_LSM6DSX_SHIFT_VAL(1, hub_settings->emb_func.mask);
> > + err = regmap_update_bits(hw->regmap,
> > + hub_settings->emb_func.addr,
> > + hub_settings->emb_func.mask, data);
> > }
> >
> > return err;
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > index dc739dfb36f2..eea555617d4a 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > @@ -221,16 +221,21 @@ st_lsm6dsx_shub_read(struct st_lsm6dsx_sensor *sensor, u8 addr,
> > u8 *data, int len)
> > {
> > const struct st_lsm6dsx_shub_settings *hub_settings;
> > + u8 config[3], slv_addr, slv_config = 0;
> > struct st_lsm6dsx_hw *hw = sensor->hw;
> > - u8 config[3], slv_addr;
> > + const struct st_lsm6dsx_reg *aux_sens;
> > int err;
> >
> > hub_settings = &hw->settings->shub_settings;
> > slv_addr = ST_LSM6DSX_SLV_ADDR(0, hub_settings->slv0_addr);
> > + aux_sens = &hw->settings->shub_settings.aux_sens;
> > + /* do not overwrite aux_sens */
> > + if (slv_addr + 2 == aux_sens->addr)
> > + slv_config = ST_LSM6DSX_SHIFT_VAL(3, aux_sens->mask);
> >
> > config[0] = (sensor->ext_info.addr << 1) | 1;
> > config[1] = addr;
> > - config[2] = len & ST_LS6DSX_READ_OP_MASK;
> > + config[2] = (len & ST_LS6DSX_READ_OP_MASK) | slv_config;
> >
> > err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config,
> > sizeof(config));
> > @@ -248,7 +253,9 @@ st_lsm6dsx_shub_read(struct st_lsm6dsx_sensor *sensor, u8 addr,
> >
> > st_lsm6dsx_shub_master_enable(sensor, false);
> >
> > - memset(config, 0, sizeof(config));
> > + config[0] = hub_settings->pause;
> > + config[1] = 0;
> > + config[2] = slv_config;
> > return st_lsm6dsx_shub_write_reg(hw, slv_addr, config,
> > sizeof(config));
> > }
> > @@ -305,7 +312,8 @@ st_lsm6dsx_shub_write(struct st_lsm6dsx_sensor *sensor, u8 addr,
> > st_lsm6dsx_shub_master_enable(sensor, false);
> > }
> >
> > - memset(config, 0, sizeof(config));
> > + config[0] = hub_settings->pause;
> > + config[1] = 0;
> > return st_lsm6dsx_shub_write_reg(hw, slv_addr, config, sizeof(config));
> > }
> >
> > @@ -697,14 +705,19 @@ st_lsm6dsx_shub_check_wai(struct st_lsm6dsx_hw *hw, u8 *i2c_addr,
> > const struct st_lsm6dsx_ext_dev_settings *settings)
> > {
> > const struct st_lsm6dsx_shub_settings *hub_settings;
> > + u8 config[3], data, slv_addr, slv_config = 0;
> > + const struct st_lsm6dsx_reg *aux_sens;
> > struct st_lsm6dsx_sensor *sensor;
> > - u8 config[3], data, slv_addr;
> > bool found = false;
> > int i, err;
> >
> > + sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
> > hub_settings = &hw->settings->shub_settings;
> > + aux_sens = &hw->settings->shub_settings.aux_sens;
> > slv_addr = ST_LSM6DSX_SLV_ADDR(0, hub_settings->slv0_addr);
> > - sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
> > + /* do not overwrite aux_sens */
> > + if (slv_addr + 2 == aux_sens->addr)
> > + slv_config = ST_LSM6DSX_SHIFT_VAL(3, aux_sens->mask);
> >
> > for (i = 0; i < ARRAY_SIZE(settings->i2c_addr); i++) {
> > if (!settings->i2c_addr[i])
> > @@ -713,7 +726,7 @@ st_lsm6dsx_shub_check_wai(struct st_lsm6dsx_hw *hw, u8 *i2c_addr,
> > /* read wai slave register */
> > config[0] = (settings->i2c_addr[i] << 1) | 0x1;
> > config[1] = settings->wai.addr;
> > - config[2] = 0x1;
> > + config[2] = 0x1 | slv_config;
> >
> > err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config,
> > sizeof(config));
> > @@ -742,7 +755,9 @@ st_lsm6dsx_shub_check_wai(struct st_lsm6dsx_hw *hw, u8 *i2c_addr,
> > }
> >
> > /* reset SLV0 channel */
> > - memset(config, 0, sizeof(config));
> > + config[0] = hub_settings->pause;
> > + config[1] = 0;
> > + config[2] = slv_config;
> > err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config,
> > sizeof(config));
> > if (err < 0)
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2019-12-23 17:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-14 16:52 [PATCH 0/6] introduce i2c master controller support for LSM6DSM Lorenzo Bianconi
2019-12-14 16:52 ` [PATCH 1/6] iio: imu: st_lsm6dsx: export max num of slave devices in st_lsm6dsx_shub_settings Lorenzo Bianconi
2019-12-23 16:50 ` Jonathan Cameron
2019-12-14 16:52 ` [PATCH 2/6] iio: imu: st_lsm6dsx: check if master_enable is located in primary page Lorenzo Bianconi
2019-12-23 16:51 ` Jonathan Cameron
2019-12-14 16:52 ` [PATCH 3/6] iio: imu: st_lsm6dsx: check if pull_up " Lorenzo Bianconi
2019-12-23 16:51 ` Jonathan Cameron
2019-12-23 16:59 ` Jonathan Cameron
2019-12-14 16:52 ` [PATCH 4/6] iio: imu: st_lsm6dsx: check if shub_output reg " Lorenzo Bianconi
2019-12-23 17:00 ` Jonathan Cameron
2019-12-14 16:52 ` [PATCH 5/6] iio: imu: st_lsm6dsx: rename st_lsm6dsx_shub_read_reg in st_lsm6dsx_shub_read_output Lorenzo Bianconi
2019-12-23 17:01 ` Jonathan Cameron
2019-12-14 16:52 ` [PATCH 6/6] iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm Lorenzo Bianconi
2019-12-23 16:49 ` Jonathan Cameron
2019-12-23 17:25 ` 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=20191223172539.GE6274@localhost.localdomain \
--to=lorenzo.bianconi@redhat.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzo@kernel.org \
/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