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