board_late_init.c 1.2 KB

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