1 /* 2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 #include <errno.h> 9 #include <string.h> 10 11 #include <arch_helpers.h> 12 #include <common/bl_common.h> 13 #include <common/debug.h> 14 #include <drivers/delay_timer.h> 15 #include <lib/mmio.h> 16 17 #include <hi3660.h> 18 19 #define ADDR_CONVERT(addr) ((addr) < 0x40000 ? \ 20 (addr) + 0xFFF30000 : \ 21 (addr) + 0x40000000) 22 fw_data_init(void)23static void fw_data_init(void) 24 { 25 unsigned long data_head_addr; 26 unsigned int *data_addr; 27 28 data_head_addr = mmio_read_32((uintptr_t) HISI_DATA_HEAD_BASE) + 0x14; 29 data_addr = (unsigned int *) ADDR_CONVERT(data_head_addr); 30 31 memcpy((void *)HISI_DATA0_BASE, 32 (const void *)(unsigned long)ADDR_CONVERT(data_addr[0]), 33 HISI_DATA0_SIZE); 34 memcpy((void *)HISI_DATA1_BASE, 35 (const void *)(unsigned long)ADDR_CONVERT(data_addr[1]), 36 HISI_DATA1_SIZE); 37 } 38 load_lpm3(void)39int load_lpm3(void) 40 { 41 INFO("start fw loading\n"); 42 43 fw_data_init(); 44 45 flush_dcache_range((uintptr_t)HISI_RESERVED_MEM_BASE, 46 HISI_RESERVED_MEM_SIZE); 47 48 sev(); 49 sev(); 50 51 INFO("fw load success\n"); 52 53 return 0; 54 } 55