cmd_dasa_sim.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. * (C) Copyright 2001
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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. */
  24. #include <common.h>
  25. #include <command.h>
  26. #include <pci.h>
  27. #define OK 0
  28. #define ERROR (-1)
  29. #define TRUE 1
  30. #define FALSE 0
  31. extern u_long pci9054_iobase;
  32. /***************************************************************************
  33. *
  34. * Routines for PLX PCI9054 eeprom access
  35. *
  36. */
  37. static unsigned int PciEepromReadLongVPD (int offs)
  38. {
  39. unsigned int value;
  40. unsigned int ret;
  41. int count;
  42. pci_write_config_dword (CFG_PCI9054_DEV_FN, 0x4c,
  43. (offs << 16) | 0x0003);
  44. count = 0;
  45. for (;;) {
  46. udelay (10 * 1000);
  47. pci_read_config_dword (CFG_PCI9054_DEV_FN, 0x4c, &ret);
  48. if ((ret & 0x80000000) != 0) {
  49. break;
  50. } else {
  51. count++;
  52. if (count > 10) {
  53. printf ("\nTimeout: ret=%08x - Please try again!\n", ret);
  54. break;
  55. }
  56. }
  57. }
  58. pci_read_config_dword (CFG_PCI9054_DEV_FN, 0x50, &value);
  59. return value;
  60. }
  61. static int PciEepromWriteLongVPD (int offs, unsigned int value)
  62. {
  63. unsigned int ret;
  64. int count;
  65. pci_write_config_dword (CFG_PCI9054_DEV_FN, 0x50, value);
  66. pci_write_config_dword (CFG_PCI9054_DEV_FN, 0x4c,
  67. (offs << 16) | 0x80000003);
  68. count = 0;
  69. for (;;) {
  70. udelay (10 * 1000);
  71. pci_read_config_dword (CFG_PCI9054_DEV_FN, 0x4c, &ret);
  72. if ((ret & 0x80000000) == 0) {
  73. break;
  74. } else {
  75. count++;
  76. if (count > 10) {
  77. printf ("\nTimeout: ret=%08x - Please try again!\n", ret);
  78. break;
  79. }
  80. }
  81. }
  82. return TRUE;
  83. }
  84. static void showPci9054 (void)
  85. {
  86. int val;
  87. int l, i;
  88. /* read 9054-values */
  89. for (l = 0; l < 6; l++) {
  90. printf ("%02x: ", l * 0x10);
  91. for (i = 0; i < 4; i++) {
  92. pci_read_config_dword (CFG_PCI9054_DEV_FN,
  93. l * 16 + i * 4,
  94. (unsigned int *)&val);
  95. printf ("%08x ", val);
  96. }
  97. printf ("\n");
  98. }
  99. printf ("\n");
  100. for (l = 0; l < 7; l++) {
  101. printf ("%02x: ", l * 0x10);
  102. for (i = 0; i < 4; i++)
  103. printf ("%08x ",
  104. PciEepromReadLongVPD ((i + l * 4) * 4));
  105. printf ("\n");
  106. }
  107. printf ("\n");
  108. }
  109. static void updatePci9054 (void)
  110. {
  111. int val;
  112. /*
  113. * Set EEPROM write-protect register to 0
  114. */
  115. out32 (pci9054_iobase + 0x0c,
  116. in32 (pci9054_iobase + 0x0c) & 0xffff00ff);
  117. /* Long Serial EEPROM Load Registers... */
  118. val = PciEepromWriteLongVPD (0x00, 0x905410b5);
  119. val = PciEepromWriteLongVPD (0x04, 0x09800001); /* other input controller */
  120. val = PciEepromWriteLongVPD (0x08, 0x28140100);
  121. val = PciEepromWriteLongVPD (0x0c, 0x00000000); /* MBOX0... */
  122. val = PciEepromWriteLongVPD (0x10, 0x00000000);
  123. /* las0: fpga access (0x0000.0000 ... 0x0003.ffff) */
  124. val = PciEepromWriteLongVPD (0x14, 0xfffc0000); /* LAS0RR... */
  125. val = PciEepromWriteLongVPD (0x18, 0x00000001); /* LAS0BA */
  126. val = PciEepromWriteLongVPD (0x1c, 0x00200000); /* MARBR... */
  127. val = PciEepromWriteLongVPD (0x20, 0x00300500); /* LMISC/BIGEND */
  128. val = PciEepromWriteLongVPD (0x24, 0x00000000); /* EROMRR... */
  129. val = PciEepromWriteLongVPD (0x28, 0x00000000); /* EROMBA */
  130. val = PciEepromWriteLongVPD (0x2c, 0x43030000); /* LBRD0... */
  131. val = PciEepromWriteLongVPD (0x30, 0x00000000); /* DMRR... */
  132. val = PciEepromWriteLongVPD (0x34, 0x00000000);
  133. val = PciEepromWriteLongVPD (0x38, 0x00000000);
  134. val = PciEepromWriteLongVPD (0x3c, 0x00000000); /* DMPBAM... */
  135. val = PciEepromWriteLongVPD (0x40, 0x00000000);
  136. /* Extra Long Serial EEPROM Load Registers... */
  137. val = PciEepromWriteLongVPD (0x44, 0x010212fe); /* PCISID... */
  138. /* las1: 505-sram access (0x0004.0000 ... 0x001f.ffff) */
  139. /* Offset to LAS1: Group 1: 0x00040000 */
  140. /* Group 2: 0x00080000 */
  141. /* Group 3: 0x000c0000 */
  142. val = PciEepromWriteLongVPD (0x48, 0xffe00000); /* LAS1RR */
  143. val = PciEepromWriteLongVPD (0x4c, 0x00040001); /* LAS1BA */
  144. val = PciEepromWriteLongVPD (0x50, 0x00000208); /* LBRD1 */ /* so wars bisher */
  145. val = PciEepromWriteLongVPD (0x54, 0x00004c06); /* HotSwap... */
  146. printf ("Finished writing defaults into PLX PCI9054 EEPROM!\n");
  147. }
  148. static void clearPci9054 (void)
  149. {
  150. int val;
  151. /*
  152. * Set EEPROM write-protect register to 0
  153. */
  154. out32 (pci9054_iobase + 0x0c,
  155. in32 (pci9054_iobase + 0x0c) & 0xffff00ff);
  156. /* Long Serial EEPROM Load Registers... */
  157. val = PciEepromWriteLongVPD (0x00, 0xffffffff);
  158. val = PciEepromWriteLongVPD (0x04, 0xffffffff); /* other input controller */
  159. printf ("Finished clearing PLX PCI9054 EEPROM!\n");
  160. }
  161. /* ------------------------------------------------------------------------- */
  162. int do_pci9054 (cmd_tbl_t * cmdtp, int flag, int argc,
  163. char *argv[])
  164. {
  165. if (strcmp (argv[1], "info") == 0) {
  166. showPci9054 ();
  167. return 0;
  168. }
  169. if (strcmp (argv[1], "update") == 0) {
  170. updatePci9054 ();
  171. return 0;
  172. }
  173. if (strcmp (argv[1], "clear") == 0) {
  174. clearPci9054 ();
  175. return 0;
  176. }
  177. printf ("Usage:\n%s\n", cmdtp->usage);
  178. return 1;
  179. }
  180. U_BOOT_CMD(
  181. pci9054, 3, 1, do_pci9054,
  182. "pci9054 - PLX PCI9054 EEPROM access\n",
  183. "pci9054 info - print EEPROM values\n"
  184. "pci9054 update - updates EEPROM with default values\n"
  185. );
  186. /* ------------------------------------------------------------------------- */