blob: 793b8b8e390babef3af1ea196837e0d7e78b8361 [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>
Alif Zakuan Yuslaimi61f598d2025-02-18 16:35:00 +08004 * Copyright (C) 2025 Altera Corporation <www.altera.com>
Ley Foon Tanf80cb342018-05-24 00:17:24 +08005 *
6 */
7
8#include <altera.h>
Alif Zakuan Yuslaimi71257822025-02-18 16:35:01 +08009#include <asm/arch/board.h>
Chee Hong Angf18fe842020-07-10 23:52:32 +080010#include <asm/arch/mailbox_s10.h>
11#include <asm/arch/misc.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080012#include <asm/arch/reset_manager.h>
13#include <asm/arch/system_manager.h>
Siew Chin Lime377bf22021-08-10 11:26:35 +080014#include <asm/io.h>
15#include <asm/global_data.h>
16#include <env.h>
17#include <errno.h>
18#include <init.h>
19#include <log.h>
Tom Rini3fb5b2f2022-03-30 18:07:23 -040020#include <mach/clock_manager.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080021
22DECLARE_GLOBAL_DATA_PTR;
23
Ley Foon Tanf80cb342018-05-24 00:17:24 +080024/*
Ang, Chee Hongff14f162018-12-19 18:35:15 -080025 * FPGA programming support for SoC FPGA Stratix 10
26 */
27static Altera_desc altera_fpga[] = {
28 {
29 /* Family */
Chee Hong Ang14192452020-08-07 11:50:03 +080030 Intel_FPGA_SDM_Mailbox,
Ang, Chee Hongff14f162018-12-19 18:35:15 -080031 /* Interface type */
32 secure_device_manager_mailbox,
33 /* No limitation as additional data will be ignored */
34 -1,
35 /* No device function table */
36 NULL,
37 /* Base interface address specified in driver */
38 NULL,
39 /* No cookie implementation */
40 0
41 },
42};
43
Ley Foon Tanf80cb342018-05-24 00:17:24 +080044/*
45 * Print CPU information
46 */
47#if defined(CONFIG_DISPLAY_CPUINFO)
48int print_cpuinfo(void)
49{
Alif Zakuan Yuslaimi61f598d2025-02-18 16:35:00 +080050 printf("CPU: Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-%s)\n",
51 IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) ? "A55/A76" : "A53");
Ley Foon Tanf80cb342018-05-24 00:17:24 +080052
53 return 0;
54}
55#endif
56
57#ifdef CONFIG_ARCH_MISC_INIT
58int arch_misc_init(void)
59{
60 char qspi_string[13];
Alif Zakuan Yuslaimi71257822025-02-18 16:35:01 +080061 unsigned long id;
Ley Foon Tanf80cb342018-05-24 00:17:24 +080062
63 sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
64 env_set("qspi_clock", qspi_string);
65
Alif Zakuan Yuslaimi71257822025-02-18 16:35:01 +080066 /* Export board_id as environment variable */
67 id = socfpga_get_board_id();
68 env_set_ulong("board_id", id);
69
Ley Foon Tanf80cb342018-05-24 00:17:24 +080070 return 0;
71}
72#endif
73
74int arch_early_init_r(void)
75{
Ang, Chee Hongff14f162018-12-19 18:35:15 -080076 socfpga_fpga_add(&altera_fpga[0]);
77
Ley Foon Tanf80cb342018-05-24 00:17:24 +080078 return 0;
79}
80
Chee Hong Ang61e91992020-08-06 11:56:29 +080081/* Return 1 if FPGA is ready otherwise return 0 */
82int is_fpga_config_ready(void)
83{
84 return (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGA_CONFIG) &
85 SYSMGR_FPGACONFIG_READY_MASK) == SYSMGR_FPGACONFIG_READY_MASK;
86}
87
Marek Vasut713a8a22019-04-16 22:28:08 +020088void do_bridge_reset(int enable, unsigned int mask)
Ley Foon Tanf80cb342018-05-24 00:17:24 +080089{
Ang, Chee Hongd7404452019-05-03 01:18:27 -070090 /* Check FPGA status before bridge enable */
Chee Hong Ang61e91992020-08-06 11:56:29 +080091 if (!is_fpga_config_ready()) {
92 puts("FPGA not ready. Bridge reset aborted!\n");
93 return;
Ang, Chee Hongd7404452019-05-03 01:18:27 -070094 }
95
Ley Foon Tanf80cb342018-05-24 00:17:24 +080096 socfpga_bridges_reset(enable);
97}