Haojian Zhuang | 1f73c0c | 2017-06-01 14:03:22 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Haojian Zhuang | 1f73c0c | 2017-06-01 14:03:22 +0800 | [diff] [blame] | 7 | #include <assert.h> |
Haojian Zhuang | 1f73c0c | 2017-06-01 14:03:22 +0800 | [diff] [blame] | 8 | #include <errno.h> |
Haojian Zhuang | 1f73c0c | 2017-06-01 14:03:22 +0800 | [diff] [blame] | 9 | #include <string.h> |
| 10 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 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 | |
Haojian Zhuang | 1f73c0c | 2017-06-01 14:03:22 +0800 | [diff] [blame] | 19 | #define ADDR_CONVERT(addr) ((addr) < 0x40000 ? \ |
| 20 | (addr) + 0xFFF30000 : \ |
| 21 | (addr) + 0x40000000) |
| 22 | |
| 23 | static 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 | |
| 39 | int 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 | } |