update.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include <config.h>
  24. #include <common.h>
  25. #include <command.h>
  26. #include <asm/processor.h>
  27. #include <asm/io.h>
  28. #include <asm/gpio.h>
  29. #include <i2c.h>
  30. #if defined(CONFIG_ZEUS)
  31. u8 buf_zeus_ce[] = {
  32. /*00 01 02 03 04 05 06 07 */
  33. 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  34. /*08 09 0a 0b 0c 0d 0e 0f */
  35. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  36. /*10 11 12 13 14 15 16 17 */
  37. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  38. /*18 19 1a 1b 1c 1d 1e 1f */
  39. 0x00, 0xc0, 0x50, 0x12, 0x72, 0x3e, 0x00, 0x00 };
  40. u8 buf_zeus_pe[] = {
  41. /* CPU_CLOCK_DIV 1 = 00
  42. CPU_PLB_FREQ_DIV 3 = 10
  43. OPB_PLB_FREQ_DIV 2 = 01
  44. EBC_PLB_FREQ_DIV 2 = 00
  45. MAL_PLB_FREQ_DIV 1 = 00
  46. PCI_PLB_FRQ_DIV 3 = 10
  47. PLL_PLLOUTA = IS SET
  48. PLL_OPERATING = IS NOT SET
  49. PLL_FDB_MUL 10 = 1010
  50. PLL_FWD_DIV_A 3 = 101
  51. PLL_FWD_DIV_B 3 = 101
  52. TUNE = 0x2be */
  53. /*00 01 02 03 04 05 06 07 */
  54. 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  55. /*08 09 0a 0b 0c 0d 0e 0f */
  56. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  57. /*10 11 12 13 14 15 16 17 */
  58. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  59. /*18 19 1a 1b 1c 1d 1e 1f */
  60. 0x00, 0x60, 0x68, 0x2d, 0x42, 0xbe, 0x00, 0x00 };
  61. static int update_boot_eeprom(void)
  62. {
  63. u32 len = 0x20;
  64. u8 chip = CONFIG_SYS_I2C_EEPROM_ADDR;
  65. u8 *pbuf;
  66. u8 base;
  67. int i;
  68. if (in_be32((void *)GPIO0_IR) & GPIO_VAL(CONFIG_SYS_GPIO_ZEUS_PE)) {
  69. pbuf = buf_zeus_pe;
  70. base = 0x40;
  71. } else {
  72. pbuf = buf_zeus_ce;
  73. base = 0x00;
  74. }
  75. for (i = 0; i < len; i++, base++) {
  76. if (i2c_write(chip, base, 1, &pbuf[i], 1) != 0) {
  77. printf("i2c_write fail\n");
  78. return 1;
  79. }
  80. udelay(11000);
  81. }
  82. return 0;
  83. }
  84. int do_update_boot_eeprom(cmd_tbl_t* cmdtp, int flag, int argc, char* argv[])
  85. {
  86. return update_boot_eeprom();
  87. }
  88. U_BOOT_CMD (
  89. update_boot_eeprom, 1, 1, do_update_boot_eeprom,
  90. "update boot eeprom content",
  91. NULL
  92. );
  93. #endif