rk3188-board.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2015 Google, Inc
  4. */
  5. #include <common.h>
  6. #include <clk.h>
  7. #include <dm.h>
  8. #include <ram.h>
  9. #include <syscon.h>
  10. #include <asm/gpio.h>
  11. #include <asm/io.h>
  12. #include <asm/arch-rockchip/clock.h>
  13. #include <asm/arch-rockchip/grf_rk3188.h>
  14. #include <asm/arch-rockchip/periph.h>
  15. #include <asm/arch-rockchip/pmu_rk3288.h>
  16. #include <asm/arch-rockchip/boot_mode.h>
  17. #include <dm/pinctrl.h>
  18. __weak int rk_board_late_init(void)
  19. {
  20. return 0;
  21. }
  22. int board_late_init(void)
  23. {
  24. struct rk3188_grf *grf;
  25. setup_boot_mode();
  26. grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
  27. if (IS_ERR(grf)) {
  28. pr_err("grf syscon returned %ld\n", PTR_ERR(grf));
  29. } else {
  30. /* enable noc remap to mimic legacy loaders */
  31. rk_clrsetreg(&grf->soc_con0,
  32. NOC_REMAP_MASK << NOC_REMAP_SHIFT,
  33. NOC_REMAP_MASK << NOC_REMAP_SHIFT);
  34. }
  35. return rk_board_late_init();
  36. }
  37. int board_init(void)
  38. {
  39. #if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
  40. struct udevice *pinctrl;
  41. int ret;
  42. /*
  43. * We need to implement sdcard iomux here for the further
  44. * initialization, otherwise, it'll hit sdcard command sending
  45. * timeout exception.
  46. */
  47. ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
  48. if (ret) {
  49. debug("%s: Cannot find pinctrl device\n", __func__);
  50. goto err;
  51. }
  52. ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
  53. if (ret) {
  54. debug("%s: Failed to set up SD card\n", __func__);
  55. goto err;
  56. }
  57. return 0;
  58. err:
  59. printf("board_init: Error %d\n", ret);
  60. /* No way to report error here */
  61. hang();
  62. return -1;
  63. #else
  64. return 0;
  65. #endif
  66. }
  67. #ifndef CONFIG_SYS_DCACHE_OFF
  68. void enable_caches(void)
  69. {
  70. /* Enable D-cache. I-cache is already enabled in start.S */
  71. dcache_enable();
  72. }
  73. #endif