From: Andrzej Hajda <a.hajda@xxxxxxxxxxx> The regulator bulk API doesn't guarantee an order in which regulators are enabled or disabled. Make sure the regulators are enabled sequentially, as specified in the sensor's datasheet. Additionally a 1ms delay is added after the reset GPIO (de)assertion. Signed-off-by: Andrzej Hajda <a.hajda@xxxxxxxxxxx> Signed-off-by: Sylwester Nawrocki <s.nawrocki@xxxxxxxxxxx> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx> --- drivers/media/i2c/m5mols/m5mols_core.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 0b899cb..a364781 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -740,6 +740,24 @@ static const struct v4l2_subdev_video_ops m5mols_video_ops = { .s_stream = m5mols_s_stream, }; +static int regulator_bulk_enable_sync(int num_consumers, + struct regulator_bulk_data *consumers) +{ + int ret = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(supplies); ++i) { + ret = regulator_enable(supplies[i].consumer); + if (ret < 0) { + for (; i >= 0; --i) + regulator_disable(supplies[i].consumer); + return ret; + } + } + + return 0; +} + static int m5mols_sensor_power(struct m5mols_info *info, bool enable) { struct v4l2_subdev *sd = &info->sd; @@ -757,13 +775,15 @@ static int m5mols_sensor_power(struct m5mols_info *info, bool enable) return ret; } - ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies); + ret = regulator_bulk_enable_sync(ARRAY_SIZE(supplies), + supplies); if (ret) { info->set_power(&client->dev, 0); return ret; } gpio_set_value(pdata->gpio_reset, !pdata->reset_polarity); + usleep_range(1000, 1000); info->power = 1; return ret; @@ -777,6 +797,7 @@ static int m5mols_sensor_power(struct m5mols_info *info, bool enable) info->set_power(&client->dev, 0); gpio_set_value(pdata->gpio_reset, pdata->reset_polarity); + usleep_range(1000, 1000); info->isp_ready = 0; info->power = 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html