Michael Walle | f5253fb | 2020-11-18 17:46:01 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * LS1028A TF-A calling support |
| 4 | * |
| 5 | * Copyright (c) 2020 Michael Walle <michael@walle.cc> |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <atf_common.h> |
| 11 | #include <spl.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | struct region_info { |
| 16 | u64 addr; |
| 17 | u64 size; |
| 18 | }; |
| 19 | |
| 20 | struct dram_regions_info { |
| 21 | u64 num_dram_regions; |
| 22 | u64 total_dram_size; |
| 23 | struct region_info region[CONFIG_NR_DRAM_BANKS]; |
| 24 | }; |
| 25 | |
| 26 | struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry, |
| 27 | uintptr_t bl33_entry, |
| 28 | uintptr_t fdt_addr) |
| 29 | { |
| 30 | static struct dram_regions_info dram_regions_info = { 0 }; |
| 31 | struct bl_params *bl_params; |
| 32 | struct bl_params_node *node; |
| 33 | void *dcfg_ccsr = (void *)DCFG_BASE; |
| 34 | int i; |
| 35 | |
| 36 | dram_regions_info.num_dram_regions = CONFIG_NR_DRAM_BANKS; |
| 37 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 38 | dram_regions_info.region[i].addr = gd->bd->bi_dram[i].start; |
| 39 | dram_regions_info.region[i].size = gd->bd->bi_dram[i].size; |
| 40 | dram_regions_info.total_dram_size += gd->bd->bi_dram[i].size; |
| 41 | } |
| 42 | |
| 43 | bl_params = bl2_plat_get_bl31_params_v2_default(bl32_entry, bl33_entry, |
| 44 | fdt_addr); |
| 45 | |
| 46 | for_each_bl_params_node(bl_params, node) { |
| 47 | if (node->image_id == ATF_BL31_IMAGE_ID) { |
| 48 | node->ep_info->args.arg3 = (uintptr_t)&dram_regions_info; |
| 49 | node->ep_info->args.arg4 = in_le32(dcfg_ccsr + DCFG_PORSR1); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return bl_params; |
| 54 | } |