blob: 902fc6bfb5d1a0058da468383b5451bc925e0146 [file] [log] [blame]
Siew Chin Lim954d5992021-03-24 13:11:34 +08001/* SPDX-License-Identifier: GPL-2.0
2 *
Tien Fong Cheedf89b502021-08-10 11:26:29 +08003 * Copyright (C) 2016-2021 Intel Corporation <www.intel.com>
Siew Chin Lim954d5992021-03-24 13:11:34 +08004 *
5 */
6
7#ifndef _HANDOFF_SOC64_H_
8#define _HANDOFF_SOC64_H_
9
10/*
11 * Offset for HW handoff from Quartus tools
12 */
Siew Chin Lim02d25002021-03-24 13:11:37 +080013/* HPS handoff */
Siew Chin Limff1eec32021-03-24 13:11:38 +080014#define SOC64_HANDOFF_MAGIC_BOOT 0x424F4F54
Siew Chin Lim954d5992021-03-24 13:11:34 +080015#define SOC64_HANDOFF_MAGIC_MUX 0x504D5558
16#define SOC64_HANDOFF_MAGIC_IOCTL 0x494F4354
17#define SOC64_HANDOFF_MAGIC_FPGA 0x46504741
18#define SOC64_HANDOFF_MAGIC_DELAY 0x444C4159
19#define SOC64_HANDOFF_MAGIC_CLOCK 0x434C4B53
20#define SOC64_HANDOFF_MAGIC_MISC 0x4D495343
Siew Chin Lim02d25002021-03-24 13:11:37 +080021
Siew Chin Lim954d5992021-03-24 13:11:34 +080022#define SOC64_HANDOFF_OFFSET_LENGTH 0x4
23#define SOC64_HANDOFF_OFFSET_DATA 0x10
Siew Chin Lim02d25002021-03-24 13:11:37 +080024#define SOC64_HANDOFF_SIZE 4096
25
Tien Fong Cheedf89b502021-08-10 11:26:29 +080026#if IS_ENABLED(CONFIG_TARGET_SOCFPGA_STRATIX10) || \
27 IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX)
Siew Chin Lim02d25002021-03-24 13:11:37 +080028#define SOC64_HANDOFF_BASE 0xFFE3F000
29#define SOC64_HANDOFF_MISC (SOC64_HANDOFF_BASE + 0x610)
Tien Fong Cheedf89b502021-08-10 11:26:29 +080030#elif IS_ENABLED(CONFIG_TARGET_SOCFPGA_N5X)
31#define SOC64_HANDOFF_BASE 0xFFE5F000
32#define SOC64_HANDOFF_MISC (SOC64_HANDOFF_BASE + 0x630)
33
34/* DDR handoff */
35#define SOC64_HANDOFF_DDR_BASE 0xFFE5C000
36#define SOC64_HANDOFF_DDR_MAGIC 0x48524444
37#define SOC64_HANDOFF_DDR_UMCTL2_MAGIC 0x4C54434D
38#define SOC64_HANDOFF_DDR_UMCTL2_DDR4_TYPE 0x34524444
39#define SOC64_HANDOFF_DDR_UMCTL2_LPDDR4_0_TYPE 0x3044504C
40#define SOC64_HANDOFF_DDR_UMCTL2_LPDDR4_1_TYPE 0x3144504C
41#define SOC64_HANDOFF_DDR_MEMRESET_BASE (SOC64_HANDOFF_DDR_BASE + 0xC)
42#define SOC64_HANDOFF_DDR_UMCTL2_SECTION (SOC64_HANDOFF_DDR_BASE + 0x10)
43#define SOC64_HANDOFF_DDR_PHY_MAGIC 0x43594850
44#define SOC64_HANDOFF_DDR_PHY_INIT_ENGINE_MAGIC 0x45594850
45#define SOC64_HANDOFF_DDR_PHY_BASE_OFFSET 0x8
46#define SOC64_HANDOFF_DDR_UMCTL2_TYPE_OFFSET 0x8
47#define SOC64_HANDOFF_DDR_UMCTL2_BASE_ADDR_OFFSET 0xC
48#define SOC64_HANDOFF_DDR_TRAIN_IMEM_1D_SECTION 0xFFE50000
49#define SOC64_HANDOFF_DDR_TRAIN_DMEM_1D_SECTION 0xFFE58000
50#define SOC64_HANDOFF_DDR_TRAIN_IMEM_2D_SECTION 0xFFE44000
51#define SOC64_HANDOFF_DDR_TRAIN_DMEM_2D_SECTION 0xFFE4C000
52#define SOC64_HANDOFF_DDR_TRAIN_IMEM_LENGTH SZ_32K
53#define SOC64_HANDOFF_DDR_TRAIN_DMEM_LENGTH SZ_16K
54#endif
55
Siew Chin Lim02d25002021-03-24 13:11:37 +080056#define SOC64_HANDOFF_MUX (SOC64_HANDOFF_BASE + 0x10)
57#define SOC64_HANDOFF_IOCTL (SOC64_HANDOFF_BASE + 0x1A0)
58#define SOC64_HANDOFF_FPGA (SOC64_HANDOFF_BASE + 0x330)
59#define SOC64_HANDOFF_DELAY (SOC64_HANDOFF_BASE + 0x3F0)
60#define SOC64_HANDOFF_CLOCK (SOC64_HANDOFF_BASE + 0x580)
Siew Chin Lim954d5992021-03-24 13:11:34 +080061
Siew Chin Limff1eec32021-03-24 13:11:38 +080062#if IS_ENABLED(CONFIG_TARGET_SOCFPGA_STRATIX10)
Siew Chin Lim954d5992021-03-24 13:11:34 +080063#define SOC64_HANDOFF_CLOCK_OSC (SOC64_HANDOFF_BASE + 0x608)
64#define SOC64_HANDOFF_CLOCK_FPGA (SOC64_HANDOFF_BASE + 0x60C)
65#else
66#define SOC64_HANDOFF_CLOCK_OSC (SOC64_HANDOFF_BASE + 0x5fc)
67#define SOC64_HANDOFF_CLOCK_FPGA (SOC64_HANDOFF_BASE + 0x600)
68#endif
69
Siew Chin Limff1eec32021-03-24 13:11:38 +080070#define SOC64_HANDOFF_MUX_LEN 96
71#define SOC64_HANDOFF_IOCTL_LEN 96
72#if IS_ENABLED(CONFIG_TARGET_SOCFPGA_STRATIX10)
73#define SOC64_HANDOFF_FPGA_LEN 42
74#else
75#define SOC64_HANDOFF_FPGA_LEN 40
76#endif
77#define SOC64_HANDOFF_DELAY_LEN 96
78
79#ifndef __ASSEMBLY__
80#include <asm/types.h>
81enum endianness {
82 LITTLE_ENDIAN = 0,
Tien Fong Cheedf89b502021-08-10 11:26:29 +080083 BIG_ENDIAN,
84 UNKNOWN_ENDIANNESS
Siew Chin Limff1eec32021-03-24 13:11:38 +080085};
86
Tien Fong Cheedf89b502021-08-10 11:26:29 +080087int socfpga_get_handoff_size(void *handoff_address);
88int socfpga_handoff_read(void *handoff_address, void *table, u32 table_len);
Siew Chin Limff1eec32021-03-24 13:11:38 +080089#endif
Siew Chin Lim954d5992021-03-24 13:11:34 +080090#endif /* _HANDOFF_SOC64_H_ */