Lines Matching full:ipu
22 #include <linux/dma/ipu-dma.h>
36 * struct ipu *ipu = to_ipu(to_idmac(ichan->dma_chan.device));
39 static struct ipu ipu_data;
41 #define to_ipu(id) container_of(id, struct ipu, idmac)
43 static u32 __idmac_read_icreg(struct ipu *ipu, unsigned long reg) in __idmac_read_icreg() argument
45 return __raw_readl(ipu->reg_ic + reg); in __idmac_read_icreg()
48 #define idmac_read_icreg(ipu, reg) __idmac_read_icreg(ipu, reg - IC_CONF) argument
50 static void __idmac_write_icreg(struct ipu *ipu, u32 value, unsigned long reg) in __idmac_write_icreg() argument
52 __raw_writel(value, ipu->reg_ic + reg); in __idmac_write_icreg()
55 #define idmac_write_icreg(ipu, v, reg) __idmac_write_icreg(ipu, v, reg - IC_CONF) argument
57 static u32 idmac_read_ipureg(struct ipu *ipu, unsigned long reg) in idmac_read_ipureg() argument
59 return __raw_readl(ipu->reg_ipu + reg); in idmac_read_ipureg()
62 static void idmac_write_ipureg(struct ipu *ipu, u32 value, unsigned long reg) in idmac_write_ipureg() argument
64 __raw_writel(value, ipu->reg_ipu + reg); in idmac_write_ipureg()
68 * IPU / IC common functions
70 static void dump_idmac_reg(struct ipu *ipu) in dump_idmac_reg() argument
72 dev_dbg(ipu->dev, "IDMAC_CONF 0x%x, IC_CONF 0x%x, IDMAC_CHA_EN 0x%x, " in dump_idmac_reg()
74 idmac_read_icreg(ipu, IDMAC_CONF), in dump_idmac_reg()
75 idmac_read_icreg(ipu, IC_CONF), in dump_idmac_reg()
76 idmac_read_icreg(ipu, IDMAC_CHA_EN), in dump_idmac_reg()
77 idmac_read_icreg(ipu, IDMAC_CHA_PRI), in dump_idmac_reg()
78 idmac_read_icreg(ipu, IDMAC_CHA_BUSY)); in dump_idmac_reg()
79 dev_dbg(ipu->dev, "BUF0_RDY 0x%x, BUF1_RDY 0x%x, CUR_BUF 0x%x, " in dump_idmac_reg()
81 idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY), in dump_idmac_reg()
82 idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY), in dump_idmac_reg()
83 idmac_read_ipureg(ipu, IPU_CHA_CUR_BUF), in dump_idmac_reg()
84 idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL), in dump_idmac_reg()
85 idmac_read_ipureg(ipu, IPU_TASKS_STAT)); in dump_idmac_reg()
113 static void ipu_ic_enable_task(struct ipu *ipu, enum ipu_channel channel) in ipu_ic_enable_task() argument
127 ic_conf = idmac_read_icreg(ipu, IC_CONF) | mask; in ipu_ic_enable_task()
128 idmac_write_icreg(ipu, ic_conf, IC_CONF); in ipu_ic_enable_task()
132 static void ipu_ic_disable_task(struct ipu *ipu, enum ipu_channel channel) in ipu_ic_disable_task() argument
146 ic_conf = idmac_read_icreg(ipu, IC_CONF) & ~mask; in ipu_ic_disable_task()
147 idmac_write_icreg(ipu, ic_conf, IC_CONF); in ipu_ic_disable_task()
150 static uint32_t ipu_channel_status(struct ipu *ipu, enum ipu_channel channel) in ipu_channel_status() argument
153 uint32_t task_stat_reg = idmac_read_ipureg(ipu, IPU_TASKS_STAT); in ipu_channel_status()
415 "mx3 ipu: unimplemented pixel format %d\n", pixel_fmt); in ipu_ch_param_set_size()
508 static int ipu_ic_init_prpenc(struct ipu *ipu, in ipu_ic_init_prpenc() argument
536 dev_err(ipu->dev, "Colourspace conversion unsupported!\n"); in ipu_ic_init_prpenc()
540 idmac_write_icreg(ipu, reg, IC_PRP_ENC_RSC); in ipu_ic_init_prpenc()
542 ic_conf = idmac_read_icreg(ipu, IC_CONF); in ipu_ic_init_prpenc()
549 idmac_write_icreg(ipu, ic_conf, IC_CONF); in ipu_ic_init_prpenc()
560 static void ipu_channel_set_priority(struct ipu *ipu, enum ipu_channel channel, in ipu_channel_set_priority() argument
563 u32 reg = idmac_read_icreg(ipu, IDMAC_CHA_PRI); in ipu_channel_set_priority()
570 idmac_write_icreg(ipu, reg, IDMAC_CHA_PRI); in ipu_channel_set_priority()
572 dump_idmac_reg(ipu); in ipu_channel_set_priority()
597 * ipu_enable_channel() - enable an IPU channel.
598 * @idmac: IPU DMAC context.
604 struct ipu *ipu = to_ipu(idmac); in ipu_enable_channel() local
609 spin_lock_irqsave(&ipu->lock, flags); in ipu_enable_channel()
612 idmac_write_ipureg(ipu, 1UL << channel, IPU_CHA_CUR_BUF); in ipu_enable_channel()
620 ipu_channel_set_priority(ipu, channel, true); in ipu_enable_channel()
626 reg = idmac_read_icreg(ipu, IDMAC_CHA_EN); in ipu_enable_channel()
628 idmac_write_icreg(ipu, reg | (1UL << channel), IDMAC_CHA_EN); in ipu_enable_channel()
630 ipu_ic_enable_task(ipu, channel); in ipu_enable_channel()
632 spin_unlock_irqrestore(&ipu->lock, flags); in ipu_enable_channel()
637 * ipu_init_channel_buffer() - initialize a buffer for logical IPU channel.
660 struct ipu *ipu = to_ipu(idmac); in ipu_init_channel_buffer() local
669 dev_err(ipu->dev, in ipu_init_channel_buffer()
677 dev_err(ipu->dev, "Stride must be 8 pixel multiple\n"); in ipu_init_channel_buffer()
686 spin_lock_irqsave(&ipu->lock, flags); in ipu_init_channel_buffer()
690 reg = idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL); in ipu_init_channel_buffer()
697 idmac_write_ipureg(ipu, reg, IPU_CHA_DB_MODE_SEL); in ipu_init_channel_buffer()
701 spin_unlock_irqrestore(&ipu->lock, flags); in ipu_init_channel_buffer()
713 /* No locking - this is a write-one-to-set register, cleared by IPU */ in ipu_select_buffer()
825 struct ipu *ipu = to_ipu(idmac); in idmac_tx_submit() local
869 /* ipu->lock can be taken under ichan->lock, but not v.v. */ in idmac_tx_submit()
891 dump_idmac_reg(ipu); in idmac_tx_submit()
944 * ipu_init_channel() - initialize an IPU channel.
945 * @idmac: IPU DMAC context.
956 struct ipu *ipu = to_ipu(idmac); in ipu_init_channel() local
959 dev_dbg(ipu->dev, "init channel = %d\n", channel); in ipu_init_channel()
965 spin_lock_irqsave(&ipu->lock, flags); in ipu_init_channel()
970 reg = idmac_read_icreg(ipu, IC_CONF); in ipu_init_channel()
971 idmac_write_icreg(ipu, reg & ~IC_CONF_CSI_MEM_WR_EN, IC_CONF); in ipu_init_channel()
975 reg = idmac_read_ipureg(ipu, IPU_FS_PROC_FLOW); in ipu_init_channel()
976 idmac_write_ipureg(ipu, reg & ~FS_ENC_IN_VALID, IPU_FS_PROC_FLOW); in ipu_init_channel()
977 ret = ipu_ic_init_prpenc(ipu, params, true); in ipu_init_channel()
987 ipu->channel_init_mask |= 1L << channel; in ipu_init_channel()
989 /* Enable IPU sub module */ in ipu_init_channel()
990 ipu_conf = idmac_read_ipureg(ipu, IPU_CONF) | in ipu_init_channel()
992 idmac_write_ipureg(ipu, ipu_conf, IPU_CONF); in ipu_init_channel()
994 spin_unlock_irqrestore(&ipu->lock, flags); in ipu_init_channel()
999 dump_idmac_reg(ipu); in ipu_init_channel()
1005 * ipu_uninit_channel() - uninitialize an IPU channel.
1006 * @idmac: IPU DMAC context.
1016 struct ipu *ipu = to_ipu(idmac); in ipu_uninit_channel() local
1018 spin_lock_irqsave(&ipu->lock, flags); in ipu_uninit_channel()
1020 if (!(ipu->channel_init_mask & chan_mask)) { in ipu_uninit_channel()
1021 dev_err(ipu->dev, "Channel already uninitialized %d\n", in ipu_uninit_channel()
1023 spin_unlock_irqrestore(&ipu->lock, flags); in ipu_uninit_channel()
1028 reg = idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL); in ipu_uninit_channel()
1029 idmac_write_ipureg(ipu, reg & ~chan_mask, IPU_CHA_DB_MODE_SEL); in ipu_uninit_channel()
1035 reg = idmac_read_icreg(ipu, IC_CONF); in ipu_uninit_channel()
1036 idmac_write_icreg(ipu, reg & ~(IC_CONF_RWS_EN | IC_CONF_PRPENC_EN), in ipu_uninit_channel()
1040 reg = idmac_read_icreg(ipu, IC_CONF); in ipu_uninit_channel()
1041 idmac_write_icreg(ipu, reg & ~(IC_CONF_PRPENC_EN | IC_CONF_PRPENC_CSC1), in ipu_uninit_channel()
1050 ipu->channel_init_mask &= ~(1L << channel); in ipu_uninit_channel()
1052 ipu_conf = idmac_read_ipureg(ipu, IPU_CONF) & in ipu_uninit_channel()
1054 idmac_write_ipureg(ipu, ipu_conf, IPU_CONF); in ipu_uninit_channel()
1056 spin_unlock_irqrestore(&ipu->lock, flags); in ipu_uninit_channel()
1064 * ipu_disable_channel() - disable an IPU channel.
1065 * @idmac: IPU DMAC context.
1075 struct ipu *ipu = to_ipu(idmac); in ipu_disable_channel() local
1084 while ((idmac_read_icreg(ipu, IDMAC_CHA_BUSY) & chan_mask) || in ipu_disable_channel()
1085 (ipu_channel_status(ipu, channel) == TASK_STAT_ACTIVE)) { in ipu_disable_channel()
1090 dev_dbg(ipu->dev, in ipu_disable_channel()
1094 idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY), in ipu_disable_channel()
1095 idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY), in ipu_disable_channel()
1096 idmac_read_icreg(ipu, IDMAC_CHA_BUSY), in ipu_disable_channel()
1097 idmac_read_ipureg(ipu, IPU_TASKS_STAT)); in ipu_disable_channel()
1101 dev_dbg(ipu->dev, "timeout = %d * 10ms\n", 40 - timeout); in ipu_disable_channel()
1111 spin_lock_irqsave(&ipu->lock, flags); in ipu_disable_channel()
1114 ipu_ic_disable_task(ipu, channel); in ipu_disable_channel()
1117 reg = idmac_read_icreg(ipu, IDMAC_CHA_EN); in ipu_disable_channel()
1118 idmac_write_icreg(ipu, reg & ~chan_mask, IDMAC_CHA_EN); in ipu_disable_channel()
1120 spin_unlock_irqrestore(&ipu->lock, flags); in ipu_disable_channel()
1305 struct ipu *ipu = from_tasklet(ipu, t, tasklet); in ipu_gc_tasklet() local
1309 struct idmac_channel *ichan = ipu->channel + i; in ipu_gc_tasklet()
1382 struct ipu *ipu = to_ipu(idmac); in idmac_issue_pending() local
1386 spin_lock_irqsave(&ipu->lock, flags); in idmac_issue_pending()
1388 spin_unlock_irqrestore(&ipu->lock, flags); in idmac_issue_pending()
1402 struct ipu *ipu = to_ipu(idmac); in idmac_pause() local
1408 spin_lock_irqsave(&ipu->lock, flags); in idmac_pause()
1409 ipu_ic_disable_task(ipu, chan->chan_id); in idmac_pause()
1418 spin_unlock_irqrestore(&ipu->lock, flags); in idmac_pause()
1431 struct ipu *ipu = to_ipu(idmac); in __idmac_terminate_all() local
1438 tasklet_disable(&ipu->tasklet); in __idmac_terminate_all()
1458 tasklet_enable(&ipu->tasklet); in __idmac_terminate_all()
1609 static int __init ipu_idmac_init(struct ipu *ipu) in ipu_idmac_init() argument
1611 struct idmac *idmac = &ipu->idmac; in ipu_idmac_init()
1619 dma->dev = ipu->dev; in ipu_idmac_init()
1632 struct idmac_channel *ichan = ipu->channel + i; in ipu_idmac_init()
1648 idmac_write_icreg(ipu, 0x00000070, IDMAC_CONF); in ipu_idmac_init()
1653 static void ipu_idmac_exit(struct ipu *ipu) in ipu_idmac_exit() argument
1656 struct idmac *idmac = &ipu->idmac; in ipu_idmac_exit()
1659 struct idmac_channel *ichan = ipu->channel + i; in ipu_idmac_exit()
1668 * IPU common probe / remove
1701 /* Remap IPU common registers */ in ipu_probe()
1715 /* Get IPU clock */ in ipu_probe()
1722 /* Make sure IPU HSP clock is running */ in ipu_probe()
1748 dev_dbg(ipu_data.dev, "IPU initialized\n"); in ipu_probe()
1763 dev_err(&pdev->dev, "Failed to probe IPU: %d\n", ret); in ipu_probe()
1769 struct ipu *ipu = platform_get_drvdata(pdev); in ipu_remove() local
1771 ipu_idmac_exit(ipu); in ipu_remove()
1772 ipu_irq_detach_irq(ipu, pdev); in ipu_remove()
1773 clk_disable_unprepare(ipu->ipu_clk); in ipu_remove()
1774 clk_put(ipu->ipu_clk); in ipu_remove()
1775 iounmap(ipu->reg_ic); in ipu_remove()
1776 iounmap(ipu->reg_ipu); in ipu_remove()
1777 tasklet_kill(&ipu->tasklet); in ipu_remove()
1783 * We need two MEM resources - with IPU-common and Image Converter registers,
1788 .name = "ipu-core",
1799 MODULE_DESCRIPTION("IPU core driver");
1802 MODULE_ALIAS("platform:ipu-core");