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