rk3188-board.c 1.6 KB

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