cmd_yucca.c 6.8 KB

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