blob: bc05aecc446dd83f4c54de89f933c5763c4a17e5 [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 Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Simon Glass495a5dc2019-11-14 12:57:30 -070012#include <time.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040014#include <linux/types.h>
Simon Glass313112a2019-08-01 09:46:46 -060015#include <env.h>
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040016#include <asm/io.h>
17#include <asm/bootm.h>
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040018#include <mach/timer.h>
19#include <mmc.h>
20#include <fdtdec.h>
21
22DECLARE_GLOBAL_DATA_PTR;
23
Marek BehĂșn4bebdd32021-05-20 13:23:52 +020024#define BCMSTB_DATA_SECTION __section(".data")
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040025
26struct bcmstb_boot_parameters bcmstb_boot_parameters BCMSTB_DATA_SECTION;
27
28phys_addr_t prior_stage_fdt_address BCMSTB_DATA_SECTION;
29
30union reg_value_union {
31 const char *data;
32 const phys_addr_t *address;
33};
34
35int board_init(void)
36{
37 return 0;
38}
39
Harald Seiler6f14d5f2020-12-15 16:47:52 +010040void reset_cpu(void)
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040041{
42}
43
44int print_cpuinfo(void)
45{
46 return 0;
47}
48
49int dram_init(void)
50{
Siva Durga Prasad Paladugub3d55ea2018-07-16 15:56:11 +053051 if (fdtdec_setup_mem_size_base() != 0)
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040052 return -EINVAL;
53
54 return 0;
55}
56
57int dram_init_banksize(void)
58{
59 fdtdec_setup_memory_banksize();
60
61 /*
62 * On this SoC, U-Boot is running as an ELF file. Change the
Simon Glass72cc5382022-10-20 18:22:39 -060063 * relocation address to CONFIG_TEXT_BASE, so that in
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040064 * 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.
68 */
Simon Glass72cc5382022-10-20 18:22:39 -060069 gd->relocaddr = CONFIG_TEXT_BASE;
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040070
71 return 0;
72}
73
74void enable_caches(void)
75{
76 /*
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.
80 */
81}
82
Thomas Fitzsimmons919646d2018-06-08 17:59:45 -040083int timer_init(void)
84{
85 gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY);
86
87 return 0;
88}
89
90ulong get_tbclk(void)
91{
92 return gd->arch.timer_rate_hz;
93}
94
95uint64_t get_ticks(void)
96{
97 gd->timebase_h = readl(BCMSTB_TIMER_HIGH);
98 gd->timebase_l = readl(BCMSTB_TIMER_LOW);
99
100 return ((uint64_t)gd->timebase_h << 32) | gd->timebase_l;
101}
102
103int board_late_init(void)
104{
105 debug("Arguments from prior stage bootloader:\n");
106 debug("General Purpose Register 0: 0x%x\n", bcmstb_boot_parameters.r0);
107 debug("General Purpose Register 1: 0x%x\n", bcmstb_boot_parameters.r1);
108 debug("General Purpose Register 2: 0x%x\n", bcmstb_boot_parameters.r2);
109 debug("General Purpose Register 3: 0x%x\n", bcmstb_boot_parameters.r3);
110 debug("Stack Pointer Register: 0x%x\n", bcmstb_boot_parameters.sp);
111 debug("Link Register: 0x%x\n", bcmstb_boot_parameters.lr);
112 debug("Assuming timer frequency register at: 0x%p\n",
113 (void *)BCMSTB_TIMER_FREQUENCY);
114 debug("Read timer frequency (in Hz): %ld\n", gd->arch.timer_rate_hz);
115 debug("Prior stage provided DTB at: 0x%p\n",
116 (void *)prior_stage_fdt_address);
117
118 /*
119 * Set fdtcontroladdr in the environment so that scripts can
120 * refer to it, for example, to reuse it for fdtaddr.
121 */
122 env_set_hex("fdtcontroladdr", prior_stage_fdt_address);
123
124 /*
125 * Do not set machid to the machine identifier value provided
126 * by the prior stage bootloader (bcmstb_boot_parameters.r1)
127 * because we're using a device tree to boot Linux.
128 */
129
130 return 0;
131}
Ilias Apalodimascd851d02021-10-12 00:00:14 +0300132
Ilias Apalodimasab5348a2021-10-26 09:12:33 +0300133void *board_fdt_blob_setup(int *err)
Ilias Apalodimascd851d02021-10-12 00:00:14 +0300134{
Ilias Apalodimasab5348a2021-10-26 09:12:33 +0300135 *err = 0;
Ilias Apalodimascd851d02021-10-12 00:00:14 +0300136 /* Stored the DTB address there during our init */
137 return (void *)prior_stage_fdt_address;
138}