sdram.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * sdram.c - create INT6300 sdram configuration files;
  11. *
  12. * sdram.h
  13. *
  14. * this program writes two sdram configuration files in the current
  15. * working directory; both files are for Linux toolkit programs and
  16. * not the Windows Device Manager;
  17. *
  18. * one of these sdram configuration blocks must be sent to the
  19. * INT6300 bootloader with VS_SET_SDRAM before downloading NVM
  20. * and PIB files;
  21. *
  22. * Contributor(s):
  23. * Charles Maier <cmaier@qca.qualcomm.com>
  24. *
  25. *--------------------------------------------------------------------*/
  26. #include <stdio.h>
  27. #include <unistd.h>
  28. #include <stdint.h>
  29. #include <fcntl.h>
  30. #include "../tools/memory.h"
  31. #include "../ram/sdram.h"
  32. #ifndef MAKEFILE
  33. #include "../tools/checksum32.c"
  34. #endif
  35. #define FILE1 "sdram16mb.cfg"
  36. #define FILE2 "sdram64mb.cfg"
  37. int main (int argc, char const * argv [])
  38. {
  39. const uint8_t sdram16mb [32] =
  40. {
  41. 0x00,
  42. 0x00,
  43. 0x00,
  44. 0x01,
  45. 0x68,
  46. 0x2f,
  47. 0x14,
  48. 0x00,
  49. 0x92,
  50. 0xd4,
  51. 0xe1,
  52. 0x01,
  53. 0xd6,
  54. 0x83,
  55. 0x08,
  56. 0x00,
  57. 0x88,
  58. 0x32,
  59. 0x00,
  60. 0x00,
  61. 0xdb,
  62. 0x06,
  63. 0x00,
  64. 0x00,
  65. 0x00,
  66. 0x00,
  67. 0x00,
  68. 0x00,
  69. 0x00,
  70. 0x00,
  71. 0x00,
  72. 0x00
  73. };
  74. const uint8_t sdram64mb [32] =
  75. {
  76. 0x00,
  77. 0x00,
  78. 0x00,
  79. 0x04,
  80. 0x88,
  81. 0x31,
  82. 0x14,
  83. 0x00,
  84. 0x91,
  85. 0xd4,
  86. 0xe1,
  87. 0x01,
  88. 0xe3,
  89. 0x2b,
  90. 0x01,
  91. 0x00,
  92. 0x89,
  93. 0x30,
  94. 0x00,
  95. 0x00,
  96. 0x66,
  97. 0x03,
  98. 0x00,
  99. 0x00,
  100. 0x00,
  101. 0x01,
  102. 0x00,
  103. 0x00,
  104. 0x00,
  105. 0x00,
  106. 0x00,
  107. 0x00
  108. };
  109. int fd;
  110. uint32_t checksum;
  111. if ((fd = open (FILE1, O_CREAT | O_WRONLY | O_TRUNC, 0444)) != - 1)
  112. {
  113. printf ("writing %s\n", FILE1);
  114. checksum = checksum32 (sdram16mb, sizeof (sdram16mb), 0);
  115. write (fd, sdram16mb, sizeof (sdram16mb));
  116. write (fd, & checksum, sizeof (checksum));
  117. close (fd);
  118. }
  119. if ((fd = open (FILE2, O_CREAT | O_WRONLY | O_TRUNC, 0444)) != - 1)
  120. {
  121. printf ("writing %s\n", FILE2);
  122. checksum = checksum32 (sdram64mb, sizeof (sdram64mb), 0);
  123. write (fd, sdram64mb, sizeof (sdram64mb));
  124. write (fd, & checksum, sizeof (checksum));
  125. close (fd);
  126. }
  127. return (0);
  128. }