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) ...@@ -2014,22 +2014,17 @@ static void ov5640_set_power_off(struct ov5640_dev *sensor)
clk_disable_unprepare(sensor->xclk); 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; int ret;
if (on) {
ret = ov5640_set_power_on(sensor);
if (ret)
return ret;
ret = ov5640_restore_mode(sensor);
if (ret)
goto power_off;
/* We're done here for DVP bus, while CSI-2 needs setup. */ if (!on) {
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);
return 0; return 0;
}
/* /*
* Power up MIPI HS Tx and LS Rx; 2 data lanes mode * 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) ...@@ -2041,10 +2036,9 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
* [3] = 0 : Power up MIPI LS Rx * [3] = 0 : Power up MIPI LS Rx
* [2] = 0 : MIPI interface disabled * [2] = 0 : MIPI interface disabled
*/ */
ret = ov5640_write_reg(sensor, ret = ov5640_write_reg(sensor, OV5640_REG_IO_MIPI_CTRL00, 0x40);
OV5640_REG_IO_MIPI_CTRL00, 0x40);
if (ret) if (ret)
goto power_off; return ret;
/* /*
* Gate clock and set LP11 in 'no packets mode' (idle) * 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) ...@@ -2053,10 +2047,9 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
* [5] = 1 : Gate clock when 'no packets' * [5] = 1 : Gate clock when 'no packets'
* [2] = 1 : MIPI bus in LP11 when 'no packets' * [2] = 1 : MIPI bus in LP11 when 'no packets'
*/ */
ret = ov5640_write_reg(sensor, ret = ov5640_write_reg(sensor, OV5640_REG_MIPI_CTRL00, 0x24);
OV5640_REG_MIPI_CTRL00, 0x24);
if (ret) if (ret)
goto power_off; return ret;
/* /*
* Set data lanes and clock in LP11 when 'sleeping' * Set data lanes and clock in LP11 when 'sleeping'
...@@ -2066,27 +2059,38 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on) ...@@ -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' * [5] = 1 : MIPI data lane 1 in LP11 when 'sleeping'
* [4] = 1 : MIPI clock lane in LP11 when 'sleeping' * [4] = 1 : MIPI clock lane in LP11 when 'sleeping'
*/ */
ret = ov5640_write_reg(sensor, ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT00, 0x70);
OV5640_REG_PAD_OUTPUT00, 0x70);
if (ret) if (ret)
goto power_off; return ret;
/* Give lanes some time to coax into LP11 state. */ /* Give lanes some time to coax into LP11 state. */
usleep_range(500, 1000); 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) { if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
/* Reset MIPI bus settings to their default values. */ ret = ov5640_set_power_mipi(sensor, on);
ov5640_write_reg(sensor, if (ret)
OV5640_REG_IO_MIPI_CTRL00, 0x58); goto power_off;
ov5640_write_reg(sensor,
OV5640_REG_MIPI_CTRL00, 0x04);
ov5640_write_reg(sensor,
OV5640_REG_PAD_OUTPUT00, 0x00);
} }
if (!on)
ov5640_set_power_off(sensor); ov5640_set_power_off(sensor);
}
return 0; 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