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
54 if (dev->fw_get_done) in s5p_mfc_load_firmware()
58 if (!dev->variant->fw_name[i]) in s5p_mfc_load_firmware()
61 dev->variant->fw_name[i], &dev->plat_dev->dev); in s5p_mfc_load_firmware()
63 dev->fw_ver = (enum s5p_mfc_fw_ver) i; in s5p_mfc_load_firmware()
72 if (fw_blob->size > dev->fw_buf.size) { in s5p_mfc_load_firmware()
77 memcpy(dev->fw_buf.virt, fw_blob->data, fw_blob->size); in s5p_mfc_load_firmware()
79 dev->fw_get_done = true; in s5p_mfc_load_firmware()
86 int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev) in s5p_mfc_release_firmware() argument
90 s5p_mfc_release_priv_buf(dev, &dev->fw_buf); in s5p_mfc_release_firmware()
91 dev->fw_get_done = false; in s5p_mfc_release_firmware()
95 static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev) in s5p_mfc_bus_reset() argument
101 mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
109 status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL); in s5p_mfc_bus_reset()
115 int s5p_mfc_reset(struct s5p_mfc_dev *dev) in s5p_mfc_reset() argument
123 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_reset()
125 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6); in s5p_mfc_reset()
126 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6); in s5p_mfc_reset()
127 mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_reset()
130 mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4)); in s5p_mfc_reset()
133 if (dev->risc_on) in s5p_mfc_reset()
134 if (s5p_mfc_bus_reset(dev)) in s5p_mfc_reset()
140 if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev))) in s5p_mfc_reset()
141 mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6); in s5p_mfc_reset()
143 mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
144 mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6); in s5p_mfc_reset()
148 mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
150 mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
161 mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS); in s5p_mfc_reset()
165 mfc_write(dev, 0x0, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
166 mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET); in s5p_mfc_reset()
173 static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev) in s5p_mfc_init_memctrl() argument
175 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_memctrl()
176 mfc_write(dev, dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
179 &dev->dma_base[BANK_L_CTX]); in s5p_mfc_init_memctrl()
181 mfc_write(dev, dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
183 mfc_write(dev, dev->dma_base[BANK_R_CTX], in s5p_mfc_init_memctrl()
186 &dev->dma_base[BANK_L_CTX], in s5p_mfc_init_memctrl()
187 &dev->dma_base[BANK_R_CTX]); in s5p_mfc_init_memctrl()
191 static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) in s5p_mfc_clear_cmds() argument
193 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_clear_cmds()
197 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_clear_cmds()
198 mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID); in s5p_mfc_clear_cmds()
199 mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD); in s5p_mfc_clear_cmds()
200 mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD); in s5p_mfc_clear_cmds()
205 int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) in s5p_mfc_init_hw() argument
211 if (!dev->fw_buf.virt) { in s5p_mfc_init_hw()
219 dev->risc_on = 0; in s5p_mfc_init_hw()
220 ret = s5p_mfc_reset(dev); in s5p_mfc_init_hw()
227 s5p_mfc_init_memctrl(dev); in s5p_mfc_init_hw()
229 s5p_mfc_clear_cmds(dev); in s5p_mfc_init_hw()
231 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
232 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_init_hw()
233 dev->risc_on = 1; in s5p_mfc_init_hw()
234 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_init_hw()
237 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_init_hw()
239 if (IS_MFCV10(dev)) in s5p_mfc_init_hw()
240 mfc_write(dev, 0x0, S5P_FIMV_MFC_CLOCK_OFF_V10); in s5p_mfc_init_hw()
243 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_init_hw()
245 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
249 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_init_hw()
251 ret = s5p_mfc_hw_call(dev->mfc_cmds, sys_init_cmd, dev); in s5p_mfc_init_hw()
254 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
259 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) { in s5p_mfc_init_hw()
261 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
265 dev->int_cond = 0; in s5p_mfc_init_hw()
266 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_init_hw()
270 dev->int_err, dev->int_type); in s5p_mfc_init_hw()
271 s5p_mfc_reset(dev); in s5p_mfc_init_hw()
275 if (IS_MFCV6_PLUS(dev)) in s5p_mfc_init_hw()
276 ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); in s5p_mfc_init_hw()
278 ver = mfc_read(dev, S5P_FIMV_FW_VERSION); in s5p_mfc_init_hw()
289 void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev) in s5p_mfc_deinit_hw() argument
293 s5p_mfc_reset(dev); in s5p_mfc_deinit_hw()
294 s5p_mfc_hw_call(dev->mfc_ops, release_dev_context_buffer, dev); in s5p_mfc_deinit_hw()
299 int s5p_mfc_sleep(struct s5p_mfc_dev *dev) in s5p_mfc_sleep() argument
305 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_sleep()
306 ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev); in s5p_mfc_sleep()
311 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SLEEP_RET)) { in s5p_mfc_sleep()
316 dev->int_cond = 0; in s5p_mfc_sleep()
317 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_sleep()
320 mfc_err("Failed to sleep - error: %d int: %d\n", dev->int_err, in s5p_mfc_sleep()
321 dev->int_type); in s5p_mfc_sleep()
328 static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_v8_wait_wakeup() argument
333 dev->risc_on = 1; in s5p_mfc_v8_wait_wakeup()
334 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_v8_wait_wakeup()
336 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { in s5p_mfc_v8_wait_wakeup()
341 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_v8_wait_wakeup()
347 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_v8_wait_wakeup()
354 static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wait_wakeup() argument
359 ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); in s5p_mfc_wait_wakeup()
366 if (IS_MFCV6_PLUS(dev)) { in s5p_mfc_wait_wakeup()
367 dev->risc_on = 1; in s5p_mfc_wait_wakeup()
368 mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); in s5p_mfc_wait_wakeup()
370 mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); in s5p_mfc_wait_wakeup()
373 if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { in s5p_mfc_wait_wakeup()
380 int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) in s5p_mfc_wakeup() argument
388 dev->risc_on = 0; in s5p_mfc_wakeup()
389 ret = s5p_mfc_reset(dev); in s5p_mfc_wakeup()
397 s5p_mfc_init_memctrl(dev); in s5p_mfc_wakeup()
399 s5p_mfc_clear_cmds(dev); in s5p_mfc_wakeup()
400 s5p_mfc_clean_dev_int_flags(dev); in s5p_mfc_wakeup()
402 if (IS_MFCV8_PLUS(dev)) in s5p_mfc_wakeup()
403 ret = s5p_mfc_v8_wait_wakeup(dev); in s5p_mfc_wakeup()
405 ret = s5p_mfc_wait_wakeup(dev); in s5p_mfc_wakeup()
411 dev->int_cond = 0; in s5p_mfc_wakeup()
412 if (dev->int_err != 0 || dev->int_type != in s5p_mfc_wakeup()
415 mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err, in s5p_mfc_wakeup()
416 dev->int_type); in s5p_mfc_wakeup()
423 int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_open_mfc_inst() argument
427 ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
434 ret = s5p_mfc_hw_call(dev->mfc_ops, in s5p_mfc_open_mfc_inst()
443 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); in s5p_mfc_open_mfc_inst()
457 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_open_mfc_inst()
459 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_open_mfc_inst()
464 void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) in s5p_mfc_close_mfc_inst() argument
468 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); in s5p_mfc_close_mfc_inst()
477 s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx); in s5p_mfc_close_mfc_inst()
478 s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx); in s5p_mfc_close_mfc_inst()
480 s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx); in s5p_mfc_close_mfc_inst()