exynos_fb.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * Copyright (C) 2012 Samsung Electronics
  3. *
  4. * Author: InKi Dae <inki.dae@samsung.com>
  5. * Author: Donghwa Lee <dh09.lee@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <config.h>
  23. #include <common.h>
  24. #include <lcd.h>
  25. #include <asm/io.h>
  26. #include <asm/arch/cpu.h>
  27. #include <asm/arch/clock.h>
  28. #include <asm/arch/clk.h>
  29. #include <asm/arch/mipi_dsim.h>
  30. #include <asm/arch/dp_info.h>
  31. #include <asm/arch/system.h>
  32. #include "exynos_fb.h"
  33. int lcd_line_length;
  34. int lcd_color_fg;
  35. int lcd_color_bg;
  36. void *lcd_base;
  37. void *lcd_console_address;
  38. short console_col;
  39. short console_row;
  40. static unsigned int panel_width, panel_height;
  41. static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
  42. {
  43. unsigned long palette_size;
  44. unsigned int fb_size;
  45. fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3);
  46. lcd_base = lcdbase;
  47. palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
  48. exynos_fimd_lcd_init_mem((unsigned long)lcd_base,
  49. (unsigned long)fb_size, palette_size);
  50. }
  51. static void exynos_lcd_init(vidinfo_t *vid)
  52. {
  53. exynos_fimd_lcd_init(vid);
  54. /* Enable flushing after LCD writes if requested */
  55. lcd_set_flush_dcache(1);
  56. }
  57. #ifdef CONFIG_CMD_BMP
  58. static void draw_logo(void)
  59. {
  60. int x, y;
  61. ulong addr;
  62. if (panel_width >= panel_info.logo_width) {
  63. x = ((panel_width - panel_info.logo_width) >> 1);
  64. } else {
  65. x = 0;
  66. printf("Warning: image width is bigger than display width\n");
  67. }
  68. if (panel_height >= panel_info.logo_height) {
  69. y = ((panel_height - panel_info.logo_height) >> 1) - 4;
  70. } else {
  71. y = 0;
  72. printf("Warning: image height is bigger than display height\n");
  73. }
  74. addr = panel_info.logo_addr;
  75. bmp_display(addr, x, y);
  76. }
  77. #endif
  78. void __exynos_cfg_lcd_gpio(void)
  79. {
  80. }
  81. void exynos_cfg_lcd_gpio(void)
  82. __attribute__((weak, alias("__exynos_cfg_lcd_gpio")));
  83. void __exynos_backlight_on(unsigned int onoff)
  84. {
  85. }
  86. void exynos_backlight_on(unsigned int onoff)
  87. __attribute__((weak, alias("__exynos_cfg_lcd_gpio")));
  88. void __exynos_reset_lcd(void)
  89. {
  90. }
  91. void exynos_reset_lcd(void)
  92. __attribute__((weak, alias("__exynos_reset_lcd")));
  93. void __exynos_lcd_power_on(void)
  94. {
  95. }
  96. void exynos_lcd_power_on(void)
  97. __attribute__((weak, alias("__exynos_lcd_power_on")));
  98. void __exynos_cfg_ldo(void)
  99. {
  100. }
  101. void exynos_cfg_ldo(void)
  102. __attribute__((weak, alias("__exynos_cfg_ldo")));
  103. void __exynos_enable_ldo(unsigned int onoff)
  104. {
  105. }
  106. void exynos_enable_ldo(unsigned int onoff)
  107. __attribute__((weak, alias("__exynos_enable_ldo")));
  108. void __exynos_backlight_reset(void)
  109. {
  110. }
  111. void exynos_backlight_reset(void)
  112. __attribute__((weak, alias("__exynos_backlight_reset")));
  113. static void lcd_panel_on(vidinfo_t *vid)
  114. {
  115. udelay(vid->init_delay);
  116. exynos_backlight_reset();
  117. exynos_cfg_lcd_gpio();
  118. exynos_lcd_power_on();
  119. udelay(vid->power_on_delay);
  120. if (vid->dp_enabled)
  121. exynos_init_dp();
  122. exynos_reset_lcd();
  123. udelay(vid->reset_delay);
  124. exynos_backlight_on(1);
  125. exynos_cfg_ldo();
  126. exynos_enable_ldo(1);
  127. if (vid->mipi_enabled)
  128. exynos_mipi_dsi_init();
  129. }
  130. void lcd_ctrl_init(void *lcdbase)
  131. {
  132. set_system_display_ctrl();
  133. set_lcd_clk();
  134. /* initialize parameters which is specific to panel. */
  135. init_panel_info(&panel_info);
  136. panel_width = panel_info.vl_width;
  137. panel_height = panel_info.vl_height;
  138. exynos_lcd_init_mem(lcdbase, &panel_info);
  139. exynos_lcd_init(&panel_info);
  140. }
  141. void lcd_enable(void)
  142. {
  143. if (panel_info.logo_on) {
  144. memset(lcd_base, 0, panel_width * panel_height *
  145. (NBITS(panel_info.vl_bpix) >> 3));
  146. #ifdef CONFIG_CMD_BMP
  147. draw_logo();
  148. #endif
  149. }
  150. lcd_panel_on(&panel_info);
  151. }
  152. /* dummy function */
  153. void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
  154. {
  155. return;
  156. }