bcmstb.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2018 Cisco Systems, Inc.
  4. * (C) Copyright 2019 Synamedia
  5. *
  6. * Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
  7. */
  8. #include <cpu_func.h>
  9. #include <init.h>
  10. #include <log.h>
  11. #include <time.h>
  12. #include <linux/types.h>
  13. #include <common.h>
  14. #include <env.h>
  15. #include <asm/io.h>
  16. #include <asm/bootm.h>
  17. #include <mach/timer.h>
  18. #include <mmc.h>
  19. #include <fdtdec.h>
  20. DECLARE_GLOBAL_DATA_PTR;
  21. #define BCMSTB_DATA_SECTION __attribute__((section(".data")))
  22. struct bcmstb_boot_parameters bcmstb_boot_parameters BCMSTB_DATA_SECTION;
  23. phys_addr_t prior_stage_fdt_address BCMSTB_DATA_SECTION;
  24. union reg_value_union {
  25. const char *data;
  26. const phys_addr_t *address;
  27. };
  28. int board_init(void)
  29. {
  30. return 0;
  31. }
  32. u32 get_board_rev(void)
  33. {
  34. return 0;
  35. }
  36. void reset_cpu(ulong ignored)
  37. {
  38. }
  39. int print_cpuinfo(void)
  40. {
  41. return 0;
  42. }
  43. int dram_init(void)
  44. {
  45. if (fdtdec_setup_mem_size_base() != 0)
  46. return -EINVAL;
  47. return 0;
  48. }
  49. int dram_init_banksize(void)
  50. {
  51. fdtdec_setup_memory_banksize();
  52. /*
  53. * On this SoC, U-Boot is running as an ELF file. Change the
  54. * relocation address to CONFIG_SYS_TEXT_BASE, so that in
  55. * setup_reloc, gd->reloc_off works out to 0, effectively
  56. * disabling relocation. Otherwise U-Boot hangs in the setup
  57. * instructions just before relocate_code in
  58. * arch/arm/lib/crt0.S.
  59. */
  60. gd->relocaddr = CONFIG_SYS_TEXT_BASE;
  61. return 0;
  62. }
  63. void enable_caches(void)
  64. {
  65. /*
  66. * This port assumes that the prior stage bootloader has
  67. * enabled I-cache and D-cache already. Implementing this
  68. * function silences the warning in the default function.
  69. */
  70. }
  71. int timer_init(void)
  72. {
  73. gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY);
  74. return 0;
  75. }
  76. ulong get_tbclk(void)
  77. {
  78. return gd->arch.timer_rate_hz;
  79. }
  80. uint64_t get_ticks(void)
  81. {
  82. gd->timebase_h = readl(BCMSTB_TIMER_HIGH);
  83. gd->timebase_l = readl(BCMSTB_TIMER_LOW);
  84. return ((uint64_t)gd->timebase_h << 32) | gd->timebase_l;
  85. }
  86. int board_late_init(void)
  87. {
  88. debug("Arguments from prior stage bootloader:\n");
  89. debug("General Purpose Register 0: 0x%x\n", bcmstb_boot_parameters.r0);
  90. debug("General Purpose Register 1: 0x%x\n", bcmstb_boot_parameters.r1);
  91. debug("General Purpose Register 2: 0x%x\n", bcmstb_boot_parameters.r2);
  92. debug("General Purpose Register 3: 0x%x\n", bcmstb_boot_parameters.r3);
  93. debug("Stack Pointer Register: 0x%x\n", bcmstb_boot_parameters.sp);
  94. debug("Link Register: 0x%x\n", bcmstb_boot_parameters.lr);
  95. debug("Assuming timer frequency register at: 0x%p\n",
  96. (void *)BCMSTB_TIMER_FREQUENCY);
  97. debug("Read timer frequency (in Hz): %ld\n", gd->arch.timer_rate_hz);
  98. debug("Prior stage provided DTB at: 0x%p\n",
  99. (void *)prior_stage_fdt_address);
  100. /*
  101. * Set fdtcontroladdr in the environment so that scripts can
  102. * refer to it, for example, to reuse it for fdtaddr.
  103. */
  104. env_set_hex("fdtcontroladdr", prior_stage_fdt_address);
  105. /*
  106. * Do not set machid to the machine identifier value provided
  107. * by the prior stage bootloader (bcmstb_boot_parameters.r1)
  108. * because we're using a device tree to boot Linux.
  109. */
  110. return 0;
  111. }