Commit b1751ae6 authored by Lad Prabhakar's avatar Lad Prabhakar Committed by Mauro Carvalho Chehab

media: i2c: ov5640: Separate out mipi configuration from s_power

In preparation for adding DVP configuration in s_power callback
move mipi configuration into separate function
Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Tested-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 3b987d70
......@@ -2014,22 +2014,17 @@ static void ov5640_set_power_off(struct ov5640_dev *sensor)
clk_disable_unprepare(sensor->xclk);
}
static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
static int ov5640_set_power_mipi(struct ov5640_dev *sensor, bool on)
{
int ret = 0;
if (on) {
ret = ov5640_set_power_on(sensor);
if (ret)
return ret;
ret = ov5640_restore_mode(sensor);
if (ret)
goto power_off;
int ret;
/* We're done here for DVP bus, while CSI-2 needs setup. */
if (sensor->ep.bus_type != V4L2_MBUS_CSI2_DPHY)
if (!on) {
/* Reset MIPI bus settings to their default values. */
ov5640_write_reg(sensor, OV5640_REG_IO_MIPI_CTRL00, 0x58);
ov5640_write_reg(sensor, OV5640_REG_MIPI_CTRL00, 0x04);
ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT00, 0x00);
return 0;
}
/*
* Power up MIPI HS Tx and LS Rx; 2 data lanes mode
......@@ -2041,10 +2036,9 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
* [3] = 0 : Power up MIPI LS Rx
* [2] = 0 : MIPI interface disabled
*/
ret = ov5640_write_reg(sensor,
OV5640_REG_IO_MIPI_CTRL00, 0x40);
ret = ov5640_write_reg(sensor, OV5640_REG_IO_MIPI_CTRL00, 0x40);
if (ret)
goto power_off;
return ret;
/*
* Gate clock and set LP11 in 'no packets mode' (idle)
......@@ -2053,10 +2047,9 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
* [5] = 1 : Gate clock when 'no packets'
* [2] = 1 : MIPI bus in LP11 when 'no packets'
*/
ret = ov5640_write_reg(sensor,
OV5640_REG_MIPI_CTRL00, 0x24);
ret = ov5640_write_reg(sensor, OV5640_REG_MIPI_CTRL00, 0x24);
if (ret)
goto power_off;
return ret;
/*
* Set data lanes and clock in LP11 when 'sleeping'
......@@ -2066,27 +2059,38 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
* [5] = 1 : MIPI data lane 1 in LP11 when 'sleeping'
* [4] = 1 : MIPI clock lane in LP11 when 'sleeping'
*/
ret = ov5640_write_reg(sensor,
OV5640_REG_PAD_OUTPUT00, 0x70);
ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT00, 0x70);
if (ret)
goto power_off;
return ret;
/* Give lanes some time to coax into LP11 state. */
usleep_range(500, 1000);
} else {
return 0;
}
static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
{
int ret = 0;
if (on) {
ret = ov5640_set_power_on(sensor);
if (ret)
return ret;
ret = ov5640_restore_mode(sensor);
if (ret)
goto power_off;
}
if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
/* Reset MIPI bus settings to their default values. */
ov5640_write_reg(sensor,
OV5640_REG_IO_MIPI_CTRL00, 0x58);
ov5640_write_reg(sensor,
OV5640_REG_MIPI_CTRL00, 0x04);
ov5640_write_reg(sensor,
OV5640_REG_PAD_OUTPUT00, 0x00);
ret = ov5640_set_power_mipi(sensor, on);
if (ret)
goto power_off;
}
if (!on)
ov5640_set_power_off(sensor);
}
return 0;
......
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