Lines Matching refs:mpp

124 		container_of(dev, struct rkvenc_dev, mpp)
182 struct mpp_dev mpp; member
334 struct mpp_dev *mpp = session->mpp; in rkvenc_alloc_task() local
344 mpp_task->hw_info = mpp->var->hw_info; in rkvenc_alloc_task()
374 mpp_task_dump_mem_region(mpp, mpp_task); in rkvenc_alloc_task()
375 mpp_task_dump_reg(mpp, mpp_task); in rkvenc_alloc_task()
381 static int rkvenc_write_req_l2(struct mpp_dev *mpp, in rkvenc_write_req_l2() argument
391 writel_relaxed(reg, mpp->reg_base + RKVENC_L2_ADDR_BASE); in rkvenc_write_req_l2()
392 writel_relaxed(regs[i], mpp->reg_base + RKVENC_L2_WRITE_BASE); in rkvenc_write_req_l2()
398 static int rkvenc_read_req_l2(struct mpp_dev *mpp, in rkvenc_read_req_l2() argument
407 writel_relaxed(reg, mpp->reg_base + RKVENC_L2_ADDR_BASE); in rkvenc_read_req_l2()
408 regs[i] = readl_relaxed(mpp->reg_base + RKVENC_L2_READ_BASE); in rkvenc_read_req_l2()
415 static int rkvenc_write_req_backward(struct mpp_dev *mpp, u32 *regs, in rkvenc_write_req_backward() argument
423 mpp_write_relaxed(mpp, i * sizeof(u32), regs[i]); in rkvenc_write_req_backward()
429 static int rkvenc_run(struct mpp_dev *mpp, in rkvenc_run() argument
437 mpp_write_relaxed(mpp, RKVENC_REG_CLR_CACHE_BASE, 1); in rkvenc_run()
443 u32 timing_en = mpp->srv->timing_en; in rkvenc_run()
449 mpp_write_relaxed(mpp, RKVENC_OSD_CFG_BASE, 0); in rkvenc_run()
462 rkvenc_write_req_l2(mpp, task->reg_l2, s, e); in rkvenc_run()
468 rkvenc_write_req_backward(mpp, task->reg, s, e, reg_en); in rkvenc_run()
473 mpp_iommu_flush_tlb(mpp->iommu_info); in rkvenc_run()
476 mpp->cur_task = mpp_task; in rkvenc_run()
482 mpp_write(mpp, RKVENC_ENC_START_BASE, task->reg[reg_en]); in rkvenc_run()
498 static int rkvenc_irq(struct mpp_dev *mpp) in rkvenc_irq() argument
502 mpp->irq_status = mpp_read(mpp, RKVENC_INT_STATUS_BASE); in rkvenc_irq()
503 if (!mpp->irq_status) in rkvenc_irq()
506 mpp_write(mpp, RKVENC_INT_MSK_BASE, 0x100); in rkvenc_irq()
507 mpp_write(mpp, RKVENC_INT_CLR_BASE, 0xffffffff); in rkvenc_irq()
508 mpp_write(mpp, RKVENC_INT_STATUS_BASE, 0); in rkvenc_irq()
515 static int rkvenc_isr(struct mpp_dev *mpp) in rkvenc_isr() argument
518 struct mpp_task *mpp_task = mpp->cur_task; in rkvenc_isr()
519 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_isr()
525 dev_err(mpp->dev, "no current task\n"); in rkvenc_isr()
530 mpp->cur_task = NULL; in rkvenc_isr()
532 task->irq_status = mpp->irq_status; in rkvenc_isr()
536 atomic_inc(&mpp->reset_request); in rkvenc_isr()
540 mpp_task_dump_hw_reg(mpp); in rkvenc_isr()
546 iommu_unmap(mpp->iommu_info->domain, enc->aux_iova, IOMMU_PAGE_SIZE); in rkvenc_isr()
557 static int rkvenc_finish(struct mpp_dev *mpp, in rkvenc_finish() argument
578 rkvenc_read_req_l2(mpp, task->reg_l2, s, e); in rkvenc_finish()
582 mpp_read_req(mpp, task->reg, s, e); in rkvenc_finish()
599 static int rkvenc_result(struct mpp_dev *mpp, in rkvenc_result() argument
727 static int rkvenc_procfs_remove(struct mpp_dev *mpp) in rkvenc_procfs_remove() argument
729 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_procfs_remove()
786 struct mpp_dev *mpp = seq->private; in rkvenc_show_session_info() local
788 mutex_lock(&mpp->srv->session_lock); in rkvenc_show_session_info()
790 &mpp->srv->session_list, in rkvenc_show_session_info()
796 if (mpp->dev_ops->dump_session) in rkvenc_show_session_info()
797 mpp->dev_ops->dump_session(session, seq); in rkvenc_show_session_info()
799 mutex_unlock(&mpp->srv->session_lock); in rkvenc_show_session_info()
804 static int rkvenc_procfs_init(struct mpp_dev *mpp) in rkvenc_procfs_init() argument
806 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_procfs_init()
808 enc->procfs = proc_mkdir(mpp->dev->of_node->name, mpp->srv->procfs); in rkvenc_procfs_init()
816 mpp_procfs_create_common(enc->procfs, mpp); in rkvenc_procfs_init()
824 enc->procfs, &mpp->session_max_buffers); in rkvenc_procfs_init()
827 enc->procfs, rkvenc_show_session_info, mpp); in rkvenc_procfs_init()
832 static inline int rkvenc_procfs_remove(struct mpp_dev *mpp) in rkvenc_procfs_remove() argument
837 static inline int rkvenc_procfs_init(struct mpp_dev *mpp) in rkvenc_procfs_init() argument
1019 static int rkvenc_devfreq_init(struct mpp_dev *mpp) in rkvenc_devfreq_init() argument
1021 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_devfreq_init()
1030 enc->vdd = devm_regulator_get_optional(mpp->dev, "venc"); in rkvenc_devfreq_init()
1033 dev_warn(mpp->dev, "venc regulator not ready, retry\n"); in rkvenc_devfreq_init()
1037 dev_info(mpp->dev, "no regulator, devfreq is disabled\n"); in rkvenc_devfreq_init()
1043 ret = rockchip_init_opp_table(mpp->dev, &opp_info, "leakage", "venc"); in rkvenc_devfreq_init()
1045 dev_err(mpp->dev, "failed to init_opp_table\n"); in rkvenc_devfreq_init()
1051 dev_err(mpp->dev, "failed to add venc_ondemand governor\n"); in rkvenc_devfreq_init()
1057 enc->devfreq = devm_devfreq_add_device(mpp->dev, in rkvenc_devfreq_init()
1068 devfreq_register_opp_notifier(mpp->dev, enc->devfreq); in rkvenc_devfreq_init()
1070 of_property_read_u32(mpp->dev->of_node, "dynamic-power-coefficient", in rkvenc_devfreq_init()
1072 enc->model_data = rockchip_ipa_power_model_init(mpp->dev, in rkvenc_devfreq_init()
1076 dev_err(mpp->dev, "failed to initialize power model\n"); in rkvenc_devfreq_init()
1082 dev_err(mpp->dev, "failed to get dynamic-coefficient\n"); in rkvenc_devfreq_init()
1087 of_devfreq_cooling_register_power(mpp->dev->of_node, in rkvenc_devfreq_init()
1090 dev_err(mpp->dev, "failed to register cooling device\n"); in rkvenc_devfreq_init()
1093 enc->mdev_info = rockchip_system_monitor_register(mpp->dev, &enc_mdevp); in rkvenc_devfreq_init()
1095 dev_dbg(mpp->dev, "without system monitor\n"); in rkvenc_devfreq_init()
1106 dev_pm_opp_of_remove_table(mpp->dev); in rkvenc_devfreq_init()
1111 static int rkvenc_devfreq_remove(struct mpp_dev *mpp) in rkvenc_devfreq_remove() argument
1113 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_devfreq_remove()
1118 devfreq_unregister_opp_notifier(mpp->dev, enc->devfreq); in rkvenc_devfreq_remove()
1119 dev_pm_opp_of_remove_table(mpp->dev); in rkvenc_devfreq_remove()
1131 struct mpp_dev *mpp = &enc->mpp; in rkvenc_iommu_handle_work() local
1137 mpp_iommu_down_write(mpp->iommu_info); in rkvenc_iommu_handle_work()
1140 iommu_unmap(mpp->iommu_info->domain, enc->aux_iova, IOMMU_PAGE_SIZE); in rkvenc_iommu_handle_work()
1145 ret = iommu_map(mpp->iommu_info->domain, page_iova, in rkvenc_iommu_handle_work()
1153 rockchip_iommu_unmask_irq(mpp->dev); in rkvenc_iommu_handle_work()
1154 mpp_iommu_up_write(mpp->iommu_info); in rkvenc_iommu_handle_work()
1163 struct mpp_dev *mpp = (struct mpp_dev *)arg; in rkvenc_iommu_fault_handle() local
1164 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_iommu_fault_handle()
1170 rockchip_iommu_mask_irq(mpp->dev); in rkvenc_iommu_fault_handle()
1178 static int rkvenc_init(struct mpp_dev *mpp) in rkvenc_init() argument
1180 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_init()
1183 mpp->grf_info = &mpp->srv->grf_infos[MPP_DRIVER_RKVENC]; in rkvenc_init()
1186 ret = mpp_get_clk_info(mpp, &enc->aclk_info, "aclk_vcodec"); in rkvenc_init()
1189 ret = mpp_get_clk_info(mpp, &enc->hclk_info, "hclk_vcodec"); in rkvenc_init()
1192 ret = mpp_get_clk_info(mpp, &enc->core_clk_info, "clk_core"); in rkvenc_init()
1196 of_property_read_u32(mpp->dev->of_node, in rkvenc_init()
1204 enc->rst_a = mpp_reset_control_get(mpp, RST_TYPE_A, "video_a"); in rkvenc_init()
1207 enc->rst_h = mpp_reset_control_get(mpp, RST_TYPE_H, "video_h"); in rkvenc_init()
1210 enc->rst_core = mpp_reset_control_get(mpp, RST_TYPE_CORE, "video_core"); in rkvenc_init()
1215 ret = rkvenc_devfreq_init(mpp); in rkvenc_init()
1223 dev_err(mpp->dev, "allocate a page for auxiliary usage\n"); in rkvenc_init()
1235 mpp->iommu_info->hdl = rkvenc_iommu_fault_handle; in rkvenc_init()
1240 static int rkvenc_exit(struct mpp_dev *mpp) in rkvenc_exit() argument
1242 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_exit()
1245 rkvenc_devfreq_remove(mpp); in rkvenc_exit()
1252 iommu_unmap(mpp->iommu_info->domain, enc->aux_iova, IOMMU_PAGE_SIZE); in rkvenc_exit()
1264 static int rkvenc_reset(struct mpp_dev *mpp) in rkvenc_reset() argument
1266 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_reset()
1277 mpp_write(mpp, RKVENC_INT_MSK_BASE, 0x1FF); in rkvenc_reset()
1278 mpp_write(mpp, RKVENC_CLR_BASE, RKVENC_SAFE_CLR_BIT); in rkvenc_reset()
1280 mpp_debug(DEBUG_IRQ_STATUS, "irq_status: %08x\n", mpp_read(mpp, RKVENC_INT_STATUS_BASE)); in rkvenc_reset()
1281 mpp_write(mpp, RKVENC_INT_CLR_BASE, 0xffffffff); in rkvenc_reset()
1282 mpp_write(mpp, RKVENC_INT_STATUS_BASE, 0); in rkvenc_reset()
1285 mpp_pmu_idle_request(mpp, true); in rkvenc_reset()
1293 mpp_pmu_idle_request(mpp, false); in rkvenc_reset()
1305 static int rkvenc_clk_on(struct mpp_dev *mpp) in rkvenc_clk_on() argument
1307 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_clk_on()
1316 static int rkvenc_clk_off(struct mpp_dev *mpp) in rkvenc_clk_off() argument
1318 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_clk_off()
1327 static int rkvenc_get_freq(struct mpp_dev *mpp, in rkvenc_get_freq() argument
1333 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_get_freq()
1343 mutex_lock(&mpp->queue->pending_lock); in rkvenc_get_freq()
1345 &mpp->queue->pending_list, in rkvenc_get_freq()
1352 mutex_unlock(&mpp->queue->pending_lock); in rkvenc_get_freq()
1363 static int rkvenc_set_freq(struct mpp_dev *mpp, in rkvenc_set_freq() argument
1366 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_set_freq()
1441 struct mpp_dev *mpp = NULL; in rkvenc_probe() local
1449 mpp = &enc->mpp; in rkvenc_probe()
1450 platform_set_drvdata(pdev, mpp); in rkvenc_probe()
1455 mpp->var = (struct mpp_dev_var *)match->data; in rkvenc_probe()
1458 ret = mpp_dev_probe(mpp, pdev); in rkvenc_probe()
1462 ret = devm_request_threaded_irq(dev, mpp->irq, in rkvenc_probe()
1466 dev_name(dev), mpp); in rkvenc_probe()
1472 mpp->session_max_buffers = RKVENC_SESSION_MAX_BUFFERS; in rkvenc_probe()
1473 rkvenc_procfs_init(mpp); in rkvenc_probe()
1475 mpp_dev_register_srv(mpp, mpp->srv); in rkvenc_probe()
1481 mpp_dev_remove(mpp); in rkvenc_probe()
1489 struct mpp_dev *mpp = dev_get_drvdata(dev); in rkvenc_remove() local
1492 mpp_dev_remove(mpp); in rkvenc_remove()
1493 rkvenc_procfs_remove(mpp); in rkvenc_remove()