]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm64: versal-net: Add support for Versal NET platform
authorMichal Simek <michal.simek@amd.com>
Mon, 19 Sep 2022 12:21:02 +0000 (14:21 +0200)
committerMichal Simek <michal.simek@amd.com>
Mon, 26 Sep 2022 12:23:29 +0000 (14:23 +0200)
Versal NET platform is based on Versal chip which is reusing a lot of IPs.
For more information about new IPs please take a look at DT which describe
currently supported devices.
The patch is adding architecture and board support with soc detection
algorithm. Generic setting should be very similar to Versal but it will
likely diverge in longer run.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/320206853dc370ce290a4e7b6d0bb26b05206021.1663589964.git.michal.simek@amd.com
19 files changed:
Kconfig
MAINTAINERS
arch/arm/Kconfig
arch/arm/Makefile
arch/arm/dts/Makefile
arch/arm/dts/xilinx-versal-net-virt.dts [new file with mode: 0644]
arch/arm/mach-versal-net/Kconfig [new file with mode: 0644]
arch/arm/mach-versal-net/Makefile [new file with mode: 0644]
arch/arm/mach-versal-net/clk.c [new file with mode: 0644]
arch/arm/mach-versal-net/cpu.c [new file with mode: 0644]
arch/arm/mach-versal-net/include/mach/hardware.h [new file with mode: 0644]
arch/arm/mach-versal-net/include/mach/sys_proto.h [new file with mode: 0644]
board/xilinx/Kconfig
board/xilinx/versal-net/Kconfig [new file with mode: 0644]
board/xilinx/versal-net/MAINTAINERS [new file with mode: 0644]
board/xilinx/versal-net/Makefile [new file with mode: 0644]
board/xilinx/versal-net/board.c [new file with mode: 0644]
env/Kconfig
include/configs/xilinx_versal_net.h [new file with mode: 0644]

diff --git a/Kconfig b/Kconfig
index c8c22555a9423a40b73c3c1f0f6b101015a73ee6..2ea735d38e4bbab50abc1311aab735e4cdbf56cd 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -540,7 +540,7 @@ config PLATFORM_ELFENTRY
 
 config STACK_SIZE
        hex "Define max stack size that can be used by U-Boot"
-       default 0x4000000 if ARCH_VERSAL || ARCH_ZYNQMP
+       default 0x4000000 if ARCH_VERSAL_NET || ARCH_VERSAL || ARCH_ZYNQMP
        default 0x200000 if MICROBLAZE
        default 0x1000000
        help
index e4fd099f87b766c5958ad097d11b51355ed743f6..65f26e3de9e15e6ff23fb92a854b45ef047bc26d 100644 (file)
@@ -629,6 +629,13 @@ F: arch/arm/mach-uniphier/
 F:     configs/uniphier_*_defconfig
 N:     uniphier
 
+ARM VERSAL NET
+M:     Michal Simek <michal.simek@amd.com>
+S:     Maintained
+T:     git https://source.denx.de/u-boot/custodians/u-boot-microblaze.git
+F:     arch/arm/mach-versal-net/
+N:     (?<!uni)versal-net
+
 ARM VERSAL
 M:     Michal Simek <michal.simek@amd.com>
 S:     Maintained
index 9a6c2e8101dceec3eb88374acdca3c6ab4d99d05..2e8339405257ffcae78f8f848f79da976d5d201e 100644 (file)
@@ -1251,6 +1251,18 @@ config ARCH_VERSAL
        imply BOARD_LATE_INIT
        imply ENV_VARS_UBOOT_RUNTIME_CONFIG
 
+config ARCH_VERSAL_NET
+       bool "Support Xilinx Keystone Platform"
+       select ARM64
+       select CLK
+       select DM
+       select DM_ETH if NET
+       select DM_MMC if MMC
+       select DM_SERIAL
+       select OF_CONTROL
+       imply BOARD_LATE_INIT
+       imply ENV_VARS_UBOOT_RUNTIME_CONFIG
+
 config ARCH_VF610
        bool "Freescale Vybrid"
        select CPU_V7A
@@ -2300,6 +2312,8 @@ source "arch/arm/mach-zynqmp/Kconfig"
 
 source "arch/arm/mach-versal/Kconfig"
 
+source "arch/arm/mach-versal-net/Kconfig"
+
 source "arch/arm/mach-zynqmp-r5/Kconfig"
 
 source "arch/arm/cpu/armv7/Kconfig"
index 1f4a1d57883b7f23820a87d3f4e16e78ede40fd3..ac602aed9c9ac2722bd7e709915464e0413f5f36 100644 (file)
@@ -88,6 +88,7 @@ machine-$(CONFIG_ARCH_OCTEONTX)               += octeontx
 machine-$(CONFIG_ARCH_OCTEONTX2)       += octeontx2
 machine-$(CONFIG_ARCH_UNIPHIER)                += uniphier
 machine-$(CONFIG_ARCH_VERSAL)          += versal
+machine-$(CONFIG_ARCH_VERSAL_NET)      += versal-net
 machine-$(CONFIG_ARCH_ZYNQ)            += zynq
 machine-$(CONFIG_ARCH_ZYNQMP)          += zynqmp
 machine-$(CONFIG_ARCH_ZYNQMP_R5)       += zynqmp-r5
index 5a42d5061cda4864dc6f1f91cfd3af1c77a1293c..5d4b76c6be9acb292e84999b0432ae7e450fd1e8 100644 (file)
@@ -383,6 +383,8 @@ dtb-$(CONFIG_ARCH_VERSAL) += \
        versal-mini-emmc0.dtb \
        versal-mini-emmc1.dtb \
        xilinx-versal-virt.dtb
+dtb-$(CONFIG_ARCH_VERSAL_NET) += \
+       xilinx-versal-net-virt.dtb
 dtb-$(CONFIG_ARCH_ZYNQMP_R5) += \
        zynqmp-r5.dtb
 dtb-$(CONFIG_AM33XX) += \
diff --git a/arch/arm/dts/xilinx-versal-net-virt.dts b/arch/arm/dts/xilinx-versal-net-virt.dts
new file mode 100644 (file)
index 0000000..c99257c
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Empty device tree for versal-net-virt board
+ *
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ */
+
+/dts-v1/;
+
+/ {
+};
diff --git a/arch/arm/mach-versal-net/Kconfig b/arch/arm/mach-versal-net/Kconfig
new file mode 100644 (file)
index 0000000..62825e1
--- /dev/null
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: GPL-2.0
+
+if ARCH_VERSAL_NET
+
+config SYS_BOARD
+       string "Board name"
+       default "versal-net"
+
+config SYS_VENDOR
+       string "Vendor name"
+       default "xilinx"
+
+config SYS_SOC
+       default "versal-net"
+
+config SYS_CONFIG_NAME
+       string "Board configuration name"
+       default "xilinx_versal_net"
+       help
+         This option contains information about board configuration name.
+         Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.h header
+         will be used for board configuration.
+
+config SYS_MEM_RSVD_FOR_MMU
+       bool "Reserve memory for MMU Table"
+       help
+         If defined this option is used to setup different space for
+         MMU table than the one which will be allocated during
+         relocation.
+
+config GICV3
+       def_bool y
+
+config SYS_MALLOC_LEN
+       default 0x2000000
+
+config ZYNQ_SDHCI_MAX_FREQ
+       default 200000000
+
+source "board/xilinx/Kconfig"
+source "board/xilinx/versal-net/Kconfig"
+
+endif
diff --git a/arch/arm/mach-versal-net/Makefile b/arch/arm/mach-versal-net/Makefile
new file mode 100644 (file)
index 0000000..e12c4c0
--- /dev/null
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2021 - 2022, Xilinx, Inc.
+# Copyright (C) 2022, Advanced Micro Devices, Inc.
+#
+# Michal Simek <michal.simek@amd.com>
+#
+
+obj-y  += clk.o
+obj-y  += cpu.o
diff --git a/arch/arm/mach-versal-net/clk.c b/arch/arm/mach-versal-net/clk.c
new file mode 100644 (file)
index 0000000..d097de7
--- /dev/null
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016 - 2022,  Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ *
+ * Michal Simek <michal.simek@amd.com>
+ */
+
+#include <common.h>
+#include <init.h>
+#include <time.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_CLOCKS
+/**
+ * set_cpu_clk_info - Initialize clock framework
+ *
+ * Return: 0 always.
+ *
+ * This function is called from common code after relocation and sets up the
+ * clock framework. The framework must not be used before this function had been
+ * called.
+ */
+int set_cpu_clk_info(void)
+{
+       gd->cpu_clk = get_tbclk();
+
+       gd->bd->bi_arm_freq = gd->cpu_clk / 1000000;
+       gd->bd->bi_dsp_freq = 0;
+
+       return 0;
+}
+#endif
diff --git a/arch/arm/mach-versal-net/cpu.c b/arch/arm/mach-versal-net/cpu.c
new file mode 100644 (file)
index 0000000..4c9b154
--- /dev/null
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ *
+ * Michal Simek <michal.simek@amd.com>
+ */
+
+#include <common.h>
+#include <init.h>
+#include <asm/armv8/mmu.h>
+#include <asm/cache.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/cache.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define VERSAL_NET_MEM_MAP_USED        5
+
+#define DRAM_BANKS CONFIG_NR_DRAM_BANKS
+
+/* +1 is end of list which needs to be empty */
+#define VERSAL_NET_MEM_MAP_MAX (VERSAL_NET_MEM_MAP_USED + DRAM_BANKS + 1)
+
+static struct mm_region versal_mem_map[VERSAL_NET_MEM_MAP_MAX] = {
+       {
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
+               .size = 0x70000000UL,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                        PTE_BLOCK_NON_SHARE |
+                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
+       }, {
+               .virt = 0xf0000000UL,
+               .phys = 0xf0000000UL,
+               .size = 0x0fe00000UL,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                        PTE_BLOCK_NON_SHARE |
+                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
+       }, {
+               .virt = 0x400000000UL,
+               .phys = 0x400000000UL,
+               .size = 0x200000000UL,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                        PTE_BLOCK_NON_SHARE |
+                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
+       }, {
+               .virt = 0x600000000UL,
+               .phys = 0x600000000UL,
+               .size = 0x800000000UL,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+                        PTE_BLOCK_INNER_SHARE
+       }, {
+               .virt = 0xe00000000UL,
+               .phys = 0xe00000000UL,
+               .size = 0xf200000000UL,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                        PTE_BLOCK_NON_SHARE |
+                        PTE_BLOCK_PXN | PTE_BLOCK_UXN
+       }
+};
+
+void mem_map_fill(void)
+{
+       int banks = VERSAL_NET_MEM_MAP_USED;
+
+       for (int i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+               /* Zero size means no more DDR that's this is end */
+               if (!gd->bd->bi_dram[i].size)
+                       break;
+
+               versal_mem_map[banks].virt = gd->bd->bi_dram[i].start;
+               versal_mem_map[banks].phys = gd->bd->bi_dram[i].start;
+               versal_mem_map[banks].size = gd->bd->bi_dram[i].size;
+               versal_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+                                             PTE_BLOCK_INNER_SHARE;
+               banks = banks + 1;
+       }
+}
+
+struct mm_region *mem_map = versal_mem_map;
+
+u64 get_page_table_size(void)
+{
+       return 0x14000;
+}
diff --git a/arch/arm/mach-versal-net/include/mach/hardware.h b/arch/arm/mach-versal-net/include/mach/hardware.h
new file mode 100644 (file)
index 0000000..2eb5498
--- /dev/null
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2016 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ */
+
+#ifndef __ASSEMBLY__
+#include <linux/bitops.h>
+#endif
+
+#define PMC_TAP        0xF11A0000
+
+#define PMC_TAP_IDCODE         (PMC_TAP + 0)
+#define PMC_TAP_VERSION                (PMC_TAP + 0x4)
+# define PMC_VERSION_MASK      GENMASK(7, 0)
+# define PS_VERSION_MASK       GENMASK(15, 8)
+# define RTL_VERSION_MASK      GENMASK(23, 16)
+# define PLATFORM_MASK         GENMASK(27, 24)
+# define PLATFORM_VERSION_MASK GENMASK(31, 28)
+#define PMC_TAP_USERCODE       (PMC_TAP + 0x8)
+
+enum versal_net_platform {
+       VERSAL_NET_SILICON = 0,
+       VERSAL_NET_SPP = 1,
+       VERSAL_NET_EMU = 2,
+       VERSAL_NET_QEMU = 3,
+};
diff --git a/arch/arm/mach-versal-net/include/mach/sys_proto.h b/arch/arm/mach-versal-net/include/mach/sys_proto.h
new file mode 100644 (file)
index 0000000..5bba903
--- /dev/null
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ */
+
+#include <linux/build_bug.h>
+
+void mem_map_fill(void);
+
+static inline int zynqmp_mmio_write(const u32 address, const u32 mask,
+                                   const u32 value)
+{
+       BUILD_BUG();
+       return -EINVAL;
+}
index 17880661736d2d7869d70365e6423212641d01a5..746a2332ad5f758c0ea0b3f24ef818f7e88df51e 100644 (file)
@@ -42,7 +42,7 @@ endif
 
 config XILINX_OF_BOARD_DTB_ADDR
        hex "Default DTB pickup address"
-       default 0x1000 if ARCH_VERSAL
+       default 0x1000 if ARCH_VERSAL || ARCH_VERSAL_NET
        default 0x8000 if MICROBLAZE
        default 0x100000 if ARCH_ZYNQ || ARCH_ZYNQMP
        depends on OF_BOARD || OF_SEPARATE
@@ -51,10 +51,10 @@ config XILINX_OF_BOARD_DTB_ADDR
 
 config BOOT_SCRIPT_OFFSET
        hex "Boot script offset"
-       depends on ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || MICROBLAZE
+       depends on ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET || MICROBLAZE
        default 0xFC0000 if ARCH_ZYNQ || MICROBLAZE
        default 0x3E80000 if ARCH_ZYNQMP
-       default 0x7F80000 if ARCH_VERSAL
+       default 0x7F80000 if ARCH_VERSAL || ARCH_VERSAL_NET
        help
           Specifies distro boot script offset in NAND/QSPI/NOR flash.
 
diff --git a/board/xilinx/versal-net/Kconfig b/board/xilinx/versal-net/Kconfig
new file mode 100644 (file)
index 0000000..8f94d2b
--- /dev/null
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 - 2022, Xilinx, Inc.
+# Copyright (C) 2022, Advanced Micro Devices, Inc.
+#
+
+if ARCH_VERSAL_NET
+
+endif
diff --git a/board/xilinx/versal-net/MAINTAINERS b/board/xilinx/versal-net/MAINTAINERS
new file mode 100644 (file)
index 0000000..50120a8
--- /dev/null
@@ -0,0 +1,8 @@
+XILINX_VERSAL_NET BOARDS
+M:     Michal Simek <michal.simek@amd.com>
+S:     Maintained
+T:     git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git
+F:     arch/arm/dts/versal-net*
+F:     board/xilinx/versal-net/
+F:     include/configs/xilinx_versal_net*
+F:     configs/xilinx_versal_net*
diff --git a/board/xilinx/versal-net/Makefile b/board/xilinx/versal-net/Makefile
new file mode 100644 (file)
index 0000000..2008d4e
--- /dev/null
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2021 - 2022, Xilinx, Inc.
+# Copyright (C) 2022, Advanced Micro Devices, Inc.
+#
+# Michal Simek <michal.simek@amd.com>
+#
+
+obj-y  := board.o
diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c
new file mode 100644 (file)
index 0000000..7600319
--- /dev/null
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ *
+ * Michal Simek <michal.simek@amd.com>
+ */
+
+#include <common.h>
+#include <cpu_func.h>
+#include <fdtdec.h>
+#include <init.h>
+#include <log.h>
+#include <malloc.h>
+#include <time.h>
+#include <asm/cache.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/sys_proto.h>
+#include <dm/device.h>
+#include <dm/uclass.h>
+#include "../common/board.h"
+
+#include <linux/bitfield.h>
+#include <debug_uart.h>
+#include <generated/dt.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+       printf("EL Level:\tEL%d\n", current_el());
+
+       return 0;
+}
+
+static u32 platform_id, platform_version;
+
+char *soc_name_decode(void)
+{
+       char *name, *platform_name;
+
+       switch (platform_id) {
+       case VERSAL_NET_SPP:
+               platform_name = "ipp";
+               break;
+       case VERSAL_NET_EMU:
+               platform_name = "emu";
+               break;
+       case VERSAL_NET_QEMU:
+               platform_name = "qemu";
+               break;
+       default:
+               return NULL;
+       }
+
+       /*
+        * --rev. are 6 chars
+        * max platform name is qemu which is 4 chars
+        * platform version number are 1+1
+        * Plus 1 char for \n
+        */
+       name = calloc(1, strlen(CONFIG_SYS_BOARD) + 13);
+       if (!name)
+               return NULL;
+
+       sprintf(name, "%s-%s-rev%d.%d", CONFIG_SYS_BOARD,
+               platform_name, platform_version / 10,
+               platform_version % 10);
+
+       return name;
+}
+
+bool soc_detection(void)
+{
+       u32 version;
+
+       version = readl(PMC_TAP_VERSION);
+       platform_id = FIELD_GET(PLATFORM_MASK, version);
+
+       debug("idcode %x, version %x, usercode %x\n",
+             readl(PMC_TAP_IDCODE), version,
+             readl(PMC_TAP_USERCODE));
+
+       debug("pmc_ver %lx, ps version %lx, rtl version %lx\n",
+             FIELD_GET(PMC_VERSION_MASK, version),
+             FIELD_GET(PS_VERSION_MASK, version),
+             FIELD_GET(RTL_VERSION_MASK, version));
+
+       platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version);
+
+       if (platform_id == VERSAL_NET_SPP ||
+           platform_id == VERSAL_NET_EMU) {
+               /*
+                * 9 is diff for
+                * 0 means 0.9 version
+                * 1 means 1.0 version
+                * 2 means 1.1 version
+                * etc,
+                */
+               platform_version += 9;
+       }
+
+       debug("Platform id: %d version: %d.%d\n", platform_id,
+             platform_version / 10, platform_version % 10);
+
+       return true;
+}
+
+int board_early_init_f(void)
+{
+       if (IS_ENABLED(CONFIG_DEBUG_UART)) {
+               /* Uart debug for sure */
+               debug_uart_init();
+               puts("Debug uart enabled\n"); /* or printch() */
+       }
+
+       return 0;
+}
+
+int board_early_init_r(void)
+{
+       return 0;
+}
+
+int board_late_init(void)
+{
+       if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
+               debug("Saved variables - Skipping\n");
+               return 0;
+       }
+
+       if (!CONFIG_IS_ENABLED(ENV_VARS_UBOOT_RUNTIME_CONFIG))
+               return 0;
+
+       return board_late_init_xilinx();
+}
+
+int dram_init_banksize(void)
+{
+       int ret;
+
+       ret = fdtdec_setup_memory_banksize();
+       if (ret)
+               return ret;
+
+       mem_map_fill();
+
+       return 0;
+}
+
+int dram_init(void)
+{
+       int ret;
+
+       if (CONFIG_IS_ENABLED(SYS_MEM_RSVD_FOR_MMU))
+               ret = fdtdec_setup_mem_size_base();
+       else
+               ret = fdtdec_setup_mem_size_base_lowest();
+
+       if (ret)
+               return -EINVAL;
+
+       return 0;
+}
+
+void reset_cpu(void)
+{
+}
index 5329f7585be5c96376e39f4ec296daeea5543c77..24111dfaf47baafbcf05ff956199ea5cba741d14 100644 (file)
@@ -558,7 +558,7 @@ config ENV_OFFSET
        default 0xF0000 if ARCH_SUNXI
        default 0xE0000 if ARCH_ZYNQ
        default 0x1E00000 if ARCH_ZYNQMP
-       default 0x7F40000 if ARCH_VERSAL
+       default 0x7F40000 if ARCH_VERSAL || ARCH_VERSAL_NET
        default 0 if ARC
        default 0x140000 if ARCH_AT91
        default 0x260000 if ARCH_OMAP2PLUS
@@ -583,7 +583,7 @@ config ENV_SIZE
        default 0x10000 if ARCH_SUNXI
        default 0x8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
        default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
-       default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL
+       default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET
        default 0x4000 if ARC
        default 0x1f000
        help
@@ -593,7 +593,7 @@ config ENV_SECT_SIZE
        hex "Environment Sector-Size"
        depends on ENV_IS_IN_FLASH || ENV_IS_IN_SPI_FLASH
        default 0x2000 if ARCH_ROCKCHIP
-       default 0x40000 if ARCH_ZYNQMP || ARCH_VERSAL
+       default 0x40000 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET
        default 0x20000 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
        default 0x20000 if MICROBLAZE && ENV_IS_IN_SPI_FLASH
        default 0x10000 if ARCH_SUNXI && ENV_IS_IN_SPI_FLASH
diff --git a/include/configs/xilinx_versal_net.h b/include/configs/xilinx_versal_net.h
new file mode 100644 (file)
index 0000000..d9286e7
--- /dev/null
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Configuration for Xilinx Versal NET
+ * Copyright (C) 2016 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ *
+ * Michal Simek <michal.simek@amd.com>
+ *
+ * Based on Configuration for Xilinx ZynqMP
+ */
+
+#ifndef __XILINX_VERSAL_NET_H
+#define __XILINX_VERSAL_NET_H
+
+#define CONFIG_REMAKE_ELF
+
+/* FIXME this is causing issue at least on IPP */
+/* #define CONFIG_ARMV8_SWITCH_TO_EL1 */
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE      0xF9000000
+#define GICR_BASE      0xF9060000
+
+#define CONFIG_SYS_INIT_SP_ADDR                CONFIG_SYS_TEXT_BASE
+
+/* Serial setup */
+#define CONFIG_CPU_ARMV8
+
+#define CONFIG_SYS_BAUDRATE_TABLE \
+       { 4800, 9600, 19200, 38400, 57600, 115200 }
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_MAY_FAIL
+
+/* Monitor Command Prompt */
+/* Console I/O Buffer Size */
+#define CONFIG_SYS_CBSIZE              2048
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
+                                       sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
+#define CONFIG_SYS_MAXARGS             64
+
+#if defined(CONFIG_CMD_DFU)
+#define DFU_DEFAULT_POLL_TIMEOUT       300
+#define CONFIG_THOR_RESET_OFF
+#define DFU_ALT_INFO_RAM \
+       "dfu_ram_info=" \
+       "setenv dfu_alt_info " \
+       "Image ram 80000 $kernel_size_r\\\\;" \
+       "system.dtb ram $fdt_addr_r $fdt_size_r\0" \
+       "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
+       "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
+
+#define DFU_ALT_INFO  \
+               DFU_ALT_INFO_RAM
+#endif
+
+#if !defined(DFU_ALT_INFO)
+# define DFU_ALT_INFO
+#endif
+
+/* Ethernet driver */
+#if defined(CONFIG_ZYNQ_GEM)
+# define CONFIG_NET_MULTI
+# define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
+# define PHY_ANEG_TIMEOUT       20000
+#endif
+
+#define CONFIG_SYS_BOOTM_LEN   (60 * 1024 * 1024)
+
+#define CONFIG_CLOCKS
+
+#define ENV_MEM_LAYOUT_SETTINGS \
+       "fdt_addr_r=0x40000000\0" \
+       "fdt_size_r=0x400000\0" \
+       "pxefile_addr_r=0x10000000\0" \
+       "kernel_addr_r=0x18000000\0" \
+       "kernel_size_r=0x10000000\0" \
+       "scriptaddr=0x20000000\0" \
+       "ramdisk_addr_r=0x02100000\0" \
+       "script_size_f=0x80000\0"
+
+#if defined(CONFIG_MMC_SDHCI_ZYNQ)
+# define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1)
+#else
+# define BOOT_TARGET_DEVICES_MMC(func)
+#endif
+
+#if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
+# define BOOT_TARGET_DEVICES_PXE(func) func(PXE, pxe, na)
+#else
+# define BOOT_TARGET_DEVICES_PXE(func)
+#endif
+
+#if defined(CONFIG_CMD_DHCP)
+# define BOOT_TARGET_DEVICES_DHCP(func)        func(DHCP, dhcp, na)
+#else
+# define BOOT_TARGET_DEVICES_DHCP(func)
+#endif
+
+#if defined(CONFIG_ZYNQMP_GQSPI) || defined(CONFIG_CADENCE_OSPI_VERSAL_NET)
+# define BOOT_TARGET_DEVICES_XSPI(func)        func(XSPI, xspi, 0)
+#else
+# define BOOT_TARGET_DEVICES_XSPI(func)
+#endif
+
+#define BOOTENV_DEV_XSPI(devtypeu, devtypel, instance) \
+       "bootcmd_xspi0=sf probe 0 0 0 && " \
+       "sf read $scriptaddr $script_offset_f $script_size_f && " \
+       "echo XSPI: Trying to boot script at ${scriptaddr} && " \
+       "source ${scriptaddr}; echo XSPI: SCRIPT FAILED: continuing...;\0"
+
+#define BOOTENV_DEV_NAME_XSPI(devtypeu, devtypel, instance) \
+       "xspi0 "
+
+#define BOOT_TARGET_DEVICES_JTAG(func) func(JTAG, jtag, na)
+
+#define BOOTENV_DEV_JTAG(devtypeu, devtypel, instance) \
+       "bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && " \
+               "source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;\0"
+
+#define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \
+       "jtag "
+
+#define BOOT_TARGET_DEVICES_DFU_USB(func)  func(DFU_USB, dfu_usb, 0)
+
+#define BOOTENV_DEV_DFU_USB(devtypeu, devtypel, instance) \
+       "bootcmd_dfu_usb=setenv dfu_alt_info boot.scr ram $scriptaddr " \
+       "$script_size_f; dfu 0 ram 0 && " \
+       "echo DFU: Trying to boot script at ${scriptaddr} && " \
+       "source ${scriptaddr}; " \
+       "echo DFU: SCRIPT FAILED: continuing...;\0"
+
+#define BOOTENV_DEV_NAME_DFU_USB(devtypeu, devtypel, instance) \
+       ""
+
+#define BOOT_TARGET_DEVICES(func) \
+       BOOT_TARGET_DEVICES_JTAG(func) \
+       BOOT_TARGET_DEVICES_MMC(func) \
+       BOOT_TARGET_DEVICES_XSPI(func) \
+       BOOT_TARGET_DEVICES_DFU_USB(func) \
+       BOOT_TARGET_DEVICES_PXE(func) \
+       BOOT_TARGET_DEVICES_DHCP(func)
+
+#include <config_distro_bootcmd.h>
+
+/* Initial environment variables */
+#ifndef CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       ENV_MEM_LAYOUT_SETTINGS \
+       BOOTENV \
+       DFU_ALT_INFO
+#endif
+
+#endif /* __XILINX_VERSAL_NET_H */