arm: zynq: ps7* consolidation
Subsystems (3)
cover arm: zynq: ps7* consolidation
Hi,
this series is trying to cleanup ps7_init* file that we don't need to have the same copy of the same functions in different locations. This work is done based on solution from Topic.nl for miami boards where format was changed a little bit to save one word in config data segment.
At the same time older method of simply copying files to particular folder is still working.
Please test this in your board to make sure I didn't break anything. I have tested it on zybo/zc702/zc706.
Thanks,
Michal
Michal Simek (9):
arm: zynq: Add missing ps7_post_config declaration
arm: zynq: Enable debug uart on zc706
arm: zynq: Remove ps7_debug code
arm: zynq: Move ps7_* to separate file
arm: zynq: Get rid of ps7_reset_apu() for syzygy board
arm: zynq: Move common ps7_init* initialization to arch code
arm: zynq: Add ps7GetSiliconVersion() to ps7_spl_init
arm: zynq: Convert EMIT_WRITE to EMIT_MASKWRITE
arm: zynq: Convert all board to use arch ps7_init code
arch/arm/mach-zynq/Makefile | 2 +-
.../arm/mach-zynq/include/mach}/ps7_init_gpl.h | 14 +
arch/arm/mach-zynq/include/mach/sys_proto.h | 3 -
.../arm/mach-zynq/ps7_spl_init.c | 31 ++-
arch/arm/mach-zynq/spl.c | 18 +-
.../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c | 138 +---------
.../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h | 81 ------
board/topic/zynq/Makefile | 2 +-
board/topic/zynq/zynq-topic-miami/ps7_init_gpl.c | 2 +-
.../topic/zynq/zynq-topic-miamilite/ps7_init_gpl.c | 2 +-
.../topic/zynq/zynq-topic-miamiplus/ps7_init_gpl.c | 2 +-
board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c | 285 +-------------------
board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h | 117 ---------
board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c | 289 +-------------------
board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h | 117 ---------
board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c | 285 +-------------------
board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h | 117 ---------
board/xilinx/zynq/zynq-zed/ps7_init_gpl.c | 285 +-------------------
board/xilinx/zynq/zynq-zed/ps7_init_gpl.h | 117 ---------
board/xilinx/zynq/zynq-zybo/ps7_init_gpl.c | 292 +--------------------
board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h | 98 -------
configs/zynq_zc706_defconfig | 5 +
22 files changed, 60 insertions(+), 2242 deletions(-)
rename {board/topic/zynq => arch/arm/mach-zynq/include/mach}/ps7_init_gpl.h (75%)
rename board/topic/zynq/ps7_init_common.c => arch/arm/mach-zynq/ps7_spl_init.c (78%)
delete mode 100644 board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h
delete mode 100644 board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h
delete mode 100644 board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h
delete mode 100644 board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h
delete mode 100644 board/xilinx/zynq/zynq-zed/ps7_init_gpl.h
delete mode 100644 board/xilinx/zynq/zynq-zybo/ps7_init_gpl.hSignature · 1 line
1.9.1
PATCH 1/9 arm: zynq: Add missing ps7_post_config declaration
Add missing declaration to header.
Warning log:arch/arm/mach-zynq/spl.c:94:12: warning: symbol 'ps7_post_config' was not declared. Should it be static?
---
arch/arm/mach-zynq/include/mach/sys_proto.h | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-zynq/include/mach/sys_proto.h +1 -0
@@ -22,5 +22,6 @@ int zynq_board_read_rom_ethaddr(unsigned char *ethaddr);/* Driver extern functions */ extern void ps7_init (void ); +int ps7_post_config (void );#endif /* _SYS_PROTO_H_ */
Signature · 1 line
1.9.1
PATCH 2/9 arm: zynq: Enable debug uart on zc706
In reply to Michal SimekEnable debug uart by default.
---
configs/zynq_zc706_defconfig | 5 +++++ 1 file changed, 5 insertions(+)
configs/zynq_zc706_defconfig +5 -0
@@ -3,6 +3,7 @@ CONFIG_SYS_CONFIG_NAME="zynq_zc70x" CONFIG_ARCH_ZYNQ=y CONFIG_SYS_TEXT_BASE=0x4000000 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc706" +CONFIG_DEBUG_UART=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y
@@ -51,6 +52,10 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_ZYNQ_GEM=y +CONFIG_DEBUG_UART_ZYNQ=y +CONFIG_DEBUG_UART_BASE=0xe0001000 +CONFIG_DEBUG_UART_CLOCK=50000000 +CONFIG_DEBUG_UART_ANNOUNCE=y CONFIG_ZYNQ_SERIAL=y CONFIG_ZYNQ_QSPI=y CONFIG_USB=y
Signature · 1 line
1.9.1
PATCH 3/9 arm: zynq: Remove ps7_debug code
In reply to Michal SimekSPL is not calling this code that's why it is dead code and can be removed.
---
.../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c | 10 -- .../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h | 1 - board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c | 112 -------------------- board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h | 1 - board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c | 112 -------------------- board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h | 1 - board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c | 112 -------------------- board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h | 1 - board/xilinx/zynq/zynq-zed/ps7_init_gpl.c | 112 -------------------- board/xilinx/zynq/zynq-zed/ps7_init_gpl.h | 1 - board/xilinx/zynq/zynq-zybo/ps7_init_gpl.c | 114 --------------------- board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h | 1 - 12 files changed, 578 deletions(-)
board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c +0 -10
@@ -255,12 +255,6 @@ unsigned long ps7_post_config_3_0[] = { EMIT_EXIT(), }; -unsigned long ps7_debug_3_0[] = { -EMIT_WRITE (0XF8898FB0 ,0xC5ACCE55U ), -EMIT_WRITE (0XF8899FB0 ,0xC5ACCE55U ), -EMIT_WRITE (0XF8809FB0 ,0xC5ACCE55U ), -EMIT_EXIT (), -};unsigned long ps7_reset_apu_3_0[] = {EMIT_MASKWRITE (0xF8000244 ,0x00000022U ,0x00000022U ),
@@ -353,10 +347,6 @@ int ps7_post_config(void)return ps7_config (ps7_post_config_3_0); } -int ps7_debug (void ) -{ -return ps7_config (ps7_debug_3_0); -}int ps7_reset_apu (void ) {
board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h +0 -1
@@ -69,7 +69,6 @@ extern "C" {int ps7_config (unsigned long *);int ps7_init (void );int ps7_post_config (void ); -int ps7_debug (void );void perf_start_clock (void );void perf_disable_clock (void );
board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c +0 -112
136 lines not on this page · raw message
board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h +0 -1
@@ -104,7 +104,6 @@ extern unsigned long * ps7_peripherals_init_data;int ps7_config (unsigned long *);int ps7_init ();int ps7_post_config (); -int ps7_debug ();char *getPS7MessageInfo (unsigned key);void perf_start_clock (void );
board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c +0 -112
136 lines not on this page · raw message
board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h +0 -1
@@ -104,7 +104,6 @@ extern unsigned long * ps7_peripherals_init_data;int ps7_config (unsigned long *);int ps7_init ();int ps7_post_config (); -int ps7_debug ();char *getPS7MessageInfo (unsigned key);void perf_start_clock (void );
board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c +0 -112
136 lines not on this page · raw message
board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h +0 -1
@@ -104,7 +104,6 @@ extern unsigned long * ps7_peripherals_init_data;int ps7_config (unsigned long *);int ps7_init ();int ps7_post_config (); -int ps7_debug ();char *getPS7MessageInfo (unsigned key);void perf_start_clock (void );
board/xilinx/zynq/zynq-zed/ps7_init_gpl.c +0 -112
136 lines not on this page · raw message
board/xilinx/zynq/zynq-zed/ps7_init_gpl.h +0 -1
@@ -104,7 +104,6 @@ extern unsigned long * ps7_peripherals_init_data;int ps7_config (unsigned long *);int ps7_init ();int ps7_post_config (); -int ps7_debug ();char *getPS7MessageInfo (unsigned key);void perf_start_clock (void );
board/xilinx/zynq/zynq-zybo/ps7_init_gpl.c +0 -114
138 lines not on this page · raw message
board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h +0 -1
@@ -85,7 +85,6 @@ extern unsigned long *ps7_peripherals_init_data;int ps7_config (unsigned long *);int ps7_init (void );int ps7_post_config (void ); -int ps7_debug (void );char *getPS7MessageInfo (unsigned key);void perf_start_clock (void );
Signature · 1 line
1.9.1
PATCH 4/9 arm: zynq: Move ps7_* to separate file
In reply to Michal SimekExtract ps7_* from spl code to prepare for extension. And also return value.
---
arch/arm/mach-zynq/Makefile | 2 +- arch/arm/mach-zynq/include/mach/ps7_init_gpl.h | 14 +++++++++++++ arch/arm/mach-zynq/include/mach/sys_proto.h | 4 ---- arch/arm/mach-zynq/ps7_spl_init.c | 27 ++++++++++++++++++++++++++ arch/arm/mach-zynq/spl.c | 18 +---------------- 5 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 arch/arm/mach-zynq/include/mach/ps7_init_gpl.h create mode 100644 arch/arm/mach-zynq/ps7_spl_init.c
arch/arm/mach-zynq/Makefile +1 -1
@@ -15,4 +15,4 @@ obj-y += slcr.o obj-y += clk.o obj-y += lowlevel_init.o AFLAGS_lowlevel_init.o := -mfpu=neon -obj-$(CONFIG_SPL_BUILD) += spl.o +obj-$(CONFIG_SPL_BUILD) += spl.o ps7_spl_init.o
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* (c) Copyright 2010-2017 Xilinx, Inc. All rights reserved. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _ASM_ARCH_PS7_INIT_GPL_H +#define _ASM_ARCH_PS7_INIT_GPL_H + +/* Called by spl.c */ +int ps7_init (void ); +int ps7_post_config (void ); + +#endif /* _ASM_ARCH_PS7_INIT_GPL_H */
arch/arm/mach-zynq/include/mach/sys_proto.h +0 -4
@@ -20,8 +20,4 @@ extern unsigned int zynq_get_silicon_version(void);int zynq_board_read_rom_ethaddr (unsigned char *ethaddr); -/* Driver extern functions */ -extern void ps7_init (void ); -int ps7_post_config (void ); -#endif /* _SYS_PROTO_H_ */
arch/arm/mach-zynq/ps7_spl_init.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* (c) Copyright 2010-2017 Xilinx, Inc. All rights reserved. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <asm/io.h> +#include <asm/spl.h> +#include <asm/arch/ps7_init_gpl.h> + +__weak int ps7_init (void ) +{ +/* +* This function is overridden by the one in +* board/xilinx/zynq/(platform)/ps7_init_gpl.c, if it exists. +*/ +return 0 ; +} + +__weak int ps7_post_config (void ) +{ +/* +* This function is overridden by the one in +* board/xilinx/zynq/(platform)/ps7_init_gpl.c, if it exists. +*/ +return 0 ; +}
arch/arm/mach-zynq/spl.c +1 -17
@@ -11,6 +11,7 @@#include <asm/spl.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <asm/arch/ps7_init_gpl.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -83,23 +84,6 @@ int spl_start_uboot(void) }#endif -__weak void ps7_init (void ) -{ -/* -* This function is overridden by the one in -* board/xilinx/zynq/(platform)/ps7_init_gpl.c, if it exists. -*/ -} - -__weak int ps7_post_config (void ) -{ -/* -* This function is overridden by the one in -* board/xilinx/zynq/(platform)/ps7_init_gpl.c, if it exists. -*/ -return 0 ; -} -void spl_board_prepare_for_boot (void ) {ps7_post_config ();
Signature · 1 line
1.9.1
PATCH 5/9 arm: zynq: Get rid of ps7_reset_apu() for syzygy board
In reply to Michal SimekThere is no reason to call separate function.
---
board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c +1 -7
@@ -347,17 +347,11 @@ int ps7_post_config(void)return ps7_config (ps7_post_config_3_0); } - -int ps7_reset_apu (void ) -{ -return ps7_config (ps7_reset_apu_3_0); -} -int ps7_init (void ) {int ret; - ret =ps7_reset_apu (); + ret =ps7_config (ps7_reset_apu_3_0);if (ret !=PS7_INIT_SUCCESS )return ret;
Signature · 1 line
1.9.1
PATCH 6/9 arm: zynq: Move common ps7_init* initialization to arch code
In reply to Michal SimekThis patch is based on work done in topic board where the first address word also storing operation which should be done. This is reducing size of configuration data.
This patch is not breaking an option to copy default ps7_init_gpl* files from hdf file but it is doing preparation for ps7_init* consolidation.
The patch is also marking ps7_config as weak function.
---
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h | 28 ++++- arch/arm/mach-zynq/ps7_spl_init.c | 109 +++++++++++++++++++ board/topic/zynq/Makefile | 2 +- board/topic/zynq/ps7_init_common.c | 117 --------------------- board/topic/zynq/ps7_init_gpl.h | 34 ------ board/topic/zynq/zynq-topic-miami/ps7_init_gpl.c | 2 +- .../topic/zynq/zynq-topic-miamilite/ps7_init_gpl.c | 2 +- .../topic/zynq/zynq-topic-miamiplus/ps7_init_gpl.c | 2 +- 8 files changed, 140 insertions(+), 156 deletions(-) delete mode 100644 board/topic/zynq/ps7_init_common.c delete mode 100644 board/topic/zynq/ps7_init_gpl.h
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h +27 -1
@@ -1,5 +1,6 @@/* -* (c) Copyright 2010-2017 Xilinx, Inc. All rights reserved. +* (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. +* (c) Copyright 2016 Topic Embedded Products. * * SPDX-License-Identifier: GPL-2.0+ */
@@ -7,8 +8,33 @@#ifndef _ASM_ARCH_PS7_INIT_GPL_H#define _ASM_ARCH_PS7_INIT_GPL_H +/* Opcode exit is 0 all the time */ +#define OPCODE_EXIT 0U +#define OPCODE_MASKWRITE 0U +#define OPCODE_MASKPOLL 1U +#define OPCODE_MASKDELAY 2U +#define OPCODE_ADDRESS_MASK (~3U) + +/* Sentinel */ +#define EMIT_EXIT () OPCODE_EXIT +/* Opcode is in lower 2 bits of address, address is always 4-byte aligned */ +#define EMIT_MASKWRITE (addr, mask, val) OPCODE_MASKWRITE | addr, mask, val +#define EMIT_MASKPOLL (addr, mask) OPCODE_MASKPOLL | addr, mask +#define EMIT_MASKDELAY (addr, mask) OPCODE_MASKDELAY | addr, mask + +/* Returns codes of ps7_init* */ +#define PS7_INIT_SUCCESS (0) +#define PS7_INIT_CORRUPT (1) +#define PS7_INIT_TIMEOUT (2) +#define PS7_POLL_FAILED_DDR_INIT (3) +#define PS7_POLL_FAILED_DMA (4) +#define PS7_POLL_FAILED_PLL (5) +/* Called by spl.c */ int ps7_init (void );int ps7_post_config (void ); +/* Defined in ps7_init_common.c */ +int ps7_config (unsigned long *ps7_config_init); +#endif /* _ASM_ARCH_PS7_INIT_GPL_H */
arch/arm/mach-zynq/ps7_spl_init.c +109 -0
117 lines not on this page · raw message
board/topic/zynq/Makefile +1 -1
@@ -7,4 +7,4 @@ obj-y := board.o # Remove quotes hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) -obj-$(CONFIG_SPL_BUILD) += $(hw-platform-y)/ps7_init_gpl.o ps7_init_common.o +obj-$(CONFIG_SPL_BUILD) += $(hw-platform-y)/ps7_init_gpl.o
board/topic/zynq/ps7_init_common.c deleted +0 -117
117 lines not on this page · raw message
board/topic/zynq/ps7_init_gpl.h deleted +0 -34
@@ -1,34 +0,0 @@ -/* -* (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. -* (c) Copyright 2016 Topic Embedded Products. -* -* SPDX-License-Identifier: GPL-2.0+ -*/ - -#define OPCODE_EXIT 0U -#define OPCODE_MASKWRITE 0U -#define OPCODE_MASKPOLL 1U -#define OPCODE_MASKDELAY 2U -#define OPCODE_ADDRESS_MASK (~3U) - -/* Sentinel */ -#define EMIT_EXIT () OPCODE_EXIT -/* Opcode is in lower 2 bits of address, address is always 4-byte aligned */ -#define EMIT_MASKWRITE (addr, mask, val) OPCODE_MASKWRITE | addr, mask, val -#define EMIT_MASKPOLL (addr, mask) OPCODE_MASKPOLL | addr, mask -#define EMIT_MASKDELAY (addr, mask) OPCODE_MASKDELAY | addr, mask - -/* Returns codes of ps7_init* */ -#define PS7_INIT_SUCCESS (0) -#define PS7_INIT_CORRUPT (1) -#define PS7_INIT_TIMEOUT (2) -#define PS7_POLL_FAILED_DDR_INIT (3) -#define PS7_POLL_FAILED_DMA (4) -#define PS7_POLL_FAILED_PLL (5) - -/* Called by spl.c */ -int ps7_init (void ); -int ps7_post_config (void ); - -/* Defined in ps7_init_common.c */ -int ps7_config (unsigned long *ps7_config_init);
board/topic/zynq/zynq-topic-miami/ps7_init_gpl.c +1 -1
@@ -5,7 +5,7 @@* SPDX-License-Identifier: GPL-2.0+ */ -#include "../ps7_init_gpl.h" +#include <asm/arch/ps7_init_gpl.h> static unsigned long ps7_pll_init_data_3_0[] = {EMIT_MASKWRITE (0XF8000008 ,0x0000FFFFU ,0x0000DF0DU ),
board/topic/zynq/zynq-topic-miamilite/ps7_init_gpl.c +1 -1
@@ -5,7 +5,7 @@* SPDX-License-Identifier: GPL-2.0+ */ -#include "../ps7_init_gpl.h" +#include <asm/arch/ps7_init_gpl.h> static unsigned long ps7_pll_init_data_3_0[] = {EMIT_MASKWRITE (0xF8000008 ,0x0000FFFFU ,0x0000DF0DU ),
board/topic/zynq/zynq-topic-miamiplus/ps7_init_gpl.c +1 -1
@@ -5,7 +5,7 @@* SPDX-License-Identifier: GPL-2.0+ */ -#include "../ps7_init_gpl.h" +#include <asm/arch/ps7_init_gpl.h> static unsigned long ps7_pll_init_data_3_0[] = {EMIT_MASKWRITE (0XF8000008 ,0x0000FFFFU ,0x0000DF0DU ),
Signature · 1 line
1.9.1
PATCH 7/9 arm: zynq: Add ps7GetSiliconVersion() to ps7_spl_init
In reply to Michal SimekUnfortunately camelcase is coming from ps7_init* format.
---
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h | 6 ++++++ arch/arm/mach-zynq/ps7_spl_init.c | 6 ++++++ 2 files changed, 12 insertions(+)
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h +6 -0
@@ -30,6 +30,10 @@#define PS7_POLL_FAILED_DMA (4)#define PS7_POLL_FAILED_PLL (5) +#define PCW_SILICON_VERSION_1 0 +#define PCW_SILICON_VERSION_2 1 +#define PCW_SILICON_VERSION_3 2 +/* Called by spl.c */ int ps7_init (void );int ps7_post_config (void );
@@ -37,4 +41,6 @@ int ps7_post_config(void);/* Defined in ps7_init_common.c */ int ps7_config (unsigned long *ps7_config_init); +unsigned long ps7GetSiliconVersion (void ); +#endif /* _ASM_ARCH_PS7_INIT_GPL_H */
arch/arm/mach-zynq/ps7_spl_init.c +6 -0
@@ -7,6 +7,7 @@#include <asm/io.h> #include <asm/spl.h> +#include <asm/arch/sys_proto.h> #include <asm/arch/ps7_init_gpl.h> __weak int ps7_init (void )
@@ -134,3 +135,8 @@ int __weak ps7_config(unsigned long *ps7_config_init) ptr += numargs; } } + +unsigned long __weak __maybe_unused ps7GetSiliconVersion (void ) +{ +return zynq_get_silicon_version (); +}
Signature · 1 line
1.9.1
PATCH 8/9 arm: zynq: Convert EMIT_WRITE to EMIT_MASKWRITE
In reply to Michal SimekIn case that board ps7_init* files contain EMIT_WRITE convert it to MASKWRITE because default format has to work only with last two bits.
---
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-zynq/include/mach/ps7_init_gpl.h +2 -0
@@ -22,6 +22,8 @@#define EMIT_MASKPOLL (addr, mask) OPCODE_MASKPOLL | addr, mask#define EMIT_MASKDELAY (addr, mask) OPCODE_MASKDELAY | addr, mask +#define EMIT_WRITE (addr, val) EMIT_MASKWRITE(addr, 0, val) +/* Returns codes of ps7_init* */ #define PS7_INIT_SUCCESS (0)#define PS7_INIT_CORRUPT (1)
Signature · 1 line
1.9.1
PATCH 9/9 arm: zynq: Convert all board to use arch ps7_init code
In reply to Michal SimekUse generic implementation. It will also reduce config data size for converted boards.
---
.../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c | 120 +------------- .../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h | 80 --------- board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c | 173 +------------------- board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h | 116 -------------- board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c | 177 +------------------- board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h | 116 -------------- board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c | 173 +------------------- board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h | 116 -------------- board/xilinx/zynq/zynq-zed/ps7_init_gpl.c | 173 +------------------- board/xilinx/zynq/zynq-zed/ps7_init_gpl.h | 116 -------------- board/xilinx/zynq/zynq-zybo/ps7_init_gpl.c | 178 +-------------------- board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h | 97 ----------- 12 files changed, 6 insertions(+), 1629 deletions(-) delete mode 100644 board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h delete mode 100644 board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h delete mode 100644 board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h delete mode 100644 board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h delete mode 100644 board/xilinx/zynq/zynq-zed/ps7_init_gpl.h delete mode 100644 board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h
board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c +1 -119
@@ -5,8 +5,7 @@* SPDX-License-Identifier: GPL-2.0+ *****************************************************************************/ -#include "ps7_init_gpl.h" -#include "asm/io.h" +#include <asm/arch/ps7_init_gpl.h> unsigned long ps7_pll_init_data_3_0[] = {EMIT_WRITE (0XF8000008 ,0x0000DF0DU ),
@@ -255,92 +254,11 @@ unsigned long ps7_post_config_3_0[] = { EMIT_EXIT(), }; -unsigned long ps7_reset_apu_3_0[] = {EMIT_MASKWRITE (0xF8000244 ,0x00000022U ,0x00000022U ),EMIT_EXIT (), }; -#define PS7_MASK_POLL_TIME 100000000 - -static inline void iowrite (unsigned long val,unsigned long addr) -{ -__raw_writel (val, addr); -} - -static inline unsigned long ioread (unsigned long addr) -{ -return __raw_readl (addr); -} - -int ps7_config (unsigned long *ps7_config_init) -{ -unsigned long *ptr = ps7_config_init; - -unsigned long opcode;/* current instruction .. */ -unsigned long args[16 ];/* no opcode has so many args ... */ -int numargs;/* number of arguments of this instruction */ -int j;/* general purpose index */ - -unsigned long addr; -unsigned long val, mask; - -int finish =-1 ;/* loop while this is negative ! */ -int i =0 ;/* Timeout variable */ - -while (finish <0 ) { - numargs = ptr[0 ] &0xF ; - opcode = ptr[0 ] >>4 ; - -for (j =0 ; j < numargs; j++) - args[j] = ptr[j +1 ]; - ptr += numargs +1 ; - -switch (opcode) { -case OPCODE_EXIT : - finish =PS7_INIT_SUCCESS ; -break ; - -case OPCODE_WRITE : - addr = args[0 ]; - val = args[1 ]; -iowrite (val, addr); -break ; - -case OPCODE_MASKWRITE : - addr = args[0 ]; - mask = args[1 ]; - val = args[2 ]; -iowrite ((val & mask) | (ioread (addr) & ~mask) , addr); -break ; - -case OPCODE_MASKPOLL : - addr = args[0 ]; - mask = args[1 ]; - i =0 ; -while (!(ioread (addr) & mask)) { -if (i ==PS7_MASK_POLL_TIME ) { - finish =PS7_INIT_TIMEOUT ; -break ; - } - i++; - } -break ; -case OPCODE_MASKDELAY : - addr = args[0 ]; - mask = args[1 ]; -int delay =get_number_of_cycles_for_delay (mask); -perf_reset_and_start_timer (); -while (ioread (addr) < delay) - ; -break ; -default : - finish =PS7_INIT_CORRUPT ; -break ; - } - } -return finish; -}int ps7_post_config (void ) {
@@ -377,39 +295,3 @@ int ps7_init(void)return PS7_INIT_SUCCESS ; } -/* For delay calculation using global timer */ - -/* start timer */ -void perf_start_clock (void ) -{ -iowrite ((1 <<0 ) |/* Timer Enable */ - (1 <<3 ) |/* Auto-increment */ - (0 <<8 ),/* Pre-scale */ -SCU_GLOBAL_TIMER_CONTROL ); -} - -/* stop timer and reset timer count regs */ -void perf_reset_clock (void ) -{ -perf_disable_clock (); -iowrite (0 ,SCU_GLOBAL_TIMER_COUNT_L32 ); -iowrite (0 ,SCU_GLOBAL_TIMER_COUNT_U32 ); -} - -/* Compute mask for given delay in miliseconds*/ -int get_number_of_cycles_for_delay (unsigned int delay) -{ -return APU_FREQ * delay / (2 *1000 ); -} - -/* stop timer */ -void perf_disable_clock (void ) -{ -iowrite (0 ,SCU_GLOBAL_TIMER_CONTROL ); -} - -void perf_reset_and_start_timer (void ) -{ -perf_reset_clock (); -perf_start_clock (); -}
board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h deleted +0 -80
80 lines not on this page · raw message
board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c +1 -172
188 lines not on this page · raw message
board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h deleted +0 -116
116 lines not on this page · raw message
board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c +1 -176
192 lines not on this page · raw message
board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h deleted +0 -116
116 lines not on this page · raw message
board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c +1 -172
188 lines not on this page · raw message
board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h deleted +0 -116
116 lines not on this page · raw message
board/xilinx/zynq/zynq-zed/ps7_init_gpl.c +1 -172
188 lines not on this page · raw message
board/xilinx/zynq/zynq-zed/ps7_init_gpl.h deleted +0 -116
116 lines not on this page · raw message
board/xilinx/zynq/zynq-zybo/ps7_init_gpl.c +1 -177
193 lines not on this page · raw message
board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h deleted +0 -97
97 lines not on this page · raw message
Signature · 1 line
1.9.1
cover arm: zynq: ps7* consolidation
In reply to Michal SimekQuoted 7 lines · Michal Simek
Hi,
this series is trying to cleanup ps7_init* file that we don't need to have the same copy of the same functions in different locations. This work is done based on solution from Topic.nl for miami boards where format was changed a little bit to save one word in config data segment.
Nice to see one's work appreciated. A bit of comment below.
Quoted 9 lines
At the same time older method of simply copying files to particular folder is still working.
Please test this in your board to make sure I didn't break anything. I have tested it on zybo/zc702/zc706.Thanks,
Michal
Quoted 9 lines
Michal Simek (9):
arm: zynq: Add missingps7_post_configdeclaration
arm: zynq: Enable debug uart on zc706
arm: zynq: Removeps7_debugcode
arm: zynq: Move ps7_* to separate file
arm: zynq: Get rid ofps7_reset_apu()for syzygy board
arm: zynq: Move common ps7_init* initialization to arch code
arm: zynq: Addps7GetSiliconVersion()tops7_spl_init
arm: zynq: ConvertEMIT_WRITEtoEMIT_MASKWRITE
There's actually room for one more opcode, so I would recommend implementing MASK_WRITE instead of forcing everything to be done in read-modify-write mode.
#define OPCODE_MASKWRITE 3U
#define EMIT_MASKWRITE(addr, val) OPCODE_MASKWRITE | addr, val
This "constant table" approach could also be implemented for the zynqmp platforms, cutting down the size of the SPL considerably.
(Only thing remaining is to have Vivado output these files properly...)
Quoted 25 lines
arm: zynq: Convert all board to use arch
ps7_initcodearch/arm/mach-zynq/Makefile | 2 +- .../arm/mach-zynq/include/mach}/ps7_init_gpl.h | 14 + arch/arm/mach-zynq/include/mach/sys_proto.h | 3 - .../arm/mach-zynq/ps7_spl_init.c | 31 ++- arch/arm/mach-zynq/spl.c | 18 +- .../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c | 138 +--------- .../opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.h | 81 ------ board/topic/zynq/Makefile | 2 +- board/topic/zynq/zynq-topic-miami/ps7_init_gpl.c | 2 +- .../topic/zynq/zynq-topic-miamilite/ps7_init_gpl.c | 2 +- .../topic/zynq/zynq-topic-miamiplus/ps7_init_gpl.c | 2 +- board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c | 285 +------------------- board/xilinx/zynq/zynq-microzed/ps7_init_gpl.h | 117 --------- board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c | 289 +------------------- board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h | 117 --------- board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c | 285 +------------------- board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h | 117 --------- board/xilinx/zynq/zynq-zed/ps7_init_gpl.c | 285 +------------------- board/xilinx/zynq/zynq-zed/ps7_init_gpl.h | 117 --------- board/xilinx/zynq/zynq-zybo/ps7_init_gpl.c | 292 +-------------------- board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h | 98 ------- configs/zynq_zc706_defconfig | 5 + 22 files changed, 60 insertions(+), 2242 deletions(-)
Quoted 9 lines
rename {board/topic/zynq =>
arch/arm/mach-zynq/include/mach}/ps7_init_gpl.h(75%) renameboard/topic/zynq/ps7_init_common.c=>arch/arm/mach-zynq/ps7_spl_init.c(78%) delete mode 100644board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.hdelete mode 100644board/xilinx/zynq/zynq-microzed/ps7_init_gpl.hdelete mode 100644board/xilinx/zynq/zynq-zc702/ps7_init_gpl.h
delete mode 100644board/xilinx/zynq/zynq-zc706/ps7_init_gpl.h
delete mode 100644board/xilinx/zynq/zynq-zed/ps7_init_gpl.h
delete mode 100644board/xilinx/zynq/zynq-zybo/ps7_init_gpl.h
Kind regards,
Mike Looijmans
System Expert
TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans at topicproducts.com
Website: www.topicproducts.com
Please consider the environment before printing this e-mail
cover arm: zynq: ps7* consolidation
Quoted 30 lines · Mike Looijmans
Quoted 7 lines · Michal Simek
Hi,
this series is trying to cleanup ps7_init* file that we don't need to have the same copy of the same functions in different locations. This work is done based on solution from Topic.nl for miami boards where format was changed a little bit to save one word in config data segment.
Nice to see one's work appreciated. A bit of comment below.
Quoted 9 lines
At the same time older method of simply copying files to particular folder is still working.
Please test this in your board to make sure I didn't break anything. I have tested it on zybo/zc702/zc706.Thanks,
MichalQuoted 9 lines
Michal Simek (9):
arm: zynq: Add missingps7_post_configdeclaration
arm: zynq: Enable debug uart on zc706
arm: zynq: Removeps7_debugcode
arm: zynq: Move ps7_* to separate file
arm: zynq: Get rid ofps7_reset_apu()for syzygy board
arm: zynq: Move common ps7_init* initialization to arch code
arm: zynq: Addps7GetSiliconVersion()tops7_spl_init
arm: zynq: ConvertEMIT_WRITEtoEMIT_MASKWRITE
Quoted 6 lines
There's actually room for one more opcode, so I would recommend implementing
MASK_WRITEinstead of forcing everything to be done in read-modify-write mode.#define OPCODE_MASKWRITE 3U
#defineEMIT_MASKWRITE(addr, val)OPCODE_MASKWRITE| addr, val
Ah right - it can be done like that. Not an issue.
Quoted 3 lines
This "constant table" approach could also be implemented for the zynqmp platforms, cutting down the size of the SPL considerably.
Probably.
Quoted 2 lines
(Only thing remaining is to have Vivado output these files properly...)
Which is the biggest problem. I don't think this will happen.
Thanks,
Michal
cover arm: zynq: ps7* consolidation
Hi Michal, Mike,
Quoted 9 lines · Michal Simek
Quoted 8 lines · Mike Looijmans
Quoted 7 lines · Michal Simek
Hi,
this series is trying to cleanup ps7_init* file that we don't need to have the same copy of the same functions in different locations. This work is done based on solution from Topic.nl for miami boards where format was changed a little bit to save one word in config data segment.
[snip]
Quoted 4 lines
Quoted 2 lines
This "constant table" approach could also be implemented for the zynqmp platforms, cutting down the size of the SPL considerably.
Probably.
Adding onto the Vivado generation wish list, it would be nice to eliminate the
FPGA versions you know you don't have. We have a v3 FPGA so the v1 and v2 tables are wasted space.
We've created a patch that we apply to the ps7_init_gpl.c file that #ifdefs the unused sections out.
(sorry for the crappy paste, I'm using gmail for this post):
Strip out the tables based on the version:
-----------------------------------------------------
ps7_init_gpl.c 2017-10-27 14:42:48.469914486 -0400 renamed from ps7_init_gpl.c 2017-10-27 11:30:48.000000000 -0400 +8 -0
@@ -25,8 +25,11 @@ * *****************************************************************************/ +#define VERSION 3 /* Target a specific version */ + #include "ps7_init_gpl.h" +#if !defined(VERSION) || (VERSION == 3) unsigned long ps7_pll_init_data_3_0[] = { // START: top // .. START: SLCR SETTINGS
@@ -4242,7 +4245,9 @@ // }; +#endif +#if !defined(VERSION) || (VERSION == 2) unsigned long ps7_pll_init_data_2_0[] = { // START: top // .. START: SLCR SETTINGS
@@ -8617,7 +8622,9 @@ // }; +#endif +#if !defined(VERSION) || (VERSION == 1) unsigned long ps7_pll_init_data_1_0[] = { // START: top // .. START: SLCR SETTINGS
@@ -12925,6 +12932,7 @@ // }; +#endif #include "xil_io.h"
-----------------------------------------------------
Now we can remove the code that uses the version information:
-----------------------------------------------------
ps7_init_gpl.c 2017-10-27 14:44:55.142353664 -0400 renamed from ps7_init_gpl.c 2017-10-27 11:30:48.000000000 -0400 +2 -0
@@ -12961,6 +12961,7 @@ return err_msg; } +#ifndef VERSION unsigned long ps7GetSiliconVersion () { // Read PS version from MCTRL register [31:28]
@@ -12969,6 +12970,7 @@ unsigned long ps_version = (*addr & mask) >> 28; return ps_version; } +#endif void mask_write (unsigned long add , unsigned long mask, unsigned long
val ) {
volatile unsigned long *addr = (volatile unsigned long*) add;@@ -13069,8 +13069,9 @@
unsigned long *ps7_peripherals_init_data = ps7_peripherals_init_data_3_0;
int
-ps7_post_config()
+ps7_post_config()
{
+#ifndef VERSION
// Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret = -1;
@@ -13085,11 +13086,19 @@
if (ret != PS7_INIT_SUCCESS) return ret;
}
return PS7_INIT_SUCCESS;
+#elif(VERSION == 1)
+ return ps7_config (ps7_post_config_1_0);
+#elif(VERSION == 2)
+ return ps7_config (ps7_post_config_2_0);
+#elif(VERSION == 3)
+ return ps7_config (ps7_post_config_3_0);
+#endif
}
int
-ps7_debug()
+ps7_debug()
{
+#ifndef VERSION
// Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret = -1;
@@ -13104,17 +13113,27 @@
if (ret != PS7_INIT_SUCCESS) return ret;
}
return PS7_INIT_SUCCESS;
+#elif (VERSION == 1)
+ return ps7_config (ps7_debug_1_0);
+#elif (VERSION == 2)
+ return ps7_config (ps7_debug_2_0);
+#elif (VERSION == 3)
+ return ps7_config (ps7_debug_3_0);
+#endif
}
int
-ps7_init()
+ps7_init()
{
+#if !defined(VERSION)
// Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion ();
+#endif
int ret;
//int pcw_ver = 0;
+#if !defined(VERSION)
if (si_ver == PCW_SILICON_VERSION_1) {
ps7_mio_init_data = ps7_mio_init_data_1_0;
ps7_pll_init_data = ps7_pll_init_data_1_0;
@@ -13139,6 +13158,28 @@
ps7_peripherals_init_data = ps7_peripherals_init_data_3_0;
//pcw_ver = 3;
}
+#elif (VERSION == 1)
+ ps7_mio_init_data = ps7_mio_init_data_1_0;
+ ps7_pll_init_data = ps7_pll_init_data_1_0;
+ ps7_clock_init_data = ps7_clock_init_data_1_0;
+ ps7_ddr_init_data = ps7_ddr_init_data_1_0;
+ ps7_peripherals_init_data = ps7_peripherals_init_data_1_0;
+ //pcw_ver = 1;
+#elif (VERSION == 2)
+ ps7_mio_init_data = ps7_mio_init_data_2_0;
+ ps7_pll_init_data = ps7_pll_init_data_2_0;
+ ps7_clock_init_data = ps7_clock_init_data_2_0;
+ ps7_ddr_init_data = ps7_ddr_init_data_2_0;
+ ps7_peripherals_init_data = ps7_peripherals_init_data_2_0;
+ //pcw_ver = 2;
+#elif (VERSION == 3)
+ ps7_mio_init_data = ps7_mio_init_data_3_0;
+ ps7_pll_init_data = ps7_pll_init_data_3_0;
+ ps7_clock_init_data = ps7_clock_init_data_3_0;
+ ps7_ddr_init_data = ps7_ddr_init_data_3_0;
+ ps7_peripherals_init_data = ps7_peripherals_init_data_3_0;
+ //pcw_ver = 3;+#endif
// MIO init
ret = ps7_config (ps7_mio_init_data);
@@ -13201,7 +13242,7 @@
*(volatile unsigned int*)SCU_GLOBAL_TIMER_CONTROL = 0;
}
-void perf_reset_and_start_timer()
+void perf_reset_and_start_timer()
{
perf_reset_clock();
perf_start_clock();-----------------------------------------------------
Oh, yeah, and add "void" to the functions that don't take arguments to keep lint from complaining,
-----------------------------------------------------
ps7_init_gpl.c 2017-10-27 16:02:00.843517518 -0400 renamed from ps7_init_gpl.c 2017-10-27 16:00:09.963459068 -0400 +5 -5
@@ -12963,7 +12963,7 @@ #ifndef VERSION unsigned long -ps7GetSiliconVersion () { +ps7GetSiliconVersion (void) { // Read PS version from MCTRL register [31:28] unsigned long mask = 0xF0000000; unsigned long *addr = (unsigned long*) 0XF8007080;
@@ -13085,7 +13085,7 @@ unsigned long *ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; int -ps7_post_config() +ps7_post_config(void) { #ifndef VERSION // Get the PS_VERSION on run time
@@ -13112,7 +13112,7 @@ } int -ps7_debug() +ps7_debug(void) { #ifndef VERSION // Get the PS_VERSION on run time
@@ -13140,7 +13140,7 @@ int -ps7_init() +ps7_init(void) { #if !defined(VERSION) // Get the PS_VERSION on run time
@@ -13258,7 +13258,7 @@ *(volatile unsigned int*)SCU_GLOBAL_TIMER_CONTROL = 0; } -void perf_reset_and_start_timer() +void perf_reset_and_start_timer(void) { perf_reset_clock(); perf_start_clock();
ps7_init_gpl.h 2017-10-27 16:01:22.547494873 -0400 renamed from ps7_init_gpl.h 2017-10-27 16:00:11.691459805 -0400 +4 -4
@@ -121,15 +121,15 @@ #define SCU_GLOBAL_TIMER_AUTO_INC 0xF8F00218 int ps7_config( unsigned long*); -int ps7_init(); -int ps7_post_config(); -int ps7_debug(); +int ps7_init(void); +int ps7_post_config(void); +int ps7_debug(void); char* getPS7MessageInfo(unsigned key); void perf_start_clock(void); void perf_disable_clock(void); void perf_reset_clock(void); -void perf_reset_and_start_timer(); +void perf_reset_and_start_timer(void); int get_number_of_cycles_for_delay(unsigned int delay); #ifdef __cplusplus }
Quoted 3 lines
Quoted 1 line
(Only thing remaining is to have Vivado output these files properly...)
Which is the biggest problem. I don't think this will happen.
:-(
Post-processing the output files with patch has been working for us. We are doing it as a manual step, but we don't have to do it often so it isn't too bad.
Quoted 2 lines
Thanks,
Michal
Thanks,
gvb
cover arm: zynq: ps7* consolidation
Hi,
Quoted 19 lines · Gerald Van Baren
Hi Michal, Mike,
Quoted 9 lines · Michal Simek
Quoted 8 lines · Mike Looijmans
Quoted 7 lines · Michal Simek
Hi,
this series is trying to cleanup ps7_init* file that we don't need to have the same copy of the same functions in different locations. This work is done based on solution from Topic.nl for miami boards where format was changed a little bit to save one word in config data segment.
[snip]
Quoted 3 lines
Quoted 2 lines
This "constant table" approach could also be implemented for the zynqmp platforms, cutting down the size of the SPL considerably.
Quoted 6 lines
Quoted 1 line
Probably.
Adding onto the Vivado generation wish list, it would be nice to eliminate the
FPGA versions you know you don't have. We have a v3 FPGA so the v1 and v2 tables are wasted space.
As you see we have done this for topic and syzygy board that code in u-boot is just removed. For zc702/zc706 and similar which are xilinx boards you can find different silicons on this board. I think I have v1 and v2 here.
For zynqmp case zcu102 can contain all silicon versions too.
Quoted 5 lines
We've created a patch that we apply to the
ps7_init_gpl.cfile that #ifdefs the unused sections out.(sorry for the crappy paste, I'm using gmail for this post):
no. Does that mean that you are also using SPL?
Quoted 231 lines
Strip out the tables based on the version:
-----------------------------------------------------ps7_init_gpl.c 2017-10-27 14:42:48.469914486 -0400 renamed from ps7_init_gpl.c 2017-10-27 11:30:48.000000000 -0400 +8
-1@@ -25,8 +25,11 @@ * *****************************************************************************/ +#define VERSION 3 /* Target a specific version */ + #include "ps7_init_gpl.h" +#if !defined(VERSION) || (VERSION == 3) unsigned long ps7_pll_init_data_3_0[] = { // START: top // .. START: SLCR SETTINGS@@ -4242,7 +4245,9 @@ // }; +#endif +#if !defined(VERSION) || (VERSION == 2) unsigned long ps7_pll_init_data_2_0[] = { // START: top // .. START: SLCR SETTINGS@@ -8617,7 +8622,9 @@ // }; +#endif +#if !defined(VERSION) || (VERSION == 1) unsigned long ps7_pll_init_data_1_0[] = { // START: top // .. START: SLCR SETTINGS@@ -12925,6 +12932,7 @@ // }; +#endif #include "xil_io.h" -----------------------------------------------------Now we can remove the code that uses the version information:
-----------------------------------------------------ps7_init_gpl.c 2017-10-27 14:44:55.142353664 -0400 renamed from ps7_init_gpl.c 2017-10-27 11:30:48.000000000 -0400 +2
-0@@ -12961,6 +12961,7 @@ return err_msg; } +#ifndef VERSION unsigned long ps7GetSiliconVersion () { // Read PS version from MCTRL register [31:28]@@ -12969,6 +12970,7 @@ unsigned long ps_version = (*addr & mask) >> 28; return ps_version; } +#endif void mask_write (unsigned long add , unsigned long mask, unsigned long val ) {volatile unsigned long *addr = (volatile unsigned long*) add;ps7_init_gpl.c 2017-10-27 14:44:55.142353664 -0400 renamed from ps7_init_gpl.c 2017-10-27 11:30:48.000000000 -0400 +45
-5@@ -13069,8 +13069,9 @@ unsigned long *ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; int -ps7_post_config() +ps7_post_config() { +#ifndef VERSION // Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret = -1;@@ -13085,11 +13086,19 @@ if (ret != PS7_INIT_SUCCESS) return ret; } return PS7_INIT_SUCCESS; +#elif(VERSION == 1) + return ps7_config (ps7_post_config_1_0); +#elif(VERSION == 2) + return ps7_config (ps7_post_config_2_0); +#elif(VERSION == 3) + return ps7_config (ps7_post_config_3_0); +#endif } int -ps7_debug() +ps7_debug() { +#ifndef VERSION // Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret = -1;@@ -13104,17 +13113,27 @@ if (ret != PS7_INIT_SUCCESS) return ret; } return PS7_INIT_SUCCESS; +#elif (VERSION == 1) + return ps7_config (ps7_debug_1_0); +#elif (VERSION == 2) + return ps7_config (ps7_debug_2_0); +#elif (VERSION == 3) + return ps7_config (ps7_debug_3_0); +#endif } int -ps7_init() +ps7_init() { +#if !defined(VERSION) // Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); +#endif int ret; //int pcw_ver = 0; +#if !defined(VERSION) if (si_ver == PCW_SILICON_VERSION_1) { ps7_mio_init_data = ps7_mio_init_data_1_0; ps7_pll_init_data = ps7_pll_init_data_1_0;@@ -13139,6 +13158,28 @@ ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; //pcw_ver = 3; } +#elif (VERSION == 1) + ps7_mio_init_data = ps7_mio_init_data_1_0; + ps7_pll_init_data = ps7_pll_init_data_1_0; + ps7_clock_init_data = ps7_clock_init_data_1_0; + ps7_ddr_init_data = ps7_ddr_init_data_1_0; + ps7_peripherals_init_data = ps7_peripherals_init_data_1_0; + //pcw_ver = 1; +#elif (VERSION == 2) + ps7_mio_init_data = ps7_mio_init_data_2_0; + ps7_pll_init_data = ps7_pll_init_data_2_0; + ps7_clock_init_data = ps7_clock_init_data_2_0; + ps7_ddr_init_data = ps7_ddr_init_data_2_0; + ps7_peripherals_init_data = ps7_peripherals_init_data_2_0; + //pcw_ver = 2; +#elif (VERSION == 3) + ps7_mio_init_data = ps7_mio_init_data_3_0; + ps7_pll_init_data = ps7_pll_init_data_3_0; + ps7_clock_init_data = ps7_clock_init_data_3_0; + ps7_ddr_init_data = ps7_ddr_init_data_3_0; + ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; + //pcw_ver = 3; +#endif // MIO init ret = ps7_config (ps7_mio_init_data);@@ -13201,7 +13242,7 @@ *(volatile unsigned int*)SCU_GLOBAL_TIMER_CONTROL = 0; } -void perf_reset_and_start_timer() +void perf_reset_and_start_timer() { perf_reset_clock(); perf_start_clock(); -----------------------------------------------------Oh, yeah, and add "void" to the functions that don't take arguments to keep lint from complaining,
-----------------------------------------------------ps7_init_gpl.c 2017-10-27 16:02:00.843517518 -0400 renamed from ps7_init_gpl.c 2017-10-27 16:00:09.963459068 -0400 +5
-5@@ -12963,7 +12963,7 @@ #ifndef VERSION unsigned long -ps7GetSiliconVersion () { +ps7GetSiliconVersion (void) { // Read PS version from MCTRL register [31:28] unsigned long mask = 0xF0000000; unsigned long *addr = (unsigned long*) 0XF8007080;@@ -13085,7 +13085,7 @@ unsigned long *ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; int -ps7_post_config() +ps7_post_config(void) { #ifndef VERSION // Get the PS_VERSION on run time@@ -13112,7 +13112,7 @@ } int -ps7_debug() +ps7_debug(void) { #ifndef VERSION // Get the PS_VERSION on run time@@ -13140,7 +13140,7 @@ int -ps7_init() +ps7_init(void) { #if !defined(VERSION) // Get the PS_VERSION on run time@@ -13258,7 +13258,7 @@ *(volatile unsigned int*)SCU_GLOBAL_TIMER_CONTROL = 0; } -void perf_reset_and_start_timer() +void perf_reset_and_start_timer(void) { perf_reset_clock(); perf_start_clock();ps7_init_gpl.h 2017-10-27 16:01:22.547494873 -0400 renamed from ps7_init_gpl.h 2017-10-27 16:00:11.691459805 -0400 +3
-3@@ -121,15 +121,15 @@ #define SCU_GLOBAL_TIMER_AUTO_INC 0xF8F00218 int ps7_config( unsigned long*); -int ps7_init(); -int ps7_post_config(); -int ps7_debug(); +int ps7_init(void); +int ps7_post_config(void); +int ps7_debug(void);
ps7_init_gpl.h 2017-10-27 16:01:22.547494873 -0400 line 135
Quoted 10 lines
ps7_init_gpl.h 2017-10-27 16:01:22.547494873 -0400 renamed from ps7_init_gpl.h 2017-10-27 16:00:11.691459805 -0400 +1
-1char* getPS7MessageInfo(unsigned key); void perf_start_clock(void); void perf_disable_clock(void); void perf_reset_clock(void); -void perf_reset_and_start_timer(); +void perf_reset_and_start_timer(void); int get_number_of_cycles_for_delay(unsigned int delay); #ifdef __cplusplus }
This patchset should eliminate the whole ps7_init_gpl.h file. And for .c file we should probably document what to do.
Remove all comments, remove all functions which are in common location, remove silicon detection code if you have only one version, remove ps7_debug function which is not called.
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
(Only thing remaining is to have Vivado output these files properly...)
Which is the biggest problem. I don't think this will happen.
:-(
Post-processing the output files with patch has been working for us. We are doing it as a manual step, but we don't have to do it often so it isn't too bad.
In general this processing is just reducing size of SPL which shouldn't be a big problem on zynq. It means you will save some space but if you don't need it then why to do it.
I have tested origin testcases that you simply copy ps7_init file to u-boot and build it and there is not an issue and that steps above should be really just for boards which you want to support upstream.
Thanks,
Michal