Commit b8ad1ec1 authored by Jonathan Marek's avatar Jonathan Marek Committed by Craig Tatlor

iio: imu: mpu6050: support regulator api and support 6515 variant

parent e92835ae
......@@ -111,6 +111,13 @@ static const struct inv_mpu6050_hw hw_info[] = {
.reg = &reg_set_6050,
.config = &chip_config_6050,
},
{
.whoami = INV_MPU6515_WHOAMI_VALUE,
.name = "MPU6515",
.reg = &reg_set_6500,
.config = &chip_config_6050,
},
{
.whoami = INV_MPU9150_WHOAMI_VALUE,
.name = "MPU9150",
......
......@@ -18,6 +18,7 @@
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
#include "inv_mpu_iio.h"
static const struct regmap_config inv_mpu_regmap_config = {
......@@ -90,6 +91,7 @@ static int inv_mpu_probe(struct i2c_client *client,
int result;
enum inv_devices chip_type;
struct regmap *regmap;
struct regulator *supply;
const char *name;
if (!i2c_check_functionality(client->adapter,
......@@ -119,6 +121,23 @@ static int inv_mpu_probe(struct i2c_client *client,
return PTR_ERR(regmap);
}
supply = devm_regulator_get(&client->dev, "vddio");
if (IS_ERR(supply)) {
if (PTR_ERR(supply) == -EPROBE_DEFER)
return PTR_ERR(supply);
/* Supply isn't always necessary */
supply = NULL;
}
if (supply) {
result = regulator_enable(supply);
if (result)
return result;
usleep_range(20000, 100000);
}
result = inv_mpu_core_probe(regmap, client->irq, name,
NULL, chip_type);
if (result < 0)
......@@ -174,6 +193,7 @@ static int inv_mpu_remove(struct i2c_client *client)
static const struct i2c_device_id inv_mpu_id[] = {
{"mpu6050", INV_MPU6050},
{"mpu6500", INV_MPU6500},
{"mpu6515", INV_MPU6515},
{"mpu9150", INV_MPU9150},
{"mpu9250", INV_MPU9250},
{"mpu9255", INV_MPU9255},
......@@ -192,6 +212,10 @@ static const struct of_device_id inv_of_match[] = {
.compatible = "invensense,mpu6500",
.data = (void *)INV_MPU6500
},
{
.compatible = "invensense,mpu6515",
.data = (void *)INV_MPU6515
},
{
.compatible = "invensense,mpu9150",
.data = (void *)INV_MPU9150
......
......@@ -77,6 +77,7 @@ enum inv_devices {
INV_MPU9150,
INV_MPU9250,
INV_MPU9255,
INV_MPU6515,
INV_ICM20608,
INV_NUM_PARTS
};
......@@ -247,6 +248,7 @@ struct inv_mpu6050_state {
#define INV_MPU9150_WHOAMI_VALUE 0x68
#define INV_MPU9250_WHOAMI_VALUE 0x71
#define INV_MPU9255_WHOAMI_VALUE 0x73
#define INV_MPU6515_WHOAMI_VALUE 0x74
#define INV_ICM20608_WHOAMI_VALUE 0xAF
/* scan element definition */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment