cmd_sequoia.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * (C) Copyright 2007
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  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 <i2c.h>
  27. static u8 boot_533_nor[] = {
  28. 0x87, 0x78, 0x82, 0x52, 0x09, 0x57, 0xa0, 0x30,
  29. 0x40, 0x08, 0x23, 0x50, 0x0d, 0x05, 0x00, 0x00
  30. };
  31. static u8 boot_533_nand[] = {
  32. 0x87, 0x78, 0x82, 0x52, 0x09, 0x57, 0xd0, 0x10,
  33. 0xa0, 0x68, 0x23, 0x58, 0x0d, 0x05, 0x00, 0x00
  34. };
  35. static u8 boot_667_nor[] = {
  36. 0x87, 0x78, 0xa2, 0x52, 0x09, 0xd7, 0xa0, 0x30,
  37. 0x40, 0x08, 0x23, 0x50, 0x0d, 0x05, 0x00, 0x00
  38. };
  39. static u8 boot_667_nand[] = {
  40. 0x87, 0x78, 0xa2, 0x52, 0x09, 0xd7, 0xd0, 0x10,
  41. 0xa0, 0x68, 0x23, 0x58, 0x0d, 0x05, 0x00, 0x00
  42. };
  43. static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  44. {
  45. u8 chip;
  46. u8 *buf;
  47. int cpu_freq;
  48. if (argc < 3) {
  49. printf("Usage:\n%s\n", cmdtp->usage);
  50. return 1;
  51. }
  52. cpu_freq = simple_strtol(argv[1], NULL, 10);
  53. if (!((cpu_freq == 533) || (cpu_freq == 667))) {
  54. printf("Unsupported cpu-frequency - only 533 and 667 supported\n");
  55. return 1;
  56. }
  57. /* use 0x52 as I2C EEPROM address for now */
  58. chip = 0x52;
  59. if ((strcmp(argv[2], "nor") != 0) &&
  60. (strcmp(argv[2], "nand") != 0)) {
  61. printf("Unsupported boot-device - only nor|nand support\n");
  62. return 1;
  63. }
  64. if (strcmp(argv[2], "nand") == 0) {
  65. switch (cpu_freq) {
  66. default:
  67. case 533:
  68. buf = boot_533_nand;
  69. break;
  70. case 667:
  71. buf = boot_667_nand;
  72. break;
  73. }
  74. } else {
  75. switch (cpu_freq) {
  76. default:
  77. case 533:
  78. buf = boot_533_nor;
  79. break;
  80. case 667:
  81. buf = boot_667_nor;
  82. break;
  83. }
  84. }
  85. if (i2c_write(chip, 0, 1, buf, 16) != 0)
  86. printf("Error writing to EEPROM at address 0x%x\n", chip);
  87. udelay(CFG_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
  88. printf("Done\n");
  89. printf("Please power-cycle the board for the changes to take effect\n");
  90. return 0;
  91. }
  92. U_BOOT_CMD(
  93. bootstrap, 3, 0, do_bootstrap,
  94. "bootstrap - program the I2C bootstrap EEPROM\n",
  95. "<cpu-freq> <nor|nand> - program the I2C bootstrap EEPROM\n"
  96. );