Lines Matching refs:dev
23 int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_alloc_firmware() argument
25 struct s5p_mfc_priv_buf *fw_buf = &dev->fw_buf; in s5p_mfc_alloc_firmware()
28 fw_buf->size = dev->variant->buf_size->fw; in s5p_mfc_alloc_firmware()
35 err = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &dev->fw_buf); in s5p_mfc_alloc_firmware()
45 int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_load_firmware() argument
59 if (!IS_MFCV12(dev)) in s5p_mfc_load_firmware()
60 if (dev->fw_get_done) in s5p_mfc_load_firmware()
64 if (!dev->variant->fw_name[i]) in s5p_mfc_load_firmware()
67 dev->variant->fw_name[i], &dev->plat_dev->dev); in s5p_mfc_load_firmware()
69 dev->fw_ver = (enum s5p_mfc_fw_ver) i; in s5p_mfc_load_firmware()
78 if (fw_blob->size > dev->fw_buf.size) { in s5p_mfc_load_firmware()
83 memcpy(dev->fw_buf.virt, fw_blob->data, fw_blob->size); in s5p_mfc_load_firmware()
85 dev->fw_get_done = true; in s5p_mfc_load_firmware()
92 int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_release_firmware() argument
96 s5p_mfc_release_priv_buf(dev, &dev->fw_buf); in s5p_mfc_release_firmware()
97 dev->fw_get_done = false; in s5p_mfc_release_firmware()
101 static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev) in s5p_mfc_bus_reset() argument
107 mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
115 status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
121 int s5p_mfc_reset(struct s5p_mfc_dev *dev) in s5p_mfc_reset() argument
129 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_reset()
131 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6); in s5p_mfc_reset()
132 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6); in s5p_mfc_reset()
133 mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_reset()
136 mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4)); in s5p_mfc_reset()
139 if (dev->risc_on && !IS_MFCV12(dev)) in s5p_mfc_reset()
140 if (s5p_mfc_bus_reset(dev)) in s5p_mfc_reset()
146 if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev))) in s5p_mfc_reset()
147 mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6); in s5p_mfc_reset()
149 mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
150 mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
154 mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
156 mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
167 mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS); in s5p_mfc_reset()
171 mfc_write(dev, 0x0, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
172 mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
179 static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev) in s5p_mfc_init_memctrl() argument
181 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_memctrl()
182 mfc_write(dev, dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
185 &dev->dma_base[BANK_L_CTX]); in s5p_mfc_init_memctrl()
187 mfc_write(dev, dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
189 mfc_write(dev, dev->dma_base[BANK_R_CTX], in s5p_mfc_init_memctrl()
192 &dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
193 &dev->dma_base[BANK_R_CTX]); in s5p_mfc_init_memctrl()
197 static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) in s5p_mfc_clear_cmds() argument
199 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_clear_cmds()
203 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_clear_cmds()
204 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID); in s5p_mfc_clear_cmds()
205 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD); in s5p_mfc_clear_cmds()
206 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD); in s5p_mfc_clear_cmds()
211 int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) in s5p_mfc_init_hw() argument
217 if (!dev->fw_buf.virt) { in s5p_mfc_init_hw()
224 s5p_mfc_clock_on(dev); in s5p_mfc_init_hw()
225 dev->risc_on = 0; in s5p_mfc_init_hw()
226 ret = s5p_mfc_reset(dev); in s5p_mfc_init_hw()
233 s5p_mfc_init_memctrl(dev); in s5p_mfc_init_hw()
235 s5p_mfc_clear_cmds(dev); in s5p_mfc_init_hw()
237 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
238 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_hw()
239 dev->risc_on = 1; in s5p_mfc_init_hw()
240 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_init_hw()
243 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_init_hw()
245 if (IS_MFCV10_PLUS(dev)) in s5p_mfc_init_hw()
246 mfc_write(dev, 0x0, S5P_FIMV_MFC_CLOCK_OFF_V10); in s5p_mfc_init_hw()
249 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_init_hw()
251 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
252 s5p_mfc_clock_off(dev); in s5p_mfc_init_hw()
255 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
257 ret = s5p_mfc_hw_call(dev->mfc_cmds, sys_init_cmd, dev); in s5p_mfc_init_hw()
260 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
261 s5p_mfc_clock_off(dev); in s5p_mfc_init_hw()
265 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) { in s5p_mfc_init_hw()
267 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
268 s5p_mfc_clock_off(dev); in s5p_mfc_init_hw()
271 dev->int_cond = 0; in s5p_mfc_init_hw()
272 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_init_hw()
276 dev->int_err, dev->int_type); in s5p_mfc_init_hw()
277 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
278 s5p_mfc_clock_off(dev); in s5p_mfc_init_hw()
281 if (IS_MFCV6_PLUS(dev)) in s5p_mfc_init_hw()
282 ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_init_hw()
284 ver = mfc_read(dev, S5P_FIMV_FW_VERSION); in s5p_mfc_init_hw()
288 s5p_mfc_clock_off(dev); in s5p_mfc_init_hw()
295 void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev) in s5p_mfc_deinit_hw() argument
297 s5p_mfc_clock_on(dev); in s5p_mfc_deinit_hw()
299 s5p_mfc_reset(dev); in s5p_mfc_deinit_hw()
300 s5p_mfc_hw_call(dev->mfc_ops, release_dev_context_buffer, dev); in s5p_mfc_deinit_hw()
302 s5p_mfc_clock_off(dev); in s5p_mfc_deinit_hw()
305 int s5p_mfc_sleep(struct s5p_mfc_dev *dev) in s5p_mfc_sleep() argument
310 s5p_mfc_clock_on(dev); in s5p_mfc_sleep()
311 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_sleep()
312 ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev); in s5p_mfc_sleep()
317 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SLEEP_RET)) { in s5p_mfc_sleep()
321 s5p_mfc_clock_off(dev); in s5p_mfc_sleep()
322 dev->int_cond = 0; in s5p_mfc_sleep()
323 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_sleep()
326 mfc_err("Failed to sleep - error: %d int: %d\n", dev->int_err, in s5p_mfc_sleep()
327 dev->int_type); in s5p_mfc_sleep()
334 static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_v8_wait_wakeup() argument
339 dev->risc_on = 1; in s5p_mfc_v8_wait_wakeup()
340 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_v8_wait_wakeup()
342 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_v8_wait_wakeup()
347 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_v8_wait_wakeup()
353 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_v8_wait_wakeup()
360 static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wait_wakeup() argument
365 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_wait_wakeup()
372 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_wait_wakeup()
373 dev->risc_on = 1; in s5p_mfc_wait_wakeup()
374 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_wait_wakeup()
376 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_wait_wakeup()
379 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_wait_wakeup()
386 int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wakeup() argument
393 s5p_mfc_clock_on(dev); in s5p_mfc_wakeup()
394 dev->risc_on = 0; in s5p_mfc_wakeup()
395 ret = s5p_mfc_reset(dev); in s5p_mfc_wakeup()
398 s5p_mfc_clock_off(dev); in s5p_mfc_wakeup()
403 s5p_mfc_init_memctrl(dev); in s5p_mfc_wakeup()
405 s5p_mfc_clear_cmds(dev); in s5p_mfc_wakeup()
406 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_wakeup()
408 if (IS_MFCV8_PLUS(dev)) in s5p_mfc_wakeup()
409 ret = s5p_mfc_v8_wait_wakeup(dev); in s5p_mfc_wakeup()
411 ret = s5p_mfc_wait_wakeup(dev); in s5p_mfc_wakeup()
413 s5p_mfc_clock_off(dev); in s5p_mfc_wakeup()
417 dev->int_cond = 0; in s5p_mfc_wakeup()
418 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_wakeup()
421 mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err, in s5p_mfc_wakeup()
422 dev->int_type); in s5p_mfc_wakeup()
429 int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_open_mfc_inst() argument
433 ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
440 ret = s5p_mfc_hw_call(dev->mfc_ops, in s5p_mfc_open_mfc_inst()
449 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); in s5p_mfc_open_mfc_inst()
463 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_open_mfc_inst()
465 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
470 void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_close_mfc_inst() argument
474 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); in s5p_mfc_close_mfc_inst()
483 s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx); in s5p_mfc_close_mfc_inst()
484 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_close_mfc_inst()
486 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_close_mfc_inst()