5 * Stefano Babic, DENX Software Engineering, sbabic@denx.de
7 * Linux IPU driver for MX51:
9 * (C) Copyright 2005-2009 Freescale Semiconductor, Inc.
11 * SPDX-License-Identifier: GPL-2.0+
14 #ifndef __IPU_REGS_INCLUDED__
15 #define __IPU_REGS_INCLUDED__
17 #define IPU_DISP0_BASE 0x00000000
18 #define IPU_MCU_T_DEFAULT 8
19 #define IPU_DISP1_BASE (IPU_MCU_T_DEFAULT << 25)
20 #define IPU_CM_REG_BASE 0x00000000
21 #define IPU_STAT_REG_BASE 0x00000200
22 #define IPU_IDMAC_REG_BASE 0x00008000
23 #define IPU_ISP_REG_BASE 0x00010000
24 #define IPU_DP_REG_BASE 0x00018000
25 #define IPU_IC_REG_BASE 0x00020000
26 #define IPU_IRT_REG_BASE 0x00028000
27 #define IPU_CSI0_REG_BASE 0x00030000
28 #define IPU_CSI1_REG_BASE 0x00038000
29 #define IPU_DI0_REG_BASE 0x00040000
30 #define IPU_DI1_REG_BASE 0x00048000
31 #define IPU_SMFC_REG_BASE 0x00050000
32 #define IPU_DC_REG_BASE 0x00058000
33 #define IPU_DMFC_REG_BASE 0x00060000
34 #define IPU_VDI_REG_BASE 0x00680000
35 #if defined(CONFIG_MX51) || defined(CONFIG_MX53)
36 #define IPU_CPMEM_REG_BASE 0x01000000
37 #define IPU_LUT_REG_BASE 0x01020000
38 #define IPU_SRM_REG_BASE 0x01040000
39 #define IPU_TPM_REG_BASE 0x01060000
40 #define IPU_DC_TMPL_REG_BASE 0x01080000
41 #define IPU_ISP_TBPR_REG_BASE 0x010C0000
42 #elif defined(CONFIG_MX6)
43 #define IPU_CPMEM_REG_BASE 0x00100000
44 #define IPU_LUT_REG_BASE 0x00120000
45 #define IPU_SRM_REG_BASE 0x00140000
46 #define IPU_TPM_REG_BASE 0x00160000
47 #define IPU_DC_TMPL_REG_BASE 0x00180000
48 #define IPU_ISP_TBPR_REG_BASE 0x001C0000
51 #define IPU_CTRL_BASE_ADDR (IPU_SOC_BASE_ADDR + IPU_SOC_OFFSET)
53 extern u32 *ipu_dc_tmpl_reg;
58 #define DC_EVT_NFIELD 3
60 #define DC_EVT_EOFIELD 5
61 #define DC_EVT_NEW_ADDR 6
62 #define DC_EVT_NEW_CHAN 7
63 #define DC_EVT_NEW_DATA 8
65 #define DC_EVT_NEW_ADDR_W_0 0
66 #define DC_EVT_NEW_ADDR_W_1 1
67 #define DC_EVT_NEW_CHAN_W_0 2
68 #define DC_EVT_NEW_CHAN_W_1 3
69 #define DC_EVT_NEW_DATA_W_0 4
70 #define DC_EVT_NEW_DATA_W_1 5
71 #define DC_EVT_NEW_ADDR_R_0 6
72 #define DC_EVT_NEW_ADDR_R_1 7
73 #define DC_EVT_NEW_CHAN_R_0 8
74 #define DC_EVT_NEW_CHAN_R_1 9
75 #define DC_EVT_NEW_DATA_R_0 10
76 #define DC_EVT_NEW_DATA_R_1 11
78 /* Software reset for ipu */
82 IPU_CONF_DP_EN = 0x00000020,
83 IPU_CONF_DI0_EN = 0x00000040,
84 IPU_CONF_DI1_EN = 0x00000080,
85 IPU_CONF_DMFC_EN = 0x00000400,
86 IPU_CONF_DC_EN = 0x00000200,
88 DI0_COUNTER_RELEASE = 0x01000000,
89 DI1_COUNTER_RELEASE = 0x02000000,
91 DI_DW_GEN_ACCESS_SIZE_OFFSET = 24,
92 DI_DW_GEN_COMPONENT_SIZE_OFFSET = 16,
94 DI_GEN_DI_CLK_EXT = 0x100000,
95 DI_GEN_POLARITY_1 = 0x00000001,
96 DI_GEN_POLARITY_2 = 0x00000002,
97 DI_GEN_POLARITY_3 = 0x00000004,
98 DI_GEN_POLARITY_4 = 0x00000008,
99 DI_GEN_POLARITY_5 = 0x00000010,
100 DI_GEN_POLARITY_6 = 0x00000020,
101 DI_GEN_POLARITY_7 = 0x00000040,
102 DI_GEN_POLARITY_8 = 0x00000080,
103 DI_GEN_POL_CLK = 0x20000,
105 DI_POL_DRDY_DATA_POLARITY = 0x00000080,
106 DI_POL_DRDY_POLARITY_15 = 0x00000010,
107 DI_VSYNC_SEL_OFFSET = 13,
109 DC_WR_CH_CONF_FIELD_MODE = 0x00000200,
110 DC_WR_CH_CONF_PROG_TYPE_OFFSET = 5,
111 DC_WR_CH_CONF_PROG_TYPE_MASK = 0x000000E0,
112 DC_WR_CH_CONF_PROG_DI_ID = 0x00000004,
113 DC_WR_CH_CONF_PROG_DISP_ID_OFFSET = 3,
114 DC_WR_CH_CONF_PROG_DISP_ID_MASK = 0x00000018,
116 DP_COM_CONF_FG_EN = 0x00000001,
117 DP_COM_CONF_GWSEL = 0x00000002,
118 DP_COM_CONF_GWAM = 0x00000004,
119 DP_COM_CONF_GWCKE = 0x00000008,
120 DP_COM_CONF_CSC_DEF_MASK = 0x00000300,
121 DP_COM_CONF_CSC_DEF_OFFSET = 8,
122 DP_COM_CONF_CSC_DEF_FG = 0x00000300,
123 DP_COM_CONF_CSC_DEF_BG = 0x00000200,
124 DP_COM_CONF_CSC_DEF_BOTH = 0x00000100,
125 DP_COM_CONF_GAMMA_EN = 0x00001000,
126 DP_COM_CONF_GAMMA_YUV_EN = 0x00002000,
146 DI_SYNC_INT_HSYNC = 1,
173 u32 ch_db_mode_sel[2];
175 u32 alt_ch_db_mode_sel[2];
177 u32 ch_trb_mode_sel[2];
195 struct ipu_com_async {
197 u32 graph_wind_ctrl_async;
201 u32 gamma_c_async[8];
202 u32 gamma_s_async[4];
203 u32 dp_csca_async[4];
209 u32 graph_wind_ctrl_sync;
218 struct ipu_com_async async[2];
249 u32 triple_cur_buf[4];
252 u32 alt_ch_buf0_rdy[2];
253 u32 alt_ch_buf1_rdy[2];
264 struct ipu_dc_ch dc_ch0_1_2[3];
267 struct ipu_dc_ch dc_ch5_6[2];
268 struct ipu_dc_ch dc_ch8;
270 struct ipu_dc_ch dc_ch9;
282 u32 wr_ch_addr_5_alt;
300 #define IPU_CM_REG ((struct ipu_cm *)(IPU_CTRL_BASE_ADDR + \
302 #define IPU_CONF (&IPU_CM_REG->conf)
303 #define IPU_SRM_PRI1 (&IPU_CM_REG->srm_pri1)
304 #define IPU_SRM_PRI2 (&IPU_CM_REG->srm_pri2)
305 #define IPU_FS_PROC_FLOW1 (&IPU_CM_REG->fs_proc_flow[0])
306 #define IPU_FS_PROC_FLOW2 (&IPU_CM_REG->fs_proc_flow[1])
307 #define IPU_FS_PROC_FLOW3 (&IPU_CM_REG->fs_proc_flow[2])
308 #define IPU_FS_DISP_FLOW1 (&IPU_CM_REG->fs_disp_flow[0])
309 #define IPU_DISP_GEN (&IPU_CM_REG->disp_gen)
310 #define IPU_MEM_RST (&IPU_CM_REG->mem_rst)
311 #define IPU_GPR (&IPU_CM_REG->gpr)
312 #define IPU_CHA_DB_MODE_SEL(ch) (&IPU_CM_REG->ch_db_mode_sel[ch / 32])
314 #define IPU_STAT ((struct ipu_stat *)(IPU_CTRL_BASE_ADDR + \
316 #define IPU_INT_STAT(n) (&IPU_STAT->int_stat[(n) - 1])
317 #define IPU_CHA_CUR_BUF(ch) (&IPU_STAT->cur_buf[ch / 32])
318 #define IPU_CHA_BUF0_RDY(ch) (&IPU_STAT->ch_buf0_rdy[ch / 32])
319 #define IPU_CHA_BUF1_RDY(ch) (&IPU_STAT->ch_buf1_rdy[ch / 32])
320 #define IPUIRQ_2_STATREG(irq) (IPU_INT_STAT(1) + ((irq) / 32))
321 #define IPUIRQ_2_MASK(irq) (1UL << ((irq) & 0x1F))
323 #define IPU_INT_CTRL(n) (&IPU_CM_REG->int_ctrl[(n) - 1])
325 #define IDMAC_REG ((struct ipu_idmac *)(IPU_CTRL_BASE_ADDR + \
327 #define IDMAC_CONF (&IDMAC_REG->conf)
328 #define IDMAC_CHA_EN(ch) (&IDMAC_REG->ch_en[ch / 32])
329 #define IDMAC_CHA_PRI(ch) (&IDMAC_REG->ch_pri[ch / 32])
331 #define DI_REG(di) ((struct ipu_di *)(IPU_CTRL_BASE_ADDR + \
332 ((di == 1) ? IPU_DI1_REG_BASE : \
334 #define DI_GENERAL(di) (&DI_REG(di)->general)
335 #define DI_BS_CLKGEN0(di) (&DI_REG(di)->bs_clkgen0)
336 #define DI_BS_CLKGEN1(di) (&DI_REG(di)->bs_clkgen1)
338 #define DI_SW_GEN0(di, gen) (&DI_REG(di)->sw_gen0[gen - 1])
339 #define DI_SW_GEN1(di, gen) (&DI_REG(di)->sw_gen1[gen - 1])
340 #define DI_STP_REP(di, gen) (&DI_REG(di)->stp_rep[(gen - 1) / 2])
341 #define DI_SYNC_AS_GEN(di) (&DI_REG(di)->sync_as)
342 #define DI_DW_GEN(di, gen) (&DI_REG(di)->dw_gen[gen])
343 #define DI_DW_SET(di, gen, set) (&DI_REG(di)->dw_set[gen + 12 * set])
344 #define DI_POL(di) (&DI_REG(di)->pol)
345 #define DI_SCR_CONF(di) (&DI_REG(di)->scr_conf)
347 #define DMFC_REG ((struct ipu_dmfc *)(IPU_CTRL_BASE_ADDR + \
349 #define DMFC_WR_CHAN (&DMFC_REG->wr_chan)
350 #define DMFC_WR_CHAN_DEF (&DMFC_REG->wr_chan_def)
351 #define DMFC_DP_CHAN (&DMFC_REG->dp_chan)
352 #define DMFC_DP_CHAN_DEF (&DMFC_REG->dp_chan_def)
353 #define DMFC_GENERAL1 (&DMFC_REG->general[0])
354 #define DMFC_IC_CTRL (&DMFC_REG->ic_ctrl)
357 #define DC_REG ((struct ipu_dc *)(IPU_CTRL_BASE_ADDR + \
359 #define DC_MAP_CONF_PTR(n) (&DC_REG->dc_map_ptr[n / 2])
360 #define DC_MAP_CONF_VAL(n) (&DC_REG->dc_map_val[n / 2])
363 static inline struct ipu_dc_ch *dc_ch_offset(int ch)
369 return &DC_REG->dc_ch0_1_2[ch];
372 return &DC_REG->dc_ch5_6[ch - 5];
374 return &DC_REG->dc_ch8;
376 return &DC_REG->dc_ch9;
378 printf("%s: invalid channel %d\n", __func__, ch);
384 #define DC_RL_CH(ch, evt) (&dc_ch_offset(ch)->rl[evt / 2])
386 #define DC_WR_CH_CONF(ch) (&dc_ch_offset(ch)->wr_ch_conf)
387 #define DC_WR_CH_ADDR(ch) (&dc_ch_offset(ch)->wr_ch_addr)
389 #define DC_WR_CH_CONF_1 DC_WR_CH_CONF(1)
390 #define DC_WR_CH_CONF_5 DC_WR_CH_CONF(5)
392 #define DC_GEN (&DC_REG->gen)
393 #define DC_DISP_CONF2(disp) (&DC_REG->disp_conf2[disp])
394 #define DC_STAT (&DC_REG->stat)
397 #define DP_ASYNC0 0x60
398 #define DP_ASYNC1 0xBC
400 #define DP_REG ((struct ipu_dp *)(IPU_CTRL_BASE_ADDR + \
402 #define DP_COM_CONF() (&DP_REG->com_conf_sync)
403 #define DP_GRAPH_WIND_CTRL() (&DP_REG->graph_wind_ctrl_sync)
404 #define DP_CSC_A_0() (&DP_REG->csca_sync[0])
405 #define DP_CSC_A_1() (&DP_REG->csca_sync[1])
406 #define DP_CSC_A_2() (&DP_REG->csca_sync[2])
407 #define DP_CSC_A_3() (&DP_REG->csca_sync[3])
409 #define DP_CSC_0() (&DP_REG->csc_sync[0])
410 #define DP_CSC_1() (&DP_REG->csc_sync[1])
412 /* DC template opcodes */
413 #define WROD(lf) (0x18 | (lf << 1))