Masami Hiramatsu | 5cd4a35 | 2021-06-04 18:45:10 +0900 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * u-boot/board/socionext/developerbox/developerbox.c |
| 4 | * |
| 5 | * Copyright (C) 2016-2017 Socionext Inc. |
| 6 | * Copyright (C) 2021 Linaro Ltd. |
| 7 | */ |
| 8 | #include <asm/types.h> |
| 9 | #include <asm/armv8/mmu.h> |
| 10 | #include <asm/global_data.h> |
| 11 | #include <asm/io.h> |
| 12 | #include <common.h> |
| 13 | #include <env_internal.h> |
| 14 | #include <fdt_support.h> |
| 15 | #include <log.h> |
| 16 | |
| 17 | static struct mm_region sc2a11_mem_map[] = { |
| 18 | { |
| 19 | .virt = 0x0UL, |
| 20 | .phys = 0x0UL, |
| 21 | .size = 0x80000000UL, |
| 22 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 23 | PTE_BLOCK_OUTER_SHARE |
| 24 | }, { |
| 25 | /* 1st DDR block */ |
| 26 | .virt = 0x80000000UL, |
| 27 | .phys = 0x80000000UL, |
| 28 | .size = PHYS_SDRAM_SIZE, |
| 29 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 30 | PTE_BLOCK_OUTER_SHARE |
| 31 | }, { |
| 32 | /* 2nd DDR place holder */ |
| 33 | 0, |
| 34 | }, { |
| 35 | /* 3rd DDR place holder */ |
| 36 | 0, |
| 37 | }, { |
| 38 | /* List terminator */ |
| 39 | 0, |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | struct mm_region *mem_map = sc2a11_mem_map; |
| 44 | |
| 45 | #define DDR_REGION_INDEX(i) (1 + (i)) |
| 46 | #define MAX_DDR_REGIONS 3 |
| 47 | |
| 48 | struct draminfo_entry { |
| 49 | u64 base; |
| 50 | u64 size; |
| 51 | }; |
| 52 | |
| 53 | struct draminfo { |
| 54 | u32 nr_regions; |
| 55 | u32 reserved; |
| 56 | struct draminfo_entry entry[3]; |
| 57 | }; |
| 58 | |
| 59 | struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE; |
| 60 | |
| 61 | DECLARE_GLOBAL_DATA_PTR; |
| 62 | |
| 63 | #define LOAD_OFFSET 0x100 |
| 64 | |
| 65 | /* |
| 66 | * Miscellaneous platform dependent initialisations |
| 67 | */ |
| 68 | int board_init(void) |
| 69 | { |
| 70 | gd->bd->bi_boot_params = CONFIG_SYS_LOAD_ADDR + LOAD_OFFSET; |
| 71 | |
| 72 | gd->env_addr = (ulong)&default_environment[0]; |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | int ft_board_setup(void *blob, struct bd_info *bd) |
| 78 | { |
| 79 | /* Remove SPI NOR and I2C0 for making DT compatible with EDK2 */ |
| 80 | fdt_del_node_and_alias(blob, "spi_nor"); |
| 81 | fdt_del_node_and_alias(blob, "i2c0"); |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * DRAM configuration |
| 88 | */ |
| 89 | |
| 90 | int dram_init(void) |
| 91 | { |
| 92 | struct draminfo_entry *ent = synquacer_draminfo->entry; |
| 93 | struct mm_region *mr; |
| 94 | int i, ri; |
| 95 | |
| 96 | if (synquacer_draminfo->nr_regions < 1) { |
| 97 | log_err("Failed to get correct DRAM information\n"); |
| 98 | return -1; |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | * U-Boot RAM size must be under the first DRAM region so that it doesn't |
| 103 | * access secure memory which is at the end of the first DRAM region. |
| 104 | */ |
| 105 | gd->ram_size = ent[0].size; |
| 106 | |
| 107 | /* Update memory region maps */ |
| 108 | for (i = 0; i < synquacer_draminfo->nr_regions; i++) { |
| 109 | if (i >= MAX_DDR_REGIONS) |
| 110 | break; |
| 111 | |
| 112 | ri = DDR_REGION_INDEX(i); |
| 113 | mem_map[ri].phys = ent[i].base; |
| 114 | mem_map[ri].size = ent[i].size; |
| 115 | if (i == 0) |
| 116 | continue; |
| 117 | |
| 118 | mr = &mem_map[DDR_REGION_INDEX(0)]; |
| 119 | mem_map[ri].virt = mr->virt + mr->size; |
| 120 | mem_map[ri].attrs = mr->attrs; |
| 121 | } |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | int dram_init_banksize(void) |
| 127 | { |
| 128 | struct draminfo_entry *ent = synquacer_draminfo->entry; |
| 129 | int i; |
| 130 | |
| 131 | for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) { |
| 132 | if (i < synquacer_draminfo->nr_regions) { |
| 133 | debug("%s: dram[%d] = %llx@%llx\n", __func__, i, ent[i].size, ent[i].base); |
| 134 | gd->bd->bi_dram[i].start = ent[i].base; |
| 135 | gd->bd->bi_dram[i].size = ent[i].size; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | int print_cpuinfo(void) |
| 143 | { |
| 144 | printf("CPU: SC2A11:Cortex-A53 MPCore 24cores\n"); |
| 145 | return 0; |
| 146 | } |