blob: 6f8f51ff9fe98cdbe09da8388b27945467d6b4e5 [file] [log] [blame]
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +05301/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <assert.h>
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +05304#include <console/console.h>
Elyes HAOUAS32727822022-01-12 13:56:47 +01005#include <program_loading.h>
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +05306#include <soc/mmu.h>
7#include <soc/cpucp.h>
8#include <soc/clock.h>
9#include <device/mmio.h>
10#include <timer.h>
11
12void cpucp_prepare(void)
13{
Sudheer Kumar Amrabadidfe817e2022-03-22 20:00:29 +053014 /* allow NS access to EPSS memory */
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +053015 setbits32(&epss_top->access_override, 0x1);
16
Sudheer Kumar Amrabadidfe817e2022-03-22 20:00:29 +053017 /* Enable subsystem clock. Required for CPUCP PDMEM access */
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +053018 setbits32(&epss_fast->epss_muc_clk_ctrl, 0x1);
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +053019}
20
21void cpucp_fw_load_reset(void)
22{
23 struct prog cpucp_fw_prog =
24 PROG_INIT(PROG_PAYLOAD, CONFIG_CBFS_PREFIX "/cpucp");
25
Sudheer Kumar Amrabadidfe817e2022-03-22 20:00:29 +053026 if (!wait_ms(300, (read32(&epss_fast->epss_muc_clk_ctrl) & 0x1) == 0x1))
27 printk(BIOS_ERR, "%s: cannot get CPUCP PDMEM access.\n", __func__);
Ravi Kumar Bokkab0d48ed2021-01-21 02:54:48 +053028
29 if (!selfload(&cpucp_fw_prog))
30 die("SOC image: CPUCP load failed");
31
32 printk(BIOS_DEBUG, "SOC:CPUCP image loaded successfully.\n");
33}