cmd_dasa_sim.c 5.8 KB

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