Re: [v7 08/14] iio: imu: add Bosch Sensortec BNO055 core driver
From: Jonathan Cameron
Date: Sun Sep 18 2022 - 13:27:37 EST
On Wed, 7 Sep 2022 15:21:59 +0200
<andrea.merello@xxxxxx> wrote:
> From: Andrea Merello <andrea.merello@xxxxxx>
>
> Add the core driver for the BNO055 IMU from Bosch. This IMU can be
> connected via both serial and I2C busses; separate patches will add support
> for them.
>
> The driver supports "AMG" (Accelerometer, Magnetometer, Gyroscope) mode,
> that provides raw data from the said internal sensors, and a couple of
> "fusion" modes (i.e. the IMU also does calculations in order to provide
> euler angles, quaternions, linear acceleration and gravity measurements).
>
> In fusion modes the AMG data is still available (with some calibration
> refinements done by the IMU), but certain settings such as low pass filters
> cut-off frequency and sensors' ranges are fixed, while in AMG mode they can
> be customized; this is why AMG mode can still be interesting.
>
> Signed-off-by: Andrea Merello <andrea.merello@xxxxxx>
Hi Andrea,
I think this is looking to be in a good state now.
There is some devm handling for clks now available that should avoid
the need to open code that here.
I've made that change whilst applying. Please take a look to make sure
I didn't mess it up!
Jonathan
> +
> +static void bno055_clk_disable(void *arg)
> +{
> + clk_disable_unprepare(arg);
> +}
> +
> +int bno055_probe(struct device *dev, struct regmap *regmap,
> + int xfer_burst_break_thr, bool sw_reset)
> +{
...
> + priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> + if (IS_ERR(priv->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(priv->reset_gpio), "Failed to get reset GPIO\n");
> +
> + priv->clk = devm_clk_get_optional(dev, "clk");
> + if (IS_ERR(priv->clk))
> + return dev_err_probe(dev, PTR_ERR(priv->clk), "Failed to get CLK\n");
> +
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + return ret;
> +
> + ret = devm_add_action_or_reset(dev, bno055_clk_disable, priv->clk);
> + if (ret)
> + return ret;#
devm_clk_get_optional_enabled() is now available and should work here I think?
> +
> + if (priv->reset_gpio) {
> + usleep_range(5000, 10000);
> + gpiod_set_value_cansleep(priv->reset_gpio, 1);
> + usleep_range(650000, 750000);
> + } else if (!sw_reset) {
> + dev_warn(dev, "No usable reset method; IMU may be unreliable\n");
> + }