1 /* 2 * Copyright (C) 2012 Freescale Semiconductor, Inc. 3 * Fabio Estevam <fabio.estevam@freescale.com> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #include <common.h> 9 #include <linux/list.h> 10 #include <asm/gpio.h> 11 #include <asm/arch/iomux-mx51.h> 12 #include <linux/fb.h> 13 #include <ipu_pixfmt.h> 14 15 #define MX51EVK_LCD_3V3 IMX_GPIO_NR(4, 9) 16 #define MX51EVK_LCD_5V IMX_GPIO_NR(4, 10) 17 #define MX51EVK_LCD_BACKLIGHT IMX_GPIO_NR(3, 4) 18 19 static struct fb_videomode const claa_wvga = { 20 .name = "CLAA07LC0ACW", 21 .refresh = 57, 22 .xres = 800, 23 .yres = 480, 24 .pixclock = 37037, 25 .left_margin = 40, 26 .right_margin = 60, 27 .upper_margin = 10, 28 .lower_margin = 10, 29 .hsync_len = 20, 30 .vsync_len = 10, 31 .sync = 0, 32 .vmode = FB_VMODE_NONINTERLACED 33 }; 34 35 static struct fb_videomode const dvi = { 36 .name = "DVI panel", 37 .refresh = 60, 38 .xres = 1024, 39 .yres = 768, 40 .pixclock = 15385, 41 .left_margin = 220, 42 .right_margin = 40, 43 .upper_margin = 21, 44 .lower_margin = 7, 45 .hsync_len = 60, 46 .vsync_len = 10, 47 .sync = 0, 48 .vmode = FB_VMODE_NONINTERLACED 49 }; 50 51 void setup_iomux_lcd(void) 52 { 53 /* DI2_PIN15 */ 54 imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15); 55 56 /* Pad settings for DI2_DISP_CLK */ 57 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK, 58 PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW)); 59 60 /* Turn on 3.3V voltage for LCD */ 61 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9, 62 NO_PAD_CTRL)); 63 gpio_direction_output(MX51EVK_LCD_3V3, 1); 64 65 /* Turn on 5V voltage for LCD */ 66 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10, 67 NO_PAD_CTRL)); 68 gpio_direction_output(MX51EVK_LCD_5V, 1); 69 70 /* Turn on GPIO backlight */ 71 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4, 72 NO_PAD_CTRL)); 73 gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1); 74 } 75 76 int board_video_skip(void) 77 { 78 int ret; 79 char const *e = env_get("panel"); 80 81 if (e) { 82 if (strcmp(e, "claa") == 0) { 83 ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565); 84 if (ret) 85 printf("claa cannot be configured: %d\n", ret); 86 return ret; 87 } 88 } 89 90 /* 91 * 'panel' env variable not found or has different value than 'claa' 92 * Defaulting to dvi output. 93 */ 94 ret = ipuv3_fb_init(&dvi, 0, IPU_PIX_FMT_RGB24); 95 if (ret) 96 printf("dvi cannot be configured: %d\n", ret); 97 return ret; 98 } 99