Re: [PATCH v2 4/4] iio: imu: inv_mpu6050: Add SPI support for MPU6000

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Adriana,

On Thu, Feb 4, 2016 at 7:20 AM, Adriana Reus <adriana.reus@xxxxxxxxx> wrote:
> The only difference between the MPU6000 and the
> MPU6050 is that the first also supports SPI.
> Add SPI driver for this chip.
>
> Signed-off-by: Adriana Reus <adriana.reus@xxxxxxxxx>
> ---

[ ... ]

> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> new file mode 100644
> index 0000000..6a1de35
> --- /dev/null
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> @@ -0,0 +1,87 @@
> +/*
> +* Copyright (C) 2015 Intel Corporation Inc.
> +*
> +* This software is licensed under the terms of the GNU General Public
> +* License version 2, as published by the Free Software Foundation, and
> +* may be copied, distributed, and modified under those terms.
> +*
> +* This program is distributed in the hope that it will be useful,
> +* but WITHOUT ANY WARRANTY; without even the implied warranty of
> +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +* GNU General Public License for more details.
> +*/
> +#include <linux/module.h>
> +#include <linux/acpi.h>
> +#include <linux/spi/spi.h>
> +#include <linux/regmap.h>
> +#include <linux/iio/iio.h>
> +#include "inv_mpu_iio.h"
> +
> +static const struct regmap_config inv_mpu_regmap_config = {
> +       .reg_bits = 8,
> +       .val_bits = 8,
> +};
> +
> +static int inv_mpu_probe(struct spi_device *spi)
> +{
> +       struct regmap *regmap;
> +       const struct spi_device_id *id = spi_get_device_id(spi);
> +       const char *name = id ? id->name : NULL;
> +       int result;
> +
> +       regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config);
> +       if (IS_ERR(regmap)) {
> +               dev_err(&spi->dev, "Failed to register spi regmap %d\n",
> +                       (int)PTR_ERR(regmap));
> +               return PTR_ERR(regmap);
> +       }
> +
> +       result = regmap_write(regmap, INV_MPU6050_REG_USER_CTRL,
> +                             INV_MPU6050_BIT_I2C_IF_DIS);
> +       if (result) {
> +               dev_err(&spi->dev, "Failed to disable I2C interface\n");
> +               return result;
> +       }
> +
> +       return inv_mpu_core_probe(regmap, spi->irq, name);

Here we reset the chip making superfluous the I2C disable above. See
note on section "9.1 I2C and SPI (MPU-6000 only) Serial Interfaces":

"To prevent switching into I 2 C mode when using SPI (MPU-6000), the I
2 C interface should be disabled by
setting the I2C_IF_DIS configuration bit. Setting this bit should be
performed immediately after waiting for the
time specified by the “Start-Up Time for Register Read/Write” in Section 6.3."

Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux