Commit c5086f13 authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Mauro Carvalho Chehab

[media] s5p-mfc: Use clock gating only on MFC v5 hardware

Newer MFC hardware have internal clock gating feature, so additional
software-triggered clock gating sometimes causes misbehavior of the MFC
firmware and results in freeze or crash. This patch changes the driver
to use software-triggered clock gating only when working with v5 MFC
hardware, where it has been proven to work properly.
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 5d1ec731
......@@ -1442,6 +1442,7 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
.buf_size = &buf_size_v5,
.buf_align = &mfc_buf_align_v5,
.fw_name[0] = "s5p-mfc.fw",
.use_clock_gating = true,
};
static struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
......
......@@ -199,6 +199,7 @@ struct s5p_mfc_buf {
struct s5p_mfc_pm {
struct clk *clock;
struct clk *clock_gate;
bool use_clock_gating;
atomic_t power;
struct device *device;
};
......@@ -235,6 +236,7 @@ struct s5p_mfc_variant {
struct s5p_mfc_buf_size *buf_size;
struct s5p_mfc_buf_align *buf_align;
char *fw_name[MFC_FW_MAX_VERSIONS];
bool use_clock_gating;
};
/**
......
......@@ -37,6 +37,7 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
pm = &dev->pm;
p_dev = dev;
pm->use_clock_gating = dev->variant->use_clock_gating;
pm->clock_gate = clk_get(&dev->plat_dev->dev, MFC_GATE_CLK_NAME);
if (IS_ERR(pm->clock_gate)) {
mfc_err("Failed to get clock-gating control\n");
......@@ -108,6 +109,8 @@ int s5p_mfc_clock_on(void)
atomic_inc(&clk_ref);
mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
#endif
if (!pm->use_clock_gating)
return 0;
if (!IS_ERR_OR_NULL(pm->clock_gate))
ret = clk_enable(pm->clock_gate);
return ret;
......@@ -119,22 +122,32 @@ void s5p_mfc_clock_off(void)
atomic_dec(&clk_ref);
mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
#endif
if (!pm->use_clock_gating)
return;
if (!IS_ERR_OR_NULL(pm->clock_gate))
clk_disable(pm->clock_gate);
}
int s5p_mfc_power_on(void)
{
int ret = 0;
#ifdef CONFIG_PM
return pm_runtime_get_sync(pm->device);
ret = pm_runtime_get_sync(pm->device);
if (ret)
return ret;
#else
atomic_set(&pm->power, 1);
return 0;
#endif
if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate))
ret = clk_enable(pm->clock_gate);
return ret;
}
int s5p_mfc_power_off(void)
{
if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate))
clk_disable(pm->clock_gate);
#ifdef CONFIG_PM
return pm_runtime_put_sync(pm->device);
#else
......
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