blob: 0d67b0fd8360b7d9216a42a33b3b8364cc347f6f [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>
Simon Glass5e6201b2019-08-01 09:46:51 -06009#include <env.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080010#include <errno.h>
Simon Glass97589732020-05-10 11:40:02 -060011#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080013#include <asm/io.h>
Chee Hong Angf18fe842020-07-10 23:52:32 +080014#include <asm/arch/mailbox_s10.h>
15#include <asm/arch/misc.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080016#include <asm/arch/reset_manager.h>
17#include <asm/arch/system_manager.h>
Ley Foon Tanf80cb342018-05-24 00:17:24 +080018
19DECLARE_GLOBAL_DATA_PTR;
20
Ley Foon Tanf80cb342018-05-24 00:17:24 +080021/*
Ang, Chee Hongff14f162018-12-19 18:35:15 -080022 * FPGA programming support for SoC FPGA Stratix 10
23 */
24static Altera_desc altera_fpga[] = {
25 {
26 /* Family */
Chee Hong Ang14192452020-08-07 11:50:03 +080027 Intel_FPGA_SDM_Mailbox,
Ang, Chee Hongff14f162018-12-19 18:35:15 -080028 /* Interface type */
29 secure_device_manager_mailbox,
30 /* No limitation as additional data will be ignored */
31 -1,
32 /* No device function table */
33 NULL,
34 /* Base interface address specified in driver */
35 NULL,
36 /* No cookie implementation */
37 0
38 },
39};
40
Ley Foon Tanf80cb342018-05-24 00:17:24 +080041
42/*
43 * Print CPU information
44 */
45#if defined(CONFIG_DISPLAY_CPUINFO)
46int print_cpuinfo(void)
47{
48 puts("CPU: Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)\n");
49
50 return 0;
51}
52#endif
53
54#ifdef CONFIG_ARCH_MISC_INIT
55int arch_misc_init(void)
56{
57 char qspi_string[13];
58
59 sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
60 env_set("qspi_clock", qspi_string);
61
Ley Foon Tanf80cb342018-05-24 00:17:24 +080062 return 0;
63}
64#endif
65
66int arch_early_init_r(void)
67{
Ang, Chee Hongff14f162018-12-19 18:35:15 -080068 socfpga_fpga_add(&altera_fpga[0]);
69
Ley Foon Tanf80cb342018-05-24 00:17:24 +080070 return 0;
71}
72
Chee Hong Ang61e91992020-08-06 11:56:29 +080073/* Return 1 if FPGA is ready otherwise return 0 */
74int is_fpga_config_ready(void)
75{
76 return (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGA_CONFIG) &
77 SYSMGR_FPGACONFIG_READY_MASK) == SYSMGR_FPGACONFIG_READY_MASK;
78}
79
Marek Vasut713a8a22019-04-16 22:28:08 +020080void do_bridge_reset(int enable, unsigned int mask)
Ley Foon Tanf80cb342018-05-24 00:17:24 +080081{
Ang, Chee Hongd7404452019-05-03 01:18:27 -070082 /* Check FPGA status before bridge enable */
Chee Hong Ang61e91992020-08-06 11:56:29 +080083 if (!is_fpga_config_ready()) {
84 puts("FPGA not ready. Bridge reset aborted!\n");
85 return;
Ang, Chee Hongd7404452019-05-03 01:18:27 -070086 }
87
Ley Foon Tanf80cb342018-05-24 00:17:24 +080088 socfpga_bridges_reset(enable);
89}