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
29 * write bit fields of special IPU regs
31 void ipu_write_field(unsigned int id_addr, unsigned int id_mask, unsigned int data)
35 id_addr += IPU_CTRL_BASE_ADDR;
36 rdata = readl(id_addr);
38 rdata |= (data * (id_mask & -id_mask)) & id_mask;
39 writel(rdata, id_addr);
45 void ipu_enable_display(void)
47 //enable DI0 (display interface 1)
48 ipu_write_field(IPU_IPU_CONF__DP_EN, 1);
49 ipu_write_field(IPU_IPU_CONF__DC_EN, 1);
50 ipu_write_field(IPU_IPU_CONF__DMFC_EN, 1);
51 ipu_write_field(IPU_IPU_CONF__DI0_EN, 1);
52 ipu_write_field(IPU_IPU_CONF__DI1_EN, 1);
53 #ifdef CYGPKG_HAL_ARM_MX51_3STACK
54 ipu_write_field(IPU_IPU_CONF__CSI1_EN, 1);
61 void ipu_disable_display(void)
63 ipu_write_field(IPU_IPU_CONF__DI0_EN, 0);
64 ipu_write_field(IPU_IPU_CONF__DI1_EN, 0);
65 ipu_write_field(IPU_IPU_CONF__DP_EN, 0);
66 ipu_write_field(IPU_IPU_CONF__DC_EN, 0);
67 ipu_write_field(IPU_IPU_CONF__DMFC_EN, 0);
68 ipu_write_field(IPU_IPU_CONF__IC_EN, 0);
69 #ifdef CYGPKG_HAL_ARM_MX51_3STACK
70 ipu_write_field(IPU_IPU_CONF__CSI0_EN, 0);
71 ipu_write_field(IPU_IPU_CONF__CSI1_EN, 0);
72 ipu_write_field(IPU_IPU_CONF__SMFC_EN, 0);
74 ipu_write_field(IPU_IC_CONF__PP_EN, 0);
75 ipu_write_field(IPU_IC_CONF__PRPVF_EN, 0);
76 ipu_write_field(IPU_IC_CONF__PRPENC_EN, 0);
79 #ifdef CYGHWR_MX51_LCD_LOGO
80 static display_buffer_info_t display_buffer;
83 * load the logo from nand flash to memory.
85 static bool do_logo_load(void)
90 unsigned int logo_size;
91 struct fis_image_desc *img;
93 /* Read the logo from storage media */
94 if ((img = fis_lookup("logo", NULL)) == NULL) {
95 diag_printf("No logo partition found in the fis table, logo not loaded\n");
99 fis_addr = (void *)img->flash_base;
100 logo_size = img->size;
101 ret = FLASH_READ(fis_addr, DISPLAY_BUFFER_ADDR, logo_size, &err_addr);
103 diag_printf("Loading logo from FLASH to MEMORY failed. error code: %d", ret);
109 * this function is used to reset ipu by SRC(system reset controller)
110 * the return value should be negative if resetting timeout
112 #define IPU_RESET (1 << 3)
113 static int ipu_sw_reset(int timeout)
117 tmpVal = readl(SRC_BASE_ADDR);
118 writel(tmpVal | IPU_RESET, SRC_BASE_ADDR);
119 while (timeout > 0) {
120 if (!(readl(SRC_BASE_ADDR) & IPU_RESET))
124 diag_printf("Error: ipu software reset timed out\n");
128 static void redboot_fastlogo_display(void)
130 bool fastlogo_feature_enable;
133 ok = CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
134 "fastlogo_enable", &fastlogo_feature_enable, CONFIG_BOOL);
136 if (ok && fastlogo_feature_enable) {
137 display_buffer.startAddr = (CYG_ADDRESS)DISPLAY_BUFFER_ADDR;
138 display_buffer.width = 640;
139 display_buffer.height = 480;
140 display_buffer.dataFormat = RGB565;
141 display_buffer.bpp = 16; // bit per pixel
142 display_buffer.channel = 28;
144 ipu_sw_reset(0x10000);
145 if (!do_logo_load()) {
148 //mxc_ipu_iomux_config();
151 fastlogo_init(&display_buffer);
156 ipu_enable_display();
157 ipu_idmac_channel_buf_ready(display_buffer.channel, 0);
161 #ifdef CYGPKG_REDBOOT
162 RedBoot_init(redboot_fastlogo_display, RedBoot_INIT_SECOND);
165 RedBoot_config_option("Enable fast logo display at boot",
167 ALWAYS_ENABLED, true,