sm501.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * (C) Copyright 2002
  3. * Stäubli Faverges - <www.staubli.com>
  4. * Pierre AUBERT p.aubert@staubli.com
  5. *
  6. * (C) Copyright 2005
  7. * Martin Krause TQ-Systems GmbH martin.krause@tqs.de
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. /*
  28. * Basic video support for SMI SM501 "Voyager" graphic controller
  29. */
  30. #include <common.h>
  31. #ifdef CONFIG_VIDEO_SM501
  32. #include <video_fb.h>
  33. #include <sm501.h>
  34. #define read8(ptrReg) \
  35. *(volatile unsigned char *)(sm501.isaBase + ptrReg)
  36. #define write8(ptrReg,value) \
  37. *(volatile unsigned char *)(sm501.isaBase + ptrReg) = value
  38. #define read16(ptrReg) \
  39. (*(volatile unsigned short *)(sm501.isaBase + ptrReg))
  40. #define write16(ptrReg,value) \
  41. (*(volatile unsigned short *)(sm501.isaBase + ptrReg) = value)
  42. #define read32(ptrReg) \
  43. (*(volatile unsigned int *)(sm501.isaBase + ptrReg))
  44. #define write32(ptrReg, value) \
  45. (*(volatile unsigned int *)(sm501.isaBase + ptrReg) = value)
  46. GraphicDevice sm501;
  47. /*-----------------------------------------------------------------------------
  48. * SmiSetRegs --
  49. *-----------------------------------------------------------------------------
  50. */
  51. static void SmiSetRegs (void)
  52. {
  53. /*
  54. * The content of the chipset register depends on the board (clocks,
  55. * ...)
  56. */
  57. const SMI_REGS *preg = board_get_regs ();
  58. while (preg->Index) {
  59. write32 (preg->Index, preg->Value);
  60. /*
  61. * Insert a delay between
  62. */
  63. udelay (1000);
  64. preg ++;
  65. }
  66. }
  67. /*-----------------------------------------------------------------------------
  68. * video_hw_init --
  69. *-----------------------------------------------------------------------------
  70. */
  71. void *video_hw_init (void)
  72. {
  73. unsigned int *vm, i;
  74. memset (&sm501, 0, sizeof (GraphicDevice));
  75. /*
  76. * Initialization of the access to the graphic chipset Retreive base
  77. * address of the chipset (see board/RPXClassic/eccx.c)
  78. */
  79. if ((sm501.isaBase = board_video_init ()) == 0) {
  80. return (NULL);
  81. }
  82. if ((sm501.frameAdrs = board_video_get_fb ()) == 0) {
  83. return (NULL);
  84. }
  85. sm501.winSizeX = board_get_width ();
  86. sm501.winSizeY = board_get_height ();
  87. #if defined(CONFIG_VIDEO_SM501_8BPP)
  88. sm501.gdfIndex = GDF__8BIT_INDEX;
  89. sm501.gdfBytesPP = 1;
  90. #elif defined(CONFIG_VIDEO_SM501_16BPP)
  91. sm501.gdfIndex = GDF_16BIT_565RGB;
  92. sm501.gdfBytesPP = 2;
  93. #elif defined(CONFIG_VIDEO_SM501_32BPP)
  94. sm501.gdfIndex = GDF_32BIT_X888RGB;
  95. sm501.gdfBytesPP = 4;
  96. #else
  97. #error Unsupported SM501 BPP
  98. #endif
  99. sm501.memSize = sm501.winSizeX * sm501.winSizeY * sm501.gdfBytesPP;
  100. /* Load Smi registers */
  101. SmiSetRegs ();
  102. /* (see board/RPXClassic/RPXClassic.c) */
  103. board_validate_screen (sm501.isaBase);
  104. /* Clear video memory */
  105. i = sm501.memSize/4;
  106. vm = (unsigned int *)sm501.frameAdrs;
  107. while(i--)
  108. *vm++ = 0;
  109. return (&sm501);
  110. }
  111. /*-----------------------------------------------------------------------------
  112. * video_set_lut --
  113. *-----------------------------------------------------------------------------
  114. */
  115. void video_set_lut (
  116. unsigned int index, /* color number */
  117. unsigned char r, /* red */
  118. unsigned char g, /* green */
  119. unsigned char b /* blue */
  120. )
  121. {
  122. }
  123. #endif /* CONFIG_VIDEO_SM501 */