static int msenc_dma_wait_idle(struct platform_device *dev, u32 *timeout) { nvhost_dbg_fn(""); if (!*timeout) *timeout = MSENC_IDLE_TIMEOUT_DEFAULT; do { u32 check = min_t(u32, MSENC_IDLE_CHECK_PERIOD, *timeout); u32 dmatrfcmd = host1x_readl(dev, msenc_dmatrfcmd_r()); u32 idle_v = msenc_dmatrfcmd_idle_v(dmatrfcmd); if (msenc_dmatrfcmd_idle_true_v() == idle_v) { nvhost_dbg_fn("done"); return 0; } udelay(MSENC_IDLE_CHECK_PERIOD); *timeout -= check; } while (*timeout); dev_err(&dev->dev, "dma idle timeout"); return -1; }
static int msenc_dma_pa_to_internal_256b(struct platform_device *dev, u32 offset, u32 internal_offset, bool imem) { u32 cmd = msenc_dmatrfcmd_size_256b_f(); u32 pa_offset = msenc_dmatrffboffs_offs_f(offset); u32 i_offset = msenc_dmatrfmoffs_offs_f(internal_offset); u32 timeout = 0; /* default*/ if (imem) cmd |= msenc_dmatrfcmd_imem_true_f(); nvhost_device_writel(dev, msenc_dmatrfmoffs_r(), i_offset); nvhost_device_writel(dev, msenc_dmatrffboffs_r(), pa_offset); nvhost_device_writel(dev, msenc_dmatrfcmd_r(), cmd); return msenc_dma_wait_idle(dev, &timeout); }