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/clock.h>
26 #include <asm/arch/imx-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 #if defined(CONFIG_DISPLAY_VBEST_VGG322403)
62 #define PANEL_TYPE IPU_PANEL_TFT
63 #define PIXEL_CLK 156000
64 #define PIXEL_FMT IPU_PIX_FMT_RGB666
65 #define H_START_WIDTH 20 /* left_margin */
66 #define H_SYNC_WIDTH 30 /* hsync_len */
67 #define H_END_WIDTH (38 + 30) /* right_margin + hsync_len */
68 #define V_START_WIDTH 7 /* upper_margin */
69 #define V_SYNC_WIDTH 3 /* vsync_len */
70 #define V_END_WIDTH (26 + 3) /* lower_margin + vsync_len */
71 #define SIG_POL (DI_D3_DRDY_SHARP_POL | DI_D3_CLK_POL)
73 #define IF_CLK_DIV 0x175
74 #elif defined(CONFIG_DISPLAY_COM57H5M10XRC)
77 #define PANEL_TYPE IPU_PANEL_TFT
78 #define PIXEL_CLK 40000
79 #define PIXEL_FMT IPU_PIX_FMT_RGB666
80 #define H_START_WIDTH 120 /* left_margin */
81 #define H_SYNC_WIDTH 30 /* hsync_len */
82 #define H_END_WIDTH (10 + 30) /* right_margin + hsync_len */
83 #define V_START_WIDTH 35 /* upper_margin */
84 #define V_SYNC_WIDTH 3 /* vsync_len */
85 #define V_END_WIDTH (7 + 3) /* lower_margin + vsync_len */
86 #define SIG_POL (DI_D3_DRDY_SHARP_POL | DI_D3_CLK_POL)
88 #define IF_CLK_DIV 0x55
92 #define PANEL_TYPE IPU_PANEL_TFT
93 #define PIXEL_CLK 185925
94 #define PIXEL_FMT IPU_PIX_FMT_RGB666
95 #define H_START_WIDTH 9 /* left_margin */
96 #define H_SYNC_WIDTH 1 /* hsync_len */
97 #define H_END_WIDTH (16 + 1) /* right_margin + hsync_len */
98 #define V_START_WIDTH 7 /* upper_margin */
99 #define V_SYNC_WIDTH 1 /* vsync_len */
100 #define V_END_WIDTH (9 + 1) /* lower_margin + vsync_len */
101 #define SIG_POL (DI_D3_DRDY_SHARP_POL | DI_D3_CLK_POL)
103 #define IF_CLK_DIV 0x175
106 #define LCD_COLOR_IPU LCD_COLOR16
108 static ushort colormap
[256];
110 vidinfo_t panel_info
= {
113 .vl_bpix
= LCD_COLOR_IPU
,
117 #define BIT_PER_PIXEL NBITS(LCD_COLOR_IPU)
119 /* IPU DMA Controller channel definitions. */
121 IDMAC_IC_0
= 0, /* IC (encoding task) to memory */
122 IDMAC_IC_1
= 1, /* IC (viewfinder task) to memory */
130 IDMAC_IC_7
= 7, /* IC (sensor data) to memory */
137 IDMAC_SDC_0
= 14, /* Background synchronous display data */
138 IDMAC_SDC_1
= 15, /* Foreground data (overlay) */
157 /* More formats can be copied from the Linux driver if needed */
167 struct pixel_fmt_cfg
{
174 static struct pixel_fmt_cfg fmt_cfg
[] = {
175 [IPU_PIX_FMT_RGB24
] = {
176 0x1600AAAA, 0x00E05555, 0x00070000, 3,
178 [IPU_PIX_FMT_RGB666
] = {
179 0x0005000F, 0x000B000F, 0x0011000F, 1,
181 [IPU_PIX_FMT_BGR666
] = {
182 0x0011000F, 0x000B000F, 0x0005000F, 1,
184 [IPU_PIX_FMT_RGB565
] = {
185 0x0004003F, 0x000A000F, 0x000F003F, 1,
194 /* IPU Common registers */
195 /* IPU_CONF and its bits already defined in imx-regs.h */
196 #define IPU_CHA_BUF0_RDY (0x04 + IPU_BASE)
197 #define IPU_CHA_BUF1_RDY (0x08 + IPU_BASE)
198 #define IPU_CHA_DB_MODE_SEL (0x0C + IPU_BASE)
199 #define IPU_CHA_CUR_BUF (0x10 + IPU_BASE)
200 #define IPU_FS_PROC_FLOW (0x14 + IPU_BASE)
201 #define IPU_FS_DISP_FLOW (0x18 + IPU_BASE)
202 #define IPU_TASKS_STAT (0x1C + IPU_BASE)
203 #define IPU_IMA_ADDR (0x20 + IPU_BASE)
204 #define IPU_IMA_DATA (0x24 + IPU_BASE)
205 #define IPU_INT_CTRL_1 (0x28 + IPU_BASE)
206 #define IPU_INT_CTRL_2 (0x2C + IPU_BASE)
207 #define IPU_INT_CTRL_3 (0x30 + IPU_BASE)
208 #define IPU_INT_CTRL_4 (0x34 + IPU_BASE)
209 #define IPU_INT_CTRL_5 (0x38 + IPU_BASE)
210 #define IPU_INT_STAT_1 (0x3C + IPU_BASE)
211 #define IPU_INT_STAT_2 (0x40 + IPU_BASE)
212 #define IPU_INT_STAT_3 (0x44 + IPU_BASE)
213 #define IPU_INT_STAT_4 (0x48 + IPU_BASE)
214 #define IPU_INT_STAT_5 (0x4C + IPU_BASE)
215 #define IPU_BRK_CTRL_1 (0x50 + IPU_BASE)
216 #define IPU_BRK_CTRL_2 (0x54 + IPU_BASE)
217 #define IPU_BRK_STAT (0x58 + IPU_BASE)
218 #define IPU_DIAGB_CTRL (0x5C + IPU_BASE)
220 /* Image Converter Registers */
221 #define IC_CONF (0x88 + IPU_BASE)
222 #define IC_PRP_ENC_RSC (0x8C + IPU_BASE)
223 #define IC_PRP_VF_RSC (0x90 + IPU_BASE)
224 #define IC_PP_RSC (0x94 + IPU_BASE)
225 #define IC_CMBP_1 (0x98 + IPU_BASE)
226 #define IC_CMBP_2 (0x9C + IPU_BASE)
227 #define PF_CONF (0xA0 + IPU_BASE)
228 #define IDMAC_CONF (0xA4 + IPU_BASE)
229 #define IDMAC_CHA_EN (0xA8 + IPU_BASE)
230 #define IDMAC_CHA_PRI (0xAC + IPU_BASE)
231 #define IDMAC_CHA_BUSY (0xB0 + IPU_BASE)
233 /* Image Converter Register bits */
234 #define IC_CONF_PRPENC_EN 0x00000001
235 #define IC_CONF_PRPENC_CSC1 0x00000002
236 #define IC_CONF_PRPENC_ROT_EN 0x00000004
237 #define IC_CONF_PRPVF_EN 0x00000100
238 #define IC_CONF_PRPVF_CSC1 0x00000200
239 #define IC_CONF_PRPVF_CSC2 0x00000400
240 #define IC_CONF_PRPVF_CMB 0x00000800
241 #define IC_CONF_PRPVF_ROT_EN 0x00001000
242 #define IC_CONF_PP_EN 0x00010000
243 #define IC_CONF_PP_CSC1 0x00020000
244 #define IC_CONF_PP_CSC2 0x00040000
245 #define IC_CONF_PP_CMB 0x00080000
246 #define IC_CONF_PP_ROT_EN 0x00100000
247 #define IC_CONF_IC_GLB_LOC_A 0x10000000
248 #define IC_CONF_KEY_COLOR_EN 0x20000000
249 #define IC_CONF_RWS_EN 0x40000000
250 #define IC_CONF_CSI_MEM_WR_EN 0x80000000
253 #define SDC_COM_CONF (0xB4 + IPU_BASE)
254 #define SDC_GW_CTRL (0xB8 + IPU_BASE)
255 #define SDC_FG_POS (0xBC + IPU_BASE)
256 #define SDC_BG_POS (0xC0 + IPU_BASE)
257 #define SDC_CUR_POS (0xC4 + IPU_BASE)
258 #define SDC_PWM_CTRL (0xC8 + IPU_BASE)
259 #define SDC_CUR_MAP (0xCC + IPU_BASE)
260 #define SDC_HOR_CONF (0xD0 + IPU_BASE)
261 #define SDC_VER_CONF (0xD4 + IPU_BASE)
262 #define SDC_SHARP_CONF_1 (0xD8 + IPU_BASE)
263 #define SDC_SHARP_CONF_2 (0xDC + IPU_BASE)
266 #define SDC_COM_TFT_COLOR 0x00000001UL
267 #define SDC_COM_FG_EN 0x00000010UL
268 #define SDC_COM_GWSEL 0x00000020UL
269 #define SDC_COM_GLB_A 0x00000040UL
270 #define SDC_COM_KEY_COLOR_G 0x00000080UL
271 #define SDC_COM_BG_EN 0x00000200UL
272 #define SDC_COM_SHARP 0x00001000UL
274 #define SDC_V_SYNC_WIDTH_L 0x00000001UL
276 /* Display Interface registers */
277 #define DI_DISP_IF_CONF (0x0124 + IPU_BASE)
278 #define DI_DISP_SIG_POL (0x0128 + IPU_BASE)
279 #define DI_SER_DISP1_CONF (0x012C + IPU_BASE)
280 #define DI_SER_DISP2_CONF (0x0130 + IPU_BASE)
281 #define DI_HSP_CLK_PER (0x0134 + IPU_BASE)
282 #define DI_DISP0_TIME_CONF_1 (0x0138 + IPU_BASE)
283 #define DI_DISP0_TIME_CONF_2 (0x013C + IPU_BASE)
284 #define DI_DISP0_TIME_CONF_3 (0x0140 + IPU_BASE)
285 #define DI_DISP1_TIME_CONF_1 (0x0144 + IPU_BASE)
286 #define DI_DISP1_TIME_CONF_2 (0x0148 + IPU_BASE)
287 #define DI_DISP1_TIME_CONF_3 (0x014C + IPU_BASE)
288 #define DI_DISP2_TIME_CONF_1 (0x0150 + IPU_BASE)
289 #define DI_DISP2_TIME_CONF_2 (0x0154 + IPU_BASE)
290 #define DI_DISP2_TIME_CONF_3 (0x0158 + IPU_BASE)
291 #define DI_DISP3_TIME_CONF (0x015C + IPU_BASE)
292 #define DI_DISP0_DB0_MAP (0x0160 + IPU_BASE)
293 #define DI_DISP0_DB1_MAP (0x0164 + IPU_BASE)
294 #define DI_DISP0_DB2_MAP (0x0168 + IPU_BASE)
295 #define DI_DISP0_CB0_MAP (0x016C + IPU_BASE)
296 #define DI_DISP0_CB1_MAP (0x0170 + IPU_BASE)
297 #define DI_DISP0_CB2_MAP (0x0174 + IPU_BASE)
298 #define DI_DISP1_DB0_MAP (0x0178 + IPU_BASE)
299 #define DI_DISP1_DB1_MAP (0x017C + IPU_BASE)
300 #define DI_DISP1_DB2_MAP (0x0180 + IPU_BASE)
301 #define DI_DISP1_CB0_MAP (0x0184 + IPU_BASE)
302 #define DI_DISP1_CB1_MAP (0x0188 + IPU_BASE)
303 #define DI_DISP1_CB2_MAP (0x018C + IPU_BASE)
304 #define DI_DISP2_DB0_MAP (0x0190 + IPU_BASE)
305 #define DI_DISP2_DB1_MAP (0x0194 + IPU_BASE)
306 #define DI_DISP2_DB2_MAP (0x0198 + IPU_BASE)
307 #define DI_DISP2_CB0_MAP (0x019C + IPU_BASE)
308 #define DI_DISP2_CB1_MAP (0x01A0 + IPU_BASE)
309 #define DI_DISP2_CB2_MAP (0x01A4 + IPU_BASE)
310 #define DI_DISP3_B0_MAP (0x01A8 + IPU_BASE)
311 #define DI_DISP3_B1_MAP (0x01AC + IPU_BASE)
312 #define DI_DISP3_B2_MAP (0x01B0 + IPU_BASE)
313 #define DI_DISP_ACC_CC (0x01B4 + IPU_BASE)
314 #define DI_DISP_LLA_CONF (0x01B8 + IPU_BASE)
315 #define DI_DISP_LLA_DATA (0x01BC + IPU_BASE)
317 /* DI_DISP_SIG_POL bits */
318 #define DI_D3_VSYNC_POL (1 << 28)
319 #define DI_D3_HSYNC_POL (1 << 27)
320 #define DI_D3_DRDY_SHARP_POL (1 << 26)
321 #define DI_D3_CLK_POL (1 << 25)
322 #define DI_D3_DATA_POL (1 << 24)
324 /* DI_DISP_IF_CONF bits */
325 #define DI_D3_CLK_IDLE (1 << 26)
326 #define DI_D3_CLK_SEL (1 << 25)
327 #define DI_D3_DATAMSK (1 << 24)
329 #define IOMUX_PADNUM_MASK 0x1ff
330 #define IOMUX_GPIONUM_SHIFT 9
331 #define IOMUX_GPIONUM_MASK (0xff << IOMUX_GPIONUM_SHIFT)
333 #define IOMUX_PIN(gpionum, padnum) ((padnum) & IOMUX_PADNUM_MASK)
335 #define IOMUX_MODE_L(pin, mode) IOMUX_MODE(((pin) + 0xc) ^ 3, mode)
337 struct chan_param_mem_planar
{
375 } __attribute__ ((packed
));
377 struct chan_param_mem_interleaved
{
434 } __attribute__ ((packed
));
436 union chan_param_mem
{
437 struct chan_param_mem_planar pp
;
438 struct chan_param_mem_interleaved ip
;
441 static inline u32
reg_read(unsigned long reg
)
446 static inline void reg_write(u32 value
, unsigned long reg
)
452 * sdc_init_panel() - initialize a synchronous LCD panel.
453 * @width: width of panel in pixels.
454 * @height: height of panel in pixels.
455 * @pixel_fmt: pixel format of buffer as FOURCC ASCII code.
456 * @return: 0 on success or negative error code on failure.
458 static int sdc_init_panel(u16 width
, u16 height
, enum pixel_fmt pixel_fmt
)
463 /* Init panel size and blanking periods */
464 reg
= ((H_SYNC_WIDTH
- 1) << 26) |
465 ((u32
)(width
+ H_START_WIDTH
+ H_END_WIDTH
- 1) << 16);
466 reg_write(reg
, SDC_HOR_CONF
);
468 reg
= ((V_SYNC_WIDTH
- 1) << 26) | SDC_V_SYNC_WIDTH_L
|
469 ((u32
)(height
+ V_START_WIDTH
+ V_END_WIDTH
- 1) << 16);
470 reg_write(reg
, SDC_VER_CONF
);
472 switch (PANEL_TYPE
) {
473 case IPU_PANEL_SHARP_TFT
:
474 reg_write(0x00FD0102L
, SDC_SHARP_CONF_1
);
475 reg_write(0x00F500F4L
, SDC_SHARP_CONF_2
);
476 reg_write(SDC_COM_SHARP
| SDC_COM_TFT_COLOR
, SDC_COM_CONF
);
479 reg_write(SDC_COM_TFT_COLOR
, SDC_COM_CONF
);
488 * Calculate divider: fractional part is 4 bits so simply multiple by
489 * 2^4 to get fractional part, as long as we stay under ~250MHz and on
490 * i.MX31 it (HSP_CLK) is <= 178MHz. Currently 128.267MHz
493 reg_write((((IF_CLK_DIV
/ 8) - 1) << 22) |
494 IF_CLK_DIV
, DI_DISP3_TIME_CONF
);
497 old_conf
= reg_read(DI_DISP_IF_CONF
) & 0x78FFFFFF;
498 reg_write(old_conf
| IF_CONF
, DI_DISP_IF_CONF
);
500 old_conf
= reg_read(DI_DISP_SIG_POL
) & 0xE0FFFFFF;
501 reg_write(old_conf
| SIG_POL
, DI_DISP_SIG_POL
);
503 reg_write(fmt_cfg
[pixel_fmt
].b0
, DI_DISP3_B0_MAP
);
504 reg_write(fmt_cfg
[pixel_fmt
].b1
, DI_DISP3_B1_MAP
);
505 reg_write(fmt_cfg
[pixel_fmt
].b2
, DI_DISP3_B2_MAP
);
506 reg_write(reg_read(DI_DISP_ACC_CC
) |
507 ((fmt_cfg
[pixel_fmt
].acc
- 1) << 12), DI_DISP_ACC_CC
);
512 static void ipu_ch_param_set_size(union chan_param_mem
*params
,
513 uint32_t pixel_fmt
, uint16_t width
,
514 uint16_t height
, uint16_t stride
)
516 params
->pp
.fw
= width
- 1;
517 params
->pp
.fh_l
= height
- 1;
518 params
->pp
.fh_h
= (height
- 1) >> 8;
519 params
->pp
.sl
= stride
- 1;
521 /* See above, for further formats see the Linux driver */
523 case IPU_PIX_FMT_RGB565
:
527 params
->ip
.sat
= 2; /* SAT = 32-bit access */
528 params
->ip
.ofs0
= 0; /* Red bit offset */
529 params
->ip
.ofs1
= 5; /* Green bit offset */
530 params
->ip
.ofs2
= 11; /* Blue bit offset */
531 params
->ip
.ofs3
= 16; /* Alpha bit offset */
532 params
->ip
.wid0
= 4; /* Red bit width - 1 */
533 params
->ip
.wid1
= 5; /* Green bit width - 1 */
534 params
->ip
.wid2
= 4; /* Blue bit width - 1 */
536 case IPU_PIX_FMT_RGB24
:
537 params
->ip
.bpp
= 1; /* 24 BPP & RGB PFS */
540 params
->ip
.sat
= 2; /* SAT = 32-bit access */
541 params
->ip
.ofs0
= 16; /* Red bit offset */
542 params
->ip
.ofs1
= 8; /* Green bit offset */
543 params
->ip
.ofs2
= 0; /* Blue bit offset */
544 params
->ip
.ofs3
= 24; /* Alpha bit offset */
545 params
->ip
.wid0
= 7; /* Red bit width - 1 */
546 params
->ip
.wid1
= 7; /* Green bit width - 1 */
547 params
->ip
.wid2
= 7; /* Blue bit width - 1 */
556 static void ipu_ch_param_set_buffer(union chan_param_mem
*params
,
557 void *buf0
, void *buf1
)
559 params
->pp
.eba0
= (u32
)buf0
;
560 params
->pp
.eba1
= (u32
)buf1
;
563 static void ipu_write_param_mem(uint32_t addr
, uint32_t *data
,
566 for (; num_words
> 0; num_words
--) {
567 reg_write(addr
, IPU_IMA_ADDR
);
568 reg_write(*data
++, IPU_IMA_DATA
);
570 if ((addr
& 0x7) == 5) {
571 addr
&= ~0x7; /* set to word 0 */
572 addr
+= 8; /* increment to next row */
577 static uint32_t bpp_to_pixfmt(int bpp
)
581 return IPU_PIX_FMT_RGB565
;
587 static uint32_t dma_param_addr(enum ipu_channel channel
)
589 /* Channel Parameter Memory */
590 return 0x10000 | (channel
<< 4);
593 static void ipu_init_channel_buffer(enum ipu_channel channel
, void *fbmem
)
595 union chan_param_mem params
= {};
597 uint32_t stride_bytes
;
599 stride_bytes
= (XRES
* ((BIT_PER_PIXEL
+ 7) / 8) + 3) & ~3;
601 /* Build parameter memory data for DMA channel */
602 ipu_ch_param_set_size(¶ms
, bpp_to_pixfmt(BIT_PER_PIXEL
),
603 XRES
, YRES
, stride_bytes
);
604 ipu_ch_param_set_buffer(¶ms
, fbmem
, NULL
);
606 /* Some channels (rotation) have restriction on burst length */
610 /* In original code only IPU_PIX_FMT_RGB565 was setting burst */
611 params
.pp
.npb
= 16 - 1;
617 ipu_write_param_mem(dma_param_addr(channel
), (uint32_t *)¶ms
, 10);
619 /* Disable double-buffering */
620 reg
= reg_read(IPU_CHA_DB_MODE_SEL
);
621 reg
&= ~(1UL << channel
);
622 reg_write(reg
, IPU_CHA_DB_MODE_SEL
);
625 static void ipu_channel_set_priority(enum ipu_channel channel
,
628 u32 reg
= reg_read(IDMAC_CHA_PRI
);
631 reg
|= 1UL << channel
;
633 reg
&= ~(1UL << channel
);
635 reg_write(reg
, IDMAC_CHA_PRI
);
639 * ipu_enable_channel() - enable an IPU channel.
640 * @channel: channel ID.
641 * @return: 0 on success or negative error code on failure.
643 static int ipu_enable_channel(enum ipu_channel channel
)
647 /* Reset to buffer 0 */
648 reg_write(1UL << channel
, IPU_CHA_CUR_BUF
);
652 ipu_channel_set_priority(channel
, 1);
658 reg
= reg_read(IDMAC_CHA_EN
);
659 reg_write(reg
| (1UL << channel
), IDMAC_CHA_EN
);
664 static int ipu_update_channel_buffer(enum ipu_channel channel
, void *buf
)
668 reg
= reg_read(IPU_CHA_BUF0_RDY
);
669 if (reg
& (1UL << channel
))
672 /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 0) */
673 reg_write(dma_param_addr(channel
) + 0x0008UL
, IPU_IMA_ADDR
);
674 reg_write((u32
)buf
, IPU_IMA_DATA
);
679 static int idmac_tx_submit(enum ipu_channel channel
, void *buf
)
683 ipu_init_channel_buffer(channel
, buf
);
686 /* ipu_idmac.c::ipu_submit_channel_buffers() */
687 ret
= ipu_update_channel_buffer(channel
, buf
);
691 /* ipu_idmac.c::ipu_select_buffer() */
692 /* Mark buffer 0 as ready. */
693 reg_write(1UL << channel
, IPU_CHA_BUF0_RDY
);
696 ret
= ipu_enable_channel(channel
);
700 static void sdc_enable_channel(void *fbmem
)
705 ret
= idmac_tx_submit(IDMAC_SDC_0
, fbmem
);
707 /* mx3fb.c::sdc_fb_init() */
709 reg
= reg_read(SDC_COM_CONF
);
710 reg_write(reg
| SDC_COM_BG_EN
, SDC_COM_CONF
);
714 * Attention! Without this msleep the channel keeps generating
715 * interrupts. Next sdc_set_brightness() is going to be called
716 * from mx3fb_blank().
722 * mx3fb_set_par() - set framebuffer parameters and change the operating mode.
723 * @return: 0 on success or negative error code on failure.
725 static int mx3fb_set_par(void)
729 ret
= sdc_init_panel(XRES
, YRES
, PIXEL_FMT
);
733 reg_write((H_START_WIDTH
<< 16) | V_START_WIDTH
, SDC_BG_POS
);
738 /* References in this function refer to respective Linux kernel sources */
739 void lcd_enable(void)
743 /* pcm037.c::mxc_board_init() */
745 /* Display Interface #3 */
746 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD0
, MUX_CTL_FUNC
));
747 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD1
, MUX_CTL_FUNC
));
748 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD2
, MUX_CTL_FUNC
));
749 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD3
, MUX_CTL_FUNC
));
750 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD4
, MUX_CTL_FUNC
));
751 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD5
, MUX_CTL_FUNC
));
752 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD6
, MUX_CTL_FUNC
));
753 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD7
, MUX_CTL_FUNC
));
754 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD8
, MUX_CTL_FUNC
));
755 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD9
, MUX_CTL_FUNC
));
756 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD10
, MUX_CTL_FUNC
));
757 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD11
, MUX_CTL_FUNC
));
758 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD12
, MUX_CTL_FUNC
));
759 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD13
, MUX_CTL_FUNC
));
760 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD14
, MUX_CTL_FUNC
));
761 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD15
, MUX_CTL_FUNC
));
762 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD16
, MUX_CTL_FUNC
));
763 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_LD17
, MUX_CTL_FUNC
));
764 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_VSYNC3
, MUX_CTL_FUNC
));
765 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_HSYNC
, MUX_CTL_FUNC
));
766 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_FPSHIFT
, MUX_CTL_FUNC
));
767 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_DRDY0
, MUX_CTL_FUNC
));
768 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_REV
, MUX_CTL_FUNC
));
769 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_CONTRAST
, MUX_CTL_FUNC
));
770 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_SPL
, MUX_CTL_FUNC
));
771 mx31_gpio_mux(IOMUX_MODE_L(MX31_PIN_D3_CLS
, MUX_CTL_FUNC
));
774 /* ipu_idmac.c::ipu_probe() */
776 /* Start the clock */
777 __REG(CCM_CGR1
) = __REG(CCM_CGR1
) | (3 << 22);
780 /* ipu_idmac.c::ipu_idmac_init() */
782 /* Service request counter to maximum - shouldn't be needed */
783 reg_write(0x00000070, IDMAC_CONF
);
786 /* ipu_idmac.c::ipu_init_channel() */
788 /* Enable IPU sub modules */
789 reg
= reg_read(IPU_CONF
) | IPU_CONF_SDC_EN
| IPU_CONF_DI_EN
;
790 reg_write(reg
, IPU_CONF
);
793 /* mx3fb.c::init_fb_chan() */
795 /* set Display Interface clock period */
796 reg_write(0x00100010L
, DI_HSP_CLK_PER
);
797 /* Might need to trigger HSP clock change - see 44.3.3.8.5 */
800 /* mx3fb.c::sdc_set_brightness() */
802 /* This might be board-specific */
803 reg_write(0x03000000UL
| 255 << 16, SDC_PWM_CTRL
);
806 /* mx3fb.c::sdc_set_global_alpha() */
808 /* Use global - not per-pixel - Alpha-blending */
809 reg
= reg_read(SDC_GW_CTRL
) & 0x00FFFFFFL
;
810 reg_write(reg
| ((uint32_t) 0xff << 24), SDC_GW_CTRL
);
812 reg
= reg_read(SDC_COM_CONF
);
813 reg_write(reg
| SDC_COM_GLB_A
, SDC_COM_CONF
);
816 /* mx3fb.c::sdc_set_color_key() */
818 /* Disable colour-keying for background */
819 reg
= reg_read(SDC_COM_CONF
) &
820 ~(SDC_COM_GWSEL
| SDC_COM_KEY_COLOR_G
);
821 reg_write(reg
, SDC_COM_CONF
);
826 sdc_enable_channel(lcd_base
);
829 * Linux driver calls sdc_set_brightness() here again,
830 * once is enough for us
834 void lcd_ctrl_init(void *lcdbase
)
836 u32 mem_len
= XRES
* YRES
* BIT_PER_PIXEL
/ 8;
838 * We rely on lcdbase being a physical address, i.e., either MMU off,
839 * or 1-to-1 mapping. Might want to add some virt2phys here.
844 memset(lcdbase
, 0, mem_len
);
847 ulong
calc_fbsize(void)
849 return ((panel_info
.vl_col
* panel_info
.vl_row
*
850 NBITS(panel_info
.vl_bpix
)) / 8) + PAGE_SIZE
;
853 int overwrite_console(void)
855 /* Keep stdout / stderr on serial, our LCD is for splashscreen only */