cmd_yucca.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * (C) Copyright 2001
  3. * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
  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. * hacked for evb440spe
  24. */
  25. #include <common.h>
  26. #include <command.h>
  27. #include "yucca.h"
  28. #include <i2c.h>
  29. #include <asm/byteorder.h>
  30. extern void print_evb440spe_info(void);
  31. static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag,
  32. int flag, int argc, char * const argv[]);
  33. /* ------------------------------------------------------------------------- */
  34. int do_evb440spe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  35. {
  36. return setBootStrapClock (cmdtp, 1, flag, argc, argv);
  37. }
  38. /* ------------------------------------------------------------------------- */
  39. /* Modify memory.
  40. *
  41. * Syntax:
  42. * evb440spe wrclk prom0,prom1
  43. */
  44. static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,
  45. int argc, char * const argv[])
  46. {
  47. uchar chip;
  48. ulong data;
  49. int nbytes;
  50. extern char console_buffer[];
  51. char sysClock[4];
  52. char cpuClock[4];
  53. char plbClock[4];
  54. char pcixClock[4];
  55. if (argc < 3)
  56. return cmd_usage(cmdtp);
  57. if (strcmp(argv[2], "prom0") == 0)
  58. chip = IIC0_BOOTPROM_ADDR;
  59. else
  60. chip = IIC0_ALT_BOOTPROM_ADDR;
  61. do {
  62. printf("enter sys clock frequency 33 or 66 MHz or quit to abort\n");
  63. nbytes = readline (" ? ");
  64. if (strcmp(console_buffer, "quit") == 0)
  65. return 0;
  66. if ((strcmp(console_buffer, "33") != 0) &
  67. (strcmp(console_buffer, "66") != 0))
  68. nbytes=0;
  69. strcpy(sysClock, console_buffer);
  70. } while (nbytes == 0);
  71. do {
  72. if (strcmp(sysClock, "66") == 0) {
  73. printf("enter cpu clock frequency 400, 533 MHz or quit to abort\n");
  74. } else {
  75. #ifdef CONFIG_STRESS
  76. printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
  77. #else
  78. printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
  79. #endif
  80. }
  81. nbytes = readline (" ? ");
  82. if (strcmp(console_buffer, "quit") == 0)
  83. return 0;
  84. if (strcmp(sysClock, "66") == 0) {
  85. if ((strcmp(console_buffer, "400") != 0) &
  86. (strcmp(console_buffer, "533") != 0)
  87. #ifdef CONFIG_STRESS
  88. & (strcmp(console_buffer, "667") != 0)
  89. #endif
  90. ) {
  91. nbytes = 0;
  92. }
  93. } else {
  94. if ((strcmp(console_buffer, "400") != 0) &
  95. (strcmp(console_buffer, "500") != 0) &
  96. (strcmp(console_buffer, "533") != 0)
  97. #ifdef CONFIG_STRESS
  98. & (strcmp(console_buffer, "667") != 0)
  99. #endif
  100. ) {
  101. nbytes = 0;
  102. }
  103. }
  104. strcpy(cpuClock, console_buffer);
  105. } while (nbytes == 0);
  106. if (strcmp(cpuClock, "500") == 0){
  107. strcpy(plbClock, "166");
  108. } else if (strcmp(cpuClock, "533") == 0){
  109. strcpy(plbClock, "133");
  110. } else {
  111. do {
  112. if (strcmp(cpuClock, "400") == 0)
  113. printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
  114. #ifdef CONFIG_STRESS
  115. if (strcmp(cpuClock, "667") == 0)
  116. printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
  117. #endif
  118. nbytes = readline (" ? ");
  119. if (strcmp(console_buffer, "quit") == 0)
  120. return 0;
  121. if (strcmp(cpuClock, "400") == 0) {
  122. if ((strcmp(console_buffer, "100") != 0) &
  123. (strcmp(console_buffer, "133") != 0))
  124. nbytes = 0;
  125. }
  126. #ifdef CONFIG_STRESS
  127. if (strcmp(cpuClock, "667") == 0) {
  128. if ((strcmp(console_buffer, "133") != 0) &
  129. (strcmp(console_buffer, "166") != 0))
  130. nbytes = 0;
  131. }
  132. #endif
  133. strcpy(plbClock, console_buffer);
  134. } while (nbytes == 0);
  135. }
  136. do {
  137. printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
  138. nbytes = readline (" ? ");
  139. if (strcmp(console_buffer, "quit") == 0)
  140. return 0;
  141. if ((strcmp(console_buffer, "33") != 0) &
  142. (strcmp(console_buffer, "66") != 0) &
  143. (strcmp(console_buffer, "100") != 0) &
  144. (strcmp(console_buffer, "133") != 0)) {
  145. nbytes = 0;
  146. }
  147. strcpy(pcixClock, console_buffer);
  148. } while (nbytes == 0);
  149. printf("\nsys clk = %s MHz\n", sysClock);
  150. printf("cpu clk = %s MHz\n", cpuClock);
  151. printf("plb clk = %s MHz\n", plbClock);
  152. printf("Pci-X clk = %s MHz\n", pcixClock);
  153. do {
  154. printf("\npress [y] to write I2C bootstrap \n");
  155. printf("or [n] to abort. \n");
  156. printf("Don't forget to set board switches \n");
  157. printf("according to your choice before re-starting \n");
  158. printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
  159. nbytes = readline (" ? ");
  160. if (strcmp(console_buffer, "n") == 0)
  161. return 0;
  162. } while (nbytes == 0);
  163. if (strcmp(sysClock, "33") == 0) {
  164. if ((strcmp(cpuClock, "400") == 0) &
  165. (strcmp(plbClock, "100") == 0))
  166. data = 0x8678c206;
  167. if ((strcmp(cpuClock, "400") == 0) &
  168. (strcmp(plbClock, "133") == 0))
  169. data = 0x8678c2c6;
  170. if ((strcmp(cpuClock, "500") == 0))
  171. data = 0x8778f2c6;
  172. if ((strcmp(cpuClock, "533") == 0))
  173. data = 0x87790252;
  174. #ifdef CONFIG_STRESS
  175. if ((strcmp(cpuClock, "667") == 0) &
  176. (strcmp(plbClock, "133") == 0))
  177. data = 0x87794256;
  178. if ((strcmp(cpuClock, "667") == 0) &
  179. (strcmp(plbClock, "166") == 0))
  180. data = 0x87794206;
  181. #endif
  182. }
  183. if (strcmp(sysClock, "66") == 0) {
  184. if ((strcmp(cpuClock, "400") == 0) &
  185. (strcmp(plbClock, "100") == 0))
  186. data = 0x84706206;
  187. if ((strcmp(cpuClock, "400") == 0) &
  188. (strcmp(plbClock, "133") == 0))
  189. data = 0x847062c6;
  190. if ((strcmp(cpuClock, "533") == 0))
  191. data = 0x85708206;
  192. #ifdef CONFIG_STRESS
  193. if ((strcmp(cpuClock, "667") == 0) &
  194. (strcmp(plbClock, "133") == 0))
  195. data = 0x8570a256;
  196. if ((strcmp(cpuClock, "667") == 0) &
  197. (strcmp(plbClock, "166") == 0))
  198. data = 0x8570a206;
  199. #endif
  200. }
  201. #ifdef DEBUG
  202. printf(" pin strap0 to write in i2c = %x\n", data);
  203. #endif /* DEBUG */
  204. if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
  205. printf("Error writing strap0 in %s\n", argv[2]);
  206. if (strcmp(pcixClock, "33") == 0)
  207. data = 0x00000701;
  208. if (strcmp(pcixClock, "66") == 0)
  209. data = 0x00000601;
  210. if (strcmp(pcixClock, "100") == 0)
  211. data = 0x00000501;
  212. if (strcmp(pcixClock, "133") == 0)
  213. data = 0x00000401;
  214. if (strcmp(plbClock, "166") == 0)
  215. data = data | 0x05950000;
  216. else
  217. data = data | 0x05A50000;
  218. #ifdef DEBUG
  219. printf(" pin strap1 to write in i2c = %x\n", data);
  220. #endif /* DEBUG */
  221. udelay(1000);
  222. if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
  223. printf("Error writing strap1 in %s\n", argv[2]);
  224. return 0;
  225. }
  226. U_BOOT_CMD(
  227. evb440spe, 3, 1, do_evb440spe,
  228. "program the serial device strap",
  229. "wrclk [prom0|prom1] - program the serial device strap"
  230. );