bcmstb.c 3.0 KB

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