Lines Matching +full:pre +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-only
8 #include <linux/delay.h>
14 #include <video/imx-ipu-v3.h>
16 #include "ipu-prv.h"
125 of_parse_phandle(dev->of_node, name, index); in ipu_pre_lookup_by_phandle()
126 struct ipu_pre *pre; in ipu_pre_lookup_by_phandle() local
129 list_for_each_entry(pre, &ipu_pre_list, list) { in ipu_pre_lookup_by_phandle()
130 if (pre_node == pre->dev->of_node) { in ipu_pre_lookup_by_phandle()
132 device_link_add(dev, pre->dev, in ipu_pre_lookup_by_phandle()
134 return pre; in ipu_pre_lookup_by_phandle()
142 int ipu_pre_get(struct ipu_pre *pre) in ipu_pre_get() argument
146 if (pre->cur.in_use) in ipu_pre_get()
147 return -EBUSY; in ipu_pre_get()
150 writel(0, pre->regs + IPU_PRE_CTRL); in ipu_pre_get()
157 writel(val, pre->regs + IPU_PRE_CTRL); in ipu_pre_get()
159 pre->cur.in_use = true; in ipu_pre_get()
163 void ipu_pre_put(struct ipu_pre *pre) in ipu_pre_put() argument
165 writel(IPU_PRE_CTRL_SFTRST, pre->regs + IPU_PRE_CTRL); in ipu_pre_put()
167 pre->cur.in_use = false; in ipu_pre_put()
171 ipu_pre_update_safe_window(struct ipu_pre *pre) in ipu_pre_update_safe_window() argument
173 if (pre->cur.modifier == DRM_FORMAT_MOD_LINEAR) in ipu_pre_update_safe_window()
174 pre->cur.safe_window_end = pre->cur.height - 2; in ipu_pre_update_safe_window()
176 pre->cur.safe_window_end = DIV_ROUND_UP(pre->cur.height, 4) - 1; in ipu_pre_update_safe_window()
180 ipu_pre_configure_modifier(struct ipu_pre *pre, uint64_t modifier) in ipu_pre_configure_modifier() argument
184 val = readl(pre->regs + IPU_PRE_TPR_CTRL); in ipu_pre_configure_modifier()
191 if (pre->cur.cpp == 2) in ipu_pre_configure_modifier()
194 writel(val, pre->regs + IPU_PRE_TPR_CTRL); in ipu_pre_configure_modifier()
197 pre->cur.ctrl &= ~IPU_PRE_CTRL_BLOCK_EN; in ipu_pre_configure_modifier()
199 pre->cur.ctrl |= IPU_PRE_CTRL_BLOCK_EN; in ipu_pre_configure_modifier()
201 pre->cur.modifier = modifier; in ipu_pre_configure_modifier()
204 void ipu_pre_configure(struct ipu_pre *pre, unsigned int width, in ipu_pre_configure() argument
209 u32 active_bpp = info->cpp[0] >> 1; in ipu_pre_configure()
212 pre->cur.bufaddr = bufaddr; in ipu_pre_configure()
213 pre->cur.height = height; in ipu_pre_configure()
214 pre->cur.cpp = info->cpp[0]; in ipu_pre_configure()
215 pre->cur.ctrl = readl(pre->regs + IPU_PRE_CTRL); in ipu_pre_configure()
218 ipu_pre_update_safe_window(pre); in ipu_pre_configure()
220 writel(bufaddr, pre->regs + IPU_PRE_CUR_BUF); in ipu_pre_configure()
221 writel(bufaddr, pre->regs + IPU_PRE_NEXT_BUF); in ipu_pre_configure()
228 writel(val, pre->regs + IPU_PRE_PREFETCH_ENG_CTRL); in ipu_pre_configure()
232 writel(val, pre->regs + IPU_PRE_PREFETCH_ENG_INPUT_SIZE); in ipu_pre_configure()
235 writel(val, pre->regs + IPU_PRE_PREFETCH_ENG_PITCH); in ipu_pre_configure()
240 writel(val, pre->regs + IPU_PRE_STORE_ENG_CTRL); in ipu_pre_configure()
244 writel(val, pre->regs + IPU_PRE_STORE_ENG_SIZE); in ipu_pre_configure()
247 writel(val, pre->regs + IPU_PRE_STORE_ENG_PITCH); in ipu_pre_configure()
249 writel(pre->buffer_paddr, pre->regs + IPU_PRE_STORE_ENG_ADDR); in ipu_pre_configure()
251 ipu_pre_configure_modifier(pre, modifier); in ipu_pre_configure()
253 pre->cur.ctrl |= IPU_PRE_CTRL_EN_REPEAT | IPU_PRE_CTRL_ENABLE; in ipu_pre_configure()
254 writel(pre->cur.ctrl | IPU_PRE_CTRL_SDW_UPDATE, in ipu_pre_configure()
255 pre->regs + IPU_PRE_CTRL); in ipu_pre_configure()
258 void ipu_pre_update(struct ipu_pre *pre, uint64_t modifier, unsigned int bufaddr) in ipu_pre_update() argument
260 if (bufaddr == pre->cur.bufaddr && in ipu_pre_update()
261 modifier == pre->cur.modifier) in ipu_pre_update()
264 writel(bufaddr, pre->regs + IPU_PRE_NEXT_BUF); in ipu_pre_update()
265 pre->cur.bufaddr = bufaddr; in ipu_pre_update()
267 if (modifier != pre->cur.modifier) in ipu_pre_update()
268 ipu_pre_configure_modifier(pre, modifier); in ipu_pre_update()
275 dev_warn(pre->dev, "timeout waiting for PRE safe window\n"); in ipu_pre_update()
279 val = readl(pre->regs + IPU_PRE_STORE_ENG_STATUS); in ipu_pre_update()
285 current_yblock < pre->cur.safe_window_end) in ipu_pre_update()
292 writel(pre->cur.ctrl | IPU_PRE_CTRL_SDW_UPDATE, in ipu_pre_update()
293 pre->regs + IPU_PRE_CTRL); in ipu_pre_update()
296 ipu_pre_update_safe_window(pre); in ipu_pre_update()
299 bool ipu_pre_update_pending(struct ipu_pre *pre) in ipu_pre_update_pending() argument
301 return !!(readl_relaxed(pre->regs + IPU_PRE_CTRL) & in ipu_pre_update_pending()
305 u32 ipu_pre_get_baddr(struct ipu_pre *pre) in ipu_pre_get_baddr() argument
307 return (u32)pre->buffer_paddr; in ipu_pre_get_baddr()
312 struct device *dev = &pdev->dev; in ipu_pre_probe()
313 struct ipu_pre *pre; in ipu_pre_probe() local
315 pre = devm_kzalloc(dev, sizeof(*pre), GFP_KERNEL); in ipu_pre_probe()
316 if (!pre) in ipu_pre_probe()
317 return -ENOMEM; in ipu_pre_probe()
319 pre->regs = devm_platform_ioremap_resource(pdev, 0); in ipu_pre_probe()
320 if (IS_ERR(pre->regs)) in ipu_pre_probe()
321 return PTR_ERR(pre->regs); in ipu_pre_probe()
323 pre->clk_axi = devm_clk_get(dev, "axi"); in ipu_pre_probe()
324 if (IS_ERR(pre->clk_axi)) in ipu_pre_probe()
325 return PTR_ERR(pre->clk_axi); in ipu_pre_probe()
327 pre->iram = of_gen_pool_get(dev->of_node, "fsl,iram", 0); in ipu_pre_probe()
328 if (!pre->iram) in ipu_pre_probe()
329 return -EPROBE_DEFER; in ipu_pre_probe()
336 pre->buffer_virt = gen_pool_dma_alloc(pre->iram, IPU_PRE_MAX_WIDTH * in ipu_pre_probe()
338 &pre->buffer_paddr); in ipu_pre_probe()
339 if (!pre->buffer_virt) in ipu_pre_probe()
340 return -ENOMEM; in ipu_pre_probe()
342 clk_prepare_enable(pre->clk_axi); in ipu_pre_probe()
344 pre->dev = dev; in ipu_pre_probe()
345 platform_set_drvdata(pdev, pre); in ipu_pre_probe()
347 list_add(&pre->list, &ipu_pre_list); in ipu_pre_probe()
356 struct ipu_pre *pre = platform_get_drvdata(pdev); in ipu_pre_remove() local
359 list_del(&pre->list); in ipu_pre_remove()
360 available_pres--; in ipu_pre_remove()
363 clk_disable_unprepare(pre->clk_axi); in ipu_pre_remove()
365 if (pre->buffer_virt) in ipu_pre_remove()
366 gen_pool_free(pre->iram, (unsigned long)pre->buffer_virt, in ipu_pre_remove()
371 { .compatible = "fsl,imx6qp-pre", },
379 .name = "imx-ipu-pre",