blob: 2acdfad07b35be6d583869b2e0587558596e04c5 [file] [log] [blame]
Ley Foon Tanf80cb342018-05-24 00:17:24 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
4 *
5 */
6
7#include <altera.h>
8#include <common.h>
Chee Hong Angf18fe842020-07-10 23:52:32 +08009#include <asm/arch/mailbox_s10.h>
10#include <asm/arch/misc.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080011#include <asm/arch/reset_manager.h>
12#include <asm/arch/system_manager.h>
Siew Chin Lime377bf22021-08-10 11:26:35 +080013#include <asm/io.h>
14#include <asm/global_data.h>
15#include <env.h>
16#include <errno.h>
17#include <init.h>
18#include <log.h>
Tom Rini3fb5b2f2022-03-30 18:07:23 -040019#include <mach/clock_manager.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080020
21DECLARE_GLOBAL_DATA_PTR;
22
Ley Foon Tanf80cb342018-05-24 00:17:24 +080023/*
Ang, Chee Hongff14f162018-12-19 18:35:15 -080024 * FPGA programming support for SoC FPGA Stratix 10
25 */
26static Altera_desc altera_fpga[] = {
27 {
28 /* Family */
Chee Hong Ang14192452020-08-07 11:50:03 +080029 Intel_FPGA_SDM_Mailbox,
Ang, Chee Hongff14f162018-12-19 18:35:15 -080030 /* Interface type */
31 secure_device_manager_mailbox,
32 /* No limitation as additional data will be ignored */
33 -1,
34 /* No device function table */
35 NULL,
36 /* Base interface address specified in driver */
37 NULL,
38 /* No cookie implementation */
39 0
40 },
41};
42
Ley Foon Tanf80cb342018-05-24 00:17:24 +080043
44/*
45 * Print CPU information
46 */
47#if defined(CONFIG_DISPLAY_CPUINFO)
48int print_cpuinfo(void)
49{
50 puts("CPU: Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)\n");
51
52 return 0;
53}
54#endif
55
56#ifdef CONFIG_ARCH_MISC_INIT
57int arch_misc_init(void)
58{
59 char qspi_string[13];
60
61 sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
62 env_set("qspi_clock", qspi_string);
63
Ley Foon Tanf80cb342018-05-24 00:17:24 +080064 return 0;
65}
66#endif
67
68int arch_early_init_r(void)
69{
Ang, Chee Hongff14f162018-12-19 18:35:15 -080070 socfpga_fpga_add(&altera_fpga[0]);
71
Ley Foon Tanf80cb342018-05-24 00:17:24 +080072 return 0;
73}
74
Chee Hong Ang61e91992020-08-06 11:56:29 +080075/* Return 1 if FPGA is ready otherwise return 0 */
76int is_fpga_config_ready(void)
77{
78 return (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGA_CONFIG) &
79 SYSMGR_FPGACONFIG_READY_MASK) == SYSMGR_FPGACONFIG_READY_MASK;
80}
81
Marek Vasut713a8a22019-04-16 22:28:08 +020082void do_bridge_reset(int enable, unsigned int mask)
Ley Foon Tanf80cb342018-05-24 00:17:24 +080083{
Ang, Chee Hongd7404452019-05-03 01:18:27 -070084 /* Check FPGA status before bridge enable */
Chee Hong Ang61e91992020-08-06 11:56:29 +080085 if (!is_fpga_config_ready()) {
86 puts("FPGA not ready. Bridge reset aborted!\n");
87 return;
Ang, Chee Hongd7404452019-05-03 01:18:27 -070088 }
89
Ley Foon Tanf80cb342018-05-24 00:17:24 +080090 socfpga_bridges_reset(enable);
91}