1 /***************************************************************************
5 * Copyright 2005-2006 by Freescale Semiconductor, Inc.
6 * All modifications are confidential and proprietary information
7 * of Freescale Semiconductor, Inc. ALL RIGHTS RESERVED.
9 ***************************************************************************
11 * Author(s) : Ray Sun-B17777 <Yanfei.Sun@freescale.com>
12 * Create Date : 2008-11-10
13 * Description : common functions definition for IPU API.
15 ***************************************************************************/
16 #include <cyg/io/ipu_common.h>
20 #include <cyg/io/flash.h>
21 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
22 #include <flash_config.h>
24 #ifdef CYGOPT_REDBOOT_FIS
27 #include CYGBLD_HAL_PLATFORM_H
30 * write bit fields of special IPU regs
32 void ipu_write_field(unsigned int id_addr, unsigned int id_mask, unsigned int data)
36 id_addr += IPU_CTRL_BASE_ADDR;
37 rdata = readl(id_addr);
39 rdata |= (data * (id_mask & -id_mask)) & id_mask;
40 writel(rdata, id_addr);
46 void ipu_enable_display(void)
48 //enable DI0 (display interface 1)
49 ipu_write_field(IPU_IPU_CONF__DP_EN, 1);
50 ipu_write_field(IPU_IPU_CONF__DC_EN, 1);
51 ipu_write_field(IPU_IPU_CONF__DMFC_EN, 1);
52 ipu_write_field(IPU_IPU_CONF__DI0_EN, 1);
53 ipu_write_field(IPU_IPU_CONF__DI1_EN, 1);
54 #ifdef CYGPKG_HAL_ARM_MX51_3STACK
55 ipu_write_field(IPU_IPU_CONF__CSI1_EN, 1);
62 void ipu_disable_display(void)
64 ipu_write_field(IPU_IPU_CONF__DI0_EN, 0);
65 ipu_write_field(IPU_IPU_CONF__DI1_EN, 0);
66 ipu_write_field(IPU_IPU_CONF__DP_EN, 0);
67 ipu_write_field(IPU_IPU_CONF__DC_EN, 0);
68 ipu_write_field(IPU_IPU_CONF__DMFC_EN, 0);
69 ipu_write_field(IPU_IPU_CONF__IC_EN, 0);
70 #ifdef CYGPKG_HAL_ARM_MX51_3STACK
71 ipu_write_field(IPU_IPU_CONF__CSI0_EN, 0);
72 ipu_write_field(IPU_IPU_CONF__CSI1_EN, 0);
73 ipu_write_field(IPU_IPU_CONF__SMFC_EN, 0);
75 ipu_write_field(IPU_IC_CONF__PP_EN, 0);
76 ipu_write_field(IPU_IC_CONF__PRPVF_EN, 0);
77 ipu_write_field(IPU_IC_CONF__PRPENC_EN, 0);
80 #ifdef CYGHWR_MX51_LCD_LOGO
81 static display_buffer_info_t display_buffer;
84 * load the logo from nand flash to memory.
86 static bool do_logo_load(void)
91 unsigned int logo_size;
92 struct fis_image_desc *img;
94 /* Read the logo from storage media */
95 if ((img = fis_lookup("logo", NULL)) == NULL) {
96 diag_printf("No logo partition found in the fis table, logo not loaded\n");
100 fis_addr = (void *)img->flash_base;
101 logo_size = img->size;
102 ret = FLASH_READ(fis_addr, DISPLAY_BUFFER_ADDR, logo_size, &err_addr);
104 diag_printf("Loading logo from FLASH to MEMORY failed. error code: %d", ret);
110 * this function is used to reset ipu by SRC(system reset controller)
111 * the return value should be negative if resetting timeout
113 #define IPU_RESET (1 << 3)
114 static int ipu_sw_reset(int timeout)
118 tmpVal = readl(SRC_BASE_ADDR);
119 writel(tmpVal | IPU_RESET, SRC_BASE_ADDR);
120 while (timeout > 0) {
121 if (!(readl(SRC_BASE_ADDR) & IPU_RESET))
125 diag_printf("Error: ipu software reset timed out\n");
129 static void redboot_fastlogo_display(void)
131 bool fastlogo_feature_enable;
134 ok = CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
135 "fastlogo_enable", &fastlogo_feature_enable, CONFIG_BOOL);
137 if (ok && fastlogo_feature_enable) {
138 display_buffer.startAddr = (CYG_ADDRESS)DISPLAY_BUFFER_ADDR;
139 display_buffer.width = 640;
140 display_buffer.height = 480;
141 display_buffer.dataFormat = RGB565;
142 display_buffer.bpp = 16; // bit per pixel
143 display_buffer.channel = 28;
145 ipu_sw_reset(0x10000);
146 if (!do_logo_load()) {
149 mxc_ipu_iomux_config();
152 fastlogo_init(&display_buffer);
157 ipu_enable_display();
158 ipu_idmac_channel_buf_ready(display_buffer.channel, 0);
162 #ifdef CYGPKG_REDBOOT
163 RedBoot_init(redboot_fastlogo_display, RedBoot_INIT_SECOND);
166 RedBoot_config_option("Enable fast logo display at boot",
168 ALWAYS_ENABLED, true,