drivers: iio: imu: enabled regulator for bmi160 sensor
BMI160 will not power on if regulator does not enabled from probe Change-Id: I134687a7923416dd87c8753e980337f68f6862c4 Signed-off-by: puneet <puneet@codeaurora.org>
This commit is contained in:
parent
f1587d8660
commit
6e5c601011
2 changed files with 44 additions and 1 deletions
|
@ -569,7 +569,7 @@ static int bmi_check_chip_id(struct bmi_client_data *client_data)
|
|||
dev_notice(client_data->dev,
|
||||
"Bosch Sensortec Device detected, "
|
||||
"HW IC name: %s\n", sensor_type_map[i].sensor_name);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (i < bmi_sensor_cnt)
|
||||
|
@ -586,6 +586,7 @@ static int bmi_check_chip_id(struct bmi_client_data *client_data)
|
|||
bmi_delay(1);
|
||||
}
|
||||
}
|
||||
err = -ENODEV;
|
||||
return err;
|
||||
|
||||
}
|
||||
|
|
|
@ -20,12 +20,19 @@
|
|||
#include <linux/i2c.h>
|
||||
#include <linux/delay.h>
|
||||
#include "bmi160_driver.h"
|
||||
#include <linux/regulator/consumer.h>
|
||||
|
||||
/*! @defgroup bmi160_i2c_src
|
||||
* @brief bmi160 i2c driver module
|
||||
@{*/
|
||||
|
||||
static struct i2c_client *bmi_client;
|
||||
|
||||
struct BMI160Supply {
|
||||
struct regulator *vdd_reg;
|
||||
struct regulator *vio_reg;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief define i2c wirte function
|
||||
*
|
||||
|
@ -256,9 +263,44 @@ static int bmi_i2c_probe(struct i2c_client *client,
|
|||
{
|
||||
int err = 0;
|
||||
struct bmi_client_data *client_data = NULL;
|
||||
struct BMI160Supply bmi160Supply;
|
||||
|
||||
dev_info(&client->dev, "BMI160 i2c function probe entrance");
|
||||
|
||||
dev_info(&client->dev, "bmi_i2c_probe regulator ON\n");
|
||||
|
||||
bmi160Supply.vdd_reg = devm_regulator_get(&client->dev, "vdd");
|
||||
if (IS_ERR(bmi160Supply.vdd_reg)) {
|
||||
if (PTR_ERR(bmi160Supply.vdd_reg) != -EPROBE_DEFER)
|
||||
dev_err(&client->dev, "bmi160Supply->vdd_reg EPROBE_DEFER Unable to get regulator\n");
|
||||
err = PTR_ERR(bmi160Supply.vdd_reg);
|
||||
goto exit_err_clean;
|
||||
}
|
||||
|
||||
dev_err(&client->dev, "bmi_i2c_probe before regulator_enable(VDD)\n");
|
||||
if (regulator_enable(bmi160Supply.vdd_reg)) {
|
||||
dev_err(&client->dev, "bmi160Supply->vdd_reg error!regulator cannot enable");
|
||||
err = -EIO;
|
||||
goto exit_err_clean;
|
||||
}
|
||||
dev_err(&client->dev, "bmi_i2c_probe after regulator_enable(VDD)\n");
|
||||
|
||||
bmi160Supply.vio_reg = devm_regulator_get(&client->dev, "vio");
|
||||
if (IS_ERR(bmi160Supply.vio_reg)) {
|
||||
if (PTR_ERR(bmi160Supply.vio_reg) != -EPROBE_DEFER)
|
||||
dev_err(&client->dev, "bmi160Supply->vio_reg EPROBE_DEFER Unable to get regulator\n");
|
||||
err = PTR_ERR(bmi160Supply.vio_reg);
|
||||
goto exit_err_clean;
|
||||
}
|
||||
|
||||
dev_err(&client->dev, "bmi_i2c_probe before regulator_enable(VIO)\n");
|
||||
if (regulator_enable(bmi160Supply.vio_reg)) {
|
||||
dev_err(&client->dev, "bmi160Supply->vio_reg error!regulator cannot enable");
|
||||
err = -EIO;
|
||||
goto exit_err_clean;
|
||||
}
|
||||
dev_err(&client->dev, "bmi_i2c_probe after regulator_enable(VIO)\n");
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
||||
dev_err(&client->dev, "i2c_check_functionality error!");
|
||||
err = -EIO;
|
||||
|
|
Loading…
Add table
Reference in a new issue