blob: 02bb648ce71ffe20c18b446d2c416427a966d2a7 [file] [log] [blame]
Usama Arif9218a112020-08-12 16:12:53 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2020 Arm Limited
4 * Usama Arif <usama.arif@arm.com>
5 */
6
Tom Rinidec7ea02024-05-20 13:35:03 -06007#include <config.h>
Usama Arif9218a112020-08-12 16:12:53 +01008#include <dm.h>
9#include <dm/platform_data/serial_pl01x.h>
Boyan Karatotevf5e18c02024-10-25 18:18:14 +010010#include <env.h>
Boyan Karatotev898f4b92024-10-25 18:18:15 +010011#include <linux/sizes.h>
12
Usama Arif9218a112020-08-12 16:12:53 +010013#include <asm/armv8/mmu.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <asm/global_data.h>
Boyan Karatotevf5e18c02024-10-25 18:18:14 +010015#include <asm/system.h>
Usama Arif9218a112020-08-12 16:12:53 +010016
17static struct mm_region total_compute_mem_map[] = {
18 {
19 .virt = 0x0UL,
20 .phys = 0x0UL,
21 .size = 0x80000000UL,
22 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
23 PTE_BLOCK_NON_SHARE |
24 PTE_BLOCK_PXN | PTE_BLOCK_UXN
25 }, {
26 .virt = 0x80000000UL,
27 .phys = 0x80000000UL,
28 .size = 0xff80000000UL,
29 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
30 PTE_BLOCK_INNER_SHARE
31 }, {
32 /* List terminator */
33 0,
34 }
35};
36
37struct mm_region *mem_map = total_compute_mem_map;
38
Boyan Karatotevf5e18c02024-10-25 18:18:14 +010039/*
40 * Push the variable into the .data section so that it
41 * does not get cleared later.
42 */
43unsigned long __section(".data") fw_dtb_pointer;
44
45void *board_fdt_blob_setup(int *err)
46{
47 *err = 0;
48 if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) {
49 *err = -ENXIO;
50 return NULL;
51 }
52
53 return (void *)fw_dtb_pointer;
54}
55
Boyan Karatotev898f4b92024-10-25 18:18:15 +010056int misc_init_r(void)
57{
58 size_t base;
59
60 if (!env_get("fdt_addr_r"))
61 env_set_hex("fdt_addr_r", fw_dtb_pointer);
62
63 if (!env_get("kernel_addr_r")) {
64 /*
65 * The kernel has to be 2M aligned and the first 64K at the
66 * start of SDRAM is reserved for DTB.
67 */
68 base = gd->ram_base + SZ_2M;
69 assert(IS_ALIGNED(base, SZ_2M));
70
71 env_set_hex("kernel_addr_r", base);
72 }
73
74 return 0;
75}
76
Usama Arif9218a112020-08-12 16:12:53 +010077int board_init(void)
78{
79 return 0;
80}
81
82int dram_init(void)
83{
Boyan Karatotevf5e18c02024-10-25 18:18:14 +010084 return fdtdec_setup_mem_size_base();
Usama Arif9218a112020-08-12 16:12:53 +010085}
86
87int dram_init_banksize(void)
88{
Boyan Karatotevf5e18c02024-10-25 18:18:14 +010089 return fdtdec_setup_memory_banksize();
Usama Arif9218a112020-08-12 16:12:53 +010090}
91
92/* Nothing to be done here as handled by PSCI interface */
Harald Seiler6f14d5f2020-12-15 16:47:52 +010093void reset_cpu(void)
Usama Arif9218a112020-08-12 16:12:53 +010094{
95}