[COMMON] media: scaler: add reset sequence for scaler 5.0.1
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Mon, 21 Aug 2017 02:33:25 +0000 (11:33 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:17 +0000 (20:22 +0300)
Change-Id: Iedfb4b3a0ac1b544ad62e2da062c4cab547f00b1
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
drivers/media/platform/exynos/scaler/scaler-core.c
drivers/media/platform/exynos/scaler/scaler-regs.h

index eed4b15850c5ad804763257ea51c04a26afd7d2e..8c76f5fab1e95a7f2b9044c5a61ed2cc0805d805 100644 (file)
@@ -330,7 +330,7 @@ static const struct sc_fmt sc_formats[] = {
 
 /* must specify in revers order of SCALER_VERSION(xyz) */
 static const u32 sc_version_table[][2] = {
-       { 0x02000100, SCALER_VERSION(5, 0, 0) }, /* SC_POLY */
+       { 0x02000100, SCALER_VERSION(5, 0, 1) }, /* SC_POLY */
        { 0x02000000, SCALER_VERSION(5, 0, 0) },
        { 0x80060007, SCALER_VERSION(4, 2, 0) }, /* SC_BI */
        { 0x0100000f, SCALER_VERSION(4, 0, 1) }, /* SC_POLY */
@@ -350,6 +350,30 @@ static const u32 sc_version_table[][2] = {
 
 static const struct sc_variant sc_variant[] = {
        {
+               .limit_input = {
+                       .min_w          = 16,
+                       .min_h          = 16,
+                       .max_w          = 8192,
+                       .max_h          = 8192,
+               },
+               .limit_output = {
+                       .min_w          = 4,
+                       .min_h          = 4,
+                       .max_w          = 8192,
+                       .max_h          = 8192,
+               },
+               .version                = SCALER_VERSION(5, 0, 1),
+               .sc_up_max              = SCALE_RATIO_CONST(1, 8),
+               .sc_down_min            = SCALE_RATIO_CONST(4, 1),
+               .sc_up_swmax            = SCALE_RATIO_CONST(1, 64),
+               .sc_down_swmin          = SCALE_RATIO_CONST(16, 1),
+               .blending               = 0,
+               .prescale               = 0,
+               .ratio_20bit            = 1,
+               .initphase              = 1,
+               .pixfmt_10bit           = 1,
+               .extra_buf              = 1,
+       }, {
                .limit_input = {
                        .min_w          = 16,
                        .min_h          = 16,
@@ -2610,6 +2634,7 @@ static int sc_run_next_job(struct sc_dev *sc)
        d_frame = &ctx->d_frame;
 
        sc_hwset_init(sc);
+       sc_hwset_clk_request(sc, true);
 
        if (ctx->i_frame) {
                set_bit(CTX_INT_FRAME, &ctx->flags);
@@ -2780,6 +2805,8 @@ static irqreturn_t sc_irq_handler(int irq, void *priv)
        if (!SCALER_INT_OK(irq_status))
                sc_hwset_soft_reset(sc);
 
+       sc_hwset_clk_request(sc, false);
+
        clear_bit(DEV_RUN, &sc->state);
        clear_bit(CTX_RUN, &ctx->flags);
 
index daf6faa261df5278f1f581abf23eafa39a5128f0..c305a6dc006026b56a04b06d4b60bad470273c97 100644 (file)
@@ -29,6 +29,8 @@
 #define SCALER_CFG_BURST_WR            (1 << 8)
 #define SCALER_CFG_BURST_RD            (1 << 7)
 #define SCALER_CFG_CSC_Y_OFFSET_DST    (1 << 9)
+#define SCALER_CFG_STOP_REQ            (1 << 3)
+#define SCALER_CFG_RESET_OKAY          (1 << 2)
 #define SCALER_CFG_SOFT_RST            (1 << 1)
 #define SCALER_CFG_START_CMD           (1 << 0)
 
 
 #define SCALER_TIMEOUT_CTRL            0x2c0
 #define SCALER_TIMEOUT_CNT             0x2c4
+#define SCALER_CLK_REQ                 0x2cc
 
 #define SCALER_SRC_YH_INIT_PHASE       0x2d0
 #define SCALER_SRC_YV_INIT_PHASE       0x2d4
 #define SCALER_VAL_SRC_POS(l, t) (((l) & 0x3FFF) << 18) | (((t) & 0x3FFF) << 2)
 #define SCALER_VAL_DST_POS(l, t) (((l) & 0x3FFF) << 16) | ((t) & 0x3FFF)
 
+static inline void sc_hwset_clk_request(struct sc_dev *sc, bool enable)
+{
+       if (sc->version == SCALER_VERSION(5, 0, 1))
+               __raw_writel(enable ? 1 : 0, sc->regs + SCALER_CLK_REQ);
+}
+
 static inline void sc_hwset_src_pos(struct sc_dev *sc, __s32 left, __s32 top,
                                unsigned int chshift, unsigned int cvshift)
 {
@@ -273,6 +282,19 @@ static inline void sc_hwset_init(struct sc_dev *sc)
 {
        unsigned long cfg;
 
+       if (sc->version == SCALER_VERSION(5, 0, 1)) {
+               int cnt = 1000;
+
+               __raw_writel(SCALER_CFG_STOP_REQ, sc->regs + SCALER_CFG);
+
+               while (cnt-- > 0)
+                       if (__raw_readl(sc->regs + SCALER_CFG)
+                                               & SCALER_CFG_RESET_OKAY)
+                               break;
+
+               WARN_ON(cnt <= 0);
+       }
+
 #ifdef SC_NO_SOFTRST
        cfg = (SCALER_CFG_CSC_Y_OFFSET_SRC | SCALER_CFG_CSC_Y_OFFSET_DST);
 #else