From 6a3c66dbd1e4d4108ecd004cb147f63a5a785ba0 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sun, 26 Jan 2020 00:28:10 +0100 Subject: [PATCH 160/478] media: ov5640: Don't powerup the sensor during driver probe It causes autofocus clicking during boot on some devices, and it's enough to do it when turning on the sensor power by media pipeline via s_power callback, later on. Signed-off-by: Ondrej Jirman --- drivers/media/i2c/ov5640.c | 40 ++++++++------------------------------ 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 8a53c0c36864..75f71e6aaf84 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -1932,6 +1932,7 @@ static void ov5640_reset(struct ov5640_dev *sensor) static int ov5640_set_power_on(struct ov5640_dev *sensor) { struct i2c_client *client = sensor->i2c_client; + u16 chip_id; int ret; ret = clk_prepare_enable(sensor->xclk); @@ -1956,6 +1957,13 @@ static int ov5640_set_power_on(struct ov5640_dev *sensor) if (ret) goto power_off; + ret = ov5640_read_reg16(sensor, OV5640_REG_CHIP_ID, &chip_id); + if (ret) { + dev_err(&client->dev, "%s: failed to read chip identifier\n", + __func__); + goto power_off; + } + return 0; power_off: @@ -3039,34 +3047,6 @@ static int ov5640_get_regulators(struct ov5640_dev *sensor) sensor->supplies); } -static int ov5640_check_chip_id(struct ov5640_dev *sensor) -{ - struct i2c_client *client = sensor->i2c_client; - int ret = 0; - u16 chip_id; - - ret = ov5640_set_power_on(sensor); - if (ret) - return ret; - - ret = ov5640_read_reg16(sensor, OV5640_REG_CHIP_ID, &chip_id); - if (ret) { - dev_err(&client->dev, "%s: failed to read chip identifier\n", - __func__); - goto power_off; - } - - if (chip_id != 0x5640) { - dev_err(&client->dev, "%s: wrong chip identifier, expected 0x5640, got 0x%x\n", - __func__, chip_id); - ret = -ENXIO; - } - -power_off: - ov5640_set_power_off(sensor); - return ret; -} - static int ov5640_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -3184,10 +3164,6 @@ static int ov5640_probe(struct i2c_client *client) mutex_init(&sensor->lock); - ret = ov5640_check_chip_id(sensor); - if (ret) - goto entity_cleanup; - ret = ov5640_init_controls(sensor); if (ret) goto entity_cleanup; -- 2.35.3