]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/video/ipu_regs.h
TX6 Release 2013-04-22
[karo-tx-uboot.git] / drivers / video / ipu_regs.h
1 /*
2  * Porting to u-boot:
3  *
4  * (C) Copyright 2010
5  * Stefano Babic, DENX Software Engineering, sbabic@denx.de
6  *
7  * Linux IPU driver:
8  *
9  * (C) Copyright 2005-2011 Freescale Semiconductor, Inc.
10  *
11  * See file CREDITS for list of people who contributed to this
12  * project.
13  *
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.
18  *
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.
23  *
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,
27  * MA 02111-1307 USA
28  */
29
30 #ifndef __IPU_REGS_INCLUDED__
31 #define __IPU_REGS_INCLUDED__
32
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) :             \
37                                 0x00000000)
38
39 #define IPUV3DEX_REG_BASE       0x1E000000
40 #define IPUV3M_REG_BASE         0x1E000000
41 #define IPUV3H_REG_BASE         0x00200000
42
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 ?   \
59                                 0x00100000 :                            \
60                                 0x01000000)
61 #define IPU_LUT_REG_BASE        (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ?   \
62                                 0x00120000 :                            \
63                                 0x01020000)
64 #define IPU_SRM_REG_BASE        (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ?   \
65                                 0x00140000 :                            \
66                                 0x01040000)
67 #define IPU_TPM_REG_BASE        (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ?   \
68                                 0x00160000 :                            \
69                                 0x01060000)
70 #define IPU_DC_TMPL_REG_BASE    (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ?   \
71                                 0x00180000 :                            \
72                                 0x01080000)
73 #define IPU_ISP_TBPR_REG_BASE   (gd->arch.ipu_hw_rev >= IPUV3_HW_REV_IPUV3H ?   \
74                                 0x001C0000 :                            \
75                                 0x010C0000)
76
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)
80
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];
85
86 extern int g_ipu_clk_enabled;
87 extern unsigned char g_dc_di_assignment[];
88
89 #define DC_EVT_NF               0
90 #define DC_EVT_NL               1
91 #define DC_EVT_EOF              2
92 #define DC_EVT_NFIELD           3
93 #define DC_EVT_EOL              4
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
98
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
111
112 /* Software reset for ipu */
113 #define SW_IPU_RST      8
114
115 enum {
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,
121
122         DI0_COUNTER_RELEASE = 0x01000000,
123         DI1_COUNTER_RELEASE = 0x02000000,
124
125         DI_DW_GEN_ACCESS_SIZE_OFFSET = 24,
126         DI_DW_GEN_COMPONENT_SIZE_OFFSET = 16,
127
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,
138
139         DI_POL_DRDY_DATA_POLARITY = 0x00000080,
140         DI_POL_DRDY_POLARITY_15 = 0x00000010,
141         DI_VSYNC_SEL_OFFSET = 13,
142
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,
149
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,
161 };
162
163 enum di_pins {
164         DI_PIN11 = 0,
165         DI_PIN12 = 1,
166         DI_PIN13 = 2,
167         DI_PIN14 = 3,
168         DI_PIN15 = 4,
169         DI_PIN16 = 5,
170         DI_PIN17 = 6,
171         DI_PIN_CS = 7,
172
173         DI_PIN_SER_CLK = 0,
174         DI_PIN_SER_RS = 1,
175 };
176
177 enum di_sync_wave {
178         DI_SYNC_NONE = -1,
179         DI_SYNC_CLK = 0,
180         DI_SYNC_INT_HSYNC = 1,
181         DI_SYNC_HSYNC = 2,
182         DI_SYNC_VSYNC = 3,
183         DI_SYNC_DE = 5,
184 };
185
186 struct ipu_cm {
187         u32 conf;
188         u32 sisg_ctrl0;
189         u32 sisg_ctrl1;
190         u32 sisg_set[6];
191         u32 sisg_clear[6];
192         u32 int_ctrl[15];
193         u32 sdma_event[10];
194         u32 srm_pri1;
195         u32 srm_pri2;
196         u32 fs_proc_flow[3];
197         u32 fs_disp_flow[2];
198         u32 skip;
199         u32 disp_alt_conf;
200         u32 disp_gen;
201         u32 disp_alt[4];
202         u32 snoop;
203         u32 mem_rst;
204         u32 pm;
205         u32 gpr;
206         u32 reserved0[26];
207         u32 ch_db_mode_sel[2];
208         u32 reserved1[16];
209         u32 alt_ch_db_mode_sel[2];
210         u32 reserved2[2];
211         u32 ch_trb_mode_sel[2];
212 };
213
214 struct ipu_idmac {
215         u32 conf;
216         u32 ch_en[2];
217         u32 sep_alpha;
218         u32 alt_sep_alpha;
219         u32 ch_pri[2];
220         u32 wm_en[2];
221         u32 lock_en[2];
222         u32 sub_addr[5];
223         u32 bndm_en[2];
224         u32 sc_cord[2];
225         u32 reserved[45];
226         u32 ch_busy[2];
227 };
228
229 struct ipu_com_async {
230         u32 com_conf_async;
231         u32 graph_wind_ctrl_async;
232         u32 fg_pos_async;
233         u32 cur_pos_async;
234         u32 cur_map_async;
235         u32 gamma_c_async[8];
236         u32 gamma_s_async[4];
237         u32 dp_csca_async[4];
238         u32 dp_csc_async[2];
239 };
240
241 struct ipu_dp {
242         u32 com_conf_sync;
243         u32 graph_wind_ctrl_sync;
244         u32 fg_pos_sync;
245         u32 cur_pos_sync;
246         u32 cur_map_sync;
247         u32 gamma_c_sync[8];
248         u32 gamma_s_sync[4];
249         u32 csca_sync[4];
250         u32 csc_sync[2];
251         u32 cur_pos_alt;
252         struct ipu_com_async async[2];
253 };
254
255 struct ipu_di {
256         u32 general;
257         u32 bs_clkgen0;
258         u32 bs_clkgen1;
259         u32 sw_gen0[9];
260         u32 sw_gen1[9];
261         u32 sync_as;
262         u32 dw_gen[12];
263         u32 dw_set[48];
264         u32 stp_rep[4];
265         u32 stp_rep9;
266         u32 ser_conf;
267         u32 ssc;
268         u32 pol;
269         u32 aw0;
270         u32 aw1;
271         u32 scr_conf;
272         u32 stat;
273 };
274
275 struct ipu_stat {
276         u32 int_stat[15];
277         u32 cur_buf[2];
278         u32 alt_cur_buf_0;
279         u32 alt_cur_buf_1;
280         u32 srm_stat;
281         u32 proc_task_stat;
282         u32 disp_task_stat;
283         u32 triple_cur_buf[4];
284         u32 ch_buf0_rdy[2];
285         u32 ch_buf1_rdy[2];
286         u32 alt_ch_buf0_rdy[2];
287         u32 alt_ch_buf1_rdy[2];
288         u32 ch_buf2_rdy[2];
289 };
290
291 struct ipu_dc_ch {
292         u32 wr_ch_conf;
293         u32 wr_ch_addr;
294         u32 rl[5];
295 };
296
297 struct ipu_dc {
298         struct ipu_dc_ch dc_ch0_1_2[3];
299         u32 cmd_ch_conf_3;
300         u32 cmd_ch_conf_4;
301         struct ipu_dc_ch dc_ch5_6[2];
302         struct ipu_dc_ch dc_ch8;
303         u32 rl6_ch_8;
304         struct ipu_dc_ch dc_ch9;
305         u32 rl6_ch_9;
306         u32 gen;
307         u32 disp_conf1[4];
308         u32 disp_conf2[4];
309         u32 di0_conf[2];
310         u32 di1_conf[2];
311         u32 dc_map_ptr[15];
312         u32 dc_map_val[12];
313         u32 udge[16];
314         u32 lla[2];
315         u32 r_lla[2];
316         u32 wr_ch_addr_5_alt;
317         u32 stat;
318 };
319
320 struct ipu_dmfc {
321         u32 rd_chan;
322         u32 wr_chan;
323         u32 wr_chan_def;
324         u32 dp_chan;
325         u32 dp_chan_def;
326         u32 general[2];
327         u32 ic_ctrl;
328         u32 wr_chan_alt;
329         u32 wr_chan_def_alt;
330         u32 general1_alt;
331         u32 stat;
332 };
333
334 #define IPU_CM_REG              ((struct ipu_cm *)(IPU_DISP_REG_BASE_ADDR + \
335                                 IPU_CM_REG_BASE))
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])
348
349 #define IPU_STAT                ((struct ipu_stat *)(IPU_DISP_REG_BASE_ADDR + \
350                                 IPU_STAT_REG_BASE))
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])
354
355 #define IPU_INT_CTRL(n)         (&IPU_CM_REG->int_ctrl[(n) - 1])
356
357 #define IDMAC_REG               ((struct ipu_idmac *)(IPU_DISP_REG_BASE_ADDR + \
358                                 IPU_IDMAC_REG_BASE))
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])
363
364 #define DI_REG(di)              ((struct ipu_di *)(IPU_DISP_REG_BASE_ADDR + \
365                                         (((di) == 1) ? IPU_DI1_REG_BASE : \
366                                         IPU_DI0_REG_BASE)))
367
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)
371
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)
380
381 #define DMFC_REG                ((struct ipu_dmfc *)(IPU_DISP_REG_BASE_ADDR + \
382                                 IPU_DMFC_REG_BASE))
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)
389
390 #define DC_REG                  ((struct ipu_dc *)(IPU_DISP_REG_BASE_ADDR + \
391                                 IPU_DC_REG_BASE))
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])
394
395 DECLARE_GLOBAL_DATA_PTR;
396
397 static inline struct ipu_dc_ch *dc_ch_offset(int ch)
398 {
399         switch (ch) {
400         case 0:
401         case 1:
402         case 2:
403                 return &DC_REG->dc_ch0_1_2[ch];
404         case 5:
405         case 6:
406                 return &DC_REG->dc_ch5_6[ch - 5];
407         case 8:
408                 return &DC_REG->dc_ch8;
409         case 9:
410                 return &DC_REG->dc_ch9;
411         default:
412                 printf("%s: invalid channel %d\n", __func__, ch);
413                 return NULL;
414         }
415 }
416
417 #define DC_RL_CH(ch, evt)       (&dc_ch_offset(ch)->rl[(evt) / 2])
418
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)
421
422 #define DC_WR_CH_CONF_1         DC_WR_CH_CONF(1)
423 #define DC_WR_CH_CONF_5         DC_WR_CH_CONF(5)
424
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)
428
429 #define DP_SYNC 0
430 #define DP_ASYNC0 0x60
431 #define DP_ASYNC1 0xBC
432
433 #define DP_REG                  ((struct ipu_dp *)(IPU_DISP_REG_BASE_ADDR + \
434                                 IPU_DP_REG_BASE))
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])
441
442 #define DP_CSC_0()              (&DP_REG->csc_sync[0])
443 #define DP_CSC_1()              (&DP_REG->csc_sync[1])
444
445 /* DC template opcodes */
446 #define WROD(lf)                (0x18 | ((lf) << 1))
447
448 #endif