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)
59 #ifndef CONFIG_DISPLAY_VBEST_VGG322403
62 #define PANEL_TYPE IPU_PANEL_TFT
63 #define PIXEL_CLK 185925
64 #define PIXEL_FMT IPU_PIX_FMT_RGB666
65 #define H_START_WIDTH 9 /* left_margin */
66 #define H_SYNC_WIDTH 1 /* hsync_len */
67 #define H_END_WIDTH (16 + 1) /* right_margin + hsync_len */
68 #define V_START_WIDTH 7 /* upper_margin */
69 #define V_SYNC_WIDTH 1 /* vsync_len */
70 #define V_END_WIDTH (9 + 1) /* lower_margin + vsync_len */
71 #define SIG_POL (DI_D3_DRDY_SHARP_POL | DI_D3_CLK_POL)
73 #define IF_CLK_DIV 0x175
74 #else /* Display Vbest VGG322403 */
77 #define PANEL_TYPE IPU_PANEL_TFT
78 #define PIXEL_CLK 156000
79 #define PIXEL_FMT IPU_PIX_FMT_RGB666
80 #define H_START_WIDTH 20 /* left_margin */
81 #define H_SYNC_WIDTH 30 /* hsync_len */
82 #define H_END_WIDTH (38 + 30) /* right_margin + hsync_len */
83 #define V_START_WIDTH 7 /* upper_margin */
84 #define V_SYNC_WIDTH 3 /* vsync_len */
85 #define V_END_WIDTH (26 + 3) /* lower_margin + vsync_len */
86 #define SIG_POL (DI_D3_DRDY_SHARP_POL | DI_D3_CLK_POL)
88 #define IF_CLK_DIV 0x175
91 #define LCD_COLOR_IPU LCD_COLOR16
93 static ushort colormap[256];
95 vidinfo_t panel_info = {
98 .vl_bpix = LCD_COLOR_IPU,
102 #define BIT_PER_PIXEL NBITS(LCD_COLOR_IPU)
104 /* IPU DMA Controller channel definitions. */
106 IDMAC_IC_0 = 0, /* IC (encoding task) to memory */
107 IDMAC_IC_1 = 1, /* IC (viewfinder task) to memory */
115 IDMAC_IC_7 = 7, /* IC (sensor data) to memory */
122 IDMAC_SDC_0 = 14, /* Background synchronous display data */
123 IDMAC_SDC_1 = 15, /* Foreground data (overlay) */
142 /* More formats can be copied from the Linux driver if needed */
152 struct pixel_fmt_cfg {
159 static struct pixel_fmt_cfg fmt_cfg[] = {
160 [IPU_PIX_FMT_RGB24] = {
161 0x1600AAAA, 0x00E05555, 0x00070000, 3,
163 [IPU_PIX_FMT_RGB666] = {
164 0x0005000F, 0x000B000F, 0x0011000F, 1,
166 [IPU_PIX_FMT_BGR666] = {
167 0x0011000F, 0x000B000F, 0x0005000F, 1,
169 [IPU_PIX_FMT_RGB565] = {
170 0x0004003F, 0x000A000F, 0x000F003F, 1,
179 /* IPU Common registers */
180 /* IPU_CONF and its bits already defined in mx31-regs.h */
181 #define IPU_CHA_BUF0_RDY (0x04 + IPU_BASE)
182 #define IPU_CHA_BUF1_RDY (0x08 + IPU_BASE)
183 #define IPU_CHA_DB_MODE_SEL (0x0C + IPU_BASE)
184 #define IPU_CHA_CUR_BUF (0x10 + IPU_BASE)
185 #define IPU_FS_PROC_FLOW (0x14 + IPU_BASE)
186 #define IPU_FS_DISP_FLOW (0x18 + IPU_BASE)
187 #define IPU_TASKS_STAT (0x1C + IPU_BASE)
188 #define IPU_IMA_ADDR (0x20 + IPU_BASE)
189 #define IPU_IMA_DATA (0x24 + IPU_BASE)
190 #define IPU_INT_CTRL_1 (0x28 + IPU_BASE)
191 #define IPU_INT_CTRL_2 (0x2C + IPU_BASE)
192 #define IPU_INT_CTRL_3 (0x30 + IPU_BASE)
193 #define IPU_INT_CTRL_4 (0x34 + IPU_BASE)
194 #define IPU_INT_CTRL_5 (0x38 + IPU_BASE)
195 #define IPU_INT_STAT_1 (0x3C + IPU_BASE)
196 #define IPU_INT_STAT_2 (0x40 + IPU_BASE)
197 #define IPU_INT_STAT_3 (0x44 + IPU_BASE)
198 #define IPU_INT_STAT_4 (0x48 + IPU_BASE)
199 #define IPU_INT_STAT_5 (0x4C + IPU_BASE)
200 #define IPU_BRK_CTRL_1 (0x50 + IPU_BASE)
201 #define IPU_BRK_CTRL_2 (0x54 + IPU_BASE)
202 #define IPU_BRK_STAT (0x58 + IPU_BASE)
203 #define IPU_DIAGB_CTRL (0x5C + IPU_BASE)
205 /* Image Converter Registers */
206 #define IC_CONF (0x88 + IPU_BASE)
207 #define IC_PRP_ENC_RSC (0x8C + IPU_BASE)
208 #define IC_PRP_VF_RSC (0x90 + IPU_BASE)
209 #define IC_PP_RSC (0x94 + IPU_BASE)
210 #define IC_CMBP_1 (0x98 + IPU_BASE)
211 #define IC_CMBP_2 (0x9C + IPU_BASE)
212 #define PF_CONF (0xA0 + IPU_BASE)
213 #define IDMAC_CONF (0xA4 + IPU_BASE)
214 #define IDMAC_CHA_EN (0xA8 + IPU_BASE)
215 #define IDMAC_CHA_PRI (0xAC + IPU_BASE)
216 #define IDMAC_CHA_BUSY (0xB0 + IPU_BASE)
218 /* Image Converter Register bits */
219 #define IC_CONF_PRPENC_EN 0x00000001
220 #define IC_CONF_PRPENC_CSC1 0x00000002
221 #define IC_CONF_PRPENC_ROT_EN 0x00000004
222 #define IC_CONF_PRPVF_EN 0x00000100
223 #define IC_CONF_PRPVF_CSC1 0x00000200
224 #define IC_CONF_PRPVF_CSC2 0x00000400
225 #define IC_CONF_PRPVF_CMB 0x00000800
226 #define IC_CONF_PRPVF_ROT_EN 0x00001000
227 #define IC_CONF_PP_EN 0x00010000
228 #define IC_CONF_PP_CSC1 0x00020000
229 #define IC_CONF_PP_CSC2 0x00040000
230 #define IC_CONF_PP_CMB 0x00080000
231 #define IC_CONF_PP_ROT_EN 0x00100000
232 #define IC_CONF_IC_GLB_LOC_A 0x10000000
233 #define IC_CONF_KEY_COLOR_EN 0x20000000
234 #define IC_CONF_RWS_EN 0x40000000
235 #define IC_CONF_CSI_MEM_WR_EN 0x80000000
238 #define SDC_COM_CONF (0xB4 + IPU_BASE)
239 #define SDC_GW_CTRL (0xB8 + IPU_BASE)
240 #define SDC_FG_POS (0xBC + IPU_BASE)
241 #define SDC_BG_POS (0xC0 + IPU_BASE)
242 #define SDC_CUR_POS (0xC4 + IPU_BASE)
243 #define SDC_PWM_CTRL (0xC8 + IPU_BASE)
244 #define SDC_CUR_MAP (0xCC + IPU_BASE)
245 #define SDC_HOR_CONF (0xD0 + IPU_BASE)
246 #define SDC_VER_CONF (0xD4 + IPU_BASE)
247 #define SDC_SHARP_CONF_1 (0xD8 + IPU_BASE)
248 #define SDC_SHARP_CONF_2 (0xDC + IPU_BASE)
251 #define SDC_COM_TFT_COLOR 0x00000001UL
252 #define SDC_COM_FG_EN 0x00000010UL
253 #define SDC_COM_GWSEL 0x00000020UL
254 #define SDC_COM_GLB_A 0x00000040UL
255 #define SDC_COM_KEY_COLOR_G 0x00000080UL
256 #define SDC_COM_BG_EN 0x00000200UL
257 #define SDC_COM_SHARP 0x00001000UL
259 #define SDC_V_SYNC_WIDTH_L 0x00000001UL
261 /* Display Interface registers */
262 #define DI_DISP_IF_CONF (0x0124 + IPU_BASE)
263 #define DI_DISP_SIG_POL (0x0128 + IPU_BASE)
264 #define DI_SER_DISP1_CONF (0x012C + IPU_BASE)
265 #define DI_SER_DISP2_CONF (0x0130 + IPU_BASE)
266 #define DI_HSP_CLK_PER (0x0134 + IPU_BASE)
267 #define DI_DISP0_TIME_CONF_1 (0x0138 + IPU_BASE)
268 #define DI_DISP0_TIME_CONF_2 (0x013C + IPU_BASE)
269 #define DI_DISP0_TIME_CONF_3 (0x0140 + IPU_BASE)
270 #define DI_DISP1_TIME_CONF_1 (0x0144 + IPU_BASE)
271 #define DI_DISP1_TIME_CONF_2 (0x0148 + IPU_BASE)
272 #define DI_DISP1_TIME_CONF_3 (0x014C + IPU_BASE)
273 #define DI_DISP2_TIME_CONF_1 (0x0150 + IPU_BASE)
274 #define DI_DISP2_TIME_CONF_2 (0x0154 + IPU_BASE)
275 #define DI_DISP2_TIME_CONF_3 (0x0158 + IPU_BASE)
276 #define DI_DISP3_TIME_CONF (0x015C + IPU_BASE)
277 #define DI_DISP0_DB0_MAP (0x0160 + IPU_BASE)
278 #define DI_DISP0_DB1_MAP (0x0164 + IPU_BASE)
279 #define DI_DISP0_DB2_MAP (0x0168 + IPU_BASE)
280 #define DI_DISP0_CB0_MAP (0x016C + IPU_BASE)
281 #define DI_DISP0_CB1_MAP (0x0170 + IPU_BASE)
282 #define DI_DISP0_CB2_MAP (0x0174 + IPU_BASE)
283 #define DI_DISP1_DB0_MAP (0x0178 + IPU_BASE)
284 #define DI_DISP1_DB1_MAP (0x017C + IPU_BASE)
285 #define DI_DISP1_DB2_MAP (0x0180 + IPU_BASE)
286 #define DI_DISP1_CB0_MAP (0x0184 + IPU_BASE)
287 #define DI_DISP1_CB1_MAP (0x0188 + IPU_BASE)
288 #define DI_DISP1_CB2_MAP (0x018C + IPU_BASE)
289 #define DI_DISP2_DB0_MAP (0x0190 + IPU_BASE)
290 #define DI_DISP2_DB1_MAP (0x0194 + IPU_BASE)
291 #define DI_DISP2_DB2_MAP (0x0198 + IPU_BASE)
292 #define DI_DISP2_CB0_MAP (0x019C + IPU_BASE)
293 #define DI_DISP2_CB1_MAP (0x01A0 + IPU_BASE)
294 #define DI_DISP2_CB2_MAP (0x01A4 + IPU_BASE)
295 #define DI_DISP3_B0_MAP (0x01A8 + IPU_BASE)
296 #define DI_DISP3_B1_MAP (0x01AC + IPU_BASE)
297 #define DI_DISP3_B2_MAP (0x01B0 + IPU_BASE)
298 #define DI_DISP_ACC_CC (0x01B4 + IPU_BASE)
299 #define DI_DISP_LLA_CONF (0x01B8 + IPU_BASE)
300 #define DI_DISP_LLA_DATA (0x01BC + IPU_BASE)
302 /* DI_DISP_SIG_POL bits */
303 #define DI_D3_VSYNC_POL (1 << 28)
304 #define DI_D3_HSYNC_POL (1 << 27)
305 #define DI_D3_DRDY_SHARP_POL (1 << 26)
306 #define DI_D3_CLK_POL (1 << 25)
307 #define DI_D3_DATA_POL (1 << 24)
309 /* DI_DISP_IF_CONF bits */
310 #define DI_D3_CLK_IDLE (1 << 26)
311 #define DI_D3_CLK_SEL (1 << 25)
312 #define DI_D3_DATAMSK (1 << 24)
314 #define IOMUX_PADNUM_MASK 0x1ff
315 #define IOMUX_GPIONUM_SHIFT 9
316 #define IOMUX_GPIONUM_MASK (0xff << IOMUX_GPIONUM_SHIFT)
318 #define IOMUX_PIN(gpionum, padnum) ((padnum) & IOMUX_PADNUM_MASK)
320 #define IOMUX_MODE_L(pin, mode) IOMUX_MODE(((pin) + 0xc) ^ 3, mode)
323 MX31_PIN_D3_SPL = IOMUX_PIN(0xff, 19),
324 MX31_PIN_D3_CLS = IOMUX_PIN(0xff, 20),
325 MX31_PIN_D3_REV = IOMUX_PIN(0xff, 21),
326 MX31_PIN_CONTRAST = IOMUX_PIN(0xff, 22),
327 MX31_PIN_VSYNC3 = IOMUX_PIN(0xff, 23),
329 MX31_PIN_DRDY0 = IOMUX_PIN(0xff, 33),
330 MX31_PIN_FPSHIFT = IOMUX_PIN(0xff, 34),
331 MX31_PIN_HSYNC = IOMUX_PIN(0xff, 35),
333 MX31_PIN_LD17 = IOMUX_PIN(0xff, 37),
334 MX31_PIN_LD16 = IOMUX_PIN(0xff, 38),
335 MX31_PIN_LD15 = IOMUX_PIN(0xff, 39),
336 MX31_PIN_LD14 = IOMUX_PIN(0xff, 40),
337 MX31_PIN_LD13 = IOMUX_PIN(0xff, 41),
338 MX31_PIN_LD12 = IOMUX_PIN(0xff, 42),
339 MX31_PIN_LD11 = IOMUX_PIN(0xff, 43),
340 MX31_PIN_LD10 = IOMUX_PIN(0xff, 44),
341 MX31_PIN_LD9 = IOMUX_PIN(0xff, 45),
342 MX31_PIN_LD8 = IOMUX_PIN(0xff, 46),
343 MX31_PIN_LD7 = IOMUX_PIN(0xff, 47),
344 MX31_PIN_LD6 = IOMUX_PIN(0xff, 48),
345 MX31_PIN_LD5 = IOMUX_PIN(0xff, 49),
346 MX31_PIN_LD4 = IOMUX_PIN(0xff, 50),
347 MX31_PIN_LD3 = IOMUX_PIN(0xff, 51),
348 MX31_PIN_LD2 = IOMUX_PIN(0xff, 52),
349 MX31_PIN_LD1 = IOMUX_PIN(0xff, 53),
350 MX31_PIN_LD0 = IOMUX_PIN(0xff, 54),
353 struct chan_param_mem_planar {
391 } __attribute__ ((packed));
393 struct chan_param_mem_interleaved {
450 } __attribute__ ((packed));
452 union chan_param_mem {
453 struct chan_param_mem_planar pp;
454 struct chan_param_mem_interleaved ip;
457 static inline u32 reg_read(unsigned long reg)
462 static inline void reg_write(u32 value, unsigned long reg)
468 * sdc_init_panel() - initialize a synchronous LCD panel.
469 * @width: width of panel in pixels.
470 * @height: height of panel in pixels.
471 * @pixel_fmt: pixel format of buffer as FOURCC ASCII code.
472 * @return: 0 on success or negative error code on failure.
474 static int sdc_init_panel(u16 width, u16 height, enum pixel_fmt pixel_fmt)
479 /* Init panel size and blanking periods */
480 reg = ((H_SYNC_WIDTH - 1) << 26) |
481 ((u32)(width + H_START_WIDTH + H_END_WIDTH - 1) << 16);
482 reg_write(reg, SDC_HOR_CONF);
484 reg = ((V_SYNC_WIDTH - 1) << 26) | SDC_V_SYNC_WIDTH_L |
485 ((u32)(height + V_START_WIDTH + V_END_WIDTH - 1) << 16);
486 reg_write(reg, SDC_VER_CONF);
488 switch (PANEL_TYPE) {
489 case IPU_PANEL_SHARP_TFT:
490 reg_write(0x00FD0102L, SDC_SHARP_CONF_1);
491 reg_write(0x00F500F4L, SDC_SHARP_CONF_2);
492 reg_write(SDC_COM_SHARP | SDC_COM_TFT_COLOR, SDC_COM_CONF);
495 reg_write(SDC_COM_TFT_COLOR, SDC_COM_CONF);
504 * Calculate divider: fractional part is 4 bits so simply multiple by
505 * 2^4 to get fractional part, as long as we stay under ~250MHz and on
506 * i.MX31 it (HSP_CLK) is <= 178MHz. Currently 128.267MHz
509 reg_write((((IF_CLK_DIV / 8) - 1) << 22) |
510 IF_CLK_DIV, DI_DISP3_TIME_CONF);
513 old_conf = reg_read(DI_DISP_IF_CONF) & 0x78FFFFFF;
514 reg_write(old_conf | IF_CONF, DI_DISP_IF_CONF);
516 old_conf = reg_read(DI_DISP_SIG_POL) & 0xE0FFFFFF;
517 reg_write(old_conf | SIG_POL, DI_DISP_SIG_POL);
519 reg_write(fmt_cfg[pixel_fmt].b0, DI_DISP3_B0_MAP);
520 reg_write(fmt_cfg[pixel_fmt].b1, DI_DISP3_B1_MAP);
521 reg_write(fmt_cfg[pixel_fmt].b2, DI_DISP3_B2_MAP);
522 reg_write(reg_read(DI_DISP_ACC_CC) |
523 ((fmt_cfg[pixel_fmt].acc - 1) << 12), DI_DISP_ACC_CC);
528 static void ipu_ch_param_set_size(union chan_param_mem *params,
529 uint32_t pixel_fmt, uint16_t width,
530 uint16_t height, uint16_t stride)
532 params->pp.fw = width - 1;
533 params->pp.fh_l = height - 1;
534 params->pp.fh_h = (height - 1) >> 8;
535 params->pp.sl = stride - 1;
537 /* See above, for further formats see the Linux driver */
539 case IPU_PIX_FMT_RGB565:
543 params->ip.sat = 2; /* SAT = 32-bit access */
544 params->ip.ofs0 = 0; /* Red bit offset */
545 params->ip.ofs1 = 5; /* Green bit offset */
546 params->ip.ofs2 = 11; /* Blue bit offset */
547 params->ip.ofs3 = 16; /* Alpha bit offset */
548 params->ip.wid0 = 4; /* Red bit width - 1 */
549 params->ip.wid1 = 5; /* Green bit width - 1 */
550 params->ip.wid2 = 4; /* Blue bit width - 1 */
552 case IPU_PIX_FMT_RGB24:
553 params->ip.bpp = 1; /* 24 BPP & RGB PFS */
556 params->ip.sat = 2; /* SAT = 32-bit access */
557 params->ip.ofs0 = 16; /* Red bit offset */
558 params->ip.ofs1 = 8; /* Green bit offset */
559 params->ip.ofs2 = 0; /* Blue bit offset */
560 params->ip.ofs3 = 24; /* Alpha bit offset */
561 params->ip.wid0 = 7; /* Red bit width - 1 */
562 params->ip.wid1 = 7; /* Green bit width - 1 */
563 params->ip.wid2 = 7; /* Blue bit width - 1 */
572 static void ipu_ch_param_set_buffer(union chan_param_mem *params,
573 void *buf0, void *buf1)
575 params->pp.eba0 = (u32)buf0;
576 params->pp.eba1 = (u32)buf1;
579 static void ipu_write_param_mem(uint32_t addr, uint32_t *data,
582 for (; num_words > 0; num_words--) {
583 reg_write(addr, IPU_IMA_ADDR);
584 reg_write(*data++, IPU_IMA_DATA);
586 if ((addr & 0x7) == 5) {
587 addr &= ~0x7; /* set to word 0 */
588 addr += 8; /* increment to next row */
593 static uint32_t bpp_to_pixfmt(int bpp)
597 return IPU_PIX_FMT_RGB565;
603 static uint32_t dma_param_addr(enum ipu_channel channel)
605 /* Channel Parameter Memory */
606 return 0x10000 | (channel << 4);
609 static void ipu_init_channel_buffer(enum ipu_channel channel, void *fbmem)
611 union chan_param_mem params = {};
613 uint32_t stride_bytes;
615 stride_bytes = (XRES * ((BIT_PER_PIXEL + 7) / 8) + 3) & ~3;
617 /* Build parameter memory data for DMA channel */
618 ipu_ch_param_set_size(¶ms, bpp_to_pixfmt(BIT_PER_PIXEL),
619 XRES, YRES, stride_bytes);
620 ipu_ch_param_set_buffer(¶ms, fbmem, NULL);
622 /* Some channels (rotation) have restriction on burst length */
626 /* In original code only IPU_PIX_FMT_RGB565 was setting burst */
627 params.pp.npb = 16 - 1;
633 ipu_write_param_mem(dma_param_addr(channel), (uint32_t *)¶ms, 10);
635 /* Disable double-buffering */
636 reg = reg_read(IPU_CHA_DB_MODE_SEL);
637 reg &= ~(1UL << channel);
638 reg_write(reg, IPU_CHA_DB_MODE_SEL);
641 static void ipu_channel_set_priority(enum ipu_channel channel,
644 u32 reg = reg_read(IDMAC_CHA_PRI);
647 reg |= 1UL << channel;
649 reg &= ~(1UL << channel);
651 reg_write(reg, IDMAC_CHA_PRI);
655 * ipu_enable_channel() - enable an IPU channel.
656 * @channel: channel ID.
657 * @return: 0 on success or negative error code on failure.
659 static int ipu_enable_channel(enum ipu_channel channel)
663 /* Reset to buffer 0 */
664 reg_write(1UL << channel, IPU_CHA_CUR_BUF);
668 ipu_channel_set_priority(channel, 1);
674 reg = reg_read(IDMAC_CHA_EN);
675 reg_write(reg | (1UL << channel), IDMAC_CHA_EN);
680 static int ipu_update_channel_buffer(enum ipu_channel channel, void *buf)
684 reg = reg_read(IPU_CHA_BUF0_RDY);
685 if (reg & (1UL << channel))
688 /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 0) */
689 reg_write(dma_param_addr(channel) + 0x0008UL, IPU_IMA_ADDR);
690 reg_write((u32)buf, IPU_IMA_DATA);
695 static int idmac_tx_submit(enum ipu_channel channel, void *buf)
699 ipu_init_channel_buffer(channel, buf);
702 /* ipu_idmac.c::ipu_submit_channel_buffers() */
703 ret = ipu_update_channel_buffer(channel, buf);
707 /* ipu_idmac.c::ipu_select_buffer() */
708 /* Mark buffer 0 as ready. */
709 reg_write(1UL << channel, IPU_CHA_BUF0_RDY);
712 ret = ipu_enable_channel(channel);
716 static void sdc_enable_channel(void *fbmem)
721 ret = idmac_tx_submit(IDMAC_SDC_0, fbmem);
723 /* mx3fb.c::sdc_fb_init() */
725 reg = reg_read(SDC_COM_CONF);
726 reg_write(reg | SDC_COM_BG_EN, SDC_COM_CONF);
730 * Attention! Without this msleep the channel keeps generating
731 * interrupts. Next sdc_set_brightness() is going to be called
732 * from mx3fb_blank().
738 * mx3fb_set_par() - set framebuffer parameters and change the operating mode.
739 * @return: 0 on success or negative error code on failure.
741 static int mx3fb_set_par(void)
745 ret = sdc_init_panel(XRES, YRES, PIXEL_FMT);
749 reg_write((H_START_WIDTH << 16) | V_START_WIDTH, SDC_BG_POS);
754 /* References in this function refer to respective Linux kernel sources */
755 void lcd_enable(void)
759 /* pcm037.c::mxc_board_init() */
761 /* Display Interface #3 */
762 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD0, MUX_CTL_FUNC));
763 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD1, MUX_CTL_FUNC));
764 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD2, MUX_CTL_FUNC));
765 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD3, MUX_CTL_FUNC));
766 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD4, MUX_CTL_FUNC));
767 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD5, MUX_CTL_FUNC));
768 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD6, MUX_CTL_FUNC));
769 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD7, MUX_CTL_FUNC));
770 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD8, MUX_CTL_FUNC));
771 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD9, MUX_CTL_FUNC));
772 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD10, MUX_CTL_FUNC));
773 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD11, MUX_CTL_FUNC));
774 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD12, MUX_CTL_FUNC));
775 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD13, MUX_CTL_FUNC));
776 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD14, MUX_CTL_FUNC));
777 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD15, MUX_CTL_FUNC));
778 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD16, MUX_CTL_FUNC));
779 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD17, MUX_CTL_FUNC));
780 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_VSYNC3, MUX_CTL_FUNC));
781 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_HSYNC, MUX_CTL_FUNC));
782 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_FPSHIFT, MUX_CTL_FUNC));
783 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_DRDY0, MUX_CTL_FUNC));
784 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_REV, MUX_CTL_FUNC));
785 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_CONTRAST, MUX_CTL_FUNC));
786 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_SPL, MUX_CTL_FUNC));
787 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_CLS, MUX_CTL_FUNC));
790 /* ipu_idmac.c::ipu_probe() */
792 /* Start the clock */
793 __REG(CCM_CGR1) = __REG(CCM_CGR1) | (3 << 22);
796 /* ipu_idmac.c::ipu_idmac_init() */
798 /* Service request counter to maximum - shouldn't be needed */
799 reg_write(0x00000070, IDMAC_CONF);
802 /* ipu_idmac.c::ipu_init_channel() */
804 /* Enable IPU sub modules */
805 reg = reg_read(IPU_CONF) | IPU_CONF_SDC_EN | IPU_CONF_DI_EN;
806 reg_write(reg, IPU_CONF);
809 /* mx3fb.c::init_fb_chan() */
811 /* set Display Interface clock period */
812 reg_write(0x00100010L, DI_HSP_CLK_PER);
813 /* Might need to trigger HSP clock change - see 44.3.3.8.5 */
816 /* mx3fb.c::sdc_set_brightness() */
818 /* This might be board-specific */
819 reg_write(0x03000000UL | 255 << 16, SDC_PWM_CTRL);
822 /* mx3fb.c::sdc_set_global_alpha() */
824 /* Use global - not per-pixel - Alpha-blending */
825 reg = reg_read(SDC_GW_CTRL) & 0x00FFFFFFL;
826 reg_write(reg | ((uint32_t) 0xff << 24), SDC_GW_CTRL);
828 reg = reg_read(SDC_COM_CONF);
829 reg_write(reg | SDC_COM_GLB_A, SDC_COM_CONF);
832 /* mx3fb.c::sdc_set_color_key() */
834 /* Disable colour-keying for background */
835 reg = reg_read(SDC_COM_CONF) &
836 ~(SDC_COM_GWSEL | SDC_COM_KEY_COLOR_G);
837 reg_write(reg, SDC_COM_CONF);
842 sdc_enable_channel(lcd_base);
845 * Linux driver calls sdc_set_brightness() here again,
846 * once is enough for us
850 void lcd_ctrl_init(void *lcdbase)
852 u32 mem_len = XRES * YRES * BIT_PER_PIXEL / 8;
854 * We rely on lcdbase being a physical address, i.e., either MMU off,
855 * or 1-to-1 mapping. Might want to add some virt2phys here.
860 memset(lcdbase, 0, mem_len);
863 ulong calc_fbsize(void)
865 return ((panel_info.vl_col * panel_info.vl_row *
866 NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
869 int overwrite_console(void)
871 /* Keep stdout / stderr on serial, our LCD is for splashscreen only */