mx51evk_video.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #include <common.h>
  8. #include <linux/list.h>
  9. #include <asm/gpio.h>
  10. #include <asm/arch/iomux-mx51.h>
  11. #include <linux/fb.h>
  12. #include <ipu_pixfmt.h>
  13. #define MX51EVK_LCD_3V3 IMX_GPIO_NR(4, 9)
  14. #define MX51EVK_LCD_5V IMX_GPIO_NR(4, 10)
  15. #define MX51EVK_LCD_BACKLIGHT IMX_GPIO_NR(3, 4)
  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. static struct fb_videomode const dvi = {
  32. .name = "DVI panel",
  33. .refresh = 60,
  34. .xres = 1024,
  35. .yres = 768,
  36. .pixclock = 15385,
  37. .left_margin = 220,
  38. .right_margin = 40,
  39. .upper_margin = 21,
  40. .lower_margin = 7,
  41. .hsync_len = 60,
  42. .vsync_len = 10,
  43. .sync = 0,
  44. .vmode = FB_VMODE_NONINTERLACED
  45. };
  46. void setup_iomux_lcd(void)
  47. {
  48. /* DI2_PIN15 */
  49. imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
  50. /* Pad settings for DI2_DISP_CLK */
  51. imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK,
  52. PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW));
  53. /* Turn on 3.3V voltage for LCD */
  54. imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
  55. NO_PAD_CTRL));
  56. gpio_direction_output(MX51EVK_LCD_3V3, 1);
  57. /* Turn on 5V voltage for LCD */
  58. imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
  59. NO_PAD_CTRL));
  60. gpio_direction_output(MX51EVK_LCD_5V, 1);
  61. /* Turn on GPIO backlight */
  62. imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
  63. NO_PAD_CTRL));
  64. gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
  65. }
  66. int board_video_skip(void)
  67. {
  68. int ret;
  69. char const *e = getenv("panel");
  70. if (e) {
  71. if (strcmp(e, "claa") == 0) {
  72. ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565);
  73. if (ret)
  74. printf("claa cannot be configured: %d\n", ret);
  75. return ret;
  76. }
  77. }
  78. /*
  79. * 'panel' env variable not found or has different value than 'claa'
  80. * Defaulting to dvi output.
  81. */
  82. ret = ipuv3_fb_init(&dvi, 0, IPU_PIX_FMT_RGB24);
  83. if (ret)
  84. printf("dvi cannot be configured: %d\n", ret);
  85. return ret;
  86. }