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