spl_nand.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2011
  3. * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.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 <common.h>
  24. #include <asm/u-boot.h>
  25. #include <asm/utils.h>
  26. #include <asm/arch/sys_proto.h>
  27. #include <nand.h>
  28. #include <timestamp_autogenerated.h>
  29. #include <version_autogenerated.h>
  30. #include <asm/omap_common.h>
  31. void spl_nand_load_image(void)
  32. {
  33. struct image_header *header;
  34. switch (omap_boot_mode()) {
  35. case NAND_MODE_HW_ECC:
  36. debug("spl: nand - using hw ecc\n");
  37. gpmc_init();
  38. nand_init();
  39. break;
  40. default:
  41. puts("spl: ERROR: This bootmode is not implemented - hanging");
  42. hang();
  43. }
  44. /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
  45. header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
  46. #ifdef CONFIG_NAND_ENV_DST
  47. nand_spl_load_image(CONFIG_ENV_OFFSET,
  48. CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
  49. spl_parse_image_header(header);
  50. nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
  51. (void *)image_load_addr);
  52. #ifdef CONFIG_ENV_OFFSET_REDUND
  53. nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
  54. CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
  55. spl_parse_image_header(header);
  56. nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
  57. (void *)image_load_addr);
  58. #endif
  59. #endif
  60. /* Load u-boot */
  61. nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
  62. CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
  63. spl_parse_image_header(header);
  64. nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
  65. spl_image.size, (void *)spl_image.load_addr);
  66. nand_deselect();
  67. }