1 // SPDX-License-Identifier: GPL-2.0
3 * u-boot/board/socionext/developerbox/developerbox.c
5 * Copyright (C) 2016-2017 Socionext Inc.
6 * Copyright (C) 2021 Linaro Ltd.
9 #include <asm/armv8/mmu.h>
10 #include <asm/global_data.h>
14 #include <efi_loader.h>
15 #include <env_internal.h>
16 #include <fdt_support.h>
19 #include <linux/kernel.h>
21 #if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
22 struct efi_fw_image fw_images[] = {
24 .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
25 .fw_name = u"DEVELOPERBOX-UBOOT",
29 .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
30 .fw_name = u"DEVELOPERBOX-FIP",
34 .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
35 .fw_name = u"DEVELOPERBOX-OPTEE",
40 struct efi_capsule_update_info update_info = {
41 .dfu_string = "mtd nor1=u-boot.bin raw 200000 100000;"
42 "fip.bin raw 180000 78000;"
43 "optee.bin raw 500000 100000",
47 u8 num_image_type_guids = ARRAY_SIZE(fw_images);
48 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
50 static struct mm_region sc2a11_mem_map[] = {
55 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
61 .size = PHYS_SDRAM_SIZE,
62 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
65 /* 2nd DDR place holder */
68 /* 3rd DDR place holder */
76 struct mm_region *mem_map = sc2a11_mem_map;
78 #define DDR_REGION_INDEX(i) (1 + (i))
79 #define MAX_DDR_REGIONS 3
81 struct draminfo_entry {
89 struct draminfo_entry entry[3];
92 struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE;
94 DECLARE_GLOBAL_DATA_PTR;
96 #define LOAD_OFFSET 0x100
98 /* SCBM System MMU is used for eMMC and NETSEC */
99 #define SCBM_SMMU_ADDR (0x52e00000UL)
100 #define SMMU_SCR0_OFFS (0x0)
101 #define SMMU_SCR0_SHCFG_INNER (0x2 << 22)
102 #define SMMU_SCR0_MTCFG (0x1 << 20)
103 #define SMMU_SCR0_MEMATTR_INNER_OUTER_WB (0xf << 16)
105 static void synquacer_setup_scbm_smmu(void)
107 writel(SMMU_SCR0_SHCFG_INNER | SMMU_SCR0_MTCFG | SMMU_SCR0_MEMATTR_INNER_OUTER_WB,
108 SCBM_SMMU_ADDR + SMMU_SCR0_OFFS);
112 * Miscellaneous platform dependent initialisations
116 gd->bd->bi_boot_params = CONFIG_SYS_LOAD_ADDR + LOAD_OFFSET;
118 gd->env_addr = (ulong)&default_environment[0];
120 synquacer_setup_scbm_smmu();
125 int ft_board_setup(void *blob, struct bd_info *bd)
127 /* Remove SPI NOR and I2C0 for making DT compatible with EDK2 */
128 fdt_del_node_and_alias(blob, "spi_nor");
129 fdt_del_node_and_alias(blob, "i2c0");
140 struct draminfo_entry *ent = synquacer_draminfo->entry;
141 struct mm_region *mr;
144 if (synquacer_draminfo->nr_regions < 1) {
145 log_err("Failed to get correct DRAM information\n");
150 * U-Boot RAM size must be under the first DRAM region so that it doesn't
151 * access secure memory which is at the end of the first DRAM region.
153 gd->ram_size = ent[0].size;
155 /* Update memory region maps */
156 for (i = 0; i < synquacer_draminfo->nr_regions; i++) {
157 if (i >= MAX_DDR_REGIONS)
160 ri = DDR_REGION_INDEX(i);
161 mem_map[ri].phys = ent[i].base;
162 mem_map[ri].size = ent[i].size;
166 mr = &mem_map[DDR_REGION_INDEX(0)];
167 mem_map[ri].virt = mr->virt + mr->size;
168 mem_map[ri].attrs = mr->attrs;
174 int dram_init_banksize(void)
176 struct draminfo_entry *ent = synquacer_draminfo->entry;
179 for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) {
180 if (i < synquacer_draminfo->nr_regions) {
181 debug("%s: dram[%d] = %llx@%llx\n", __func__, i, ent[i].size, ent[i].base);
182 gd->bd->bi_dram[i].start = ent[i].base;
183 gd->bd->bi_dram[i].size = ent[i].size;
190 int print_cpuinfo(void)
192 printf("CPU: SC2A11:Cortex-A53 MPCore 24cores\n");