hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/video/rockchip/mpp/mpp_rkvenc.c
....@@ -28,6 +28,7 @@
2828 #include <linux/nospec.h>
2929 #include <linux/workqueue.h>
3030 #include <soc/rockchip/pm_domains.h>
31
+#include <soc/rockchip/rockchip_iommu.h>
3132 #include <soc/rockchip/rockchip_ipa.h>
3233 #include <soc/rockchip/rockchip_opp_select.h>
3334 #include <soc/rockchip/rockchip_system_monitor.h>
....@@ -439,6 +440,7 @@
439440 int i;
440441 struct mpp_request *req;
441442 u32 reg_en = mpp_task->hw_info->reg_en;
443
+ u32 timing_en = mpp->srv->timing_en;
442444
443445 /*
444446 * Tips: ensure osd plt clock is 0 before setting register,
....@@ -466,11 +468,20 @@
466468 rkvenc_write_req_backward(mpp, task->reg, s, e, reg_en);
467469 }
468470 }
471
+
472
+ /* flush tlb before starting hardware */
473
+ mpp_iommu_flush_tlb(mpp->iommu_info);
474
+
469475 /* init current task */
470476 mpp->cur_task = mpp_task;
477
+
478
+ mpp_task_run_begin(mpp_task, timing_en, MPP_WORK_TIMEOUT_DELAY);
479
+
471480 /* Flush the register before the start the device */
472481 wmb();
473482 mpp_write(mpp, RKVENC_ENC_START_BASE, task->reg[reg_en]);
483
+
484
+ mpp_task_run_end(mpp_task, timing_en);
474485 } break;
475486 case RKVENC_MODE_LINKTABLE_FIX:
476487 case RKVENC_MODE_LINKTABLE_UPDATE:
....@@ -494,7 +505,6 @@
494505
495506 mpp_write(mpp, RKVENC_INT_MSK_BASE, 0x100);
496507 mpp_write(mpp, RKVENC_INT_CLR_BASE, 0xffffffff);
497
- udelay(5);
498508 mpp_write(mpp, RKVENC_INT_STATUS_BASE, 0);
499509
500510 mpp_debug_leave();
....@@ -524,11 +534,10 @@
524534
525535 if (task->irq_status & RKVENC_INT_ERROR_BITS) {
526536 atomic_inc(&mpp->reset_request);
527
- /* dump register */
528537 if (mpp_debug_unlikely(DEBUG_DUMP_ERR_REG)) {
529
- mpp_debug(DEBUG_DUMP_ERR_REG, "irq_status: %08x\n",
530
- task->irq_status);
531
- mpp_task_dump_hw_reg(mpp, mpp_task);
538
+ /* dump error register */
539
+ mpp_debug(DEBUG_DUMP_ERR_REG, "irq_status: %08x\n", task->irq_status);
540
+ mpp_task_dump_hw_reg(mpp);
532541 }
533542 }
534543
....@@ -746,7 +755,7 @@
746755 }
747756 seq_puts(seq, "\n");
748757 /* item data*/
749
- seq_printf(seq, "|%8p|", session);
758
+ seq_printf(seq, "|%8d|", session->index);
750759 seq_printf(seq, "%8s|", mpp_device_name[session->device_type]);
751760 for (i = ENC_INFO_BASE; i < ENC_INFO_BUTT; i++) {
752761 u32 flag = priv->codec_info[i].flag;
....@@ -779,7 +788,7 @@
779788 mutex_lock(&mpp->srv->session_lock);
780789 list_for_each_entry_safe(session, n,
781790 &mpp->srv->session_list,
782
- session_link) {
791
+ service_link) {
783792 if (session->device_type != MPP_DEVICE_RKVENC)
784793 continue;
785794 if (!session->priv)
....@@ -802,6 +811,10 @@
802811 enc->procfs = NULL;
803812 return -EIO;
804813 }
814
+
815
+ /* for common mpp_dev options */
816
+ mpp_procfs_create_common(enc->procfs, mpp);
817
+
805818 /* for debug */
806819 mpp_procfs_create_u32("aclk", 0644,
807820 enc->procfs, &enc->aclk_info.debug_rate_hz);
....@@ -956,7 +969,7 @@
956969 };
957970
958971 static struct monitor_dev_profile enc_mdevp = {
959
- .type = MONITOR_TPYE_DEV,
972
+ .type = MONITOR_TYPE_DEV,
960973 .low_temp_adjust = rockchip_monitor_dev_low_temp_adjust,
961974 .high_temp_adjust = rockchip_monitor_dev_high_temp_adjust,
962975 };
....@@ -985,15 +998,19 @@
985998 return ret;
986999 }
9871000
1001
+static const struct rockchip_opp_data __maybe_unused rv1126_rkvenc_opp_data = {
1002
+ .get_soc_info = rv1126_get_soc_info,
1003
+};
1004
+
9881005 static const struct of_device_id rockchip_rkvenc_of_match[] = {
9891006 #ifdef CONFIG_CPU_RV1126
9901007 {
9911008 .compatible = "rockchip,rv1109",
992
- .data = (void *)&rv1126_get_soc_info,
1009
+ .data = (void *)&rv1126_rkvenc_opp_data,
9931010 },
9941011 {
9951012 .compatible = "rockchip,rv1126",
996
- .data = (void *)&rv1126_get_soc_info,
1013
+ .data = (void *)&rv1126_rkvenc_opp_data,
9971014 },
9981015 #endif
9991016 {},
....@@ -1004,6 +1021,7 @@
10041021 struct rkvenc_dev *enc = to_rkvenc_dev(mpp);
10051022 struct clk *clk_core = enc->core_clk_info.clk;
10061023 struct devfreq_cooling_power *venc_dcp = &venc_cooling_power_data;
1024
+ struct rockchip_opp_info opp_info = {0};
10071025 int ret = 0;
10081026
10091027 if (!clk_core)
....@@ -1021,8 +1039,8 @@
10211039 return 0;
10221040 }
10231041
1024
- ret = rockchip_init_opp_table(mpp->dev, rockchip_rkvenc_of_match,
1025
- "leakage", "venc");
1042
+ rockchip_get_opp_data(rockchip_rkvenc_of_match, &opp_info);
1043
+ ret = rockchip_init_opp_table(mpp->dev, &opp_info, "leakage", "venc");
10261044 if (ret) {
10271045 dev_err(mpp->dev, "failed to init_opp_table\n");
10281046 return ret;
....@@ -1132,7 +1150,7 @@
11321150 else
11331151 enc->aux_iova = page_iova;
11341152
1135
- rk_iommu_unmask_irq(mpp->dev);
1153
+ rockchip_iommu_unmask_irq(mpp->dev);
11361154 mpp_iommu_up_write(mpp->iommu_info);
11371155
11381156 mpp_debug_leave();
....@@ -1149,7 +1167,7 @@
11491167 mpp_debug(DEBUG_IOMMU, "IOMMU_GET_BUS_ID(status)=%d\n", IOMMU_GET_BUS_ID(status));
11501168 if (IOMMU_GET_BUS_ID(status)) {
11511169 enc->fault_iova = iova;
1152
- rk_iommu_mask_irq(mpp->dev);
1170
+ rockchip_iommu_mask_irq(mpp->dev);
11531171 queue_work(enc->iommu_wq, &enc->iommu_work);
11541172 }
11551173 mpp_debug_leave();
....@@ -1214,7 +1232,7 @@
12141232 }
12151233 INIT_WORK(&enc->iommu_work, rkvenc_iommu_handle_work);
12161234
1217
- mpp->iommu_info->hdl = rkvenc_iommu_fault_handle;
1235
+ mpp->fault_handler = rkvenc_iommu_fault_handle;
12181236
12191237 return ret;
12201238 }
....@@ -1264,7 +1282,7 @@
12641282 mpp_write(mpp, RKVENC_INT_STATUS_BASE, 0);
12651283 /* cru reset */
12661284 if (enc->rst_a && enc->rst_h && enc->rst_core) {
1267
- rockchip_pmu_idle_request(mpp->dev, true);
1285
+ mpp_pmu_idle_request(mpp, true);
12681286 mpp_safe_reset(enc->rst_a);
12691287 mpp_safe_reset(enc->rst_h);
12701288 mpp_safe_reset(enc->rst_core);
....@@ -1272,7 +1290,7 @@
12721290 mpp_safe_unreset(enc->rst_a);
12731291 mpp_safe_unreset(enc->rst_h);
12741292 mpp_safe_unreset(enc->rst_core);
1275
- rockchip_pmu_idle_request(mpp->dev, false);
1293
+ mpp_pmu_idle_request(mpp, false);
12761294 }
12771295 #ifdef CONFIG_PM_DEVFREQ
12781296 if (enc->devfreq)
....@@ -1429,7 +1447,7 @@
14291447 if (!enc)
14301448 return -ENOMEM;
14311449 mpp = &enc->mpp;
1432
- platform_set_drvdata(pdev, enc);
1450
+ platform_set_drvdata(pdev, mpp);
14331451
14341452 if (pdev->dev.of_node) {
14351453 match = of_match_node(mpp_rkvenc_dt_match, pdev->dev.of_node);
....@@ -1468,39 +1486,19 @@
14681486 static int rkvenc_remove(struct platform_device *pdev)
14691487 {
14701488 struct device *dev = &pdev->dev;
1471
- struct rkvenc_dev *enc = platform_get_drvdata(pdev);
1489
+ struct mpp_dev *mpp = dev_get_drvdata(dev);
14721490
14731491 dev_info(dev, "remove device\n");
1474
- mpp_dev_remove(&enc->mpp);
1475
- rkvenc_procfs_remove(&enc->mpp);
1492
+ mpp_dev_remove(mpp);
1493
+ rkvenc_procfs_remove(mpp);
14761494
14771495 return 0;
1478
-}
1479
-
1480
-static void rkvenc_shutdown(struct platform_device *pdev)
1481
-{
1482
- int ret;
1483
- int val;
1484
- struct device *dev = &pdev->dev;
1485
- struct rkvenc_dev *enc = platform_get_drvdata(pdev);
1486
- struct mpp_dev *mpp = &enc->mpp;
1487
-
1488
- dev_info(dev, "shutdown device\n");
1489
-
1490
- atomic_inc(&mpp->srv->shutdown_request);
1491
- ret = readx_poll_timeout(atomic_read,
1492
- &mpp->task_count,
1493
- val, val == 0, 1000, 200000);
1494
- if (ret == -ETIMEDOUT)
1495
- dev_err(dev, "wait total running time out\n");
1496
-
1497
- dev_info(dev, "shutdown success\n");
14981496 }
14991497
15001498 struct platform_driver rockchip_rkvenc_driver = {
15011499 .probe = rkvenc_probe,
15021500 .remove = rkvenc_remove,
1503
- .shutdown = rkvenc_shutdown,
1501
+ .shutdown = mpp_dev_shutdown,
15041502 .driver = {
15051503 .name = RKVENC_DRIVER_NAME,
15061504 .of_match_table = of_match_ptr(mpp_rkvenc_dt_match),