bcmstb.c 3.1 KB

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