0004-arm-arm64-zynq-zynqmp-pass-the-PS-init-file-as-a-kco.patch 6.7 KB

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