Commit acdff8e1 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: imx: imx7_mipi_csis: Move PHY control to dedicated functions

Move the PHY regulator and reset handling to dedicated functions. This
groups all related code together, and prepares for i.MX8 support that
doesn't require control of the PHY regulator and reset.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Tested-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 88fc8138
......@@ -457,25 +457,6 @@ static void mipi_csis_sw_reset(struct csi_state *state)
usleep_range(10, 20);
}
static int mipi_csis_phy_init(struct csi_state *state)
{
state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
if (IS_ERR(state->mipi_phy_regulator))
return PTR_ERR(state->mipi_phy_regulator);
return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
1000000);
}
static void mipi_csis_phy_reset(struct csi_state *state)
{
reset_control_assert(state->mrst);
msleep(20);
reset_control_deassert(state->mrst);
}
static void mipi_csis_system_enable(struct csi_state *state, int on)
{
u32 val, mask;
......@@ -679,6 +660,42 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}
/* -----------------------------------------------------------------------------
* PHY regulator and reset
*/
static int mipi_csis_phy_enable(struct csi_state *state)
{
return regulator_enable(state->mipi_phy_regulator);
}
static int mipi_csis_phy_disable(struct csi_state *state)
{
return regulator_disable(state->mipi_phy_regulator);
}
static void mipi_csis_phy_reset(struct csi_state *state)
{
reset_control_assert(state->mrst);
msleep(20);
reset_control_deassert(state->mrst);
}
static int mipi_csis_phy_init(struct csi_state *state)
{
/* Get MIPI PHY reset and regulator. */
state->mrst = devm_reset_control_get_exclusive(state->dev, NULL);
if (IS_ERR(state->mrst))
return PTR_ERR(state->mrst);
state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
if (IS_ERR(state->mipi_phy_regulator))
return PTR_ERR(state->mipi_phy_regulator);
return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
1000000);
}
/* -----------------------------------------------------------------------------
* Debug
*/
......@@ -1177,7 +1194,7 @@ static int mipi_csis_pm_suspend(struct device *dev, bool runtime)
mutex_lock(&state->lock);
if (state->state & ST_POWERED) {
mipi_csis_stop_stream(state);
ret = regulator_disable(state->mipi_phy_regulator);
ret = mipi_csis_phy_disable(state);
if (ret)
goto unlock;
mipi_csis_clk_disable(state);
......@@ -1203,7 +1220,7 @@ static int mipi_csis_pm_resume(struct device *dev, bool runtime)
goto unlock;
if (!(state->state & ST_POWERED)) {
ret = regulator_enable(state->mipi_phy_regulator);
ret = mipi_csis_phy_enable(state);
if (ret)
goto unlock;
......@@ -1287,11 +1304,6 @@ static int mipi_csis_parse_dt(struct csi_state *state)
&state->clk_frequency))
state->clk_frequency = DEFAULT_SCLK_CSIS_FREQ;
/* Get MIPI PHY resets */
state->mrst = devm_reset_control_get_exclusive(state->dev, NULL);
if (IS_ERR(state->mrst))
return PTR_ERR(state->mrst);
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