bcmstb.c 3.1 KB

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