From: Jonathan Cameron <jic23@kernel.org>
To: Quentin Schulz <quentin.schulz@free-electrons.com>,
knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net
Cc: irina.tirdea@intel.com, gregor.boirie@parrot.com,
amsfield22@gmail.com, s.trumtrar@pengutronix.de,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@free-electrons.com
Subject: Re: [PATCH] iio: bmg160: reset chip when probing
Date: Sat, 25 Mar 2017 16:37:11 +0000 [thread overview]
Message-ID: <4e094dd9-afdb-80fa-c943-ec870f9cd57c@kernel.org> (raw)
In-Reply-To: <20170321155214.18060-1-quentin.schulz@free-electrons.com>
On 21/03/17 15:52, Quentin Schulz wrote:
> The gyroscope chip might need to be reset to be used.
>
> Without the chip being reset, the driver stopped at the first
> regmap_read (to get the CHIP_ID) and failed to probe.
>
> The datasheet of the gyroscope says that a minimum wait of 30ms after
> the reset has to be done.
>
> This patch has been checked on a BMX055 and the datasheet of the BMG160
> and the BMI055 give the same reset register and bits.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> ---
> drivers/iio/gyro/bmg160_core.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
> index f7fcfa8..821919d 100644
> --- a/drivers/iio/gyro/bmg160_core.c
> +++ b/drivers/iio/gyro/bmg160_core.c
> @@ -27,6 +27,7 @@
> #include <linux/iio/trigger_consumer.h>
> #include <linux/iio/triggered_buffer.h>
> #include <linux/regmap.h>
> +#include <linux/delay.h>
> #include "bmg160.h"
>
> #define BMG160_IRQ_NAME "bmg160_event"
> @@ -52,6 +53,9 @@
> #define BMG160_DEF_BW 100
> #define BMG160_REG_PMU_BW_RES BIT(7)
>
> +#define BMG160_GYRO_REG_RESET 0x14
> +#define BMG160_GYRO_RESET_VAL 0xb6
> +
> #define BMG160_REG_INT_MAP_0 0x17
> #define BMG160_INT_MAP_0_BIT_ANY BIT(1)
>
> @@ -236,6 +240,14 @@ static int bmg160_chip_init(struct bmg160_data *data)
> int ret;
> unsigned int val;
>
> + /*
> + * Reset chip to get it in a known good state. A delay of 30ms after
> + * reset is required according to the datasheet.
> + */
> + regmap_write(data->regmap, BMG160_GYRO_REG_RESET,
> + BMG160_GYRO_RESET_VAL);
> + usleep_range(30000, 30700);
> +
> ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val);
> if (ret < 0) {
> dev_err(dev, "Error reading reg_chip_id\n");
>
prev parent reply other threads:[~2017-03-25 16:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 15:52 Quentin Schulz
2017-03-25 16:37 ` Jonathan Cameron [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=4e094dd9-afdb-80fa-c943-ec870f9cd57c@kernel.org \
--to=jic23@kernel.org \
--cc=amsfield22@gmail.com \
--cc=gregor.boirie@parrot.com \
--cc=irina.tirdea@intel.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=quentin.schulz@free-electrons.com \
--cc=s.trumtrar@pengutronix.de \
--cc=thomas.petazzoni@free-electrons.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
all inboxes | Powered by JetHome®