cmd_yucca.c 7.0 KB

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