cmd_yucca.c 6.9 KB

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