Lines Matching refs:dev

27 int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)  in s5p_mfc_alloc_firmware()  argument
29 struct s5p_mfc_priv_buf *fw_buf = &dev->fw_buf; in s5p_mfc_alloc_firmware()
32 fw_buf->size = dev->variant->buf_size->fw; in s5p_mfc_alloc_firmware()
39 err = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &dev->fw_buf); in s5p_mfc_alloc_firmware()
49 int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_load_firmware() argument
58 if (dev->fw_get_done) in s5p_mfc_load_firmware()
62 if (!dev->variant->fw_name[i]) in s5p_mfc_load_firmware()
65 dev->variant->fw_name[i], &dev->plat_dev->dev); in s5p_mfc_load_firmware()
67 dev->fw_ver = (enum s5p_mfc_fw_ver) i; in s5p_mfc_load_firmware()
76 if (fw_blob->size > dev->fw_buf.size) { in s5p_mfc_load_firmware()
81 memcpy(dev->fw_buf.virt, fw_blob->data, fw_blob->size); in s5p_mfc_load_firmware()
83 dev->fw_get_done = true; in s5p_mfc_load_firmware()
90 int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_release_firmware() argument
94 s5p_mfc_release_priv_buf(dev, &dev->fw_buf); in s5p_mfc_release_firmware()
95 dev->fw_get_done = false; in s5p_mfc_release_firmware()
99 static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev) in s5p_mfc_bus_reset() argument
105 mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
113 status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
119 int s5p_mfc_reset(struct s5p_mfc_dev *dev) in s5p_mfc_reset() argument
127 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_reset()
129 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6); in s5p_mfc_reset()
130 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6); in s5p_mfc_reset()
131 mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_reset()
134 mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4)); in s5p_mfc_reset()
137 if (dev->risc_on) in s5p_mfc_reset()
138 if (s5p_mfc_bus_reset(dev)) in s5p_mfc_reset()
144 if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev))) in s5p_mfc_reset()
145 mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6); in s5p_mfc_reset()
147 mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
148 mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
152 mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
154 mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
165 mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS); in s5p_mfc_reset()
169 mfc_write(dev, 0x0, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
170 mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
177 static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev) in s5p_mfc_init_memctrl() argument
179 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_memctrl()
180 mfc_write(dev, dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
183 &dev->dma_base[BANK_L_CTX]); in s5p_mfc_init_memctrl()
185 mfc_write(dev, dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
187 mfc_write(dev, dev->dma_base[BANK_R_CTX], in s5p_mfc_init_memctrl()
190 &dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
191 &dev->dma_base[BANK_R_CTX]); in s5p_mfc_init_memctrl()
195 static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) in s5p_mfc_clear_cmds() argument
197 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_clear_cmds()
201 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_clear_cmds()
202 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID); in s5p_mfc_clear_cmds()
203 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD); in s5p_mfc_clear_cmds()
204 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD); in s5p_mfc_clear_cmds()
209 int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) in s5p_mfc_init_hw() argument
215 if (!dev->fw_buf.virt) { in s5p_mfc_init_hw()
223 dev->risc_on = 0; in s5p_mfc_init_hw()
224 ret = s5p_mfc_reset(dev); in s5p_mfc_init_hw()
231 s5p_mfc_init_memctrl(dev); in s5p_mfc_init_hw()
233 s5p_mfc_clear_cmds(dev); in s5p_mfc_init_hw()
235 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
236 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_hw()
237 dev->risc_on = 1; in s5p_mfc_init_hw()
238 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_init_hw()
241 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_init_hw()
243 if (IS_MFCV10(dev)) in s5p_mfc_init_hw()
244 mfc_write(dev, 0x0, S5P_FIMV_MFC_CLOCK_OFF_V10); in s5p_mfc_init_hw()
247 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_init_hw()
249 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
253 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
255 ret = s5p_mfc_hw_call(dev->mfc_cmds, sys_init_cmd, dev); in s5p_mfc_init_hw()
258 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
263 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) { in s5p_mfc_init_hw()
265 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
269 dev->int_cond = 0; in s5p_mfc_init_hw()
270 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_init_hw()
274 dev->int_err, dev->int_type); in s5p_mfc_init_hw()
275 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
279 if (IS_MFCV6_PLUS(dev)) in s5p_mfc_init_hw()
280 ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_init_hw()
282 ver = mfc_read(dev, S5P_FIMV_FW_VERSION); in s5p_mfc_init_hw()
293 void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev) in s5p_mfc_deinit_hw() argument
297 s5p_mfc_reset(dev); in s5p_mfc_deinit_hw()
298 s5p_mfc_hw_call(dev->mfc_ops, release_dev_context_buffer, dev); in s5p_mfc_deinit_hw()
303 int s5p_mfc_sleep(struct s5p_mfc_dev *dev) in s5p_mfc_sleep() argument
309 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_sleep()
310 ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev); in s5p_mfc_sleep()
315 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SLEEP_RET)) { in s5p_mfc_sleep()
320 dev->int_cond = 0; in s5p_mfc_sleep()
321 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_sleep()
324 mfc_err("Failed to sleep - error: %d int: %d\n", dev->int_err, in s5p_mfc_sleep()
325 dev->int_type); in s5p_mfc_sleep()
332 static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_v8_wait_wakeup() argument
337 dev->risc_on = 1; in s5p_mfc_v8_wait_wakeup()
338 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_v8_wait_wakeup()
340 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_v8_wait_wakeup()
345 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_v8_wait_wakeup()
351 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_v8_wait_wakeup()
358 static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wait_wakeup() argument
363 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_wait_wakeup()
370 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_wait_wakeup()
371 dev->risc_on = 1; in s5p_mfc_wait_wakeup()
372 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_wait_wakeup()
374 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_wait_wakeup()
377 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_wait_wakeup()
384 int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wakeup() argument
392 dev->risc_on = 0; in s5p_mfc_wakeup()
393 ret = s5p_mfc_reset(dev); in s5p_mfc_wakeup()
401 s5p_mfc_init_memctrl(dev); in s5p_mfc_wakeup()
403 s5p_mfc_clear_cmds(dev); in s5p_mfc_wakeup()
404 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_wakeup()
406 if (IS_MFCV8_PLUS(dev)) in s5p_mfc_wakeup()
407 ret = s5p_mfc_v8_wait_wakeup(dev); in s5p_mfc_wakeup()
409 ret = s5p_mfc_wait_wakeup(dev); in s5p_mfc_wakeup()
415 dev->int_cond = 0; in s5p_mfc_wakeup()
416 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_wakeup()
419 mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err, in s5p_mfc_wakeup()
420 dev->int_type); in s5p_mfc_wakeup()
427 int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_open_mfc_inst() argument
431 ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
438 ret = s5p_mfc_hw_call(dev->mfc_ops, in s5p_mfc_open_mfc_inst()
447 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); in s5p_mfc_open_mfc_inst()
461 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_open_mfc_inst()
463 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
468 void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_close_mfc_inst() argument
472 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); in s5p_mfc_close_mfc_inst()
479 s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx); in s5p_mfc_close_mfc_inst()
480 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_close_mfc_inst()
482 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_close_mfc_inst()