display.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * (C) Copyright 2010
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __ASM_ARCH_TEGRA_DISPLAY_H
  24. #define __ASM_ARCH_TEGRA_DISPLAY_H
  25. #include <asm/arch/dc.h>
  26. #include <fdtdec.h>
  27. /* This holds information about a window which can be displayed */
  28. struct disp_ctl_win {
  29. enum win_color_depth_id fmt; /* Color depth/format */
  30. unsigned bpp; /* Bits per pixel */
  31. phys_addr_t phys_addr; /* Physical address in memory */
  32. unsigned x; /* Horizontal address offset (bytes) */
  33. unsigned y; /* Veritical address offset (bytes) */
  34. unsigned w; /* Width of source window */
  35. unsigned h; /* Height of source window */
  36. unsigned stride; /* Number of bytes per line */
  37. unsigned out_x; /* Left edge of output window (col) */
  38. unsigned out_y; /* Top edge of output window (row) */
  39. unsigned out_w; /* Width of output window in pixels */
  40. unsigned out_h; /* Height of output window in pixels */
  41. };
  42. #define FDT_LCD_TIMINGS 4
  43. enum {
  44. FDT_LCD_TIMING_REF_TO_SYNC,
  45. FDT_LCD_TIMING_SYNC_WIDTH,
  46. FDT_LCD_TIMING_BACK_PORCH,
  47. FDT_LCD_TIMING_FRONT_PORCH,
  48. FDT_LCD_TIMING_COUNT,
  49. };
  50. enum lcd_cache_t {
  51. FDT_LCD_CACHE_OFF = 0,
  52. FDT_LCD_CACHE_WRITE_THROUGH = 1 << 0,
  53. FDT_LCD_CACHE_WRITE_BACK = 1 << 1,
  54. FDT_LCD_CACHE_FLUSH = 1 << 2,
  55. FDT_LCD_CACHE_WRITE_BACK_FLUSH = FDT_LCD_CACHE_WRITE_BACK |
  56. FDT_LCD_CACHE_FLUSH,
  57. };
  58. /* Information about the display controller */
  59. struct fdt_disp_config {
  60. int valid; /* config is valid */
  61. int width; /* width in pixels */
  62. int height; /* height in pixels */
  63. int bpp; /* number of bits per pixel */
  64. /*
  65. * log2 of number of bpp, in general, unless it bpp is 24 in which
  66. * case this field holds 24 also! This is a U-Boot thing.
  67. */
  68. int log2_bpp;
  69. struct disp_ctlr *disp; /* Display controller to use */
  70. fdt_addr_t frame_buffer; /* Address of frame buffer */
  71. unsigned pixel_clock; /* Pixel clock in Hz */
  72. uint horiz_timing[FDT_LCD_TIMING_COUNT]; /* Horizontal timing */
  73. uint vert_timing[FDT_LCD_TIMING_COUNT]; /* Vertical timing */
  74. int panel_node; /* node offset of panel information */
  75. };
  76. /* Information about the LCD panel */
  77. struct fdt_panel_config {
  78. int pwm_channel; /* PWM channel to use for backlight */
  79. enum lcd_cache_t cache_type;
  80. struct fdt_gpio_state backlight_en; /* GPIO for backlight enable */
  81. struct fdt_gpio_state lvds_shutdown; /* GPIO for lvds shutdown */
  82. struct fdt_gpio_state backlight_vdd; /* GPIO for backlight vdd */
  83. struct fdt_gpio_state panel_vdd; /* GPIO for panel vdd */
  84. /*
  85. * Panel required timings
  86. * Timing 1: delay between panel_vdd-rise and data-rise
  87. * Timing 2: delay between data-rise and backlight_vdd-rise
  88. * Timing 3: delay between backlight_vdd and pwm-rise
  89. * Timing 4: delay between pwm-rise and backlight_en-rise
  90. */
  91. uint panel_timings[FDT_LCD_TIMINGS];
  92. };
  93. /**
  94. * Register a new display based on device tree configuration.
  95. *
  96. * The frame buffer can be positioned by U-Boot or overriden by the fdt.
  97. * You should pass in the U-Boot address here, and check the contents of
  98. * struct fdt_disp_config to see what was actually chosen.
  99. *
  100. * @param blob Device tree blob
  101. * @param default_lcd_base Default address of LCD frame buffer
  102. * @return 0 if ok, -1 on error (unsupported bits per pixel)
  103. */
  104. int tegra_display_probe(const void *blob, void *default_lcd_base);
  105. /**
  106. * Return the current display configuration
  107. *
  108. * @return pointer to display configuration, or NULL if there is no valid
  109. * config
  110. */
  111. struct fdt_disp_config *tegra_display_get_config(void);
  112. /**
  113. * Perform the next stage of the LCD init if it is time to do so.
  114. *
  115. * LCD init can be time-consuming because of the number of delays we need
  116. * while waiting for the backlight power supply, etc. This function can
  117. * be called at various times during U-Boot operation to advance the
  118. * initialization of the LCD to the next stage if sufficient time has
  119. * passed since the last stage. It keeps track of what stage it is up to
  120. * and the time that it is permitted to move to the next stage.
  121. *
  122. * The final call should have wait=1 to complete the init.
  123. *
  124. * @param blob fdt blob containing LCD information
  125. * @param wait 1 to wait until all init is complete, and then return
  126. * 0 to return immediately, potentially doing nothing if it is
  127. * not yet time for the next init.
  128. */
  129. int tegra_lcd_check_next_stage(const void *blob, int wait);
  130. /**
  131. * Set up the maximum LCD size so we can size the frame buffer.
  132. *
  133. * @param blob fdt blob containing LCD information
  134. */
  135. void tegra_lcd_early_init(const void *blob);
  136. #endif /*__ASM_ARCH_TEGRA_DISPLAY_H*/