2018-05-18 14:05:22 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/arch/clock_manager.h>
|
|
|
|
#include <asm/io.h>
|
2021-03-24 05:11:34 +00:00
|
|
|
#include <asm/arch/handoff_soc64.h>
|
2018-05-18 14:05:22 +00:00
|
|
|
#include <asm/arch/system_manager.h>
|
|
|
|
|
|
|
|
const struct cm_config * const cm_get_default_config(void)
|
|
|
|
{
|
2020-12-24 10:21:10 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
2018-05-18 14:05:22 +00:00
|
|
|
struct cm_config *cm_handoff_cfg = (struct cm_config *)
|
2021-03-24 05:11:34 +00:00
|
|
|
(SOC64_HANDOFF_CLOCK + SOC64_HANDOFF_OFFSET_DATA);
|
2018-05-18 14:05:22 +00:00
|
|
|
u32 *conversion = (u32 *)cm_handoff_cfg;
|
|
|
|
u32 i;
|
2021-03-24 05:11:34 +00:00
|
|
|
u32 handoff_clk = readl(SOC64_HANDOFF_CLOCK);
|
2018-05-18 14:05:22 +00:00
|
|
|
|
2021-03-24 05:11:34 +00:00
|
|
|
if (swab32(handoff_clk) == SOC64_HANDOFF_MAGIC_CLOCK) {
|
|
|
|
writel(swab32(handoff_clk), SOC64_HANDOFF_CLOCK);
|
2018-05-18 14:05:22 +00:00
|
|
|
for (i = 0; i < (sizeof(*cm_handoff_cfg) / sizeof(u32)); i++)
|
|
|
|
conversion[i] = swab32(conversion[i]);
|
|
|
|
return cm_handoff_cfg;
|
2021-03-24 05:11:34 +00:00
|
|
|
} else if (handoff_clk == SOC64_HANDOFF_MAGIC_CLOCK) {
|
2018-05-18 14:05:22 +00:00
|
|
|
return cm_handoff_cfg;
|
|
|
|
}
|
2020-12-24 10:21:10 +00:00
|
|
|
#endif
|
2018-05-18 14:05:22 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const unsigned int cm_get_osc_clk_hz(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SPL_BUILD
|
2019-11-27 07:55:25 +00:00
|
|
|
|
2021-03-24 05:11:34 +00:00
|
|
|
u32 clock = readl(SOC64_HANDOFF_CLOCK_OSC);
|
2018-05-18 14:05:22 +00:00
|
|
|
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(clock,
|
2019-11-27 07:55:18 +00:00
|
|
|
socfpga_get_sysmgr_addr() + SYSMGR_SOC64_BOOT_SCRATCH_COLD1);
|
2018-05-18 14:05:22 +00:00
|
|
|
#endif
|
2019-11-27 07:55:18 +00:00
|
|
|
return readl(socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_SOC64_BOOT_SCRATCH_COLD1);
|
2018-05-18 14:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const unsigned int cm_get_intosc_clk_hz(void)
|
|
|
|
{
|
|
|
|
return CLKMGR_INTOSC_HZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
const unsigned int cm_get_fpga_clk_hz(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SPL_BUILD
|
2021-03-24 05:11:34 +00:00
|
|
|
u32 clock = readl(SOC64_HANDOFF_CLOCK_FPGA);
|
2018-05-18 14:05:22 +00:00
|
|
|
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(clock,
|
2019-11-27 07:55:18 +00:00
|
|
|
socfpga_get_sysmgr_addr() + SYSMGR_SOC64_BOOT_SCRATCH_COLD2);
|
2018-05-18 14:05:22 +00:00
|
|
|
#endif
|
2019-11-27 07:55:18 +00:00
|
|
|
return readl(socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_SOC64_BOOT_SCRATCH_COLD2);
|
2018-05-18 14:05:22 +00:00
|
|
|
}
|