Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Freescale Semiconductor, Inc. |
| 3 | * Fabio Estevam <fabio.estevam@freescale.com> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <linux/list.h> |
| 10 | #include <asm/gpio.h> |
Benoît Thébaudeau | 4d15d36 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 11 | #include <asm/arch/iomux-mx51.h> |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 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 | |
Fabio Estevam | 11d80af | 2013-01-09 04:55:09 +0000 | [diff] [blame] | 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 | |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 51 | void setup_iomux_lcd(void) |
| 52 | { |
| 53 | /* DI2_PIN15 */ |
Benoît Thébaudeau | 4d15d36 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 54 | imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15); |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 55 | |
Benoît Thébaudeau | 4d15d36 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 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)); |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 59 | |
| 60 | /* Turn on 3.3V voltage for LCD */ |
Benoît Thébaudeau | 4d15d36 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 61 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9, |
| 62 | NO_PAD_CTRL)); |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 63 | gpio_direction_output(MX51EVK_LCD_3V3, 1); |
| 64 | |
| 65 | /* Turn on 5V voltage for LCD */ |
Benoît Thébaudeau | 4d15d36 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 66 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10, |
| 67 | NO_PAD_CTRL)); |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 68 | gpio_direction_output(MX51EVK_LCD_5V, 1); |
| 69 | |
| 70 | /* Turn on GPIO backlight */ |
Benoît Thébaudeau | 4d15d36 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 71 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4, |
| 72 | NO_PAD_CTRL)); |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 73 | gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1); |
| 74 | } |
| 75 | |
Fabio Estevam | 11d80af | 2013-01-09 04:55:09 +0000 | [diff] [blame] | 76 | int board_video_skip(void) |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 77 | { |
Fabio Estevam | 11d80af | 2013-01-09 04:55:09 +0000 | [diff] [blame] | 78 | int ret; |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 79 | char const *e = env_get("panel"); |
Fabio Estevam | 11d80af | 2013-01-09 04:55:09 +0000 | [diff] [blame] | 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); |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 95 | if (ret) |
Fabio Estevam | 11d80af | 2013-01-09 04:55:09 +0000 | [diff] [blame] | 96 | printf("dvi cannot be configured: %d\n", ret); |
| 97 | return ret; |
Vikram Narayanan | 5d71bd2 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 98 | } |