1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2018 Cisco Systems, Inc.
5 * Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
8 #include <linux/types.h>
11 #include <asm/bootm.h>
12 #include <mach/sdhci.h>
13 #include <mach/timer.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 #define BCMSTB_DATA_SECTION __attribute__((section(".data")))
21 struct bcmstb_boot_parameters bcmstb_boot_parameters BCMSTB_DATA_SECTION;
23 phys_addr_t prior_stage_fdt_address BCMSTB_DATA_SECTION;
25 union reg_value_union {
27 const phys_addr_t *address;
35 u32 get_board_rev(void)
40 void reset_cpu(ulong ignored)
44 int print_cpuinfo(void)
51 if (fdtdec_setup_memory_size() != 0)
57 int dram_init_banksize(void)
59 fdtdec_setup_memory_banksize();
62 * On this SoC, U-Boot is running as an ELF file. Change the
63 * relocation address to CONFIG_SYS_TEXT_BASE, so that in
64 * setup_reloc, gd->reloc_off works out to 0, effectively
65 * disabling relocation. Otherwise U-Boot hangs in the setup
66 * instructions just before relocate_code in
67 * arch/arm/lib/crt0.S.
69 gd->relocaddr = CONFIG_SYS_TEXT_BASE;
74 void enable_caches(void)
77 * This port assumes that the prior stage bootloader has
78 * enabled I-cache and D-cache already. Implementing this
79 * function silences the warning in the default function.
83 static const phys_addr_t bcmstb_sdhci_address(u32 alias_index)
87 char sdhci[16] = { 0 };
88 const void *fdt = gd->fdt_blob;
89 const char *path = NULL;
90 struct fdt_resource resource = { 0 };
93 printf("%s: Invalid gd->fdt_blob\n", __func__);
97 node = fdt_path_offset(fdt, "/aliases");
99 printf("%s: Failed to find /aliases node\n", __func__);
103 sprintf(sdhci, "sdhci%d", alias_index);
104 path = fdt_getprop(fdt, node, sdhci, NULL);
106 printf("%s: Failed to find alias for %s\n", __func__, sdhci);
110 node = fdt_path_offset(fdt, path);
112 printf("%s: Failed to resolve BCMSTB SDHCI alias\n", __func__);
116 ret = fdt_get_named_resource(fdt, node, "reg", "reg-names",
119 printf("%s: Failed to read BCMSTB SDHCI host resource\n",
124 return resource.start;
127 int board_mmc_init(bd_t *bis)
129 phys_addr_t sdhci_base_address = 0;
131 sdhci_base_address = bcmstb_sdhci_address(CONFIG_BCMSTB_SDHCI_INDEX);
133 if (!sdhci_base_address) {
134 sdhci_base_address = BCMSTB_SDHCI_BASE;
135 printf("%s: Assuming BCMSTB SDHCI address: 0x%p\n",
136 __func__, (void *)sdhci_base_address);
139 debug("BCMSTB SDHCI base address: 0x%p\n", (void *)sdhci_base_address);
141 bcmstb_sdhci_init(sdhci_base_address);
148 gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY);
153 ulong get_tbclk(void)
155 return gd->arch.timer_rate_hz;
158 uint64_t get_ticks(void)
160 gd->timebase_h = readl(BCMSTB_TIMER_HIGH);
161 gd->timebase_l = readl(BCMSTB_TIMER_LOW);
163 return ((uint64_t)gd->timebase_h << 32) | gd->timebase_l;
166 int board_late_init(void)
168 debug("Arguments from prior stage bootloader:\n");
169 debug("General Purpose Register 0: 0x%x\n", bcmstb_boot_parameters.r0);
170 debug("General Purpose Register 1: 0x%x\n", bcmstb_boot_parameters.r1);
171 debug("General Purpose Register 2: 0x%x\n", bcmstb_boot_parameters.r2);
172 debug("General Purpose Register 3: 0x%x\n", bcmstb_boot_parameters.r3);
173 debug("Stack Pointer Register: 0x%x\n", bcmstb_boot_parameters.sp);
174 debug("Link Register: 0x%x\n", bcmstb_boot_parameters.lr);
175 debug("Assuming timer frequency register at: 0x%p\n",
176 (void *)BCMSTB_TIMER_FREQUENCY);
177 debug("Read timer frequency (in Hz): %ld\n", gd->arch.timer_rate_hz);
178 debug("Prior stage provided DTB at: 0x%p\n",
179 (void *)prior_stage_fdt_address);
182 * Set fdtcontroladdr in the environment so that scripts can
183 * refer to it, for example, to reuse it for fdtaddr.
185 env_set_hex("fdtcontroladdr", prior_stage_fdt_address);
188 * Do not set machid to the machine identifier value provided
189 * by the prior stage bootloader (bcmstb_boot_parameters.r1)
190 * because we're using a device tree to boot Linux.