aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/s5p-mfc
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2016-11-10 08:31:23 -0200
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-11-16 16:40:13 -0200
commitc5086f130a77009dd1dcacf0fbc2ca83f09ebca4 (patch)
treef05eb4c8eeef88783049eb2db6395a25753b6025 /drivers/media/platform/s5p-mfc
parent[media] s5p-mfc: Skip incomplete frame (diff)
downloadlinux-dev-c5086f130a77009dd1dcacf0fbc2ca83f09ebca4.tar.xz
linux-dev-c5086f130a77009dd1dcacf0fbc2ca83f09ebca4.zip
[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: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform/s5p-mfc')
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_pm.c17
3 files changed, 18 insertions, 2 deletions
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 9f73ba1cc9c3..ba6e2c5bca05 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -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 = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 46b99f28cbd7..c068ee3ece6e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -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;
};
/**
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 930dc2dddae6..b5806ab7ac31 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -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