hikey960_mcu_load.c 1.1 KB

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