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