mbox series

[U-Boot,0/9] arm: zynq: ps7* consolidation

Message ID cover.1510311500.git.michal.simek@xilinx.com
Headers show
Series arm: zynq: ps7* consolidation | expand

Message

Michal Simek Nov. 10, 2017, 10:58 a.m. UTC
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.h

Comments

Mike Looijmans Nov. 13, 2017, 2:35 p.m. UTC | #1
On 10-11-17 11:58, Michal Simek wrote:
> 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.

> 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

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...)


>    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.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@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail
Michal Simek Nov. 13, 2017, 2:48 p.m. UTC | #2
On 13.11.2017 15:35, Mike Looijmans wrote:
> On 10-11-17 11:58, Michal Simek wrote:
>> 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.
> 
>> 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
> 
> 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

Ah right - it can be done like that. Not an issue.


> 
> This "constant table" approach could also be implemented for the zynqmp
> platforms, cutting down the size of the SPL considerably.

Probably.

> 
> (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
Jerry Van Baren Nov. 13, 2017, 3:27 p.m. UTC | #3
Hi Michal, Mike,

On Mon, Nov 13, 2017 at 9:48 AM, Michal Simek <michal.simek@xilinx.com>
wrote:
> On 13.11.2017 15:35, Mike Looijmans wrote:
>> On 10-11-17 11:58, Michal Simek wrote:
>>> 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]

>> 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 11:30:48.000000000 -0400
+++ ps7_init_gpl.c      2017-10-27 14:42:48.469914486 -0400
@@ -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 11:30:48.000000000 -0400
+++ ps7_init_gpl.c      2017-10-27 14:44:55.142353664 -0400
@@ -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:00:09.963459068 -0400
+++ ps7_init_gpl.c      2017-10-27 16:02:00.843517518 -0400
@@ -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:00:11.691459805 -0400
+++ ps7_init_gpl.h      2017-10-27 16:01:22.547494873 -0400
@@ -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
 }


>> (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.

> Thanks,
> Michal

Thanks,
gvb
Michal Simek Nov. 14, 2017, 7:11 a.m. UTC | #4
Hi,

On 13.11.2017 16:27, Gerald Van Baren wrote:
> Hi Michal, Mike,
> 
> On Mon, Nov 13, 2017 at 9:48 AM, Michal Simek <michal.simek@xilinx.com>
> wrote:
>> On 13.11.2017 15:35, Mike Looijmans wrote:
>>> On 10-11-17 11:58, Michal Simek wrote:
>>>> 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]
> 
>>> 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.

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.

> 
> 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):

no. Does that mean that you are also using SPL?

> 
> Strip out the tables based on the version:
> -----------------------------------------------------
> --- ps7_init_gpl.c      2017-10-27 11:30:48.000000000 -0400
> +++ ps7_init_gpl.c      2017-10-27 14:42:48.469914486 -0400
> @@ -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 11:30:48.000000000 -0400
> +++ ps7_init_gpl.c      2017-10-27 14:44:55.142353664 -0400
> @@ -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:00:09.963459068 -0400
> +++ ps7_init_gpl.c      2017-10-27 16:02:00.843517518 -0400
> @@ -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:00:11.691459805 -0400
> +++ ps7_init_gpl.h      2017-10-27 16:01:22.547494873 -0400
> @@ -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
>  }

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.

> 
> 
>>> (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