forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/video/rockchip/mpp/mpp_iep2.c
....@@ -20,8 +20,6 @@
2020 #include <linux/regmap.h>
2121 #include <linux/pm_runtime.h>
2222 #include <linux/proc_fs.h>
23
-#include <linux/mfd/syscon.h>
24
-#include <linux/rockchip/cpu.h>
2523 #include <soc/rockchip/pm_domains.h>
2624
2725 #include "rockchip_iep2_regs.h"
....@@ -268,8 +266,8 @@
268266
269267 mem_region = mpp_task_attach_fd(&task->mpp_task, usr_fd);
270268 if (IS_ERR(mem_region)) {
271
- mpp_debug(DEBUG_IOMMU, "reg[%3d]: %08x failed\n",
272
- iep2_addr_rnum[i], paddr[i]);
269
+ mpp_err("reg[%03d]: %08x failed\n",
270
+ iep2_addr_rnum[i], paddr[i]);
273271 return PTR_ERR(mem_region);
274272 }
275273
....@@ -979,7 +977,7 @@
979977 return -ENOMEM;
980978
981979 mpp = &iep->mpp;
982
- platform_set_drvdata(pdev, iep);
980
+ platform_set_drvdata(pdev, mpp);
983981
984982 if (pdev->dev.of_node) {
985983 match = of_match_node(mpp_iep2_match, pdev->dev.of_node);
....@@ -1015,82 +1013,24 @@
10151013 static int iep2_remove(struct platform_device *pdev)
10161014 {
10171015 struct device *dev = &pdev->dev;
1018
- struct iep2_dev *iep = platform_get_drvdata(pdev);
1016
+ struct mpp_dev *mpp = dev_get_drvdata(dev);
1017
+ struct iep2_dev *iep = to_iep2_dev(mpp);
10191018
10201019 dma_free_coherent(dev, iep->roi.size, iep->roi.vaddr, iep->roi.iova);
10211020
10221021 dev_info(dev, "remove device\n");
1023
- mpp_dev_remove(&iep->mpp);
1024
- iep2_procfs_remove(&iep->mpp);
1022
+ mpp_dev_remove(mpp);
1023
+ iep2_procfs_remove(mpp);
10251024
10261025 return 0;
10271026 }
1028
-
1029
-static void iep2_shutdown(struct platform_device *pdev)
1030
-{
1031
- int ret;
1032
- int val;
1033
- struct device *dev = &pdev->dev;
1034
- struct iep2_dev *iep = platform_get_drvdata(pdev);
1035
- struct mpp_dev *mpp = &iep->mpp;
1036
-
1037
- dev_info(dev, "shutdown device\n");
1038
-
1039
- atomic_inc(&mpp->srv->shutdown_request);
1040
- ret = readx_poll_timeout(atomic_read,
1041
- &mpp->task_count,
1042
- val, val == 0, 20000, 200000);
1043
- if (ret == -ETIMEDOUT)
1044
- dev_err(dev, "wait total running time out\n");
1045
-}
1046
-
1047
-static int iep2_runtime_suspend(struct device *dev)
1048
-{
1049
- struct mpp_dev *mpp = dev_get_drvdata(dev);
1050
- struct mpp_grf_info *info = mpp->grf_info;
1051
- struct mpp_taskqueue *queue = mpp->queue;
1052
-
1053
- if (cpu_is_rk3528() && info && info->mem_offset) {
1054
- mutex_lock(&queue->ref_lock);
1055
- if (!atomic_dec_if_positive(&queue->runtime_cnt)) {
1056
- regmap_write(info->grf, info->mem_offset,
1057
- info->val_mem_off);
1058
- }
1059
- mutex_unlock(&queue->ref_lock);
1060
- }
1061
-
1062
- return 0;
1063
-}
1064
-
1065
-static int iep2_runtime_resume(struct device *dev)
1066
-{
1067
- struct mpp_dev *mpp = dev_get_drvdata(dev);
1068
- struct mpp_grf_info *info = mpp->grf_info;
1069
- struct mpp_taskqueue *queue = mpp->queue;
1070
-
1071
- if (cpu_is_rk3528() && info && info->mem_offset) {
1072
- mutex_lock(&queue->ref_lock);
1073
- regmap_write(info->grf, info->mem_offset,
1074
- info->val_mem_on);
1075
- atomic_inc(&queue->runtime_cnt);
1076
- mutex_unlock(&queue->ref_lock);
1077
- }
1078
-
1079
- return 0;
1080
-}
1081
-
1082
-static const struct dev_pm_ops iep2_pm_ops = {
1083
- .runtime_suspend = iep2_runtime_suspend,
1084
- .runtime_resume = iep2_runtime_resume,
1085
-};
10861027
10871028 struct platform_driver rockchip_iep2_driver = {
10881029 .probe = iep2_probe,
10891030 .remove = iep2_remove,
1090
- .shutdown = iep2_shutdown,
1031
+ .shutdown = mpp_dev_shutdown,
10911032 .driver = {
10921033 .name = IEP2_DRIVER_NAME,
1093
- .pm = &iep2_pm_ops,
10941034 .of_match_table = of_match_ptr(mpp_iep2_match),
10951035 },
10961036 };