blob: 50c7f19ae14bd923a667386676a5bfd0902f3b23 [file] [log] [blame]
Ley Foon Tand5591302018-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>
Simon Glass9fb625c2019-08-01 09:46:51 -06009#include <env.h>
Ley Foon Tand5591302018-05-24 00:17:24 +080010#include <errno.h>
Simon Glass691d7192020-05-10 11:40:02 -060011#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060012#include <log.h>
Simon Glass401d1c42020-10-30 21:38:53 -060013#include <asm/global_data.h>
Ley Foon Tand5591302018-05-24 00:17:24 +080014#include <asm/io.h>
Chee Hong Ang464ca992020-07-10 23:52:32 +080015#include <asm/arch/mailbox_s10.h>
16#include <asm/arch/misc.h>
Ley Foon Tand5591302018-05-24 00:17:24 +080017#include <asm/arch/reset_manager.h>
18#include <asm/arch/system_manager.h>
Ley Foon Tand5591302018-05-24 00:17:24 +080019
20DECLARE_GLOBAL_DATA_PTR;
21
Ley Foon Tand5591302018-05-24 00:17:24 +080022/*
Ang, Chee Hong877ec6e2018-12-19 18:35:15 -080023 * FPGA programming support for SoC FPGA Stratix 10
24 */
25static Altera_desc altera_fpga[] = {
26 {
27 /* Family */
Chee Hong Angd2170162020-08-07 11:50:03 +080028 Intel_FPGA_SDM_Mailbox,
Ang, Chee Hong877ec6e2018-12-19 18:35:15 -080029 /* Interface type */
30 secure_device_manager_mailbox,
31 /* No limitation as additional data will be ignored */
32 -1,
33 /* No device function table */
34 NULL,
35 /* Base interface address specified in driver */
36 NULL,
37 /* No cookie implementation */
38 0
39 },
40};
41
Ley Foon Tand5591302018-05-24 00:17:24 +080042
43/*
44 * Print CPU information
45 */
46#if defined(CONFIG_DISPLAY_CPUINFO)
47int print_cpuinfo(void)
48{
49 puts("CPU: Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)\n");
50
51 return 0;
52}
53#endif
54
55#ifdef CONFIG_ARCH_MISC_INIT
56int arch_misc_init(void)
57{
58 char qspi_string[13];
59
60 sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
61 env_set("qspi_clock", qspi_string);
62
Ley Foon Tand5591302018-05-24 00:17:24 +080063 return 0;
64}
65#endif
66
67int arch_early_init_r(void)
68{
Ang, Chee Hong877ec6e2018-12-19 18:35:15 -080069 socfpga_fpga_add(&altera_fpga[0]);
70
Ley Foon Tand5591302018-05-24 00:17:24 +080071 return 0;
72}
73
Chee Hong Ang6b6307e2020-08-06 11:56:29 +080074/* Return 1 if FPGA is ready otherwise return 0 */
75int is_fpga_config_ready(void)
76{
77 return (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGA_CONFIG) &
78 SYSMGR_FPGACONFIG_READY_MASK) == SYSMGR_FPGACONFIG_READY_MASK;
79}
80
Marek Vasut72c347c2019-04-16 22:28:08 +020081void do_bridge_reset(int enable, unsigned int mask)
Ley Foon Tand5591302018-05-24 00:17:24 +080082{
Ang, Chee Hong32e308d2019-05-03 01:18:27 -070083 /* Check FPGA status before bridge enable */
Chee Hong Ang6b6307e2020-08-06 11:56:29 +080084 if (!is_fpga_config_ready()) {
85 puts("FPGA not ready. Bridge reset aborted!\n");
86 return;
Ang, Chee Hong32e308d2019-05-03 01:18:27 -070087 }
88
Ley Foon Tand5591302018-05-24 00:17:24 +080089 socfpga_bridges_reset(enable);
90}