board_late_init.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <spl.h>
  8. #include <nand.h>
  9. #include <linux/io.h>
  10. #include <../drivers/mtd/nand/denali.h>
  11. static void nand_denali_wp_disable(void)
  12. {
  13. #ifdef CONFIG_NAND_DENALI
  14. /*
  15. * Since the boot rom enables the write protection for NAND boot mode,
  16. * it must be disabled somewhere for "nand write", "nand erase", etc.
  17. * The workaround is here to not disturb the Denali NAND controller
  18. * driver just for a really SoC-specific thing.
  19. */
  20. void __iomem *denali_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE;
  21. writel(WRITE_PROTECT__FLAG, denali_reg + WRITE_PROTECT);
  22. #endif
  23. }
  24. int board_late_init(void)
  25. {
  26. puts("MODE: ");
  27. switch (spl_boot_device()) {
  28. case BOOT_DEVICE_MMC1:
  29. printf("eMMC Boot\n");
  30. setenv("bootmode", "emmcboot");
  31. break;
  32. case BOOT_DEVICE_NAND:
  33. printf("NAND Boot\n");
  34. setenv("bootmode", "nandboot");
  35. nand_denali_wp_disable();
  36. break;
  37. case BOOT_DEVICE_NOR:
  38. printf("NOR Boot\n");
  39. setenv("bootmode", "norboot");
  40. break;
  41. default:
  42. printf("Unsupported Boot Mode\n");
  43. return -1;
  44. }
  45. return 0;
  46. }