Lines Matching refs:dev
27 int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_alloc_firmware() argument
32 dev->fw_size = dev->variant->buf_size->fw; in s5p_mfc_alloc_firmware()
34 if (dev->fw_virt_addr) { in s5p_mfc_alloc_firmware()
39 dev->fw_virt_addr = dma_alloc_coherent(dev->mem_dev_l, dev->fw_size, in s5p_mfc_alloc_firmware()
40 &dev->bank1, GFP_KERNEL); in s5p_mfc_alloc_firmware()
42 if (!dev->fw_virt_addr) { in s5p_mfc_alloc_firmware()
47 if (HAS_PORTNUM(dev) && IS_TWOPORT(dev)) { in s5p_mfc_alloc_firmware()
48 bank2_virt = dma_alloc_coherent(dev->mem_dev_r, 1 << MFC_BASE_ALIGN_ORDER, in s5p_mfc_alloc_firmware()
53 dma_free_coherent(dev->mem_dev_l, dev->fw_size, in s5p_mfc_alloc_firmware()
54 dev->fw_virt_addr, dev->bank1); in s5p_mfc_alloc_firmware()
55 dev->fw_virt_addr = NULL; in s5p_mfc_alloc_firmware()
63 dev->bank2 = bank2_dma_addr - (1 << MFC_BASE_ALIGN_ORDER); in s5p_mfc_alloc_firmware()
65 dma_free_coherent(dev->mem_dev_r, 1 << MFC_BASE_ALIGN_ORDER, in s5p_mfc_alloc_firmware()
72 dev->bank2 = dev->bank1; in s5p_mfc_alloc_firmware()
78 int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_load_firmware() argument
88 if (!dev->variant->fw_name[i]) in s5p_mfc_load_firmware()
91 dev->variant->fw_name[i], dev->v4l2_dev.dev); in s5p_mfc_load_firmware()
93 dev->fw_ver = (enum s5p_mfc_fw_ver) i; in s5p_mfc_load_firmware()
102 if (fw_blob->size > dev->fw_size) { in s5p_mfc_load_firmware()
107 if (!dev->fw_virt_addr) { in s5p_mfc_load_firmware()
112 memcpy(dev->fw_virt_addr, fw_blob->data, fw_blob->size); in s5p_mfc_load_firmware()
120 int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_release_firmware() argument
124 if (!dev->fw_virt_addr) in s5p_mfc_release_firmware()
126 dma_free_coherent(dev->mem_dev_l, dev->fw_size, dev->fw_virt_addr, in s5p_mfc_release_firmware()
127 dev->bank1); in s5p_mfc_release_firmware()
128 dev->fw_virt_addr = NULL; in s5p_mfc_release_firmware()
132 static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev) in s5p_mfc_bus_reset() argument
138 mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
146 status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
152 int s5p_mfc_reset(struct s5p_mfc_dev *dev) in s5p_mfc_reset() argument
160 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_reset()
162 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6); in s5p_mfc_reset()
163 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6); in s5p_mfc_reset()
164 mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_reset()
167 mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4)); in s5p_mfc_reset()
170 if (dev->risc_on) in s5p_mfc_reset()
171 if (s5p_mfc_bus_reset(dev)) in s5p_mfc_reset()
177 if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev))) in s5p_mfc_reset()
178 mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6); in s5p_mfc_reset()
180 mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
181 mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
185 mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
187 mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
198 mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS); in s5p_mfc_reset()
202 mfc_write(dev, 0x0, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
203 mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
210 static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev) in s5p_mfc_init_memctrl() argument
212 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_memctrl()
213 mfc_write(dev, dev->bank1, S5P_FIMV_RISC_BASE_ADDRESS_V6); in s5p_mfc_init_memctrl()
214 mfc_debug(2, "Base Address : %pad\n", &dev->bank1); in s5p_mfc_init_memctrl()
216 mfc_write(dev, dev->bank1, S5P_FIMV_MC_DRAMBASE_ADR_A); in s5p_mfc_init_memctrl()
217 mfc_write(dev, dev->bank2, S5P_FIMV_MC_DRAMBASE_ADR_B); in s5p_mfc_init_memctrl()
219 &dev->bank1, &dev->bank2); in s5p_mfc_init_memctrl()
223 static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) in s5p_mfc_clear_cmds() argument
225 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_clear_cmds()
229 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_clear_cmds()
230 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID); in s5p_mfc_clear_cmds()
231 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD); in s5p_mfc_clear_cmds()
232 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD); in s5p_mfc_clear_cmds()
237 int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) in s5p_mfc_init_hw() argument
243 if (!dev->fw_virt_addr) { in s5p_mfc_init_hw()
251 dev->risc_on = 0; in s5p_mfc_init_hw()
252 ret = s5p_mfc_reset(dev); in s5p_mfc_init_hw()
259 s5p_mfc_init_memctrl(dev); in s5p_mfc_init_hw()
261 s5p_mfc_clear_cmds(dev); in s5p_mfc_init_hw()
263 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
264 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_hw()
265 dev->risc_on = 1; in s5p_mfc_init_hw()
266 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_init_hw()
269 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_init_hw()
271 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_init_hw()
273 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
277 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
279 ret = s5p_mfc_hw_call(dev->mfc_cmds, sys_init_cmd, dev); in s5p_mfc_init_hw()
282 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
287 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) { in s5p_mfc_init_hw()
289 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
293 dev->int_cond = 0; in s5p_mfc_init_hw()
294 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_init_hw()
298 dev->int_err, dev->int_type); in s5p_mfc_init_hw()
299 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
303 if (IS_MFCV6_PLUS(dev)) in s5p_mfc_init_hw()
304 ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_init_hw()
306 ver = mfc_read(dev, S5P_FIMV_FW_VERSION); in s5p_mfc_init_hw()
317 void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev) in s5p_mfc_deinit_hw() argument
321 s5p_mfc_reset(dev); in s5p_mfc_deinit_hw()
322 s5p_mfc_hw_call_void(dev->mfc_ops, release_dev_context_buffer, dev); in s5p_mfc_deinit_hw()
327 int s5p_mfc_sleep(struct s5p_mfc_dev *dev) in s5p_mfc_sleep() argument
333 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_sleep()
334 ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev); in s5p_mfc_sleep()
339 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SLEEP_RET)) { in s5p_mfc_sleep()
344 dev->int_cond = 0; in s5p_mfc_sleep()
345 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_sleep()
348 mfc_err("Failed to sleep - error: %d int: %d\n", dev->int_err, in s5p_mfc_sleep()
349 dev->int_type); in s5p_mfc_sleep()
356 static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_v8_wait_wakeup() argument
361 dev->risc_on = 1; in s5p_mfc_v8_wait_wakeup()
362 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_v8_wait_wakeup()
364 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_v8_wait_wakeup()
369 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_v8_wait_wakeup()
375 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_v8_wait_wakeup()
382 static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wait_wakeup() argument
387 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_wait_wakeup()
394 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_wait_wakeup()
395 dev->risc_on = 1; in s5p_mfc_wait_wakeup()
396 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_wait_wakeup()
398 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_wait_wakeup()
401 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_wait_wakeup()
408 int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wakeup() argument
416 dev->risc_on = 0; in s5p_mfc_wakeup()
417 ret = s5p_mfc_reset(dev); in s5p_mfc_wakeup()
425 s5p_mfc_init_memctrl(dev); in s5p_mfc_wakeup()
427 s5p_mfc_clear_cmds(dev); in s5p_mfc_wakeup()
428 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_wakeup()
430 if (IS_MFCV8(dev)) in s5p_mfc_wakeup()
431 ret = s5p_mfc_v8_wait_wakeup(dev); in s5p_mfc_wakeup()
433 ret = s5p_mfc_wait_wakeup(dev); in s5p_mfc_wakeup()
439 dev->int_cond = 0; in s5p_mfc_wakeup()
440 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_wakeup()
443 mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err, in s5p_mfc_wakeup()
444 dev->int_type); in s5p_mfc_wakeup()
451 int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_open_mfc_inst() argument
455 ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
462 ret = s5p_mfc_hw_call(dev->mfc_ops, in s5p_mfc_open_mfc_inst()
471 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); in s5p_mfc_open_mfc_inst()
485 s5p_mfc_hw_call_void(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_open_mfc_inst()
487 s5p_mfc_hw_call_void(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
492 void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_close_mfc_inst() argument
496 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); in s5p_mfc_close_mfc_inst()
503 s5p_mfc_hw_call_void(dev->mfc_ops, release_codec_buffers, ctx); in s5p_mfc_close_mfc_inst()
504 s5p_mfc_hw_call_void(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_close_mfc_inst()
506 s5p_mfc_hw_call_void(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_close_mfc_inst()