1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
25d71bd21SVikram Narayanan /*
35d71bd21SVikram Narayanan * Copyright (C) 2012 Freescale Semiconductor, Inc.
45d71bd21SVikram Narayanan * Fabio Estevam <fabio.estevam@freescale.com>
55d71bd21SVikram Narayanan */
65d71bd21SVikram Narayanan
75d71bd21SVikram Narayanan #include <common.h>
85d71bd21SVikram Narayanan #include <linux/list.h>
95d71bd21SVikram Narayanan #include <asm/gpio.h>
104d15d36cSBenoît Thébaudeau #include <asm/arch/iomux-mx51.h>
115d71bd21SVikram Narayanan #include <linux/fb.h>
125d71bd21SVikram Narayanan #include <ipu_pixfmt.h>
135d71bd21SVikram Narayanan
145d71bd21SVikram Narayanan #define MX51EVK_LCD_3V3 IMX_GPIO_NR(4, 9)
155d71bd21SVikram Narayanan #define MX51EVK_LCD_5V IMX_GPIO_NR(4, 10)
165d71bd21SVikram Narayanan #define MX51EVK_LCD_BACKLIGHT IMX_GPIO_NR(3, 4)
175d71bd21SVikram Narayanan
185d71bd21SVikram Narayanan static struct fb_videomode const claa_wvga = {
195d71bd21SVikram Narayanan .name = "CLAA07LC0ACW",
205d71bd21SVikram Narayanan .refresh = 57,
215d71bd21SVikram Narayanan .xres = 800,
225d71bd21SVikram Narayanan .yres = 480,
235d71bd21SVikram Narayanan .pixclock = 37037,
245d71bd21SVikram Narayanan .left_margin = 40,
255d71bd21SVikram Narayanan .right_margin = 60,
265d71bd21SVikram Narayanan .upper_margin = 10,
275d71bd21SVikram Narayanan .lower_margin = 10,
285d71bd21SVikram Narayanan .hsync_len = 20,
295d71bd21SVikram Narayanan .vsync_len = 10,
305d71bd21SVikram Narayanan .sync = 0,
315d71bd21SVikram Narayanan .vmode = FB_VMODE_NONINTERLACED
325d71bd21SVikram Narayanan };
335d71bd21SVikram Narayanan
3411d80af4SFabio Estevam static struct fb_videomode const dvi = {
3511d80af4SFabio Estevam .name = "DVI panel",
3611d80af4SFabio Estevam .refresh = 60,
3711d80af4SFabio Estevam .xres = 1024,
3811d80af4SFabio Estevam .yres = 768,
3911d80af4SFabio Estevam .pixclock = 15385,
4011d80af4SFabio Estevam .left_margin = 220,
4111d80af4SFabio Estevam .right_margin = 40,
4211d80af4SFabio Estevam .upper_margin = 21,
4311d80af4SFabio Estevam .lower_margin = 7,
4411d80af4SFabio Estevam .hsync_len = 60,
4511d80af4SFabio Estevam .vsync_len = 10,
4611d80af4SFabio Estevam .sync = 0,
4711d80af4SFabio Estevam .vmode = FB_VMODE_NONINTERLACED
4811d80af4SFabio Estevam };
4911d80af4SFabio Estevam
setup_iomux_lcd(void)505d71bd21SVikram Narayanan void setup_iomux_lcd(void)
515d71bd21SVikram Narayanan {
525d71bd21SVikram Narayanan /* DI2_PIN15 */
534d15d36cSBenoît Thébaudeau imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
545d71bd21SVikram Narayanan
554d15d36cSBenoît Thébaudeau /* Pad settings for DI2_DISP_CLK */
564d15d36cSBenoît Thébaudeau imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK,
574d15d36cSBenoît Thébaudeau PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW));
585d71bd21SVikram Narayanan
595d71bd21SVikram Narayanan /* Turn on 3.3V voltage for LCD */
604d15d36cSBenoît Thébaudeau imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
614d15d36cSBenoît Thébaudeau NO_PAD_CTRL));
625d71bd21SVikram Narayanan gpio_direction_output(MX51EVK_LCD_3V3, 1);
635d71bd21SVikram Narayanan
645d71bd21SVikram Narayanan /* Turn on 5V voltage for LCD */
654d15d36cSBenoît Thébaudeau imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
664d15d36cSBenoît Thébaudeau NO_PAD_CTRL));
675d71bd21SVikram Narayanan gpio_direction_output(MX51EVK_LCD_5V, 1);
685d71bd21SVikram Narayanan
695d71bd21SVikram Narayanan /* Turn on GPIO backlight */
704d15d36cSBenoît Thébaudeau imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
714d15d36cSBenoît Thébaudeau NO_PAD_CTRL));
725d71bd21SVikram Narayanan gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
735d71bd21SVikram Narayanan }
745d71bd21SVikram Narayanan
board_video_skip(void)7511d80af4SFabio Estevam int board_video_skip(void)
765d71bd21SVikram Narayanan {
7711d80af4SFabio Estevam int ret;
7800caae6dSSimon Glass char const *e = env_get("panel");
7911d80af4SFabio Estevam
8011d80af4SFabio Estevam if (e) {
8111d80af4SFabio Estevam if (strcmp(e, "claa") == 0) {
8211d80af4SFabio Estevam ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565);
835d71bd21SVikram Narayanan if (ret)
8411d80af4SFabio Estevam printf("claa cannot be configured: %d\n", ret);
8511d80af4SFabio Estevam return ret;
8611d80af4SFabio Estevam }
8711d80af4SFabio Estevam }
8811d80af4SFabio Estevam
8911d80af4SFabio Estevam /*
9011d80af4SFabio Estevam * 'panel' env variable not found or has different value than 'claa'
9111d80af4SFabio Estevam * Defaulting to dvi output.
9211d80af4SFabio Estevam */
9311d80af4SFabio Estevam ret = ipuv3_fb_init(&dvi, 0, IPU_PIX_FMT_RGB24);
9411d80af4SFabio Estevam if (ret)
9511d80af4SFabio Estevam printf("dvi cannot be configured: %d\n", ret);
9611d80af4SFabio Estevam return ret;
975d71bd21SVikram Narayanan }
98