1From 4c9d54ab5a41d65000c8d249b6fb1b76056f1812 Mon Sep 17 00:00:00 2001 2From: Luca Ceresoli <luca@lucaceresoli.net> 3Date: Wed, 20 Jun 2018 12:11:50 +0200 4Subject: [PATCH] arm/arm64: zynq/zynqmp: pass the PS init file as a kconfig 5 variable 6 7U-Boot needs to link ps7_init_gpl.c on Zynq or psu_init_gpl.c on 8ZynqMP (PS init for short). The current logic to locate this file for 9both platforms is: 10 11 1. if a board-specific file exists in 12 board/xilinx/zynq[mp]/$(CONFIG_DEFAULT_DEVICE_TREE)/ps?_init_gpl.c 13 then use it 14 2. otherwise use board/xilinx/zynq/ps?_init_gpl.c 15 16In the latter case the file does not exist in the U-Boot sources and 17must be copied in the source tree from the outside before starting the 18build. This is typical when it is generated from Xilinx tools while 19developing a custom hardware. However making sure that a 20board-specific file is _not_ found (and used) requires some trickery 21such as removing or overwriting all PS init files (e.g.: the current 22meta-xilinx yocto layer [0]). 23 24This generates a few problems: 25 26 * if the source tree is shared among different out-of-tree builds, 27 they will pollute (and potentially corrupt) each other 28 * the source tree cannot be read-only 29 * any buildsystem must add a command to copy the PS init file binary 30 * overwriting or deleting files in the source tree is ugly as hell 31 32Simplify usage by allowing to pass the path to the desired PS init 33file in kconfig variable XILINX_PS_INIT_FILE. It can be an absolute 34path or relative to $(srctree). If the variable is set, the 35user-specified file will always be used without being copied 36around. If the the variable is left empty, for backward compatibility 37fall back to the old behaviour. 38 39Since the issue is the same for Zynq and ZynqMP, add one kconfig 40variable in a common place and use it for both. 41 42Also use the new kconfig help text to document all the ways to give 43U-Boot the PS init file. 44 45Build-tested with all combinations of: 46 - platform: zynq or zynqmp 47 - PS init file: from XILINX_PS_INIT_FILE (absolute, relative path, 48 non-existing), in-tree board-specific, in board/xilinx/zynq[mp]/ 49 - building in-tree, in subdir, in other directory 50 51[0] https://github.com/Xilinx/meta-xilinx/blob/b2f74cc7fe5c4881589d5e440a17cb51fc66a7ab/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-spl-zynq-init.inc#L9 52 53Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> 54Cc: Albert Aribaud <albert.u.boot@aribaud.net> 55Cc: Michal Simek <michal.simek@xilinx.com> 56Cc: Nathan Rossi <nathan@nathanrossi.com> 57Backported from upstream: https://git.denx.de/?p=u-boot.git;a=commit;h=6da4f67ad09cd8b311d77b2b04e557b7ef65b56c 58--- 59 arch/arm/Kconfig | 1 + 60 board/xilinx/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++++ 61 board/xilinx/zynq/Makefile | 10 +++++++++- 62 board/xilinx/zynqmp/Makefile | 10 +++++++++- 63 4 files changed, 60 insertions(+), 2 deletions(-) 64 create mode 100644 board/xilinx/Kconfig 65 66diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig 67index 22234cde2ab6..e04979d0ef7e 100644 68--- a/arch/arm/Kconfig 69+++ b/arch/arm/Kconfig 70@@ -1293,4 +1293,5 @@ source "board/technologic/ts4600/Kconfig" 71 source "board/vscom/baltos/Kconfig" 72 source "board/woodburn/Kconfig" 73 source "board/work-microwave/work_92105/Kconfig" 74+source "board/xilinx/Kconfig" 75 source "board/zipitz2/Kconfig" 76 77 source "arch/arm/Kconfig.debug" 78diff --git a/board/xilinx/Kconfig b/board/xilinx/Kconfig 79new file mode 100644 80index 000000000000..aa3fa061edef 81--- /dev/null 82+++ b/board/xilinx/Kconfig 83@@ -0,0 +1,41 @@ 84+# Copyright (c) 2018, Luca Ceresoli <luca@lucaceresoli.net> 85+# 86+# SPDX-License-Identifier: GPL-2.0 87+ 88+if ARCH_ZYNQ || ARCH_ZYNQMP 89+ 90+config XILINX_PS_INIT_FILE 91+ string "Zynq/ZynqMP PS init file(s) location" 92+ help 93+ On Zynq and ZynqMP U-Boot SPL (or U-Boot proper if 94+ ZYNQMP_PSU_INIT_ENABLED is set) is responsible for some 95+ basic initializations, such as enabling peripherals and 96+ configuring pinmuxes. The PS init file (called 97+ psu_init_gpl.c on ZynqMP, ps7_init_gpl.c for Zynq-7000) 98+ contains the code for such initializations. 99+ 100+ U-Boot contains PS init files for some boards, but each of 101+ them describes only one specific configuration. Users of a 102+ different board, or needing a different configuration, can 103+ generate custom files using the Xilinx development tools. 104+ 105+ There are three ways to give a PS init file to U-Boot: 106+ 107+ 1. Set this variable to the path, either relative to the 108+ source tree or absolute, where the psu_init_gpl.c or 109+ ps7_init_gpl.c file is located. U-Boot will build this 110+ file. 111+ 112+ 2. If you leave an empty string here, U-Boot will use 113+ board/xilinx/zynq/$(CONFIG_DEFAULT_DEVICE_TREE)/ps7_init_gpl.c 114+ for Zynq-7000, or 115+ board/xilinx/zynqmp/$(CONFIG_DEFAULT_DEVICE_TREE)/psu_init_gpl.c 116+ for ZynqMP. 117+ 118+ 3. If the above file does not exist, U-Boot will use 119+ board/xilinx/zynq/ps7_init_gpl.c for Zynq-7000, or 120+ board/xilinx/zynqmp/psu_init_gpl.c for ZynqMP. This file 121+ is not provided by U-Boot, you have to copy it there 122+ before the build. 123+ 124+endif 125diff --git a/board/xilinx/zynq/Makefile b/board/xilinx/zynq/Makefile 126index 5a76a26720cd..03ad5f0532ee 100644 127--- a/board/xilinx/zynq/Makefile 128+++ b/board/xilinx/zynq/Makefile 129@@ -5,10 +5,18 @@ 130 131 obj-y := board.o 132 133-hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) 134+ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"") 135+PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE)) 136+init-objs := ps_init_gpl.o 137+spl/board/xilinx/zynq/ps_init_gpl.o board/xilinx/zynq/ps_init_gpl.o: $(PS_INIT_FILE) 138+ $(CC) $(c_flags) -I $(srctree)/$(src) -c -o $@ $^ 139+endif 140 141+ifeq ($(init-objs),) 142+hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) 143 init-objs := $(if $(wildcard $(srctree)/$(src)/$(hw-platform-y)/ps7_init_gpl.c),\ 144 $(hw-platform-y)/ps7_init_gpl.o) 145+endif 146 147 ifeq ($(init-objs),) 148 ifneq ($(wildcard $(srctree)/$(src)/ps7_init_gpl.c),) 149diff --git a/board/xilinx/zynqmp/Makefile b/board/xilinx/zynqmp/Makefile 150index 05ccd25dcef3..960b81fc5853 100644 151--- a/board/xilinx/zynqmp/Makefile 152+++ b/board/xilinx/zynqmp/Makefile 153@@ -5,10 +5,18 @@ 154 155 obj-y := zynqmp.o 156 157-hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) 158+ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"") 159+PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE)) 160+init-objs := ps_init_gpl.o 161+spl/board/xilinx/zynqmp/ps_init_gpl.o board/xilinx/zynqmp/ps_init_gpl.o: $(PS_INIT_FILE) 162+ $(CC) $(c_flags) -I $(srctree)/$(src) -c -o $@ $^ 163+endif 164 165+ifeq ($(init-objs),) 166+hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) 167 init-objs := $(if $(wildcard $(srctree)/$(src)/$(hw-platform-y)/psu_init_gpl.c),\ 168 $(hw-platform-y)/psu_init_gpl.o) 169+endif 170 171 ifeq ($(init-objs),) 172 ifneq ($(wildcard $(srctree)/$(src)/psu_init_gpl.c),) 173-- 1742.7.4 175 176