From 0d8657dd3056063fb115946b10157477b5c70451 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 20 Nov 2023 09:09:45 +0000
Subject: [PATCH] enable lvds 1280x800
---
kernel/drivers/video/rockchip/mpp/mpp_vdpu2.c | 84 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 81 insertions(+), 3 deletions(-)
diff --git a/kernel/drivers/video/rockchip/mpp/mpp_vdpu2.c b/kernel/drivers/video/rockchip/mpp/mpp_vdpu2.c
index f697033..1e58094 100644
--- a/kernel/drivers/video/rockchip/mpp/mpp_vdpu2.c
+++ b/kernel/drivers/video/rockchip/mpp/mpp_vdpu2.c
@@ -20,6 +20,8 @@
#include <linux/uaccess.h>
#include <linux/regmap.h>
#include <linux/proc_fs.h>
+#include <linux/mfd/syscon.h>
+#include <linux/rockchip/cpu.h>
#include <soc/rockchip/pm_domains.h>
#include "mpp_debug.h"
@@ -69,6 +71,9 @@
#define VDPU2_DEC_CLOCK_GATE_EN BIT(4)
#define VDPU2_DEC_START BIT(0)
+#define VDPU2_REG_SOFT_RESET 0x0e8
+#define VDPU2_REG_SOFT_RESET_INDEX (58)
+
#define VDPU2_REG_DIR_MV_BASE 0x0f8
#define VDPU2_REG_DIR_MV_BASE_INDEX (62)
@@ -108,6 +113,7 @@
#endif
struct reset_control *rst_a;
struct reset_control *rst_h;
+ struct regmap *grf;
};
static struct mpp_hw_info vdpu_v2_hw_info = {
@@ -340,6 +346,7 @@
u32 i;
u32 reg_en;
struct vdpu_task *task = to_vdpu_task(mpp_task);
+ u32 timing_en = mpp->srv->timing_en;
mpp_debug_enter();
@@ -354,12 +361,21 @@
mpp_write_req(mpp, task->reg, s, e, reg_en);
}
+
+ /* flush tlb before starting hardware */
+ mpp_iommu_flush_tlb(mpp->iommu_info);
+
/* init current task */
mpp->cur_task = mpp_task;
+
+ mpp_task_run_begin(mpp_task, timing_en, MPP_WORK_TIMEOUT_DELAY);
+
/* Flush the registers */
wmb();
mpp_write(mpp, VDPU2_REG_DEC_EN,
task->reg[reg_en] | VDPU2_DEC_START);
+
+ mpp_task_run_end(mpp_task, timing_en);
mpp_debug_leave();
@@ -456,6 +472,10 @@
dec->procfs = NULL;
return -EIO;
}
+
+ /* for common mpp_dev options */
+ mpp_procfs_create_common(dec->procfs, mpp);
+
mpp_procfs_create_u32("aclk", 0644,
dec->procfs, &dec->aclk_info.debug_rate_hz);
mpp_procfs_create_u32("session_buffers", 0644,
@@ -596,21 +616,38 @@
return IRQ_HANDLED;
}
+static int vdpu_soft_reset(struct mpp_dev *mpp)
+{
+ u32 val;
+
+ mpp_write(mpp, VDPU2_REG_SOFT_RESET, 1);
+ udelay(2);
+ val = mpp_read(mpp, VDPU2_REG_SOFT_RESET);
+
+ return val;
+}
+
static int vdpu_reset(struct mpp_dev *mpp)
{
struct vdpu_dev *dec = to_vdpu_dev(mpp);
+ u32 ret = 0;
mpp_write(mpp, VDPU2_REG_DEC_EN, 0);
mpp_write(mpp, VDPU2_REG_DEC_INT, 0);
- if (dec->rst_a && dec->rst_h) {
+
+ /* soft reset first */
+ ret = vdpu_soft_reset(mpp);
+ if (ret && dec->rst_a && dec->rst_h) {
/* Don't skip this or iommu won't work after reset */
- rockchip_pmu_idle_request(mpp->dev, true);
+ mpp_debug(DEBUG_RESET, "reset in\n");
+ mpp_pmu_idle_request(mpp, true);
mpp_safe_reset(dec->rst_a);
mpp_safe_reset(dec->rst_h);
udelay(5);
mpp_safe_unreset(dec->rst_a);
mpp_safe_unreset(dec->rst_h);
- rockchip_pmu_idle_request(mpp->dev, false);
+ mpp_pmu_idle_request(mpp, false);
+ mpp_debug(DEBUG_RESET, "reset out\n");
}
return 0;
@@ -758,12 +795,53 @@
dev_err(dev, "wait total running time out\n");
}
+static int vdpu_runtime_suspend(struct device *dev)
+{
+ struct mpp_dev *mpp = dev_get_drvdata(dev);
+ struct mpp_grf_info *info = mpp->grf_info;
+ struct mpp_taskqueue *queue = mpp->queue;
+
+ if (cpu_is_rk3528() && info && info->mem_offset) {
+ mutex_lock(&queue->ref_lock);
+ if (!atomic_dec_if_positive(&queue->runtime_cnt)) {
+ regmap_write(info->grf, info->mem_offset,
+ info->val_mem_off);
+ }
+ mutex_unlock(&queue->ref_lock);
+ }
+
+ return 0;
+}
+
+static int vdpu_runtime_resume(struct device *dev)
+{
+ struct mpp_dev *mpp = dev_get_drvdata(dev);
+ struct mpp_grf_info *info = mpp->grf_info;
+ struct mpp_taskqueue *queue = mpp->queue;
+
+ if (cpu_is_rk3528() && info && info->mem_offset) {
+ mutex_lock(&queue->ref_lock);
+ regmap_write(info->grf, info->mem_offset,
+ info->val_mem_on);
+ atomic_inc(&queue->runtime_cnt);
+ mutex_unlock(&queue->ref_lock);
+ }
+
+ return 0;
+}
+
+static const struct dev_pm_ops vdpu_pm_ops = {
+ .runtime_suspend = vdpu_runtime_suspend,
+ .runtime_resume = vdpu_runtime_resume,
+};
+
struct platform_driver rockchip_vdpu2_driver = {
.probe = vdpu_probe,
.remove = vdpu_remove,
.shutdown = vdpu_shutdown,
.driver = {
.name = VDPU2_DRIVER_NAME,
+ .pm = &vdpu_pm_ops,
.of_match_table = of_match_ptr(mpp_vdpu2_dt_match),
},
};
--
Gitblit v1.6.2