ipu_regs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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 for MX51:
  8. *
  9. * (C) Copyright 2005-2009 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. #ifndef __IPU_REGS_INCLUDED__
  30. #define __IPU_REGS_INCLUDED__
  31. #define IPU_DISP0_BASE 0x00000000
  32. #define IPU_MCU_T_DEFAULT 8
  33. #define IPU_DISP1_BASE (IPU_MCU_T_DEFAULT << 25)
  34. #define IPU_CM_REG_BASE 0x00000000
  35. #define IPU_STAT_REG_BASE 0x00000200
  36. #define IPU_IDMAC_REG_BASE 0x00008000
  37. #define IPU_ISP_REG_BASE 0x00010000
  38. #define IPU_DP_REG_BASE 0x00018000
  39. #define IPU_IC_REG_BASE 0x00020000
  40. #define IPU_IRT_REG_BASE 0x00028000
  41. #define IPU_CSI0_REG_BASE 0x00030000
  42. #define IPU_CSI1_REG_BASE 0x00038000
  43. #define IPU_DI0_REG_BASE 0x00040000
  44. #define IPU_DI1_REG_BASE 0x00048000
  45. #define IPU_SMFC_REG_BASE 0x00050000
  46. #define IPU_DC_REG_BASE 0x00058000
  47. #define IPU_DMFC_REG_BASE 0x00060000
  48. #define IPU_VDI_REG_BASE 0x00680000
  49. #if defined(CONFIG_MX51) || defined(CONFIG_MX53)
  50. #define IPU_CPMEM_REG_BASE 0x01000000
  51. #define IPU_LUT_REG_BASE 0x01020000
  52. #define IPU_SRM_REG_BASE 0x01040000
  53. #define IPU_TPM_REG_BASE 0x01060000
  54. #define IPU_DC_TMPL_REG_BASE 0x01080000
  55. #define IPU_ISP_TBPR_REG_BASE 0x010C0000
  56. #elif defined(CONFIG_MX6Q)
  57. #define IPU_CPMEM_REG_BASE 0x00100000
  58. #define IPU_LUT_REG_BASE 0x00120000
  59. #define IPU_SRM_REG_BASE 0x00140000
  60. #define IPU_TPM_REG_BASE 0x00160000
  61. #define IPU_DC_TMPL_REG_BASE 0x00180000
  62. #define IPU_ISP_TBPR_REG_BASE 0x001C0000
  63. #endif
  64. #define IPU_CTRL_BASE_ADDR (IPU_SOC_BASE_ADDR + IPU_SOC_OFFSET)
  65. extern u32 *ipu_dc_tmpl_reg;
  66. #define DC_EVT_NF 0
  67. #define DC_EVT_NL 1
  68. #define DC_EVT_EOF 2
  69. #define DC_EVT_NFIELD 3
  70. #define DC_EVT_EOL 4
  71. #define DC_EVT_EOFIELD 5
  72. #define DC_EVT_NEW_ADDR 6
  73. #define DC_EVT_NEW_CHAN 7
  74. #define DC_EVT_NEW_DATA 8
  75. #define DC_EVT_NEW_ADDR_W_0 0
  76. #define DC_EVT_NEW_ADDR_W_1 1
  77. #define DC_EVT_NEW_CHAN_W_0 2
  78. #define DC_EVT_NEW_CHAN_W_1 3
  79. #define DC_EVT_NEW_DATA_W_0 4
  80. #define DC_EVT_NEW_DATA_W_1 5
  81. #define DC_EVT_NEW_ADDR_R_0 6
  82. #define DC_EVT_NEW_ADDR_R_1 7
  83. #define DC_EVT_NEW_CHAN_R_0 8
  84. #define DC_EVT_NEW_CHAN_R_1 9
  85. #define DC_EVT_NEW_DATA_R_0 10
  86. #define DC_EVT_NEW_DATA_R_1 11
  87. /* Software reset for ipu */
  88. #define SW_IPU_RST 8
  89. enum {
  90. IPU_CONF_DP_EN = 0x00000020,
  91. IPU_CONF_DI0_EN = 0x00000040,
  92. IPU_CONF_DI1_EN = 0x00000080,
  93. IPU_CONF_DMFC_EN = 0x00000400,
  94. IPU_CONF_DC_EN = 0x00000200,
  95. DI0_COUNTER_RELEASE = 0x01000000,
  96. DI1_COUNTER_RELEASE = 0x02000000,
  97. DI_DW_GEN_ACCESS_SIZE_OFFSET = 24,
  98. DI_DW_GEN_COMPONENT_SIZE_OFFSET = 16,
  99. DI_GEN_DI_CLK_EXT = 0x100000,
  100. DI_GEN_POLARITY_1 = 0x00000001,
  101. DI_GEN_POLARITY_2 = 0x00000002,
  102. DI_GEN_POLARITY_3 = 0x00000004,
  103. DI_GEN_POLARITY_4 = 0x00000008,
  104. DI_GEN_POLARITY_5 = 0x00000010,
  105. DI_GEN_POLARITY_6 = 0x00000020,
  106. DI_GEN_POLARITY_7 = 0x00000040,
  107. DI_GEN_POLARITY_8 = 0x00000080,
  108. DI_GEN_POL_CLK = 0x20000,
  109. DI_POL_DRDY_DATA_POLARITY = 0x00000080,
  110. DI_POL_DRDY_POLARITY_15 = 0x00000010,
  111. DI_VSYNC_SEL_OFFSET = 13,
  112. DC_WR_CH_CONF_FIELD_MODE = 0x00000200,
  113. DC_WR_CH_CONF_PROG_TYPE_OFFSET = 5,
  114. DC_WR_CH_CONF_PROG_TYPE_MASK = 0x000000E0,
  115. DC_WR_CH_CONF_PROG_DI_ID = 0x00000004,
  116. DC_WR_CH_CONF_PROG_DISP_ID_OFFSET = 3,
  117. DC_WR_CH_CONF_PROG_DISP_ID_MASK = 0x00000018,
  118. DP_COM_CONF_FG_EN = 0x00000001,
  119. DP_COM_CONF_GWSEL = 0x00000002,
  120. DP_COM_CONF_GWAM = 0x00000004,
  121. DP_COM_CONF_GWCKE = 0x00000008,
  122. DP_COM_CONF_CSC_DEF_MASK = 0x00000300,
  123. DP_COM_CONF_CSC_DEF_OFFSET = 8,
  124. DP_COM_CONF_CSC_DEF_FG = 0x00000300,
  125. DP_COM_CONF_CSC_DEF_BG = 0x00000200,
  126. DP_COM_CONF_CSC_DEF_BOTH = 0x00000100,
  127. DP_COM_CONF_GAMMA_EN = 0x00001000,
  128. DP_COM_CONF_GAMMA_YUV_EN = 0x00002000,
  129. };
  130. enum di_pins {
  131. DI_PIN11 = 0,
  132. DI_PIN12 = 1,
  133. DI_PIN13 = 2,
  134. DI_PIN14 = 3,
  135. DI_PIN15 = 4,
  136. DI_PIN16 = 5,
  137. DI_PIN17 = 6,
  138. DI_PIN_CS = 7,
  139. DI_PIN_SER_CLK = 0,
  140. DI_PIN_SER_RS = 1,
  141. };
  142. enum di_sync_wave {
  143. DI_SYNC_NONE = -1,
  144. DI_SYNC_CLK = 0,
  145. DI_SYNC_INT_HSYNC = 1,
  146. DI_SYNC_HSYNC = 2,
  147. DI_SYNC_VSYNC = 3,
  148. DI_SYNC_DE = 5,
  149. };
  150. struct ipu_cm {
  151. u32 conf;
  152. u32 sisg_ctrl0;
  153. u32 sisg_ctrl1;
  154. u32 sisg_set[6];
  155. u32 sisg_clear[6];
  156. u32 int_ctrl[15];
  157. u32 sdma_event[10];
  158. u32 srm_pri1;
  159. u32 srm_pri2;
  160. u32 fs_proc_flow[3];
  161. u32 fs_disp_flow[2];
  162. u32 skip;
  163. u32 disp_alt_conf;
  164. u32 disp_gen;
  165. u32 disp_alt[4];
  166. u32 snoop;
  167. u32 mem_rst;
  168. u32 pm;
  169. u32 gpr;
  170. u32 reserved0[26];
  171. u32 ch_db_mode_sel[2];
  172. u32 reserved1[16];
  173. u32 alt_ch_db_mode_sel[2];
  174. u32 reserved2[2];
  175. u32 ch_trb_mode_sel[2];
  176. };
  177. struct ipu_idmac {
  178. u32 conf;
  179. u32 ch_en[2];
  180. u32 sep_alpha;
  181. u32 alt_sep_alpha;
  182. u32 ch_pri[2];
  183. u32 wm_en[2];
  184. u32 lock_en[2];
  185. u32 sub_addr[5];
  186. u32 bndm_en[2];
  187. u32 sc_cord[2];
  188. u32 reserved[45];
  189. u32 ch_busy[2];
  190. };
  191. struct ipu_com_async {
  192. u32 com_conf_async;
  193. u32 graph_wind_ctrl_async;
  194. u32 fg_pos_async;
  195. u32 cur_pos_async;
  196. u32 cur_map_async;
  197. u32 gamma_c_async[8];
  198. u32 gamma_s_async[4];
  199. u32 dp_csca_async[4];
  200. u32 dp_csc_async[2];
  201. };
  202. struct ipu_dp {
  203. u32 com_conf_sync;
  204. u32 graph_wind_ctrl_sync;
  205. u32 fg_pos_sync;
  206. u32 cur_pos_sync;
  207. u32 cur_map_sync;
  208. u32 gamma_c_sync[8];
  209. u32 gamma_s_sync[4];
  210. u32 csca_sync[4];
  211. u32 csc_sync[2];
  212. u32 cur_pos_alt;
  213. struct ipu_com_async async[2];
  214. };
  215. struct ipu_di {
  216. u32 general;
  217. u32 bs_clkgen0;
  218. u32 bs_clkgen1;
  219. u32 sw_gen0[9];
  220. u32 sw_gen1[9];
  221. u32 sync_as;
  222. u32 dw_gen[12];
  223. u32 dw_set[48];
  224. u32 stp_rep[4];
  225. u32 stp_rep9;
  226. u32 ser_conf;
  227. u32 ssc;
  228. u32 pol;
  229. u32 aw0;
  230. u32 aw1;
  231. u32 scr_conf;
  232. u32 stat;
  233. };
  234. struct ipu_stat {
  235. u32 int_stat[15];
  236. u32 cur_buf[2];
  237. u32 alt_cur_buf_0;
  238. u32 alt_cur_buf_1;
  239. u32 srm_stat;
  240. u32 proc_task_stat;
  241. u32 disp_task_stat;
  242. u32 triple_cur_buf[4];
  243. u32 ch_buf0_rdy[2];
  244. u32 ch_buf1_rdy[2];
  245. u32 alt_ch_buf0_rdy[2];
  246. u32 alt_ch_buf1_rdy[2];
  247. u32 ch_buf2_rdy[2];
  248. };
  249. struct ipu_dc_ch {
  250. u32 wr_ch_conf;
  251. u32 wr_ch_addr;
  252. u32 rl[5];
  253. };
  254. struct ipu_dc {
  255. struct ipu_dc_ch dc_ch0_1_2[3];
  256. u32 cmd_ch_conf_3;
  257. u32 cmd_ch_conf_4;
  258. struct ipu_dc_ch dc_ch5_6[2];
  259. struct ipu_dc_ch dc_ch8;
  260. u32 rl6_ch_8;
  261. struct ipu_dc_ch dc_ch9;
  262. u32 rl6_ch_9;
  263. u32 gen;
  264. u32 disp_conf1[4];
  265. u32 disp_conf2[4];
  266. u32 di0_conf[2];
  267. u32 di1_conf[2];
  268. u32 dc_map_ptr[15];
  269. u32 dc_map_val[12];
  270. u32 udge[16];
  271. u32 lla[2];
  272. u32 r_lla[2];
  273. u32 wr_ch_addr_5_alt;
  274. u32 stat;
  275. };
  276. struct ipu_dmfc {
  277. u32 rd_chan;
  278. u32 wr_chan;
  279. u32 wr_chan_def;
  280. u32 dp_chan;
  281. u32 dp_chan_def;
  282. u32 general[2];
  283. u32 ic_ctrl;
  284. u32 wr_chan_alt;
  285. u32 wr_chan_def_alt;
  286. u32 general1_alt;
  287. u32 stat;
  288. };
  289. #define IPU_CM_REG ((struct ipu_cm *)(IPU_CTRL_BASE_ADDR + \
  290. IPU_CM_REG_BASE))
  291. #define IPU_CONF (&IPU_CM_REG->conf)
  292. #define IPU_SRM_PRI1 (&IPU_CM_REG->srm_pri1)
  293. #define IPU_SRM_PRI2 (&IPU_CM_REG->srm_pri2)
  294. #define IPU_FS_PROC_FLOW1 (&IPU_CM_REG->fs_proc_flow[0])
  295. #define IPU_FS_PROC_FLOW2 (&IPU_CM_REG->fs_proc_flow[1])
  296. #define IPU_FS_PROC_FLOW3 (&IPU_CM_REG->fs_proc_flow[2])
  297. #define IPU_FS_DISP_FLOW1 (&IPU_CM_REG->fs_disp_flow[0])
  298. #define IPU_DISP_GEN (&IPU_CM_REG->disp_gen)
  299. #define IPU_MEM_RST (&IPU_CM_REG->mem_rst)
  300. #define IPU_GPR (&IPU_CM_REG->gpr)
  301. #define IPU_CHA_DB_MODE_SEL(ch) (&IPU_CM_REG->ch_db_mode_sel[ch / 32])
  302. #define IPU_STAT ((struct ipu_stat *)(IPU_CTRL_BASE_ADDR + \
  303. IPU_STAT_REG_BASE))
  304. #define IPU_CHA_CUR_BUF(ch) (&IPU_STAT->cur_buf[ch / 32])
  305. #define IPU_CHA_BUF0_RDY(ch) (&IPU_STAT->ch_buf0_rdy[ch / 32])
  306. #define IPU_CHA_BUF1_RDY(ch) (&IPU_STAT->ch_buf1_rdy[ch / 32])
  307. #define IPU_INT_CTRL(n) (&IPU_CM_REG->int_ctrl[(n) - 1])
  308. #define IDMAC_REG ((struct ipu_idmac *)(IPU_CTRL_BASE_ADDR + \
  309. IPU_IDMAC_REG_BASE))
  310. #define IDMAC_CONF (&IDMAC_REG->conf)
  311. #define IDMAC_CHA_EN(ch) (&IDMAC_REG->ch_en[ch / 32])
  312. #define IDMAC_CHA_PRI(ch) (&IDMAC_REG->ch_pri[ch / 32])
  313. #define DI_REG(di) ((struct ipu_di *)(IPU_CTRL_BASE_ADDR + \
  314. ((di == 1) ? IPU_DI1_REG_BASE : \
  315. IPU_DI0_REG_BASE)))
  316. #define DI_GENERAL(di) (&DI_REG(di)->general)
  317. #define DI_BS_CLKGEN0(di) (&DI_REG(di)->bs_clkgen0)
  318. #define DI_BS_CLKGEN1(di) (&DI_REG(di)->bs_clkgen1)
  319. #define DI_SW_GEN0(di, gen) (&DI_REG(di)->sw_gen0[gen - 1])
  320. #define DI_SW_GEN1(di, gen) (&DI_REG(di)->sw_gen1[gen - 1])
  321. #define DI_STP_REP(di, gen) (&DI_REG(di)->stp_rep[(gen - 1) / 2])
  322. #define DI_SYNC_AS_GEN(di) (&DI_REG(di)->sync_as)
  323. #define DI_DW_GEN(di, gen) (&DI_REG(di)->dw_gen[gen])
  324. #define DI_DW_SET(di, gen, set) (&DI_REG(di)->dw_set[gen + 12 * set])
  325. #define DI_POL(di) (&DI_REG(di)->pol)
  326. #define DI_SCR_CONF(di) (&DI_REG(di)->scr_conf)
  327. #define DMFC_REG ((struct ipu_dmfc *)(IPU_CTRL_BASE_ADDR + \
  328. IPU_DMFC_REG_BASE))
  329. #define DMFC_WR_CHAN (&DMFC_REG->wr_chan)
  330. #define DMFC_WR_CHAN_DEF (&DMFC_REG->wr_chan_def)
  331. #define DMFC_DP_CHAN (&DMFC_REG->dp_chan)
  332. #define DMFC_DP_CHAN_DEF (&DMFC_REG->dp_chan_def)
  333. #define DMFC_GENERAL1 (&DMFC_REG->general[0])
  334. #define DMFC_IC_CTRL (&DMFC_REG->ic_ctrl)
  335. #define DC_REG ((struct ipu_dc *)(IPU_CTRL_BASE_ADDR + \
  336. IPU_DC_REG_BASE))
  337. #define DC_MAP_CONF_PTR(n) (&DC_REG->dc_map_ptr[n / 2])
  338. #define DC_MAP_CONF_VAL(n) (&DC_REG->dc_map_val[n / 2])
  339. static inline struct ipu_dc_ch *dc_ch_offset(int ch)
  340. {
  341. switch (ch) {
  342. case 0:
  343. case 1:
  344. case 2:
  345. return &DC_REG->dc_ch0_1_2[ch];
  346. case 5:
  347. case 6:
  348. return &DC_REG->dc_ch5_6[ch - 5];
  349. case 8:
  350. return &DC_REG->dc_ch8;
  351. case 9:
  352. return &DC_REG->dc_ch9;
  353. default:
  354. printf("%s: invalid channel %d\n", __func__, ch);
  355. return NULL;
  356. }
  357. }
  358. #define DC_RL_CH(ch, evt) (&dc_ch_offset(ch)->rl[evt / 2])
  359. #define DC_WR_CH_CONF(ch) (&dc_ch_offset(ch)->wr_ch_conf)
  360. #define DC_WR_CH_ADDR(ch) (&dc_ch_offset(ch)->wr_ch_addr)
  361. #define DC_WR_CH_CONF_1 DC_WR_CH_CONF(1)
  362. #define DC_WR_CH_CONF_5 DC_WR_CH_CONF(5)
  363. #define DC_GEN (&DC_REG->gen)
  364. #define DC_DISP_CONF2(disp) (&DC_REG->disp_conf2[disp])
  365. #define DC_STAT (&DC_REG->stat)
  366. #define DP_SYNC 0
  367. #define DP_ASYNC0 0x60
  368. #define DP_ASYNC1 0xBC
  369. #define DP_REG ((struct ipu_dp *)(IPU_CTRL_BASE_ADDR + \
  370. IPU_DP_REG_BASE))
  371. #define DP_COM_CONF() (&DP_REG->com_conf_sync)
  372. #define DP_GRAPH_WIND_CTRL() (&DP_REG->graph_wind_ctrl_sync)
  373. #define DP_CSC_A_0() (&DP_REG->csca_sync[0])
  374. #define DP_CSC_A_1() (&DP_REG->csca_sync[1])
  375. #define DP_CSC_A_2() (&DP_REG->csca_sync[2])
  376. #define DP_CSC_A_3() (&DP_REG->csca_sync[3])
  377. #define DP_CSC_0() (&DP_REG->csc_sync[0])
  378. #define DP_CSC_1() (&DP_REG->csc_sync[1])
  379. /* DC template opcodes */
  380. #define WROD(lf) (0x18 | (lf << 1))
  381. #endif