blob: b9ae31368a5c13832e18aae6f1ef17a4e866be4b [file] [log] [blame]
Haojian Zhuang1f73c0c2017-06-01 14:03:22 +08001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Haojian Zhuang1f73c0c2017-06-01 14:03:22 +08007#include <assert.h>
Haojian Zhuang1f73c0c2017-06-01 14:03:22 +08008#include <errno.h>
Haojian Zhuang1f73c0c2017-06-01 14:03:22 +08009#include <string.h>
10
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#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 Zhuang1f73c0c2017-06-01 14:03:22 +080019#define ADDR_CONVERT(addr) ((addr) < 0x40000 ? \
20 (addr) + 0xFFF30000 : \
21 (addr) + 0x40000000)
22
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
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}