3 * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <asm/arch/mx31.h>
26 #include <asm/arch/mx31-regs.h>
27 #include <asm/errno.h>
29 DECLARE_GLOBAL_DATA_PTR;
31 void *lcd_base; /* Start of framebuffer memory */
32 void *lcd_console_address; /* Start of console buffer */
41 void lcd_initcolregs(void)
45 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
49 void lcd_disable(void)
53 void lcd_panel_disable(void)
57 #define msleep(a) udelay(a * 1000)
61 #define PANEL_TYPE IPU_PANEL_TFT
62 #define PIXEL_CLK 185925
63 #define PIXEL_FMT IPU_PIX_FMT_RGB666
64 #define H_START_WIDTH 9 /* left_margin */
65 #define H_SYNC_WIDTH 1 /* hsync_len */
66 #define H_END_WIDTH (16 + 1) /* right_margin + hsync_len */
67 #define V_START_WIDTH 7 /* upper_margin */
68 #define V_SYNC_WIDTH 1 /* vsync_len */
69 #define V_END_WIDTH (9 + 1) /* lower_margin + vsync_len */
70 #define SIG_POL (DI_D3_DRDY_SHARP_POL | DI_D3_CLK_POL)
72 #define IF_CLK_DIV 0x175
74 #define LCD_COLOR_IPU LCD_COLOR16
76 static ushort colormap[256];
78 vidinfo_t panel_info = {
81 .vl_bpix = LCD_COLOR_IPU,
85 #define BIT_PER_PIXEL NBITS(LCD_COLOR_IPU)
87 /* IPU DMA Controller channel definitions. */
89 IDMAC_IC_0 = 0, /* IC (encoding task) to memory */
90 IDMAC_IC_1 = 1, /* IC (viewfinder task) to memory */
98 IDMAC_IC_7 = 7, /* IC (sensor data) to memory */
105 IDMAC_SDC_0 = 14, /* Background synchronous display data */
106 IDMAC_SDC_1 = 15, /* Foreground data (overlay) */
125 /* More formats can be copied from the Linux driver if needed */
135 struct pixel_fmt_cfg {
142 static struct pixel_fmt_cfg fmt_cfg[] = {
143 [IPU_PIX_FMT_RGB24] = {
144 0x1600AAAA, 0x00E05555, 0x00070000, 3,
146 [IPU_PIX_FMT_RGB666] = {
147 0x0005000F, 0x000B000F, 0x0011000F, 1,
149 [IPU_PIX_FMT_BGR666] = {
150 0x0011000F, 0x000B000F, 0x0005000F, 1,
152 [IPU_PIX_FMT_RGB565] = {
153 0x0004003F, 0x000A000F, 0x000F003F, 1,
162 /* IPU Common registers */
163 /* IPU_CONF and its bits already defined in mx31-regs.h */
164 #define IPU_CHA_BUF0_RDY (0x04 + IPU_BASE)
165 #define IPU_CHA_BUF1_RDY (0x08 + IPU_BASE)
166 #define IPU_CHA_DB_MODE_SEL (0x0C + IPU_BASE)
167 #define IPU_CHA_CUR_BUF (0x10 + IPU_BASE)
168 #define IPU_FS_PROC_FLOW (0x14 + IPU_BASE)
169 #define IPU_FS_DISP_FLOW (0x18 + IPU_BASE)
170 #define IPU_TASKS_STAT (0x1C + IPU_BASE)
171 #define IPU_IMA_ADDR (0x20 + IPU_BASE)
172 #define IPU_IMA_DATA (0x24 + IPU_BASE)
173 #define IPU_INT_CTRL_1 (0x28 + IPU_BASE)
174 #define IPU_INT_CTRL_2 (0x2C + IPU_BASE)
175 #define IPU_INT_CTRL_3 (0x30 + IPU_BASE)
176 #define IPU_INT_CTRL_4 (0x34 + IPU_BASE)
177 #define IPU_INT_CTRL_5 (0x38 + IPU_BASE)
178 #define IPU_INT_STAT_1 (0x3C + IPU_BASE)
179 #define IPU_INT_STAT_2 (0x40 + IPU_BASE)
180 #define IPU_INT_STAT_3 (0x44 + IPU_BASE)
181 #define IPU_INT_STAT_4 (0x48 + IPU_BASE)
182 #define IPU_INT_STAT_5 (0x4C + IPU_BASE)
183 #define IPU_BRK_CTRL_1 (0x50 + IPU_BASE)
184 #define IPU_BRK_CTRL_2 (0x54 + IPU_BASE)
185 #define IPU_BRK_STAT (0x58 + IPU_BASE)
186 #define IPU_DIAGB_CTRL (0x5C + IPU_BASE)
188 /* Image Converter Registers */
189 #define IC_CONF (0x88 + IPU_BASE)
190 #define IC_PRP_ENC_RSC (0x8C + IPU_BASE)
191 #define IC_PRP_VF_RSC (0x90 + IPU_BASE)
192 #define IC_PP_RSC (0x94 + IPU_BASE)
193 #define IC_CMBP_1 (0x98 + IPU_BASE)
194 #define IC_CMBP_2 (0x9C + IPU_BASE)
195 #define PF_CONF (0xA0 + IPU_BASE)
196 #define IDMAC_CONF (0xA4 + IPU_BASE)
197 #define IDMAC_CHA_EN (0xA8 + IPU_BASE)
198 #define IDMAC_CHA_PRI (0xAC + IPU_BASE)
199 #define IDMAC_CHA_BUSY (0xB0 + IPU_BASE)
201 /* Image Converter Register bits */
202 #define IC_CONF_PRPENC_EN 0x00000001
203 #define IC_CONF_PRPENC_CSC1 0x00000002
204 #define IC_CONF_PRPENC_ROT_EN 0x00000004
205 #define IC_CONF_PRPVF_EN 0x00000100
206 #define IC_CONF_PRPVF_CSC1 0x00000200
207 #define IC_CONF_PRPVF_CSC2 0x00000400
208 #define IC_CONF_PRPVF_CMB 0x00000800
209 #define IC_CONF_PRPVF_ROT_EN 0x00001000
210 #define IC_CONF_PP_EN 0x00010000
211 #define IC_CONF_PP_CSC1 0x00020000
212 #define IC_CONF_PP_CSC2 0x00040000
213 #define IC_CONF_PP_CMB 0x00080000
214 #define IC_CONF_PP_ROT_EN 0x00100000
215 #define IC_CONF_IC_GLB_LOC_A 0x10000000
216 #define IC_CONF_KEY_COLOR_EN 0x20000000
217 #define IC_CONF_RWS_EN 0x40000000
218 #define IC_CONF_CSI_MEM_WR_EN 0x80000000
221 #define SDC_COM_CONF (0xB4 + IPU_BASE)
222 #define SDC_GW_CTRL (0xB8 + IPU_BASE)
223 #define SDC_FG_POS (0xBC + IPU_BASE)
224 #define SDC_BG_POS (0xC0 + IPU_BASE)
225 #define SDC_CUR_POS (0xC4 + IPU_BASE)
226 #define SDC_PWM_CTRL (0xC8 + IPU_BASE)
227 #define SDC_CUR_MAP (0xCC + IPU_BASE)
228 #define SDC_HOR_CONF (0xD0 + IPU_BASE)
229 #define SDC_VER_CONF (0xD4 + IPU_BASE)
230 #define SDC_SHARP_CONF_1 (0xD8 + IPU_BASE)
231 #define SDC_SHARP_CONF_2 (0xDC + IPU_BASE)
234 #define SDC_COM_TFT_COLOR 0x00000001UL
235 #define SDC_COM_FG_EN 0x00000010UL
236 #define SDC_COM_GWSEL 0x00000020UL
237 #define SDC_COM_GLB_A 0x00000040UL
238 #define SDC_COM_KEY_COLOR_G 0x00000080UL
239 #define SDC_COM_BG_EN 0x00000200UL
240 #define SDC_COM_SHARP 0x00001000UL
242 #define SDC_V_SYNC_WIDTH_L 0x00000001UL
244 /* Display Interface registers */
245 #define DI_DISP_IF_CONF (0x0124 + IPU_BASE)
246 #define DI_DISP_SIG_POL (0x0128 + IPU_BASE)
247 #define DI_SER_DISP1_CONF (0x012C + IPU_BASE)
248 #define DI_SER_DISP2_CONF (0x0130 + IPU_BASE)
249 #define DI_HSP_CLK_PER (0x0134 + IPU_BASE)
250 #define DI_DISP0_TIME_CONF_1 (0x0138 + IPU_BASE)
251 #define DI_DISP0_TIME_CONF_2 (0x013C + IPU_BASE)
252 #define DI_DISP0_TIME_CONF_3 (0x0140 + IPU_BASE)
253 #define DI_DISP1_TIME_CONF_1 (0x0144 + IPU_BASE)
254 #define DI_DISP1_TIME_CONF_2 (0x0148 + IPU_BASE)
255 #define DI_DISP1_TIME_CONF_3 (0x014C + IPU_BASE)
256 #define DI_DISP2_TIME_CONF_1 (0x0150 + IPU_BASE)
257 #define DI_DISP2_TIME_CONF_2 (0x0154 + IPU_BASE)
258 #define DI_DISP2_TIME_CONF_3 (0x0158 + IPU_BASE)
259 #define DI_DISP3_TIME_CONF (0x015C + IPU_BASE)
260 #define DI_DISP0_DB0_MAP (0x0160 + IPU_BASE)
261 #define DI_DISP0_DB1_MAP (0x0164 + IPU_BASE)
262 #define DI_DISP0_DB2_MAP (0x0168 + IPU_BASE)
263 #define DI_DISP0_CB0_MAP (0x016C + IPU_BASE)
264 #define DI_DISP0_CB1_MAP (0x0170 + IPU_BASE)
265 #define DI_DISP0_CB2_MAP (0x0174 + IPU_BASE)
266 #define DI_DISP1_DB0_MAP (0x0178 + IPU_BASE)
267 #define DI_DISP1_DB1_MAP (0x017C + IPU_BASE)
268 #define DI_DISP1_DB2_MAP (0x0180 + IPU_BASE)
269 #define DI_DISP1_CB0_MAP (0x0184 + IPU_BASE)
270 #define DI_DISP1_CB1_MAP (0x0188 + IPU_BASE)
271 #define DI_DISP1_CB2_MAP (0x018C + IPU_BASE)
272 #define DI_DISP2_DB0_MAP (0x0190 + IPU_BASE)
273 #define DI_DISP2_DB1_MAP (0x0194 + IPU_BASE)
274 #define DI_DISP2_DB2_MAP (0x0198 + IPU_BASE)
275 #define DI_DISP2_CB0_MAP (0x019C + IPU_BASE)
276 #define DI_DISP2_CB1_MAP (0x01A0 + IPU_BASE)
277 #define DI_DISP2_CB2_MAP (0x01A4 + IPU_BASE)
278 #define DI_DISP3_B0_MAP (0x01A8 + IPU_BASE)
279 #define DI_DISP3_B1_MAP (0x01AC + IPU_BASE)
280 #define DI_DISP3_B2_MAP (0x01B0 + IPU_BASE)
281 #define DI_DISP_ACC_CC (0x01B4 + IPU_BASE)
282 #define DI_DISP_LLA_CONF (0x01B8 + IPU_BASE)
283 #define DI_DISP_LLA_DATA (0x01BC + IPU_BASE)
285 /* DI_DISP_SIG_POL bits */
286 #define DI_D3_VSYNC_POL (1 << 28)
287 #define DI_D3_HSYNC_POL (1 << 27)
288 #define DI_D3_DRDY_SHARP_POL (1 << 26)
289 #define DI_D3_CLK_POL (1 << 25)
290 #define DI_D3_DATA_POL (1 << 24)
292 /* DI_DISP_IF_CONF bits */
293 #define DI_D3_CLK_IDLE (1 << 26)
294 #define DI_D3_CLK_SEL (1 << 25)
295 #define DI_D3_DATAMSK (1 << 24)
297 #define IOMUX_PADNUM_MASK 0x1ff
298 #define IOMUX_GPIONUM_SHIFT 9
299 #define IOMUX_GPIONUM_MASK (0xff << IOMUX_GPIONUM_SHIFT)
301 #define IOMUX_PIN(gpionum, padnum) ((padnum) & IOMUX_PADNUM_MASK)
303 #define IOMUX_MODE_L(pin, mode) IOMUX_MODE(((pin) + 0xc) ^ 3, mode)
306 MX31_PIN_D3_SPL = IOMUX_PIN(0xff, 19),
307 MX31_PIN_D3_CLS = IOMUX_PIN(0xff, 20),
308 MX31_PIN_D3_REV = IOMUX_PIN(0xff, 21),
309 MX31_PIN_CONTRAST = IOMUX_PIN(0xff, 22),
310 MX31_PIN_VSYNC3 = IOMUX_PIN(0xff, 23),
312 MX31_PIN_DRDY0 = IOMUX_PIN(0xff, 33),
313 MX31_PIN_FPSHIFT = IOMUX_PIN(0xff, 34),
314 MX31_PIN_HSYNC = IOMUX_PIN(0xff, 35),
316 MX31_PIN_LD17 = IOMUX_PIN(0xff, 37),
317 MX31_PIN_LD16 = IOMUX_PIN(0xff, 38),
318 MX31_PIN_LD15 = IOMUX_PIN(0xff, 39),
319 MX31_PIN_LD14 = IOMUX_PIN(0xff, 40),
320 MX31_PIN_LD13 = IOMUX_PIN(0xff, 41),
321 MX31_PIN_LD12 = IOMUX_PIN(0xff, 42),
322 MX31_PIN_LD11 = IOMUX_PIN(0xff, 43),
323 MX31_PIN_LD10 = IOMUX_PIN(0xff, 44),
324 MX31_PIN_LD9 = IOMUX_PIN(0xff, 45),
325 MX31_PIN_LD8 = IOMUX_PIN(0xff, 46),
326 MX31_PIN_LD7 = IOMUX_PIN(0xff, 47),
327 MX31_PIN_LD6 = IOMUX_PIN(0xff, 48),
328 MX31_PIN_LD5 = IOMUX_PIN(0xff, 49),
329 MX31_PIN_LD4 = IOMUX_PIN(0xff, 50),
330 MX31_PIN_LD3 = IOMUX_PIN(0xff, 51),
331 MX31_PIN_LD2 = IOMUX_PIN(0xff, 52),
332 MX31_PIN_LD1 = IOMUX_PIN(0xff, 53),
333 MX31_PIN_LD0 = IOMUX_PIN(0xff, 54),
336 struct chan_param_mem_planar {
374 } __attribute__ ((packed));
376 struct chan_param_mem_interleaved {
433 } __attribute__ ((packed));
435 union chan_param_mem {
436 struct chan_param_mem_planar pp;
437 struct chan_param_mem_interleaved ip;
440 static inline u32 reg_read(unsigned long reg)
445 static inline void reg_write(u32 value, unsigned long reg)
451 * sdc_init_panel() - initialize a synchronous LCD panel.
452 * @width: width of panel in pixels.
453 * @height: height of panel in pixels.
454 * @pixel_fmt: pixel format of buffer as FOURCC ASCII code.
455 * @return: 0 on success or negative error code on failure.
457 static int sdc_init_panel(u16 width, u16 height, enum pixel_fmt pixel_fmt)
462 /* Init panel size and blanking periods */
463 reg = ((H_SYNC_WIDTH - 1) << 26) |
464 ((u32)(width + H_START_WIDTH + H_END_WIDTH - 1) << 16);
465 reg_write(reg, SDC_HOR_CONF);
467 reg = ((V_SYNC_WIDTH - 1) << 26) | SDC_V_SYNC_WIDTH_L |
468 ((u32)(height + V_START_WIDTH + V_END_WIDTH - 1) << 16);
469 reg_write(reg, SDC_VER_CONF);
471 switch (PANEL_TYPE) {
472 case IPU_PANEL_SHARP_TFT:
473 reg_write(0x00FD0102L, SDC_SHARP_CONF_1);
474 reg_write(0x00F500F4L, SDC_SHARP_CONF_2);
475 reg_write(SDC_COM_SHARP | SDC_COM_TFT_COLOR, SDC_COM_CONF);
478 reg_write(SDC_COM_TFT_COLOR, SDC_COM_CONF);
487 * Calculate divider: fractional part is 4 bits so simply multiple by
488 * 2^4 to get fractional part, as long as we stay under ~250MHz and on
489 * i.MX31 it (HSP_CLK) is <= 178MHz. Currently 128.267MHz
492 reg_write((((IF_CLK_DIV / 8) - 1) << 22) |
493 IF_CLK_DIV, DI_DISP3_TIME_CONF);
496 old_conf = reg_read(DI_DISP_IF_CONF) & 0x78FFFFFF;
497 reg_write(old_conf | IF_CONF, DI_DISP_IF_CONF);
499 old_conf = reg_read(DI_DISP_SIG_POL) & 0xE0FFFFFF;
500 reg_write(old_conf | SIG_POL, DI_DISP_SIG_POL);
502 reg_write(fmt_cfg[pixel_fmt].b0, DI_DISP3_B0_MAP);
503 reg_write(fmt_cfg[pixel_fmt].b1, DI_DISP3_B1_MAP);
504 reg_write(fmt_cfg[pixel_fmt].b2, DI_DISP3_B2_MAP);
505 reg_write(reg_read(DI_DISP_ACC_CC) |
506 ((fmt_cfg[pixel_fmt].acc - 1) << 12), DI_DISP_ACC_CC);
511 static void ipu_ch_param_set_size(union chan_param_mem *params,
512 uint32_t pixel_fmt, uint16_t width,
513 uint16_t height, uint16_t stride)
515 params->pp.fw = width - 1;
516 params->pp.fh_l = height - 1;
517 params->pp.fh_h = (height - 1) >> 8;
518 params->pp.sl = stride - 1;
520 /* See above, for further formats see the Linux driver */
522 case IPU_PIX_FMT_RGB565:
526 params->ip.sat = 2; /* SAT = 32-bit access */
527 params->ip.ofs0 = 0; /* Red bit offset */
528 params->ip.ofs1 = 5; /* Green bit offset */
529 params->ip.ofs2 = 11; /* Blue bit offset */
530 params->ip.ofs3 = 16; /* Alpha bit offset */
531 params->ip.wid0 = 4; /* Red bit width - 1 */
532 params->ip.wid1 = 5; /* Green bit width - 1 */
533 params->ip.wid2 = 4; /* Blue bit width - 1 */
535 case IPU_PIX_FMT_RGB24:
536 params->ip.bpp = 1; /* 24 BPP & RGB PFS */
539 params->ip.sat = 2; /* SAT = 32-bit access */
540 params->ip.ofs0 = 16; /* Red bit offset */
541 params->ip.ofs1 = 8; /* Green bit offset */
542 params->ip.ofs2 = 0; /* Blue bit offset */
543 params->ip.ofs3 = 24; /* Alpha bit offset */
544 params->ip.wid0 = 7; /* Red bit width - 1 */
545 params->ip.wid1 = 7; /* Green bit width - 1 */
546 params->ip.wid2 = 7; /* Blue bit width - 1 */
555 static void ipu_ch_param_set_buffer(union chan_param_mem *params,
556 void *buf0, void *buf1)
558 params->pp.eba0 = (u32)buf0;
559 params->pp.eba1 = (u32)buf1;
562 static void ipu_write_param_mem(uint32_t addr, uint32_t *data,
565 for (; num_words > 0; num_words--) {
566 reg_write(addr, IPU_IMA_ADDR);
567 reg_write(*data++, IPU_IMA_DATA);
569 if ((addr & 0x7) == 5) {
570 addr &= ~0x7; /* set to word 0 */
571 addr += 8; /* increment to next row */
576 static uint32_t bpp_to_pixfmt(int bpp)
580 return IPU_PIX_FMT_RGB565;
586 static uint32_t dma_param_addr(enum ipu_channel channel)
588 /* Channel Parameter Memory */
589 return 0x10000 | (channel << 4);
592 static void ipu_init_channel_buffer(enum ipu_channel channel, void *fbmem)
594 union chan_param_mem params = {};
596 uint32_t stride_bytes;
598 stride_bytes = (XRES * ((BIT_PER_PIXEL + 7) / 8) + 3) & ~3;
600 /* Build parameter memory data for DMA channel */
601 ipu_ch_param_set_size(¶ms, bpp_to_pixfmt(BIT_PER_PIXEL),
602 XRES, YRES, stride_bytes);
603 ipu_ch_param_set_buffer(¶ms, fbmem, NULL);
605 /* Some channels (rotation) have restriction on burst length */
609 /* In original code only IPU_PIX_FMT_RGB565 was setting burst */
610 params.pp.npb = 16 - 1;
616 ipu_write_param_mem(dma_param_addr(channel), (uint32_t *)¶ms, 10);
618 /* Disable double-buffering */
619 reg = reg_read(IPU_CHA_DB_MODE_SEL);
620 reg &= ~(1UL << channel);
621 reg_write(reg, IPU_CHA_DB_MODE_SEL);
624 static void ipu_channel_set_priority(enum ipu_channel channel,
627 u32 reg = reg_read(IDMAC_CHA_PRI);
630 reg |= 1UL << channel;
632 reg &= ~(1UL << channel);
634 reg_write(reg, IDMAC_CHA_PRI);
638 * ipu_enable_channel() - enable an IPU channel.
639 * @channel: channel ID.
640 * @return: 0 on success or negative error code on failure.
642 static int ipu_enable_channel(enum ipu_channel channel)
646 /* Reset to buffer 0 */
647 reg_write(1UL << channel, IPU_CHA_CUR_BUF);
651 ipu_channel_set_priority(channel, 1);
657 reg = reg_read(IDMAC_CHA_EN);
658 reg_write(reg | (1UL << channel), IDMAC_CHA_EN);
663 static int ipu_update_channel_buffer(enum ipu_channel channel, void *buf)
667 reg = reg_read(IPU_CHA_BUF0_RDY);
668 if (reg & (1UL << channel))
671 /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 0) */
672 reg_write(dma_param_addr(channel) + 0x0008UL, IPU_IMA_ADDR);
673 reg_write((u32)buf, IPU_IMA_DATA);
678 static int idmac_tx_submit(enum ipu_channel channel, void *buf)
682 ipu_init_channel_buffer(channel, buf);
685 /* ipu_idmac.c::ipu_submit_channel_buffers() */
686 ret = ipu_update_channel_buffer(channel, buf);
690 /* ipu_idmac.c::ipu_select_buffer() */
691 /* Mark buffer 0 as ready. */
692 reg_write(1UL << channel, IPU_CHA_BUF0_RDY);
695 ret = ipu_enable_channel(channel);
699 static void sdc_enable_channel(void *fbmem)
704 ret = idmac_tx_submit(IDMAC_SDC_0, fbmem);
706 /* mx3fb.c::sdc_fb_init() */
708 reg = reg_read(SDC_COM_CONF);
709 reg_write(reg | SDC_COM_BG_EN, SDC_COM_CONF);
713 * Attention! Without this msleep the channel keeps generating
714 * interrupts. Next sdc_set_brightness() is going to be called
715 * from mx3fb_blank().
721 * mx3fb_set_par() - set framebuffer parameters and change the operating mode.
722 * @return: 0 on success or negative error code on failure.
724 static int mx3fb_set_par(void)
728 ret = sdc_init_panel(XRES, YRES, PIXEL_FMT);
732 reg_write((H_START_WIDTH << 16) | V_START_WIDTH, SDC_BG_POS);
737 /* References in this function refer to respective Linux kernel sources */
738 void lcd_enable(void)
742 /* pcm037.c::mxc_board_init() */
744 /* Display Interface #3 */
745 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD0, MUX_CTL_FUNC));
746 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD1, MUX_CTL_FUNC));
747 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD2, MUX_CTL_FUNC));
748 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD3, MUX_CTL_FUNC));
749 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD4, MUX_CTL_FUNC));
750 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD5, MUX_CTL_FUNC));
751 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD6, MUX_CTL_FUNC));
752 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD7, MUX_CTL_FUNC));
753 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD8, MUX_CTL_FUNC));
754 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD9, MUX_CTL_FUNC));
755 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD10, MUX_CTL_FUNC));
756 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD11, MUX_CTL_FUNC));
757 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD12, MUX_CTL_FUNC));
758 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD13, MUX_CTL_FUNC));
759 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD14, MUX_CTL_FUNC));
760 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD15, MUX_CTL_FUNC));
761 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD16, MUX_CTL_FUNC));
762 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD17, MUX_CTL_FUNC));
763 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_VSYNC3, MUX_CTL_FUNC));
764 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_HSYNC, MUX_CTL_FUNC));
765 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_FPSHIFT, MUX_CTL_FUNC));
766 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_DRDY0, MUX_CTL_FUNC));
767 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_REV, MUX_CTL_FUNC));
768 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_CONTRAST, MUX_CTL_FUNC));
769 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_SPL, MUX_CTL_FUNC));
770 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_CLS, MUX_CTL_FUNC));
773 /* ipu_idmac.c::ipu_probe() */
775 /* Start the clock */
776 __REG(CCM_CGR1) = __REG(CCM_CGR1) | (3 << 22);
779 /* ipu_idmac.c::ipu_idmac_init() */
781 /* Service request counter to maximum - shouldn't be needed */
782 reg_write(0x00000070, IDMAC_CONF);
785 /* ipu_idmac.c::ipu_init_channel() */
787 /* Enable IPU sub modules */
788 reg = reg_read(IPU_CONF) | IPU_CONF_SDC_EN | IPU_CONF_DI_EN;
789 reg_write(reg, IPU_CONF);
792 /* mx3fb.c::init_fb_chan() */
794 /* set Display Interface clock period */
795 reg_write(0x00100010L, DI_HSP_CLK_PER);
796 /* Might need to trigger HSP clock change - see 44.3.3.8.5 */
799 /* mx3fb.c::sdc_set_brightness() */
801 /* This might be board-specific */
802 reg_write(0x03000000UL | 255 << 16, SDC_PWM_CTRL);
805 /* mx3fb.c::sdc_set_global_alpha() */
807 /* Use global - not per-pixel - Alpha-blending */
808 reg = reg_read(SDC_GW_CTRL) & 0x00FFFFFFL;
809 reg_write(reg | ((uint32_t) 0xff << 24), SDC_GW_CTRL);
811 reg = reg_read(SDC_COM_CONF);
812 reg_write(reg | SDC_COM_GLB_A, SDC_COM_CONF);
815 /* mx3fb.c::sdc_set_color_key() */
817 /* Disable colour-keying for background */
818 reg = reg_read(SDC_COM_CONF) &
819 ~(SDC_COM_GWSEL | SDC_COM_KEY_COLOR_G);
820 reg_write(reg, SDC_COM_CONF);
825 sdc_enable_channel(lcd_base);
828 * Linux driver calls sdc_set_brightness() here again,
829 * once is enough for us
833 void lcd_ctrl_init(void *lcdbase)
835 u32 mem_len = XRES * YRES * BIT_PER_PIXEL / 8;
837 * We rely on lcdbase being a physical address, i.e., either MMU off,
838 * or 1-to-1 mapping. Might want to add some virt2phys here.
843 memset(lcdbase, 0, mem_len);
846 ulong calc_fbsize(void)
848 return ((panel_info.vl_col * panel_info.vl_row *
849 NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
852 int overwrite_console(void)
854 /* Keep stdout / stderr on serial, our LCD is for splashscreen only */