sdram.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or
  8. * without modification, are permitted (subject to the limitations
  9. * in the disclaimer below) provided that the following conditions
  10. * are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * * Redistributions in binary form must reproduce the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer in the documentation and/or other materials
  18. * provided with the distribution.
  19. *
  20. * * Neither the name of Qualcomm Atheros nor the names of
  21. * its contributors may be used to endorse or promote products
  22. * derived from this software without specific prior written
  23. * permission.
  24. *
  25. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  26. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
  27. * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  28. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  31. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  33. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  34. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  36. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  37. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. *--------------------------------------------------------------------*/
  41. /*====================================================================*
  42. *
  43. * sdram.c - create INT6300 sdram configuration files;
  44. *
  45. * sdram.h
  46. *
  47. * this program writes two sdram configuration files in the current
  48. * working directory; both files are for Linux toolkit programs and
  49. * not the Windows Device Manager;
  50. *
  51. * one of these sdram configuration blocks must be sent to the
  52. * INT6300 bootloader with VS_SET_SDRAM before downloading NVM
  53. * and PIB files;
  54. *
  55. * Contributor(s):
  56. * Charles Maier
  57. *
  58. *--------------------------------------------------------------------*/
  59. #include <stdio.h>
  60. #include <unistd.h>
  61. #include <stdint.h>
  62. #include <fcntl.h>
  63. #include "../tools/memory.h"
  64. #include "../ram/sdram.h"
  65. #ifndef MAKEFILE
  66. #include "../tools/checksum32.c"
  67. #endif
  68. #define FILE1 "sdram16mb.cfg"
  69. #define FILE2 "sdram64mb.cfg"
  70. int main (int argc, char const * argv [])
  71. {
  72. const uint8_t sdram16mb [32] =
  73. {
  74. 0x00,
  75. 0x00,
  76. 0x00,
  77. 0x01,
  78. 0x68,
  79. 0x2f,
  80. 0x14,
  81. 0x00,
  82. 0x92,
  83. 0xd4,
  84. 0xe1,
  85. 0x01,
  86. 0xd6,
  87. 0x83,
  88. 0x08,
  89. 0x00,
  90. 0x88,
  91. 0x32,
  92. 0x00,
  93. 0x00,
  94. 0xdb,
  95. 0x06,
  96. 0x00,
  97. 0x00,
  98. 0x00,
  99. 0x00,
  100. 0x00,
  101. 0x00,
  102. 0x00,
  103. 0x00,
  104. 0x00,
  105. 0x00
  106. };
  107. const uint8_t sdram64mb [32] =
  108. {
  109. 0x00,
  110. 0x00,
  111. 0x00,
  112. 0x04,
  113. 0x88,
  114. 0x31,
  115. 0x14,
  116. 0x00,
  117. 0x91,
  118. 0xd4,
  119. 0xe1,
  120. 0x01,
  121. 0xe3,
  122. 0x2b,
  123. 0x01,
  124. 0x00,
  125. 0x89,
  126. 0x30,
  127. 0x00,
  128. 0x00,
  129. 0x66,
  130. 0x03,
  131. 0x00,
  132. 0x00,
  133. 0x00,
  134. 0x01,
  135. 0x00,
  136. 0x00,
  137. 0x00,
  138. 0x00,
  139. 0x00,
  140. 0x00
  141. };
  142. int fd;
  143. uint32_t checksum;
  144. if ((fd = open (FILE1, O_CREAT|O_WRONLY|O_TRUNC, 0444)) != -1)
  145. {
  146. printf ("writing %s\n", FILE1);
  147. checksum = checksum32 (sdram16mb, sizeof (sdram16mb), 0);
  148. write (fd, sdram16mb, sizeof (sdram16mb));
  149. write (fd, &checksum, sizeof (checksum));
  150. close (fd);
  151. }
  152. if ((fd = open (FILE2, O_CREAT|O_WRONLY|O_TRUNC, 0444)) != -1)
  153. {
  154. printf ("writing %s\n", FILE2);
  155. checksum = checksum32 (sdram64mb, sizeof (sdram64mb), 0);
  156. write (fd, sdram64mb, sizeof (sdram64mb));
  157. write (fd, &checksum, sizeof (checksum));
  158. close (fd);
  159. }
  160. return (0);
  161. }