2 * Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>
3 * Copyright (C) 2005-2009 Freescale Semiconductor, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 #include <linux/module.h>
16 #include <linux/export.h>
17 #include <linux/types.h>
18 #include <linux/reset.h>
19 #include <linux/platform_device.h>
20 #include <linux/err.h>
21 #include <linux/spinlock.h>
22 #include <linux/delay.h>
23 #include <linux/interrupt.h>
25 #include <linux/clk.h>
26 #include <linux/list.h>
27 #include <linux/irq.h>
28 #include <linux/irqchip/chained_irq.h>
29 #include <linux/irqdomain.h>
30 #include <linux/of_device.h>
31 #include <linux/of_graph.h>
33 #include <drm/drm_fourcc.h>
35 #include <video/imx-ipu-v3.h>
38 static inline u32 ipu_cm_read(struct ipu_soc *ipu, unsigned offset)
40 return readl(ipu->cm_reg + offset);
43 static inline void ipu_cm_write(struct ipu_soc *ipu, u32 value, unsigned offset)
45 writel(value, ipu->cm_reg + offset);
48 int ipu_get_num(struct ipu_soc *ipu)
52 EXPORT_SYMBOL_GPL(ipu_get_num);
54 void ipu_srm_dp_sync_update(struct ipu_soc *ipu)
58 val = ipu_cm_read(ipu, IPU_SRM_PRI2);
60 ipu_cm_write(ipu, val, IPU_SRM_PRI2);
62 EXPORT_SYMBOL_GPL(ipu_srm_dp_sync_update);
64 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc)
67 case DRM_FORMAT_ARGB1555:
68 case DRM_FORMAT_ABGR1555:
69 case DRM_FORMAT_RGBA5551:
70 case DRM_FORMAT_BGRA5551:
71 case DRM_FORMAT_RGB565:
72 case DRM_FORMAT_BGR565:
73 case DRM_FORMAT_RGB888:
74 case DRM_FORMAT_BGR888:
75 case DRM_FORMAT_ARGB4444:
76 case DRM_FORMAT_XRGB8888:
77 case DRM_FORMAT_XBGR8888:
78 case DRM_FORMAT_RGBX8888:
79 case DRM_FORMAT_BGRX8888:
80 case DRM_FORMAT_ARGB8888:
81 case DRM_FORMAT_ABGR8888:
82 case DRM_FORMAT_RGBA8888:
83 case DRM_FORMAT_BGRA8888:
84 return IPUV3_COLORSPACE_RGB;
87 case DRM_FORMAT_YUV420:
88 case DRM_FORMAT_YVU420:
89 case DRM_FORMAT_YUV422:
90 case DRM_FORMAT_YVU422:
95 return IPUV3_COLORSPACE_YUV;
97 return IPUV3_COLORSPACE_UNKNOWN;
100 EXPORT_SYMBOL_GPL(ipu_drm_fourcc_to_colorspace);
102 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
104 switch (pixelformat) {
105 case V4L2_PIX_FMT_YUV420:
106 case V4L2_PIX_FMT_YVU420:
107 case V4L2_PIX_FMT_YUV422P:
108 case V4L2_PIX_FMT_UYVY:
109 case V4L2_PIX_FMT_YUYV:
110 case V4L2_PIX_FMT_NV12:
111 case V4L2_PIX_FMT_NV21:
112 case V4L2_PIX_FMT_NV16:
113 case V4L2_PIX_FMT_NV61:
114 return IPUV3_COLORSPACE_YUV;
115 case V4L2_PIX_FMT_RGB32:
116 case V4L2_PIX_FMT_BGR32:
117 case V4L2_PIX_FMT_RGB24:
118 case V4L2_PIX_FMT_BGR24:
119 case V4L2_PIX_FMT_RGB565:
120 return IPUV3_COLORSPACE_RGB;
122 return IPUV3_COLORSPACE_UNKNOWN;
125 EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace);
127 bool ipu_pixelformat_is_planar(u32 pixelformat)
129 switch (pixelformat) {
130 case V4L2_PIX_FMT_YUV420:
131 case V4L2_PIX_FMT_YVU420:
132 case V4L2_PIX_FMT_YUV422P:
133 case V4L2_PIX_FMT_NV12:
134 case V4L2_PIX_FMT_NV21:
135 case V4L2_PIX_FMT_NV16:
136 case V4L2_PIX_FMT_NV61:
142 EXPORT_SYMBOL_GPL(ipu_pixelformat_is_planar);
144 enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
146 switch (mbus_code & 0xf000) {
148 return IPUV3_COLORSPACE_RGB;
150 return IPUV3_COLORSPACE_YUV;
152 return IPUV3_COLORSPACE_UNKNOWN;
155 EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
157 int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
159 switch (pixelformat) {
160 case V4L2_PIX_FMT_YUV420:
161 case V4L2_PIX_FMT_YVU420:
162 case V4L2_PIX_FMT_YUV422P:
163 case V4L2_PIX_FMT_NV12:
164 case V4L2_PIX_FMT_NV21:
165 case V4L2_PIX_FMT_NV16:
166 case V4L2_PIX_FMT_NV61:
168 * for the planar YUV formats, the stride passed to
169 * cpmem must be the stride in bytes of the Y plane.
170 * And all the planar YUV formats have an 8-bit
173 return (8 * pixel_stride) >> 3;
174 case V4L2_PIX_FMT_RGB565:
175 case V4L2_PIX_FMT_YUYV:
176 case V4L2_PIX_FMT_UYVY:
177 return (16 * pixel_stride) >> 3;
178 case V4L2_PIX_FMT_BGR24:
179 case V4L2_PIX_FMT_RGB24:
180 return (24 * pixel_stride) >> 3;
181 case V4L2_PIX_FMT_BGR32:
182 case V4L2_PIX_FMT_RGB32:
183 return (32 * pixel_stride) >> 3;
190 EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
192 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
193 bool hflip, bool vflip)
219 *mode = (enum ipu_rotate_mode)((r90 << 2) | (hf << 1) | vf);
222 EXPORT_SYMBOL_GPL(ipu_degrees_to_rot_mode);
224 int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
225 bool hflip, bool vflip)
229 r90 = ((u32)mode >> 2) & 0x1;
230 hf = ((u32)mode >> 1) & 0x1;
231 vf = ((u32)mode >> 0) & 0x1;
235 switch ((enum ipu_rotate_mode)((r90 << 2) | (hf << 1) | vf)) {
236 case IPU_ROTATE_NONE:
239 case IPU_ROTATE_90_RIGHT:
245 case IPU_ROTATE_90_LEFT:
254 EXPORT_SYMBOL_GPL(ipu_rot_mode_to_degrees);
256 struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num)
258 struct ipuv3_channel *channel;
260 dev_dbg(ipu->dev, "%s %d\n", __func__, num);
263 return ERR_PTR(-ENODEV);
265 mutex_lock(&ipu->channel_lock);
267 channel = &ipu->channel[num];
270 channel = ERR_PTR(-EBUSY);
274 channel->busy = true;
278 mutex_unlock(&ipu->channel_lock);
282 EXPORT_SYMBOL_GPL(ipu_idmac_get);
284 void ipu_idmac_put(struct ipuv3_channel *channel)
286 struct ipu_soc *ipu = channel->ipu;
288 dev_dbg(ipu->dev, "%s %d\n", __func__, channel->num);
290 mutex_lock(&ipu->channel_lock);
292 channel->busy = false;
294 mutex_unlock(&ipu->channel_lock);
296 EXPORT_SYMBOL_GPL(ipu_idmac_put);
298 #define idma_mask(ch) (1 << ((ch) & 0x1f))
301 * This is an undocumented feature, a write one to a channel bit in
302 * IPU_CHA_CUR_BUF and IPU_CHA_TRIPLE_CUR_BUF will reset the channel's
303 * internal current buffer pointer so that transfers start from buffer
304 * 0 on the next channel enable (that's the theory anyway, the imx6 TRM
305 * only says these are read-only registers). This operation is required
306 * for channel linking to work correctly, for instance video capture
307 * pipelines that carry out image rotations will fail after the first
308 * streaming unless this function is called for each channel before
309 * re-enabling the channels.
311 static void __ipu_idmac_reset_current_buffer(struct ipuv3_channel *channel)
313 struct ipu_soc *ipu = channel->ipu;
314 unsigned int chno = channel->num;
316 ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_CUR_BUF(chno));
319 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
322 struct ipu_soc *ipu = channel->ipu;
326 spin_lock_irqsave(&ipu->lock, flags);
328 reg = ipu_cm_read(ipu, IPU_CHA_DB_MODE_SEL(channel->num));
330 reg |= idma_mask(channel->num);
332 reg &= ~idma_mask(channel->num);
333 ipu_cm_write(ipu, reg, IPU_CHA_DB_MODE_SEL(channel->num));
335 __ipu_idmac_reset_current_buffer(channel);
337 spin_unlock_irqrestore(&ipu->lock, flags);
339 EXPORT_SYMBOL_GPL(ipu_idmac_set_double_buffer);
341 static const struct {
345 } idmac_lock_en_info[] = {
346 { .chnum = 5, .reg = IDMAC_CH_LOCK_EN_1, .shift = 0, },
347 { .chnum = 11, .reg = IDMAC_CH_LOCK_EN_1, .shift = 2, },
348 { .chnum = 12, .reg = IDMAC_CH_LOCK_EN_1, .shift = 4, },
349 { .chnum = 14, .reg = IDMAC_CH_LOCK_EN_1, .shift = 6, },
350 { .chnum = 15, .reg = IDMAC_CH_LOCK_EN_1, .shift = 8, },
351 { .chnum = 20, .reg = IDMAC_CH_LOCK_EN_1, .shift = 10, },
352 { .chnum = 21, .reg = IDMAC_CH_LOCK_EN_1, .shift = 12, },
353 { .chnum = 22, .reg = IDMAC_CH_LOCK_EN_1, .shift = 14, },
354 { .chnum = 23, .reg = IDMAC_CH_LOCK_EN_1, .shift = 16, },
355 { .chnum = 27, .reg = IDMAC_CH_LOCK_EN_1, .shift = 18, },
356 { .chnum = 28, .reg = IDMAC_CH_LOCK_EN_1, .shift = 20, },
357 { .chnum = 45, .reg = IDMAC_CH_LOCK_EN_2, .shift = 0, },
358 { .chnum = 46, .reg = IDMAC_CH_LOCK_EN_2, .shift = 2, },
359 { .chnum = 47, .reg = IDMAC_CH_LOCK_EN_2, .shift = 4, },
360 { .chnum = 48, .reg = IDMAC_CH_LOCK_EN_2, .shift = 6, },
361 { .chnum = 49, .reg = IDMAC_CH_LOCK_EN_2, .shift = 8, },
362 { .chnum = 50, .reg = IDMAC_CH_LOCK_EN_2, .shift = 10, },
365 int ipu_idmac_lock_enable(struct ipuv3_channel *channel, int num_bursts)
367 struct ipu_soc *ipu = channel->ipu;
372 switch (num_bursts) {
375 bursts = 0x00; /* locking disabled */
390 for (i = 0; i < ARRAY_SIZE(idmac_lock_en_info); i++) {
391 if (channel->num == idmac_lock_en_info[i].chnum)
394 if (i >= ARRAY_SIZE(idmac_lock_en_info))
397 spin_lock_irqsave(&ipu->lock, flags);
399 regval = ipu_idmac_read(ipu, idmac_lock_en_info[i].reg);
400 regval &= ~(0x03 << idmac_lock_en_info[i].shift);
401 regval |= (bursts << idmac_lock_en_info[i].shift);
402 ipu_idmac_write(ipu, regval, idmac_lock_en_info[i].reg);
404 spin_unlock_irqrestore(&ipu->lock, flags);
408 EXPORT_SYMBOL_GPL(ipu_idmac_lock_enable);
410 int ipu_module_enable(struct ipu_soc *ipu, u32 mask)
412 unsigned long lock_flags;
415 spin_lock_irqsave(&ipu->lock, lock_flags);
417 val = ipu_cm_read(ipu, IPU_DISP_GEN);
419 if (mask & IPU_CONF_DI0_EN)
420 val |= IPU_DI0_COUNTER_RELEASE;
421 if (mask & IPU_CONF_DI1_EN)
422 val |= IPU_DI1_COUNTER_RELEASE;
424 ipu_cm_write(ipu, val, IPU_DISP_GEN);
426 val = ipu_cm_read(ipu, IPU_CONF);
428 ipu_cm_write(ipu, val, IPU_CONF);
430 spin_unlock_irqrestore(&ipu->lock, lock_flags);
434 EXPORT_SYMBOL_GPL(ipu_module_enable);
436 int ipu_module_disable(struct ipu_soc *ipu, u32 mask)
438 unsigned long lock_flags;
441 spin_lock_irqsave(&ipu->lock, lock_flags);
443 val = ipu_cm_read(ipu, IPU_CONF);
445 ipu_cm_write(ipu, val, IPU_CONF);
447 val = ipu_cm_read(ipu, IPU_DISP_GEN);
449 if (mask & IPU_CONF_DI0_EN)
450 val &= ~IPU_DI0_COUNTER_RELEASE;
451 if (mask & IPU_CONF_DI1_EN)
452 val &= ~IPU_DI1_COUNTER_RELEASE;
454 ipu_cm_write(ipu, val, IPU_DISP_GEN);
456 spin_unlock_irqrestore(&ipu->lock, lock_flags);
460 EXPORT_SYMBOL_GPL(ipu_module_disable);
462 int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel)
464 struct ipu_soc *ipu = channel->ipu;
465 unsigned int chno = channel->num;
467 return (ipu_cm_read(ipu, IPU_CHA_CUR_BUF(chno)) & idma_mask(chno)) ? 1 : 0;
469 EXPORT_SYMBOL_GPL(ipu_idmac_get_current_buffer);
471 bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num)
473 struct ipu_soc *ipu = channel->ipu;
477 spin_lock_irqsave(&ipu->lock, flags);
480 reg = ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(channel->num));
483 reg = ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(channel->num));
486 reg = ipu_cm_read(ipu, IPU_CHA_BUF2_RDY(channel->num));
489 spin_unlock_irqrestore(&ipu->lock, flags);
491 return ((reg & idma_mask(channel->num)) != 0);
493 EXPORT_SYMBOL_GPL(ipu_idmac_buffer_is_ready);
495 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
497 struct ipu_soc *ipu = channel->ipu;
498 unsigned int chno = channel->num;
501 spin_lock_irqsave(&ipu->lock, flags);
503 /* Mark buffer as ready. */
505 ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF0_RDY(chno));
507 ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF1_RDY(chno));
509 spin_unlock_irqrestore(&ipu->lock, flags);
511 EXPORT_SYMBOL_GPL(ipu_idmac_select_buffer);
513 void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num)
515 struct ipu_soc *ipu = channel->ipu;
516 unsigned int chno = channel->num;
519 spin_lock_irqsave(&ipu->lock, flags);
521 ipu_cm_write(ipu, 0xF0300000, IPU_GPR); /* write one to clear */
524 ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF0_RDY(chno));
527 ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF1_RDY(chno));
530 ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF2_RDY(chno));
535 ipu_cm_write(ipu, 0x0, IPU_GPR); /* write one to set */
537 spin_unlock_irqrestore(&ipu->lock, flags);
539 EXPORT_SYMBOL_GPL(ipu_idmac_clear_buffer);
541 int ipu_idmac_enable_channel(struct ipuv3_channel *channel)
543 struct ipu_soc *ipu = channel->ipu;
547 spin_lock_irqsave(&ipu->lock, flags);
549 val = ipu_idmac_read(ipu, IDMAC_CHA_EN(channel->num));
550 val |= idma_mask(channel->num);
551 ipu_idmac_write(ipu, val, IDMAC_CHA_EN(channel->num));
553 spin_unlock_irqrestore(&ipu->lock, flags);
557 EXPORT_SYMBOL_GPL(ipu_idmac_enable_channel);
559 bool ipu_idmac_channel_busy(struct ipu_soc *ipu, unsigned int chno)
561 return (ipu_idmac_read(ipu, IDMAC_CHA_BUSY(chno)) & idma_mask(chno));
563 EXPORT_SYMBOL_GPL(ipu_idmac_channel_busy);
565 int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms)
567 struct ipu_soc *ipu = channel->ipu;
568 unsigned long timeout;
570 timeout = jiffies + msecs_to_jiffies(ms);
571 while (ipu_idmac_read(ipu, IDMAC_CHA_BUSY(channel->num)) &
572 idma_mask(channel->num)) {
573 if (time_after(jiffies, timeout))
580 EXPORT_SYMBOL_GPL(ipu_idmac_wait_busy);
582 int ipu_wait_interrupt(struct ipu_soc *ipu, int irq, int ms)
584 unsigned long timeout;
586 timeout = jiffies + msecs_to_jiffies(ms);
587 ipu_cm_write(ipu, BIT(irq % 32), IPU_INT_STAT(irq / 32));
588 while (!(ipu_cm_read(ipu, IPU_INT_STAT(irq / 32) & BIT(irq % 32)))) {
589 if (time_after(jiffies, timeout))
596 EXPORT_SYMBOL_GPL(ipu_wait_interrupt);
598 int ipu_idmac_disable_channel(struct ipuv3_channel *channel)
600 struct ipu_soc *ipu = channel->ipu;
604 spin_lock_irqsave(&ipu->lock, flags);
606 /* Disable DMA channel(s) */
607 val = ipu_idmac_read(ipu, IDMAC_CHA_EN(channel->num));
608 val &= ~idma_mask(channel->num);
609 ipu_idmac_write(ipu, val, IDMAC_CHA_EN(channel->num));
611 __ipu_idmac_reset_current_buffer(channel);
613 /* Set channel buffers NOT to be ready */
614 ipu_cm_write(ipu, 0xf0000000, IPU_GPR); /* write one to clear */
616 if (ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(channel->num)) &
617 idma_mask(channel->num)) {
618 ipu_cm_write(ipu, idma_mask(channel->num),
619 IPU_CHA_BUF0_RDY(channel->num));
622 if (ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(channel->num)) &
623 idma_mask(channel->num)) {
624 ipu_cm_write(ipu, idma_mask(channel->num),
625 IPU_CHA_BUF1_RDY(channel->num));
628 ipu_cm_write(ipu, 0x0, IPU_GPR); /* write one to set */
630 /* Reset the double buffer */
631 val = ipu_cm_read(ipu, IPU_CHA_DB_MODE_SEL(channel->num));
632 val &= ~idma_mask(channel->num);
633 ipu_cm_write(ipu, val, IPU_CHA_DB_MODE_SEL(channel->num));
635 spin_unlock_irqrestore(&ipu->lock, flags);
639 EXPORT_SYMBOL_GPL(ipu_idmac_disable_channel);
642 * The imx6 rev. D TRM says that enabling the WM feature will increase
643 * a channel's priority. Refer to Table 36-8 Calculated priority value.
644 * The sub-module that is the sink or source for the channel must enable
645 * watermark signal for this to take effect (SMFC_WM for instance).
647 void ipu_idmac_enable_watermark(struct ipuv3_channel *channel, bool enable)
649 struct ipu_soc *ipu = channel->ipu;
653 spin_lock_irqsave(&ipu->lock, flags);
655 val = ipu_idmac_read(ipu, IDMAC_WM_EN(channel->num));
657 val |= 1 << (channel->num % 32);
659 val &= ~(1 << (channel->num % 32));
660 ipu_idmac_write(ipu, val, IDMAC_WM_EN(channel->num));
662 spin_unlock_irqrestore(&ipu->lock, flags);
664 EXPORT_SYMBOL_GPL(ipu_idmac_enable_watermark);
666 static int ipu_memory_reset(struct ipu_soc *ipu)
668 unsigned long timeout;
670 ipu_cm_write(ipu, 0x807FFFFF, IPU_MEM_RST);
672 timeout = jiffies + msecs_to_jiffies(1000);
673 while (ipu_cm_read(ipu, IPU_MEM_RST) & 0x80000000) {
674 if (time_after(jiffies, timeout))
683 * Set the source mux for the given CSI. Selects either parallel or
686 void ipu_set_csi_src_mux(struct ipu_soc *ipu, int csi_id, bool mipi_csi2)
691 mask = (csi_id == 1) ? IPU_CONF_CSI1_DATA_SOURCE :
692 IPU_CONF_CSI0_DATA_SOURCE;
694 spin_lock_irqsave(&ipu->lock, flags);
696 val = ipu_cm_read(ipu, IPU_CONF);
701 ipu_cm_write(ipu, val, IPU_CONF);
703 spin_unlock_irqrestore(&ipu->lock, flags);
705 EXPORT_SYMBOL_GPL(ipu_set_csi_src_mux);
708 * Set the source mux for the IC. Selects either CSI[01] or the VDI.
710 void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi)
715 spin_lock_irqsave(&ipu->lock, flags);
717 val = ipu_cm_read(ipu, IPU_CONF);
719 val |= IPU_CONF_IC_INPUT;
721 val &= ~IPU_CONF_IC_INPUT;
724 val |= IPU_CONF_CSI_SEL;
726 val &= ~IPU_CONF_CSI_SEL;
728 ipu_cm_write(ipu, val, IPU_CONF);
730 spin_unlock_irqrestore(&ipu->lock, flags);
732 EXPORT_SYMBOL_GPL(ipu_set_ic_src_mux);
735 /* Frame Synchronization Unit Channel Linking */
737 struct fsu_link_reg_info {
744 struct fsu_link_info {
745 struct fsu_link_reg_info src;
746 struct fsu_link_reg_info sink;
749 static const struct fsu_link_info fsu_link_info[] = {
751 .src = { IPUV3_CHANNEL_IC_PRP_ENC_MEM, IPU_FS_PROC_FLOW2,
752 FS_PRP_ENC_DEST_SEL_MASK, FS_PRP_ENC_DEST_SEL_IRT_ENC },
753 .sink = { IPUV3_CHANNEL_MEM_ROT_ENC, IPU_FS_PROC_FLOW1,
754 FS_PRPENC_ROT_SRC_SEL_MASK, FS_PRPENC_ROT_SRC_SEL_ENC },
756 .src = { IPUV3_CHANNEL_IC_PRP_VF_MEM, IPU_FS_PROC_FLOW2,
757 FS_PRPVF_DEST_SEL_MASK, FS_PRPVF_DEST_SEL_IRT_VF },
758 .sink = { IPUV3_CHANNEL_MEM_ROT_VF, IPU_FS_PROC_FLOW1,
759 FS_PRPVF_ROT_SRC_SEL_MASK, FS_PRPVF_ROT_SRC_SEL_VF },
761 .src = { IPUV3_CHANNEL_IC_PP_MEM, IPU_FS_PROC_FLOW2,
762 FS_PP_DEST_SEL_MASK, FS_PP_DEST_SEL_IRT_PP },
763 .sink = { IPUV3_CHANNEL_MEM_ROT_PP, IPU_FS_PROC_FLOW1,
764 FS_PP_ROT_SRC_SEL_MASK, FS_PP_ROT_SRC_SEL_PP },
766 .src = { IPUV3_CHANNEL_CSI_DIRECT, 0 },
767 .sink = { IPUV3_CHANNEL_CSI_VDI_PREV, IPU_FS_PROC_FLOW1,
768 FS_VDI_SRC_SEL_MASK, FS_VDI_SRC_SEL_CSI_DIRECT },
772 static const struct fsu_link_info *find_fsu_link_info(int src, int sink)
776 for (i = 0; i < ARRAY_SIZE(fsu_link_info); i++) {
777 if (src == fsu_link_info[i].src.chno &&
778 sink == fsu_link_info[i].sink.chno)
779 return &fsu_link_info[i];
786 * Links a source channel to a sink channel in the FSU.
788 int ipu_fsu_link(struct ipu_soc *ipu, int src_ch, int sink_ch)
790 const struct fsu_link_info *link;
791 u32 src_reg, sink_reg;
794 link = find_fsu_link_info(src_ch, sink_ch);
798 spin_lock_irqsave(&ipu->lock, flags);
800 if (link->src.mask) {
801 src_reg = ipu_cm_read(ipu, link->src.reg);
802 src_reg &= ~link->src.mask;
803 src_reg |= link->src.val;
804 ipu_cm_write(ipu, src_reg, link->src.reg);
807 if (link->sink.mask) {
808 sink_reg = ipu_cm_read(ipu, link->sink.reg);
809 sink_reg &= ~link->sink.mask;
810 sink_reg |= link->sink.val;
811 ipu_cm_write(ipu, sink_reg, link->sink.reg);
814 spin_unlock_irqrestore(&ipu->lock, flags);
817 EXPORT_SYMBOL_GPL(ipu_fsu_link);
820 * Unlinks source and sink channels in the FSU.
822 int ipu_fsu_unlink(struct ipu_soc *ipu, int src_ch, int sink_ch)
824 const struct fsu_link_info *link;
825 u32 src_reg, sink_reg;
828 link = find_fsu_link_info(src_ch, sink_ch);
832 spin_lock_irqsave(&ipu->lock, flags);
834 if (link->src.mask) {
835 src_reg = ipu_cm_read(ipu, link->src.reg);
836 src_reg &= ~link->src.mask;
837 ipu_cm_write(ipu, src_reg, link->src.reg);
840 if (link->sink.mask) {
841 sink_reg = ipu_cm_read(ipu, link->sink.reg);
842 sink_reg &= ~link->sink.mask;
843 ipu_cm_write(ipu, sink_reg, link->sink.reg);
846 spin_unlock_irqrestore(&ipu->lock, flags);
849 EXPORT_SYMBOL_GPL(ipu_fsu_unlink);
851 /* Link IDMAC channels in the FSU */
852 int ipu_idmac_link(struct ipuv3_channel *src, struct ipuv3_channel *sink)
854 return ipu_fsu_link(src->ipu, src->num, sink->num);
856 EXPORT_SYMBOL_GPL(ipu_idmac_link);
858 /* Unlink IDMAC channels in the FSU */
859 int ipu_idmac_unlink(struct ipuv3_channel *src, struct ipuv3_channel *sink)
861 return ipu_fsu_unlink(src->ipu, src->num, sink->num);
863 EXPORT_SYMBOL_GPL(ipu_idmac_unlink);
867 unsigned long cm_ofs;
868 unsigned long cpmem_ofs;
869 unsigned long srm_ofs;
870 unsigned long tpm_ofs;
871 unsigned long csi0_ofs;
872 unsigned long csi1_ofs;
873 unsigned long ic_ofs;
874 unsigned long disp0_ofs;
875 unsigned long disp1_ofs;
876 unsigned long dc_tmpl_ofs;
877 unsigned long vdi_ofs;
878 enum ipuv3_type type;
881 static struct ipu_devtype ipu_type_imx51 = {
883 .cm_ofs = 0x1e000000,
884 .cpmem_ofs = 0x1f000000,
885 .srm_ofs = 0x1f040000,
886 .tpm_ofs = 0x1f060000,
887 .csi0_ofs = 0x1e030000,
888 .csi1_ofs = 0x1e038000,
889 .ic_ofs = 0x1e020000,
890 .disp0_ofs = 0x1e040000,
891 .disp1_ofs = 0x1e048000,
892 .dc_tmpl_ofs = 0x1f080000,
893 .vdi_ofs = 0x1e068000,
897 static struct ipu_devtype ipu_type_imx53 = {
899 .cm_ofs = 0x06000000,
900 .cpmem_ofs = 0x07000000,
901 .srm_ofs = 0x07040000,
902 .tpm_ofs = 0x07060000,
903 .csi0_ofs = 0x06030000,
904 .csi1_ofs = 0x06038000,
905 .ic_ofs = 0x06020000,
906 .disp0_ofs = 0x06040000,
907 .disp1_ofs = 0x06048000,
908 .dc_tmpl_ofs = 0x07080000,
909 .vdi_ofs = 0x06068000,
913 static struct ipu_devtype ipu_type_imx6q = {
915 .cm_ofs = 0x00200000,
916 .cpmem_ofs = 0x00300000,
917 .srm_ofs = 0x00340000,
918 .tpm_ofs = 0x00360000,
919 .csi0_ofs = 0x00230000,
920 .csi1_ofs = 0x00238000,
921 .ic_ofs = 0x00220000,
922 .disp0_ofs = 0x00240000,
923 .disp1_ofs = 0x00248000,
924 .dc_tmpl_ofs = 0x00380000,
925 .vdi_ofs = 0x00268000,
929 static const struct of_device_id imx_ipu_dt_ids[] = {
930 { .compatible = "fsl,imx51-ipu", .data = &ipu_type_imx51, },
931 { .compatible = "fsl,imx53-ipu", .data = &ipu_type_imx53, },
932 { .compatible = "fsl,imx6q-ipu", .data = &ipu_type_imx6q, },
935 MODULE_DEVICE_TABLE(of, imx_ipu_dt_ids);
937 static int ipu_submodules_init(struct ipu_soc *ipu,
938 struct platform_device *pdev, unsigned long ipu_base,
943 struct device *dev = &pdev->dev;
944 const struct ipu_devtype *devtype = ipu->devtype;
946 ret = ipu_cpmem_init(ipu, dev, ipu_base + devtype->cpmem_ofs);
952 ret = ipu_csi_init(ipu, dev, 0, ipu_base + devtype->csi0_ofs,
953 IPU_CONF_CSI0_EN, ipu_clk);
959 ret = ipu_csi_init(ipu, dev, 1, ipu_base + devtype->csi1_ofs,
960 IPU_CONF_CSI1_EN, ipu_clk);
966 ret = ipu_ic_init(ipu, dev,
967 ipu_base + devtype->ic_ofs,
968 ipu_base + devtype->tpm_ofs);
974 ret = ipu_vdi_init(ipu, dev, ipu_base + devtype->vdi_ofs,
975 IPU_CONF_VDI_EN | IPU_CONF_ISP_EN |
982 ret = ipu_image_convert_init(ipu, dev);
984 unit = "image_convert";
985 goto err_image_convert;
988 ret = ipu_di_init(ipu, dev, 0, ipu_base + devtype->disp0_ofs,
989 IPU_CONF_DI0_EN, ipu_clk);
995 ret = ipu_di_init(ipu, dev, 1, ipu_base + devtype->disp1_ofs,
996 IPU_CONF_DI1_EN, ipu_clk);
1002 ret = ipu_dc_init(ipu, dev, ipu_base + devtype->cm_ofs +
1003 IPU_CM_DC_REG_OFS, ipu_base + devtype->dc_tmpl_ofs);
1005 unit = "dc_template";
1009 ret = ipu_dmfc_init(ipu, dev, ipu_base +
1010 devtype->cm_ofs + IPU_CM_DMFC_REG_OFS, ipu_clk);
1016 ret = ipu_dp_init(ipu, dev, ipu_base + devtype->srm_ofs);
1022 ret = ipu_smfc_init(ipu, dev, ipu_base +
1023 devtype->cm_ofs + IPU_CM_SMFC_REG_OFS);
1038 ipu_di_exit(ipu, 1);
1040 ipu_di_exit(ipu, 0);
1042 ipu_image_convert_exit(ipu);
1048 ipu_csi_exit(ipu, 1);
1050 ipu_csi_exit(ipu, 0);
1052 ipu_cpmem_exit(ipu);
1054 dev_err(&pdev->dev, "init %s failed with %d\n", unit, ret);
1058 static void ipu_irq_handle(struct ipu_soc *ipu, const int *regs, int num_regs)
1060 unsigned long status;
1063 for (i = 0; i < num_regs; i++) {
1065 status = ipu_cm_read(ipu, IPU_INT_STAT(regs[i]));
1066 status &= ipu_cm_read(ipu, IPU_INT_CTRL(regs[i]));
1068 for_each_set_bit(bit, &status, 32) {
1069 irq = irq_linear_revmap(ipu->domain,
1070 regs[i] * 32 + bit);
1072 generic_handle_irq(irq);
1077 static void ipu_irq_handler(struct irq_desc *desc)
1079 struct ipu_soc *ipu = irq_desc_get_handler_data(desc);
1080 struct irq_chip *chip = irq_desc_get_chip(desc);
1081 const int int_reg[] = { 0, 1, 2, 3, 10, 11, 12, 13, 14};
1083 chained_irq_enter(chip, desc);
1085 ipu_irq_handle(ipu, int_reg, ARRAY_SIZE(int_reg));
1087 chained_irq_exit(chip, desc);
1090 static void ipu_err_irq_handler(struct irq_desc *desc)
1092 struct ipu_soc *ipu = irq_desc_get_handler_data(desc);
1093 struct irq_chip *chip = irq_desc_get_chip(desc);
1094 const int int_reg[] = { 4, 5, 8, 9};
1096 chained_irq_enter(chip, desc);
1098 ipu_irq_handle(ipu, int_reg, ARRAY_SIZE(int_reg));
1100 chained_irq_exit(chip, desc);
1103 int ipu_map_irq(struct ipu_soc *ipu, int irq)
1107 virq = irq_linear_revmap(ipu->domain, irq);
1109 virq = irq_create_mapping(ipu->domain, irq);
1113 EXPORT_SYMBOL_GPL(ipu_map_irq);
1115 int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
1116 enum ipu_channel_irq irq_type)
1118 return ipu_map_irq(ipu, irq_type + channel->num);
1120 EXPORT_SYMBOL_GPL(ipu_idmac_channel_irq);
1122 static void ipu_submodules_exit(struct ipu_soc *ipu)
1128 ipu_di_exit(ipu, 1);
1129 ipu_di_exit(ipu, 0);
1130 ipu_image_convert_exit(ipu);
1133 ipu_csi_exit(ipu, 1);
1134 ipu_csi_exit(ipu, 0);
1135 ipu_cpmem_exit(ipu);
1138 static int platform_remove_devices_fn(struct device *dev, void *unused)
1140 struct platform_device *pdev = to_platform_device(dev);
1142 platform_device_unregister(pdev);
1147 static void platform_device_unregister_children(struct platform_device *pdev)
1149 device_for_each_child(&pdev->dev, NULL, platform_remove_devices_fn);
1152 struct ipu_platform_reg {
1153 struct ipu_client_platformdata pdata;
1157 /* These must be in the order of the corresponding device tree port nodes */
1158 static struct ipu_platform_reg client_reg[] = {
1162 .dma[0] = IPUV3_CHANNEL_CSI0,
1165 .name = "imx-ipuv3-csi",
1169 .dma[0] = IPUV3_CHANNEL_CSI1,
1172 .name = "imx-ipuv3-csi",
1177 .dp = IPU_DP_FLOW_SYNC_BG,
1178 .dma[0] = IPUV3_CHANNEL_MEM_BG_SYNC,
1179 .dma[1] = IPUV3_CHANNEL_MEM_FG_SYNC,
1181 .name = "imx-ipuv3-crtc",
1187 .dma[0] = IPUV3_CHANNEL_MEM_DC_SYNC,
1190 .name = "imx-ipuv3-crtc",
1194 static DEFINE_MUTEX(ipu_client_id_mutex);
1195 static int ipu_client_id;
1197 static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
1199 struct device *dev = ipu->dev;
1203 mutex_lock(&ipu_client_id_mutex);
1205 ipu_client_id += ARRAY_SIZE(client_reg);
1206 mutex_unlock(&ipu_client_id_mutex);
1208 for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
1209 struct ipu_platform_reg *reg = &client_reg[i];
1210 struct platform_device *pdev;
1211 struct device_node *of_node;
1213 /* Associate subdevice with the corresponding port node */
1214 of_node = of_graph_get_port_by_id(dev->of_node, i);
1217 "no port@%d node in %s, not using %s%d\n",
1218 i, dev->of_node->full_name,
1219 (i / 2) ? "DI" : "CSI", i % 2);
1223 pdev = platform_device_alloc(reg->name, id++);
1229 pdev->dev.parent = dev;
1231 reg->pdata.of_node = of_node;
1232 ret = platform_device_add_data(pdev, ®->pdata,
1233 sizeof(reg->pdata));
1235 ret = platform_device_add(pdev);
1237 platform_device_put(pdev);
1242 * Set of_node only after calling platform_device_add. Otherwise
1243 * the platform:imx-ipuv3-crtc modalias won't be used.
1245 pdev->dev.of_node = of_node;
1251 platform_device_unregister_children(to_platform_device(dev));
1257 static int ipu_irq_init(struct ipu_soc *ipu)
1259 struct irq_chip_generic *gc;
1260 struct irq_chip_type *ct;
1261 unsigned long unused[IPU_NUM_IRQS / 32] = {
1262 0x400100d0, 0xffe000fd,
1263 0x400100d0, 0xffe000fd,
1264 0x400100d0, 0xffe000fd,
1265 0x4077ffff, 0xffe7e1fd,
1266 0x23fffffe, 0x8880fff0,
1267 0xf98fe7d0, 0xfff81fff,
1268 0x400100d0, 0xffe000fd,
1273 ipu->domain = irq_domain_add_linear(ipu->dev->of_node, IPU_NUM_IRQS,
1274 &irq_generic_chip_ops, ipu);
1276 dev_err(ipu->dev, "failed to add irq domain\n");
1280 ret = irq_alloc_domain_generic_chips(ipu->domain, 32, 1, "IPU",
1281 handle_level_irq, 0, 0, 0);
1283 dev_err(ipu->dev, "failed to alloc generic irq chips\n");
1284 irq_domain_remove(ipu->domain);
1288 for (i = 0; i < IPU_NUM_IRQS; i += 32)
1289 ipu_cm_write(ipu, 0, IPU_INT_CTRL(i / 32));
1291 for (i = 0; i < IPU_NUM_IRQS; i += 32) {
1292 gc = irq_get_domain_generic_chip(ipu->domain, i);
1293 gc->reg_base = ipu->cm_reg;
1294 gc->unused = unused[i / 32];
1295 ct = gc->chip_types;
1296 ct->chip.irq_ack = irq_gc_ack_set_bit;
1297 ct->chip.irq_mask = irq_gc_mask_clr_bit;
1298 ct->chip.irq_unmask = irq_gc_mask_set_bit;
1299 ct->regs.ack = IPU_INT_STAT(i / 32);
1300 ct->regs.mask = IPU_INT_CTRL(i / 32);
1303 irq_set_chained_handler_and_data(ipu->irq_sync, ipu_irq_handler, ipu);
1304 irq_set_chained_handler_and_data(ipu->irq_err, ipu_err_irq_handler,
1310 static void ipu_irq_exit(struct ipu_soc *ipu)
1314 irq_set_chained_handler_and_data(ipu->irq_err, NULL, NULL);
1315 irq_set_chained_handler_and_data(ipu->irq_sync, NULL, NULL);
1317 /* TODO: remove irq_domain_generic_chips */
1319 for (i = 0; i < IPU_NUM_IRQS; i++) {
1320 irq = irq_linear_revmap(ipu->domain, i);
1322 irq_dispose_mapping(irq);
1325 irq_domain_remove(ipu->domain);
1328 void ipu_dump(struct ipu_soc *ipu)
1332 dev_dbg(ipu->dev, "IPU_CONF = \t0x%08X\n",
1333 ipu_cm_read(ipu, IPU_CONF));
1334 dev_dbg(ipu->dev, "IDMAC_CONF = \t0x%08X\n",
1335 ipu_idmac_read(ipu, IDMAC_CONF));
1336 dev_dbg(ipu->dev, "IDMAC_CHA_EN1 = \t0x%08X\n",
1337 ipu_idmac_read(ipu, IDMAC_CHA_EN(0)));
1338 dev_dbg(ipu->dev, "IDMAC_CHA_EN2 = \t0x%08X\n",
1339 ipu_idmac_read(ipu, IDMAC_CHA_EN(32)));
1340 dev_dbg(ipu->dev, "IDMAC_CHA_PRI1 = \t0x%08X\n",
1341 ipu_idmac_read(ipu, IDMAC_CHA_PRI(0)));
1342 dev_dbg(ipu->dev, "IDMAC_CHA_PRI2 = \t0x%08X\n",
1343 ipu_idmac_read(ipu, IDMAC_CHA_PRI(32)));
1344 dev_dbg(ipu->dev, "IDMAC_BAND_EN1 = \t0x%08X\n",
1345 ipu_idmac_read(ipu, IDMAC_BAND_EN(0)));
1346 dev_dbg(ipu->dev, "IDMAC_BAND_EN2 = \t0x%08X\n",
1347 ipu_idmac_read(ipu, IDMAC_BAND_EN(32)));
1348 dev_dbg(ipu->dev, "IPU_CHA_DB_MODE_SEL0 = \t0x%08X\n",
1349 ipu_cm_read(ipu, IPU_CHA_DB_MODE_SEL(0)));
1350 dev_dbg(ipu->dev, "IPU_CHA_DB_MODE_SEL1 = \t0x%08X\n",
1351 ipu_cm_read(ipu, IPU_CHA_DB_MODE_SEL(32)));
1352 dev_dbg(ipu->dev, "IPU_FS_PROC_FLOW1 = \t0x%08X\n",
1353 ipu_cm_read(ipu, IPU_FS_PROC_FLOW1));
1354 dev_dbg(ipu->dev, "IPU_FS_PROC_FLOW2 = \t0x%08X\n",
1355 ipu_cm_read(ipu, IPU_FS_PROC_FLOW2));
1356 dev_dbg(ipu->dev, "IPU_FS_PROC_FLOW3 = \t0x%08X\n",
1357 ipu_cm_read(ipu, IPU_FS_PROC_FLOW3));
1358 dev_dbg(ipu->dev, "IPU_FS_DISP_FLOW1 = \t0x%08X\n",
1359 ipu_cm_read(ipu, IPU_FS_DISP_FLOW1));
1360 for (i = 0; i < 15; i++)
1361 dev_dbg(ipu->dev, "IPU_INT_CTRL(%d) = \t%08X\n", i,
1362 ipu_cm_read(ipu, IPU_INT_CTRL(i)));
1364 EXPORT_SYMBOL_GPL(ipu_dump);
1366 static int ipu_probe(struct platform_device *pdev)
1368 struct device_node *np = pdev->dev.of_node;
1369 struct ipu_soc *ipu;
1370 struct resource *res;
1371 unsigned long ipu_base;
1372 int i, ret, irq_sync, irq_err;
1373 const struct ipu_devtype *devtype;
1375 devtype = of_device_get_match_data(&pdev->dev);
1379 irq_sync = platform_get_irq(pdev, 0);
1380 irq_err = platform_get_irq(pdev, 1);
1381 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1383 dev_dbg(&pdev->dev, "irq_sync: %d irq_err: %d\n",
1386 if (!res || irq_sync < 0 || irq_err < 0)
1389 ipu_base = res->start;
1391 ipu = devm_kzalloc(&pdev->dev, sizeof(*ipu), GFP_KERNEL);
1395 for (i = 0; i < 64; i++)
1396 ipu->channel[i].ipu = ipu;
1397 ipu->devtype = devtype;
1398 ipu->ipu_type = devtype->type;
1399 ipu->id = of_alias_get_id(np, "ipu");
1401 spin_lock_init(&ipu->lock);
1402 mutex_init(&ipu->channel_lock);
1404 dev_dbg(&pdev->dev, "cm_reg: 0x%08lx\n",
1405 ipu_base + devtype->cm_ofs);
1406 dev_dbg(&pdev->dev, "idmac: 0x%08lx\n",
1407 ipu_base + devtype->cm_ofs + IPU_CM_IDMAC_REG_OFS);
1408 dev_dbg(&pdev->dev, "cpmem: 0x%08lx\n",
1409 ipu_base + devtype->cpmem_ofs);
1410 dev_dbg(&pdev->dev, "csi0: 0x%08lx\n",
1411 ipu_base + devtype->csi0_ofs);
1412 dev_dbg(&pdev->dev, "csi1: 0x%08lx\n",
1413 ipu_base + devtype->csi1_ofs);
1414 dev_dbg(&pdev->dev, "ic: 0x%08lx\n",
1415 ipu_base + devtype->ic_ofs);
1416 dev_dbg(&pdev->dev, "disp0: 0x%08lx\n",
1417 ipu_base + devtype->disp0_ofs);
1418 dev_dbg(&pdev->dev, "disp1: 0x%08lx\n",
1419 ipu_base + devtype->disp1_ofs);
1420 dev_dbg(&pdev->dev, "srm: 0x%08lx\n",
1421 ipu_base + devtype->srm_ofs);
1422 dev_dbg(&pdev->dev, "tpm: 0x%08lx\n",
1423 ipu_base + devtype->tpm_ofs);
1424 dev_dbg(&pdev->dev, "dc: 0x%08lx\n",
1425 ipu_base + devtype->cm_ofs + IPU_CM_DC_REG_OFS);
1426 dev_dbg(&pdev->dev, "ic: 0x%08lx\n",
1427 ipu_base + devtype->cm_ofs + IPU_CM_IC_REG_OFS);
1428 dev_dbg(&pdev->dev, "dmfc: 0x%08lx\n",
1429 ipu_base + devtype->cm_ofs + IPU_CM_DMFC_REG_OFS);
1430 dev_dbg(&pdev->dev, "vdi: 0x%08lx\n",
1431 ipu_base + devtype->vdi_ofs);
1433 ipu->cm_reg = devm_ioremap(&pdev->dev,
1434 ipu_base + devtype->cm_ofs, PAGE_SIZE);
1435 ipu->idmac_reg = devm_ioremap(&pdev->dev,
1436 ipu_base + devtype->cm_ofs + IPU_CM_IDMAC_REG_OFS,
1439 if (!ipu->cm_reg || !ipu->idmac_reg)
1442 ipu->clk = devm_clk_get(&pdev->dev, "bus");
1443 if (IS_ERR(ipu->clk)) {
1444 ret = PTR_ERR(ipu->clk);
1445 dev_err(&pdev->dev, "clk_get failed with %d", ret);
1449 platform_set_drvdata(pdev, ipu);
1451 ret = clk_prepare_enable(ipu->clk);
1453 dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n", ret);
1457 ipu->dev = &pdev->dev;
1458 ipu->irq_sync = irq_sync;
1459 ipu->irq_err = irq_err;
1461 ret = device_reset(&pdev->dev);
1463 dev_err(&pdev->dev, "failed to reset: %d\n", ret);
1464 goto out_failed_reset;
1466 ret = ipu_memory_reset(ipu);
1468 goto out_failed_reset;
1470 ret = ipu_irq_init(ipu);
1472 goto out_failed_irq;
1474 /* Set MCU_T to divide MCU access window into 2 */
1475 ipu_cm_write(ipu, 0x00400000L | (IPU_MCU_T_DEFAULT << 18),
1478 ret = ipu_submodules_init(ipu, pdev, ipu_base, ipu->clk);
1480 goto failed_submodules_init;
1482 ret = ipu_add_client_devices(ipu, ipu_base);
1484 dev_err(&pdev->dev, "adding client devices failed with %d\n",
1486 goto failed_add_clients;
1489 dev_info(&pdev->dev, "%s probed\n", devtype->name);
1494 ipu_submodules_exit(ipu);
1495 failed_submodules_init:
1499 clk_disable_unprepare(ipu->clk);
1503 static int ipu_remove(struct platform_device *pdev)
1505 struct ipu_soc *ipu = platform_get_drvdata(pdev);
1507 platform_device_unregister_children(pdev);
1508 ipu_submodules_exit(ipu);
1511 clk_disable_unprepare(ipu->clk);
1516 static struct platform_driver imx_ipu_driver = {
1518 .name = "imx-ipuv3",
1519 .of_match_table = imx_ipu_dt_ids,
1522 .remove = ipu_remove,
1525 module_platform_driver(imx_ipu_driver);
1527 MODULE_ALIAS("platform:imx-ipuv3");
1528 MODULE_DESCRIPTION("i.MX IPU v3 driver");
1529 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
1530 MODULE_LICENSE("GPL");