Commit decea0a9 authored by Jai Luthra's avatar Jai Luthra Committed by Mauro Carvalho Chehab

media: ov5640: Fix soft reset sequence and timings

Move the register-based reset out of the init_setting[] and into the
powerup_sequence function. The sensor is power cycled and reset using
the gpio pins so the soft reset is not always necessary.

This also ensures that soft reset honors the timing sequence
from the datasheet [1].

[1] https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf

Fixes: 19a81c14 ("[media] add Omnivision OV5640 sensor driver")
Reported-by: default avatarNishanth Menon <nm@ti.com>
Suggested-by: default avatarJacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: default avatarJai Luthra <j-luthra@ti.com>
Reviewed-by: default avatarJacopo Mondi <jacopo.mondi@ideasonaboard.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 51c2bf13
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#define OV5640_REG_SYS_CTRL0 0x3008 #define OV5640_REG_SYS_CTRL0 0x3008
#define OV5640_REG_SYS_CTRL0_SW_PWDN 0x42 #define OV5640_REG_SYS_CTRL0_SW_PWDN 0x42
#define OV5640_REG_SYS_CTRL0_SW_PWUP 0x02 #define OV5640_REG_SYS_CTRL0_SW_PWUP 0x02
#define OV5640_REG_SYS_CTRL0_SW_RST 0x82
#define OV5640_REG_CHIP_ID 0x300a #define OV5640_REG_CHIP_ID 0x300a
#define OV5640_REG_IO_MIPI_CTRL00 0x300e #define OV5640_REG_IO_MIPI_CTRL00 0x300e
#define OV5640_REG_PAD_OUTPUT_ENABLE01 0x3017 #define OV5640_REG_PAD_OUTPUT_ENABLE01 0x3017
...@@ -543,7 +544,7 @@ static const struct v4l2_mbus_framefmt ov5640_dvp_default_fmt = { ...@@ -543,7 +544,7 @@ static const struct v4l2_mbus_framefmt ov5640_dvp_default_fmt = {
}; };
static const struct reg_value ov5640_init_setting[] = { static const struct reg_value ov5640_init_setting[] = {
{0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0}, {0x3103, 0x11, 0, 0},
{0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0}, {0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0},
{0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0},
{0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0},
...@@ -2440,6 +2441,7 @@ static void ov5640_reset(struct ov5640_dev *sensor) ...@@ -2440,6 +2441,7 @@ static void ov5640_reset(struct ov5640_dev *sensor)
if (!sensor->reset_gpio) if (!sensor->reset_gpio)
return; return;
if (sensor->pwdn_gpio) {
gpiod_set_value_cansleep(sensor->reset_gpio, 0); gpiod_set_value_cansleep(sensor->reset_gpio, 0);
/* camera power cycle */ /* camera power cycle */
...@@ -2452,7 +2454,19 @@ static void ov5640_reset(struct ov5640_dev *sensor) ...@@ -2452,7 +2454,19 @@ static void ov5640_reset(struct ov5640_dev *sensor)
usleep_range(1000, 2000); usleep_range(1000, 2000);
gpiod_set_value_cansleep(sensor->reset_gpio, 0); gpiod_set_value_cansleep(sensor->reset_gpio, 0);
} else {
/* software reset */
ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0,
OV5640_REG_SYS_CTRL0_SW_RST);
}
usleep_range(20000, 25000); usleep_range(20000, 25000);
/*
* software standby: allows registers programming;
* exit at restore_mode() for CSI, s_stream(1) for DVP
*/
ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0,
OV5640_REG_SYS_CTRL0_SW_PWDN);
} }
static int ov5640_set_power_on(struct ov5640_dev *sensor) static int ov5640_set_power_on(struct ov5640_dev *sensor)
......
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