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