1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2012 Freescale Semiconductor, Inc.
4  * Fabio Estevam <fabio.estevam@freescale.com>
5  */
6 
7 #include <common.h>
8 #include <linux/list.h>
9 #include <asm/gpio.h>
10 #include <asm/arch/iomux-mx53.h>
11 #include <linux/fb.h>
12 #include <ipu_pixfmt.h>
13 
14 #define MX53LOCO_LCD_POWER		IMX_GPIO_NR(3, 24)
15 
16 static struct fb_videomode const claa_wvga = {
17 	.name		= "CLAA07LC0ACW",
18 	.refresh	= 57,
19 	.xres		= 800,
20 	.yres		= 480,
21 	.pixclock	= 37037,
22 	.left_margin	= 40,
23 	.right_margin	= 60,
24 	.upper_margin	= 10,
25 	.lower_margin	= 10,
26 	.hsync_len	= 20,
27 	.vsync_len	= 10,
28 	.sync		= 0,
29 	.vmode		= FB_VMODE_NONINTERLACED
30 };
31 
32 static struct fb_videomode const seiko_wvga = {
33 	.name		= "Seiko-43WVF1G",
34 	.refresh	= 60,
35 	.xres		= 800,
36 	.yres		= 480,
37 	.pixclock	= 29851, /* picosecond (33.5 MHz) */
38 	.left_margin	= 89,
39 	.right_margin	= 164,
40 	.upper_margin	= 23,
41 	.lower_margin	= 10,
42 	.hsync_len	= 10,
43 	.vsync_len	= 10,
44 	.sync		= 0,
45 };
46 
setup_iomux_lcd(void)47 void setup_iomux_lcd(void)
48 {
49 	static const iomux_v3_cfg_t lcd_pads[] = {
50 		MX53_PAD_DI0_DISP_CLK__IPU_DI0_DISP_CLK,
51 		MX53_PAD_DI0_PIN15__IPU_DI0_PIN15,
52 		MX53_PAD_DI0_PIN2__IPU_DI0_PIN2,
53 		MX53_PAD_DI0_PIN3__IPU_DI0_PIN3,
54 		MX53_PAD_DISP0_DAT0__IPU_DISP0_DAT_0,
55 		MX53_PAD_DISP0_DAT1__IPU_DISP0_DAT_1,
56 		MX53_PAD_DISP0_DAT2__IPU_DISP0_DAT_2,
57 		MX53_PAD_DISP0_DAT3__IPU_DISP0_DAT_3,
58 		MX53_PAD_DISP0_DAT4__IPU_DISP0_DAT_4,
59 		MX53_PAD_DISP0_DAT5__IPU_DISP0_DAT_5,
60 		MX53_PAD_DISP0_DAT6__IPU_DISP0_DAT_6,
61 		MX53_PAD_DISP0_DAT7__IPU_DISP0_DAT_7,
62 		MX53_PAD_DISP0_DAT8__IPU_DISP0_DAT_8,
63 		MX53_PAD_DISP0_DAT9__IPU_DISP0_DAT_9,
64 		MX53_PAD_DISP0_DAT10__IPU_DISP0_DAT_10,
65 		MX53_PAD_DISP0_DAT11__IPU_DISP0_DAT_11,
66 		MX53_PAD_DISP0_DAT12__IPU_DISP0_DAT_12,
67 		MX53_PAD_DISP0_DAT13__IPU_DISP0_DAT_13,
68 		MX53_PAD_DISP0_DAT14__IPU_DISP0_DAT_14,
69 		MX53_PAD_DISP0_DAT15__IPU_DISP0_DAT_15,
70 		MX53_PAD_DISP0_DAT16__IPU_DISP0_DAT_16,
71 		MX53_PAD_DISP0_DAT17__IPU_DISP0_DAT_17,
72 		MX53_PAD_DISP0_DAT18__IPU_DISP0_DAT_18,
73 		MX53_PAD_DISP0_DAT19__IPU_DISP0_DAT_19,
74 		MX53_PAD_DISP0_DAT20__IPU_DISP0_DAT_20,
75 		MX53_PAD_DISP0_DAT21__IPU_DISP0_DAT_21,
76 		MX53_PAD_DISP0_DAT22__IPU_DISP0_DAT_22,
77 		MX53_PAD_DISP0_DAT23__IPU_DISP0_DAT_23,
78 	};
79 
80 	imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
81 
82 	/* Turn on GPIO backlight */
83 	imx_iomux_v3_setup_pad(MX53_PAD_EIM_D24__GPIO3_24);
84 	gpio_direction_output(MX53LOCO_LCD_POWER, 1);
85 
86 	/* Turn on display contrast */
87 	imx_iomux_v3_setup_pad(MX53_PAD_GPIO_1__GPIO1_1);
88 	gpio_direction_output(IMX_GPIO_NR(1, 1), 1);
89 }
90 
board_video_skip(void)91 int board_video_skip(void)
92 {
93 	int ret;
94 	char const *e = env_get("panel");
95 
96 	if (e) {
97 		if (strcmp(e, "seiko") == 0) {
98 			ret = ipuv3_fb_init(&seiko_wvga, 0, IPU_PIX_FMT_RGB24);
99 			if (ret)
100 				printf("Seiko cannot be configured: %d\n", ret);
101 			return ret;
102 		}
103 	}
104 
105 	/*
106 	 * 'panel' env variable not found or has different value than 'seiko'
107 	 *  Defaulting to claa lcd.
108 	 */
109 	ret = ipuv3_fb_init(&claa_wvga, 0, IPU_PIX_FMT_RGB565);
110 	if (ret)
111 		printf("CLAA cannot be configured: %d\n", ret);
112 	return ret;
113 }
114