1 /* SPDX-License-Identifier: GPL-2.0+ */
6 * Stefano Babic, DENX Software Engineering, sbabic@denx.de
8 * Linux IPU driver for MX51:
10 * (C) Copyright 2005-2009 Freescale Semiconductor, Inc.
13 #ifndef __IPU_REGS_INCLUDED__
14 #define __IPU_REGS_INCLUDED__
16 #define IPU_DISP0_BASE 0x00000000
17 #define IPU_MCU_T_DEFAULT 8
18 #define IPU_DISP1_BASE (IPU_MCU_T_DEFAULT << 25)
19 #define IPU_CM_REG_BASE 0x00000000
20 #define IPU_STAT_REG_BASE 0x00000200
21 #define IPU_IDMAC_REG_BASE 0x00008000
22 #define IPU_ISP_REG_BASE 0x00010000
23 #define IPU_DP_REG_BASE 0x00018000
24 #define IPU_IC_REG_BASE 0x00020000
25 #define IPU_IRT_REG_BASE 0x00028000
26 #define IPU_CSI0_REG_BASE 0x00030000
27 #define IPU_CSI1_REG_BASE 0x00038000
28 #define IPU_DI0_REG_BASE 0x00040000
29 #define IPU_DI1_REG_BASE 0x00048000
30 #define IPU_SMFC_REG_BASE 0x00050000
31 #define IPU_DC_REG_BASE 0x00058000
32 #define IPU_DMFC_REG_BASE 0x00060000
33 #define IPU_VDI_REG_BASE 0x00680000
34 #if defined(CONFIG_MX51) || defined(CONFIG_MX53)
35 #define IPU_CPMEM_REG_BASE 0x01000000
36 #define IPU_LUT_REG_BASE 0x01020000
37 #define IPU_SRM_REG_BASE 0x01040000
38 #define IPU_TPM_REG_BASE 0x01060000
39 #define IPU_DC_TMPL_REG_BASE 0x01080000
40 #define IPU_ISP_TBPR_REG_BASE 0x010C0000
41 #elif defined(CONFIG_MX6)
42 #define IPU_CPMEM_REG_BASE 0x00100000
43 #define IPU_LUT_REG_BASE 0x00120000
44 #define IPU_SRM_REG_BASE 0x00140000
45 #define IPU_TPM_REG_BASE 0x00160000
46 #define IPU_DC_TMPL_REG_BASE 0x00180000
47 #define IPU_ISP_TBPR_REG_BASE 0x001C0000
50 #define IPU_CTRL_BASE_ADDR (IPU_SOC_BASE_ADDR + IPU_SOC_OFFSET)
52 extern u32 *ipu_dc_tmpl_reg;
57 #define DC_EVT_NFIELD 3
59 #define DC_EVT_EOFIELD 5
60 #define DC_EVT_NEW_ADDR 6
61 #define DC_EVT_NEW_CHAN 7
62 #define DC_EVT_NEW_DATA 8
64 #define DC_EVT_NEW_ADDR_W_0 0
65 #define DC_EVT_NEW_ADDR_W_1 1
66 #define DC_EVT_NEW_CHAN_W_0 2
67 #define DC_EVT_NEW_CHAN_W_1 3
68 #define DC_EVT_NEW_DATA_W_0 4
69 #define DC_EVT_NEW_DATA_W_1 5
70 #define DC_EVT_NEW_ADDR_R_0 6
71 #define DC_EVT_NEW_ADDR_R_1 7
72 #define DC_EVT_NEW_CHAN_R_0 8
73 #define DC_EVT_NEW_CHAN_R_1 9
74 #define DC_EVT_NEW_DATA_R_0 10
75 #define DC_EVT_NEW_DATA_R_1 11
77 /* Software reset for ipu */
81 IPU_CONF_DP_EN = 0x00000020,
82 IPU_CONF_DI0_EN = 0x00000040,
83 IPU_CONF_DI1_EN = 0x00000080,
84 IPU_CONF_DMFC_EN = 0x00000400,
85 IPU_CONF_DC_EN = 0x00000200,
87 DI0_COUNTER_RELEASE = 0x01000000,
88 DI1_COUNTER_RELEASE = 0x02000000,
90 DI_DW_GEN_ACCESS_SIZE_OFFSET = 24,
91 DI_DW_GEN_COMPONENT_SIZE_OFFSET = 16,
93 DI_GEN_DI_CLK_EXT = 0x100000,
94 DI_GEN_POLARITY_1 = 0x00000001,
95 DI_GEN_POLARITY_2 = 0x00000002,
96 DI_GEN_POLARITY_3 = 0x00000004,
97 DI_GEN_POLARITY_4 = 0x00000008,
98 DI_GEN_POLARITY_5 = 0x00000010,
99 DI_GEN_POLARITY_6 = 0x00000020,
100 DI_GEN_POLARITY_7 = 0x00000040,
101 DI_GEN_POLARITY_8 = 0x00000080,
102 DI_GEN_POL_CLK = 0x20000,
104 DI_POL_DRDY_DATA_POLARITY = 0x00000080,
105 DI_POL_DRDY_POLARITY_15 = 0x00000010,
106 DI_VSYNC_SEL_OFFSET = 13,
108 DC_WR_CH_CONF_FIELD_MODE = 0x00000200,
109 DC_WR_CH_CONF_PROG_TYPE_OFFSET = 5,
110 DC_WR_CH_CONF_PROG_TYPE_MASK = 0x000000E0,
111 DC_WR_CH_CONF_PROG_DI_ID = 0x00000004,
112 DC_WR_CH_CONF_PROG_DISP_ID_OFFSET = 3,
113 DC_WR_CH_CONF_PROG_DISP_ID_MASK = 0x00000018,
115 DP_COM_CONF_FG_EN = 0x00000001,
116 DP_COM_CONF_GWSEL = 0x00000002,
117 DP_COM_CONF_GWAM = 0x00000004,
118 DP_COM_CONF_GWCKE = 0x00000008,
119 DP_COM_CONF_CSC_DEF_MASK = 0x00000300,
120 DP_COM_CONF_CSC_DEF_OFFSET = 8,
121 DP_COM_CONF_CSC_DEF_FG = 0x00000300,
122 DP_COM_CONF_CSC_DEF_BG = 0x00000200,
123 DP_COM_CONF_CSC_DEF_BOTH = 0x00000100,
124 DP_COM_CONF_GAMMA_EN = 0x00001000,
125 DP_COM_CONF_GAMMA_YUV_EN = 0x00002000,
145 DI_SYNC_INT_HSYNC = 1,
172 u32 ch_db_mode_sel[2];
174 u32 alt_ch_db_mode_sel[2];
176 u32 ch_trb_mode_sel[2];
194 struct ipu_com_async {
196 u32 graph_wind_ctrl_async;
200 u32 gamma_c_async[8];
201 u32 gamma_s_async[4];
202 u32 dp_csca_async[4];
208 u32 graph_wind_ctrl_sync;
217 struct ipu_com_async async[2];
248 u32 triple_cur_buf[4];
251 u32 alt_ch_buf0_rdy[2];
252 u32 alt_ch_buf1_rdy[2];
263 struct ipu_dc_ch dc_ch0_1_2[3];
266 struct ipu_dc_ch dc_ch5_6[2];
267 struct ipu_dc_ch dc_ch8;
269 struct ipu_dc_ch dc_ch9;
281 u32 wr_ch_addr_5_alt;
299 #define IPU_CM_REG ((struct ipu_cm *)(IPU_CTRL_BASE_ADDR + \
301 #define IPU_CONF (&IPU_CM_REG->conf)
302 #define IPU_SRM_PRI1 (&IPU_CM_REG->srm_pri1)
303 #define IPU_SRM_PRI2 (&IPU_CM_REG->srm_pri2)
304 #define IPU_FS_PROC_FLOW1 (&IPU_CM_REG->fs_proc_flow[0])
305 #define IPU_FS_PROC_FLOW2 (&IPU_CM_REG->fs_proc_flow[1])
306 #define IPU_FS_PROC_FLOW3 (&IPU_CM_REG->fs_proc_flow[2])
307 #define IPU_FS_DISP_FLOW1 (&IPU_CM_REG->fs_disp_flow[0])
308 #define IPU_DISP_GEN (&IPU_CM_REG->disp_gen)
309 #define IPU_MEM_RST (&IPU_CM_REG->mem_rst)
310 #define IPU_GPR (&IPU_CM_REG->gpr)
311 #define IPU_CHA_DB_MODE_SEL(ch) (&IPU_CM_REG->ch_db_mode_sel[ch / 32])
313 #define IPU_STAT ((struct ipu_stat *)(IPU_CTRL_BASE_ADDR + \
315 #define IPU_INT_STAT(n) (&IPU_STAT->int_stat[(n) - 1])
316 #define IPU_CHA_CUR_BUF(ch) (&IPU_STAT->cur_buf[ch / 32])
317 #define IPU_CHA_BUF0_RDY(ch) (&IPU_STAT->ch_buf0_rdy[ch / 32])
318 #define IPU_CHA_BUF1_RDY(ch) (&IPU_STAT->ch_buf1_rdy[ch / 32])
319 #define IPUIRQ_2_STATREG(irq) (IPU_INT_STAT(1) + ((irq) / 32))
320 #define IPUIRQ_2_MASK(irq) (1UL << ((irq) & 0x1F))
322 #define IPU_INT_CTRL(n) (&IPU_CM_REG->int_ctrl[(n) - 1])
324 #define IDMAC_REG ((struct ipu_idmac *)(IPU_CTRL_BASE_ADDR + \
326 #define IDMAC_CONF (&IDMAC_REG->conf)
327 #define IDMAC_CHA_EN(ch) (&IDMAC_REG->ch_en[ch / 32])
328 #define IDMAC_CHA_PRI(ch) (&IDMAC_REG->ch_pri[ch / 32])
330 #define DI_REG(di) ((struct ipu_di *)(IPU_CTRL_BASE_ADDR + \
331 ((di == 1) ? IPU_DI1_REG_BASE : \
333 #define DI_GENERAL(di) (&DI_REG(di)->general)
334 #define DI_BS_CLKGEN0(di) (&DI_REG(di)->bs_clkgen0)
335 #define DI_BS_CLKGEN1(di) (&DI_REG(di)->bs_clkgen1)
337 #define DI_SW_GEN0(di, gen) (&DI_REG(di)->sw_gen0[gen - 1])
338 #define DI_SW_GEN1(di, gen) (&DI_REG(di)->sw_gen1[gen - 1])
339 #define DI_STP_REP(di, gen) (&DI_REG(di)->stp_rep[(gen - 1) / 2])
340 #define DI_STP_REP9(di) (&DI_REG(di)->stp_rep9)
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))