cmd_acadia.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * (C) Copyright 2007
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <i2c.h>
  10. static u8 boot_267_nor[] = {
  11. 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x00,
  12. 0x14, 0xc0, 0x36, 0xcc, 0x00, 0x0c, 0x00, 0x00,
  13. 0x00, 0x00, 0x00, 0x00
  14. };
  15. static u8 boot_267_nand[] = {
  16. 0xd0, 0x38, 0xc3, 0x50, 0x13, 0x88, 0x8e, 0x00,
  17. 0x14, 0xc0, 0x36, 0xcc, 0x00, 0x0c, 0x00, 0x00,
  18. 0x00, 0x00, 0x00, 0x00
  19. };
  20. static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  21. {
  22. u8 chip;
  23. u8 *buf;
  24. int cpu_freq;
  25. if (argc < 3)
  26. return cmd_usage(cmdtp);
  27. cpu_freq = simple_strtol(argv[1], NULL, 10);
  28. if (cpu_freq != 267) {
  29. printf("Unsupported cpu-frequency - only 267 supported\n");
  30. return 1;
  31. }
  32. /* use 0x50 as I2C EEPROM address for now */
  33. chip = 0x50;
  34. if ((strcmp(argv[2], "nor") != 0) &&
  35. (strcmp(argv[2], "nand") != 0)) {
  36. printf("Unsupported boot-device - only nor|nand support\n");
  37. return 1;
  38. }
  39. if (strcmp(argv[2], "nand") == 0) {
  40. switch (cpu_freq) {
  41. case 267:
  42. buf = boot_267_nand;
  43. break;
  44. default:
  45. break;
  46. }
  47. } else {
  48. switch (cpu_freq) {
  49. case 267:
  50. buf = boot_267_nor;
  51. break;
  52. default:
  53. break;
  54. }
  55. }
  56. if (i2c_write(chip, 0, 1, buf, 16) != 0)
  57. printf("Error writing to EEPROM at address 0x%x\n", chip);
  58. udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
  59. if (i2c_write(chip, 0x10, 1, buf+16, 4) != 0)
  60. printf("Error2 writing to EEPROM at address 0x%x\n", chip);
  61. printf("Done\n");
  62. printf("Please power-cycle the board for the changes to take effect\n");
  63. return 0;
  64. }
  65. U_BOOT_CMD(
  66. bootstrap, 3, 0, do_bootstrap,
  67. "program the I2C bootstrap EEPROM",
  68. "<cpu-freq> <nor|nand> - program the I2C bootstrap EEPROM"
  69. );