cmd_acadia.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_267_nor[] = {
  28. 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x00,
  29. 0x14, 0xc0, 0x36, 0xcc, 0x00, 0x0c, 0x00, 0x00,
  30. 0x00, 0x00, 0x00, 0x00
  31. };
  32. static u8 boot_267_nand[] = {
  33. 0xd0, 0x38, 0xc3, 0x50, 0x13, 0x88, 0x8e, 0x00,
  34. 0x14, 0xc0, 0x36, 0xcc, 0x00, 0x0c, 0x00, 0x00,
  35. 0x00, 0x00, 0x00, 0x00
  36. };
  37. static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  38. {
  39. u8 chip;
  40. u8 *buf;
  41. int cpu_freq;
  42. if (argc < 3) {
  43. printf("Usage:\n%s\n", cmdtp->usage);
  44. return 1;
  45. }
  46. cpu_freq = simple_strtol(argv[1], NULL, 10);
  47. if (cpu_freq != 267) {
  48. printf("Unsupported cpu-frequency - only 267 supported\n");
  49. return 1;
  50. }
  51. /* use 0x50 as I2C EEPROM address for now */
  52. chip = 0x50;
  53. if ((strcmp(argv[2], "nor") != 0) &&
  54. (strcmp(argv[2], "nand") != 0)) {
  55. printf("Unsupported boot-device - only nor|nand support\n");
  56. return 1;
  57. }
  58. if (strcmp(argv[2], "nand") == 0) {
  59. switch (cpu_freq) {
  60. case 267:
  61. buf = boot_267_nand;
  62. break;
  63. default:
  64. break;
  65. }
  66. } else {
  67. switch (cpu_freq) {
  68. case 267:
  69. buf = boot_267_nor;
  70. break;
  71. default:
  72. break;
  73. }
  74. }
  75. if (i2c_write(chip, 0, 1, buf, 16) != 0)
  76. printf("Error writing to EEPROM at address 0x%x\n", chip);
  77. udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
  78. if (i2c_write(chip, 0x10, 1, buf+16, 4) != 0)
  79. printf("Error2 writing to EEPROM at address 0x%x\n", chip);
  80. printf("Done\n");
  81. printf("Please power-cycle the board for the changes to take effect\n");
  82. return 0;
  83. }
  84. U_BOOT_CMD(
  85. bootstrap, 3, 0, do_bootstrap,
  86. "bootstrap - program the I2C bootstrap EEPROM\n",
  87. "<cpu-freq> <nor|nand> - program the I2C bootstrap EEPROM\n"
  88. );