5 * Stefano Babic, DENX Software Engineering, sbabic@denx.de
9 * (C) Copyright 2005-2011 Freescale Semiconductor, Inc.
11 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #ifndef __IPU_REGS_INCLUDED__
31 #define __IPU_REGS_INCLUDED__
33 #define IPU_DISP0_BASE 0x00000000
34 #define IPU_MCU_T_DEFAULT 8
35 #define IPU_DISP1_BASE (gd->arch.ipu_hw_rev < IPUV3_HW_REV_IPUV3H ? \
36 (IPU_MCU_T_DEFAULT << 25) : \
39 #define IPUV3DEX_REG_BASE 0x1E000000
40 #define IPUV3M_REG_BASE 0x1E000000
41 #define IPUV3H_REG_BASE 0x00200000
43 #define IPU_CM_REG_BASE 0x00000000
44 #define IPU_STAT_REG_BASE 0x00000200
45 #define IPU_IDMAC_REG_BASE 0x00008000
46 #define IPU_ISP_REG_BASE 0x00010000
47 #define IPU_DP_REG_BASE 0x00018000
48 #define IPU_IC_REG_BASE 0x00020000
49 #define IPU_IRT_REG_BASE 0x00028000
50 #define IPU_CSI0_REG_BASE 0x00030000
51 #define IPU_CSI1_REG_BASE 0x00038000
52 #define IPU_DI0_REG_BASE 0x00040000
53 #define IPU_DI1_REG_BASE 0x00048000
54 #define IPU_SMFC_REG_BASE 0x00050000
55 #define IPU_DC_REG_BASE 0x00058000
56 #define IPU_DMFC_REG_BASE 0x00060000
57 #define IPU_VDI_REG_BASE 0x00068000
58 #define IPU_CPMEM_REG_BASE (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
61 #define IPU_LUT_REG_BASE (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
64 #define IPU_SRM_REG_BASE (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
67 #define IPU_TPM_REG_BASE (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
70 #define IPU_DC_TMPL_REG_BASE (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
73 #define IPU_ISP_TBPR_REG_BASE (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
77 #define IPU_DISP_REG_BASE_ADDR (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ? \
78 IPU_CTRL_BASE_ADDR + IPUV3H_REG_BASE : \
79 IPU_CTRL_BASE_ADDR + IPUV3M_REG_BASE)
81 extern u32 *ipu_dc_tmpl_reg;
82 extern struct clk *g_ipu_clk;
83 extern struct clk *g_di_clk[2];
84 extern struct clk *g_pixel_clk[2];
86 extern int g_ipu_clk_enabled;
87 extern unsigned char g_dc_di_assignment[];
92 #define DC_EVT_NFIELD 3
94 #define DC_EVT_EOFIELD 5
95 #define DC_EVT_NEW_ADDR 6
96 #define DC_EVT_NEW_CHAN 7
97 #define DC_EVT_NEW_DATA 8
99 #define DC_EVT_NEW_ADDR_W_0 0
100 #define DC_EVT_NEW_ADDR_W_1 1
101 #define DC_EVT_NEW_CHAN_W_0 2
102 #define DC_EVT_NEW_CHAN_W_1 3
103 #define DC_EVT_NEW_DATA_W_0 4
104 #define DC_EVT_NEW_DATA_W_1 5
105 #define DC_EVT_NEW_ADDR_R_0 6
106 #define DC_EVT_NEW_ADDR_R_1 7
107 #define DC_EVT_NEW_CHAN_R_0 8
108 #define DC_EVT_NEW_CHAN_R_1 9
109 #define DC_EVT_NEW_DATA_R_0 10
110 #define DC_EVT_NEW_DATA_R_1 11
112 /* Software reset for ipu */
116 IPU_CONF_DP_EN = 0x00000020,
117 IPU_CONF_DI0_EN = 0x00000040,
118 IPU_CONF_DI1_EN = 0x00000080,
119 IPU_CONF_DMFC_EN = 0x00000400,
120 IPU_CONF_DC_EN = 0x00000200,
122 DI0_COUNTER_RELEASE = 0x01000000,
123 DI1_COUNTER_RELEASE = 0x02000000,
125 DI_DW_GEN_ACCESS_SIZE_OFFSET = 24,
126 DI_DW_GEN_COMPONENT_SIZE_OFFSET = 16,
128 DI_GEN_DI_CLK_EXT = 0x00100000,
129 DI_GEN_POLARITY_1 = 0x00000001,
130 DI_GEN_POLARITY_2 = 0x00000002,
131 DI_GEN_POLARITY_3 = 0x00000004,
132 DI_GEN_POLARITY_4 = 0x00000008,
133 DI_GEN_POLARITY_5 = 0x00000010,
134 DI_GEN_POLARITY_6 = 0x00000020,
135 DI_GEN_POLARITY_7 = 0x00000040,
136 DI_GEN_POLARITY_8 = 0x00000080,
137 DI_GEN_POL_CLK = 0x00020000,
139 DI_POL_DRDY_DATA_POLARITY = 0x00000080,
140 DI_POL_DRDY_POLARITY_15 = 0x00000010,
141 DI_VSYNC_SEL_OFFSET = 13,
143 DC_WR_CH_CONF_FIELD_MODE = 0x00000200,
144 DC_WR_CH_CONF_PROG_TYPE_OFFSET = 5,
145 DC_WR_CH_CONF_PROG_TYPE_MASK = 0x000000E0,
146 DC_WR_CH_CONF_PROG_DI_ID = 0x00000004,
147 DC_WR_CH_CONF_PROG_DISP_ID_OFFSET = 3,
148 DC_WR_CH_CONF_PROG_DISP_ID_MASK = 0x00000018,
150 DP_COM_CONF_FG_EN = 0x00000001,
151 DP_COM_CONF_GWSEL = 0x00000002,
152 DP_COM_CONF_GWAM = 0x00000004,
153 DP_COM_CONF_GWCKE = 0x00000008,
154 DP_COM_CONF_CSC_DEF_MASK = 0x00000300,
155 DP_COM_CONF_CSC_DEF_OFFSET = 8,
156 DP_COM_CONF_CSC_DEF_FG = 0x00000300,
157 DP_COM_CONF_CSC_DEF_BG = 0x00000200,
158 DP_COM_CONF_CSC_DEF_BOTH = 0x00000100,
159 DP_COM_CONF_GAMMA_EN = 0x00001000,
160 DP_COM_CONF_GAMMA_YUV_EN = 0x00002000,
180 DI_SYNC_INT_HSYNC = 1,
207 u32 ch_db_mode_sel[2];
209 u32 alt_ch_db_mode_sel[2];
211 u32 ch_trb_mode_sel[2];
229 struct ipu_com_async {
231 u32 graph_wind_ctrl_async;
235 u32 gamma_c_async[8];
236 u32 gamma_s_async[4];
237 u32 dp_csca_async[4];
243 u32 graph_wind_ctrl_sync;
252 struct ipu_com_async async[2];
283 u32 triple_cur_buf[4];
286 u32 alt_ch_buf0_rdy[2];
287 u32 alt_ch_buf1_rdy[2];
298 struct ipu_dc_ch dc_ch0_1_2[3];
301 struct ipu_dc_ch dc_ch5_6[2];
302 struct ipu_dc_ch dc_ch8;
304 struct ipu_dc_ch dc_ch9;
316 u32 wr_ch_addr_5_alt;
334 #define IPU_CM_REG ((struct ipu_cm *)(IPU_DISP_REG_BASE_ADDR + \
336 #define IPU_CONF (&IPU_CM_REG->conf)
337 #define IPU_SRM_PRI1 (&IPU_CM_REG->srm_pri1)
338 #define IPU_SRM_PRI2 (&IPU_CM_REG->srm_pri2)
339 #define IPU_FS_PROC_FLOW1 (&IPU_CM_REG->fs_proc_flow[0])
340 #define IPU_FS_PROC_FLOW2 (&IPU_CM_REG->fs_proc_flow[1])
341 #define IPU_FS_PROC_FLOW3 (&IPU_CM_REG->fs_proc_flow[2])
342 #define IPU_FS_DISP_FLOW1 (&IPU_CM_REG->fs_disp_flow[0])
343 #define IPU_DISP_GEN (&IPU_CM_REG->disp_gen)
344 #define IPU_MEM_RST (&IPU_CM_REG->mem_rst)
345 #define IPU_PM (&IPU_CM_REG->pm)
346 #define IPU_GPR (&IPU_CM_REG->gpr)
347 #define IPU_CHA_DB_MODE_SEL(ch) (&IPU_CM_REG->ch_db_mode_sel[(ch) / 32])
349 #define IPU_STAT ((struct ipu_stat *)(IPU_DISP_REG_BASE_ADDR + \
351 #define IPU_CHA_CUR_BUF(ch) (&IPU_STAT->cur_buf[(ch) / 32])
352 #define IPU_CHA_BUF0_RDY(ch) (&IPU_STAT->ch_buf0_rdy[(ch) / 32])
353 #define IPU_CHA_BUF1_RDY(ch) (&IPU_STAT->ch_buf1_rdy[(ch) / 32])
355 #define IPU_INT_CTRL(n) (&IPU_CM_REG->int_ctrl[(n) - 1])
357 #define IDMAC_REG ((struct ipu_idmac *)(IPU_DISP_REG_BASE_ADDR + \
359 #define IDMAC_CONF (&IDMAC_REG->conf)
360 #define IDMAC_CHA_EN(ch) (&IDMAC_REG->ch_en[(ch) / 32])
361 #define IDMAC_CHA_PRI(ch) (&IDMAC_REG->ch_pri[(ch) / 32])
362 #define IDMAC_WM_EN(ch) (&IDMAC_REG->wm_en[(ch) / 32])
364 #define DI_REG(di) ((struct ipu_di *)(IPU_DISP_REG_BASE_ADDR + \
365 (((di) == 1) ? IPU_DI1_REG_BASE : \
368 #define DI_GENERAL(di) (&DI_REG(di)->general)
369 #define DI_BS_CLKGEN0(di) (&DI_REG(di)->bs_clkgen0)
370 #define DI_BS_CLKGEN1(di) (&DI_REG(di)->bs_clkgen1)
372 #define DI_SW_GEN0(di, gen) (&DI_REG(di)->sw_gen0[(gen) - 1])
373 #define DI_SW_GEN1(di, gen) (&DI_REG(di)->sw_gen1[(gen) - 1])
374 #define DI_STP_REP(di, gen) (&DI_REG(di)->stp_rep[((gen) - 1) / 2])
375 #define DI_SYNC_AS_GEN(di) (&DI_REG(di)->sync_as)
376 #define DI_DW_GEN(di, gen) (&DI_REG(di)->dw_gen[gen])
377 #define DI_DW_SET(di, gen, set) (&DI_REG(di)->dw_set[(gen) + 12 * set])
378 #define DI_POL(di) (&DI_REG(di)->pol)
379 #define DI_SCR_CONF(di) (&DI_REG(di)->scr_conf)
381 #define DMFC_REG ((struct ipu_dmfc *)(IPU_DISP_REG_BASE_ADDR + \
383 #define DMFC_WR_CHAN (&DMFC_REG->wr_chan)
384 #define DMFC_WR_CHAN_DEF (&DMFC_REG->wr_chan_def)
385 #define DMFC_DP_CHAN (&DMFC_REG->dp_chan)
386 #define DMFC_DP_CHAN_DEF (&DMFC_REG->dp_chan_def)
387 #define DMFC_GENERAL1 (&DMFC_REG->general[0])
388 #define DMFC_IC_CTRL (&DMFC_REG->ic_ctrl)
390 #define DC_REG ((struct ipu_dc *)(IPU_DISP_REG_BASE_ADDR + \
392 #define DC_MAP_CONF_PTR(n) (&DC_REG->dc_map_ptr[(n) / 2])
393 #define DC_MAP_CONF_VAL(n) (&DC_REG->dc_map_val[(n) / 2])
395 DECLARE_GLOBAL_DATA_PTR;
397 static inline struct ipu_dc_ch *dc_ch_offset(int ch)
403 return &DC_REG->dc_ch0_1_2[ch];
406 return &DC_REG->dc_ch5_6[ch - 5];
408 return &DC_REG->dc_ch8;
410 return &DC_REG->dc_ch9;
412 printf("%s: invalid channel %d\n", __func__, ch);
417 #define DC_RL_CH(ch, evt) (&dc_ch_offset(ch)->rl[(evt) / 2])
419 #define DC_WR_CH_CONF(ch) (&dc_ch_offset(ch)->wr_ch_conf)
420 #define DC_WR_CH_ADDR(ch) (&dc_ch_offset(ch)->wr_ch_addr)
422 #define DC_WR_CH_CONF_1 DC_WR_CH_CONF(1)
423 #define DC_WR_CH_CONF_5 DC_WR_CH_CONF(5)
425 #define DC_GEN (&DC_REG->gen)
426 #define DC_DISP_CONF2(disp) (&DC_REG->disp_conf2[disp])
427 #define DC_STAT (&DC_REG->stat)
430 #define DP_ASYNC0 0x60
431 #define DP_ASYNC1 0xBC
433 #define DP_REG ((struct ipu_dp *)(IPU_DISP_REG_BASE_ADDR + \
435 #define DP_COM_CONF() (&DP_REG->com_conf_sync)
436 #define DP_GRAPH_WIND_CTRL() (&DP_REG->graph_wind_ctrl_sync)
437 #define DP_CSC_A_0() (&DP_REG->csca_sync[0])
438 #define DP_CSC_A_1() (&DP_REG->csca_sync[1])
439 #define DP_CSC_A_2() (&DP_REG->csca_sync[2])
440 #define DP_CSC_A_3() (&DP_REG->csca_sync[3])
442 #define DP_CSC_0() (&DP_REG->csc_sync[0])
443 #define DP_CSC_1() (&DP_REG->csc_sync[1])
445 /* DC template opcodes */
446 #define WROD(lf) (0x18 | ((lf) << 1))