xilinx: zynq: add FDT_FIXUP_PARTITIONS support
PATCH 1/1 xilinx: zynq: add FDT_FIXUP_PARTITIONS support
There are situations where we may want to let U-Boot modify the FDT nand partitions for the kernel, such as when supporting multiple sizes of NAND chips.
Lets also refactor xilinx common board support to have a ft_common_board_setup which gets called by the ft_board_setup for each specific board so that we can add non-common functionality to each ft_board_setup like FDT_FIXUP_PARTITIONS as needed.
This pattern is modeled after the one used by tdx-common.c.
--- board/xilinx/common/board.c | 2 +- board/xilinx/common/board.h | 2 ++ board/xilinx/mbv/board.c | 9 +++++++++ board/xilinx/versal-net/board.c | 7 +++++++ board/xilinx/versal/board.c | 7 +++++++ board/xilinx/zynq/board.c | 17 +++++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 7 +++++++ board/xilinx/zynqmp_r5/board.c | 8 ++++++++ 8 files changed, 58 insertions(+), 1 deletion(-)
board/xilinx/common/board.c +1 -1
@@ -686,7 +686,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)#ifdef CONFIG_OF_BOARD_SETUP #define MAX_RAND_SIZE 8 -int ft_board_setup (void *blob,struct bd_info *bd) +int ft_common_board_setup (void *blob,struct bd_info *bd) {size_t n =MAX_RAND_SIZE ;struct udevice *dev;
board/xilinx/common/board.h +2 -0
@@ -18,4 +18,6 @@ bool board_detection(void);char *soc_name_decode (void );bool soc_detection (void ); + +int ft_common_board_setup (void *blob,struct bd_info *bd);#endif /* BOARD_XILINX_COMMON_BOARD_H */
board/xilinx/mbv/board.c +9 -0
@@ -5,7 +5,16 @@* Michal Simek <[email protected]> */ +#include "../common/board.h" +int board_init (void ) {return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif
board/xilinx/versal-net/board.c +7 -0
@@ -371,3 +371,10 @@ int dram_init(void)void reset_cpu (void ) { } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif
board/xilinx/versal/board.c +7 -0
@@ -320,3 +320,10 @@ enum env_location env_get_location(enum env_operation op, int prio)return ENVL_NOWHERE ; } } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif
board/xilinx/zynq/board.c +17 -0
@@ -13,10 +13,12 @@#include <env.h> #include <env_internal.h> #include <fdtdec.h> +#include <fdt_support.h> #include <fpga.h> #include <malloc.h> #include <memalign.h> #include <mmc.h> +#include <mtd_node.h> #include <watchdog.h> #include <wdt.h> #include <zynqpl.h>
@@ -201,3 +203,18 @@ void set_dfu_alt_info(char *interface, char *devstr) puts("DFU alt info setting: done\n"); }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +#ifdef CONFIG_FDT_FIXUP_PARTITIONS +static const struct node_info nodes[] = { + {"arm,pl353-nand-r2p1" ,MTD_DEV_TYPE_NAND , }, + }; + +fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes)); +#endif + +return ft_common_board_setup (blob, bd); +} +#endif
board/xilinx/zynqmp/zynqmp.c +7 -0
@@ -700,3 +700,10 @@ unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash) return offset; }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif
board/xilinx/zynqmp_r5/board.c +8 -0
@@ -6,6 +6,7 @@#include <common.h> #include <fdtdec.h> #include <init.h> +#include "../common/board.h" int board_init (void ) {
@@ -24,3 +25,10 @@ int dram_init(void)return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif
Signature · 1 line
2.34.1
Michal Simek
maintainerQuoted 1 line · James Hilliard
There are situations where we may want to let U-Boot modify the FDT
please use imperative mood.
Quoted 57 lines
nand partitions for the kernel, such as when supporting multiple sizes of NAND chips.
Lets also refactor xilinx common board support to have a
ft_common_board_setupwhich gets called by theft_board_setupfor each specific board so that we can add non-common functionality to eachft_board_setuplikeFDT_FIXUP_PARTITIONSas needed.This pattern is modeled after the one used by
tdx-common.c.Signed-off-by James Hilliard <[email protected]>--- board/xilinx/common/board.c | 2 +- board/xilinx/common/board.h | 2 ++ board/xilinx/mbv/board.c | 9 +++++++++ board/xilinx/versal-net/board.c | 7 +++++++ board/xilinx/versal/board.c | 7 +++++++ board/xilinx/zynq/board.c | 17 +++++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 7 +++++++ board/xilinx/zynqmp_r5/board.c | 8 ++++++++ 8 files changed, 58 insertions(+), 1 deletion(-)board/xilinx/common/board.c +1
-1@@ -686,7 +686,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)#ifdef CONFIG_OF_BOARD_SETUP #define MAX_RAND_SIZE 8 -int ft_board_setup (void *blob,struct bd_info *bd) +int ft_common_board_setup (void *blob,struct bd_info *bd) {size_t n =MAX_RAND_SIZE ;struct udevice *dev;board/xilinx/common/board.h +2
-0@@ -18,4 +18,6 @@ bool board_detection(void);char *soc_name_decode (void );bool soc_detection (void ); + +int ft_common_board_setup (void *blob,struct bd_info *bd);#endif /* BOARD_XILINX_COMMON_BOARD_H */ board/xilinx/mbv/board.c +2
-0@@ -5,7 +5,16 @@* Michal Simek <[email protected]> */ +#include "../common/board.h" +int board_init (void )
board/xilinx/mbv/board.c line 20
Quoted 10 lines
board/xilinx/mbv/board.c +7
-0{return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif
Any reason not to put directly to board/xilinx/common/board.c?
All xilinx boards are kept in sync from user perspective that's why generic pieces should be added to common location.
Quoted 48 lines
board/xilinx/versal-net/board.c +7
-0@@ -371,3 +371,10 @@ int dram_init(void)void reset_cpu (void ) { } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif board/xilinx/versal/board.c +7
-0@@ -320,3 +320,10 @@ enum env_location env_get_location(enum env_operation op, int prio)return ENVL_NOWHERE ; } } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif board/xilinx/zynq/board.c +2
-0@@ -13,10 +13,12 @@#include <env.h> #include <env_internal.h> #include <fdtdec.h> +#include <fdt_support.h> #include <fpga.h> #include <malloc.h> #include <memalign.h> #include <mmc.h> +#include <mtd_node.h> #include <watchdog.h> #include <wdt.h> #include <zynqpl.h>
board/xilinx/zynq/board.c void set_dfu_alt_info(char *interface, char *devstr) · line 212
Quoted 10 lines
board/xilinx/zynq/board.c +7
-0@@ -201,3 +203,18 @@ void set_dfu_alt_info(char *interface, char *devstr)puts ("DFU alt info setting: done\n" ); }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +#ifdef CONFIG_FDT_FIXUP_PARTITIONS +static const struct node_info nodes[] = { + { "arm,pl353-nand-r2p1", MTD_DEV_TYPE_NAND, },
Very likely also depends on CONFIG_NAND_ZYNQ. It means pretty much you can move this code directly to common/board.c because only Zynq uses this symbol.
Thanks,
Michal
Quoted 71 lines · Michal Simek
Quoted 1 line · James Hilliard
There are situations where we may want to let U-Boot modify the FDT
please use imperative mood.
Quoted 63 lines
nand partitions for the kernel, such as when supporting multiple sizes of NAND chips.
Lets also refactor xilinx common board support to have a
ft_common_board_setupwhich gets called by theft_board_setupfor each specific board so that we can add non-common functionality to eachft_board_setuplikeFDT_FIXUP_PARTITIONSas needed.This pattern is modeled after the one used by
tdx-common.c.Signed-off-by James Hilliard <[email protected]>--- board/xilinx/common/board.c | 2 +- board/xilinx/common/board.h | 2 ++ board/xilinx/mbv/board.c | 9 +++++++++ board/xilinx/versal-net/board.c | 7 +++++++ board/xilinx/versal/board.c | 7 +++++++ board/xilinx/zynq/board.c | 17 +++++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 7 +++++++ board/xilinx/zynqmp_r5/board.c | 8 ++++++++ 8 files changed, 58 insertions(+), 1 deletion(-)board/xilinx/common/board.c +1
-1@@ -686,7 +686,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)#ifdef CONFIG_OF_BOARD_SETUP #define MAX_RAND_SIZE 8 -int ft_board_setup (void *blob,struct bd_info *bd) +int ft_common_board_setup (void *blob,struct bd_info *bd) {size_t n =MAX_RAND_SIZE ;struct udevice *dev;board/xilinx/common/board.h +2
-0@@ -18,4 +18,6 @@ bool board_detection(void);char *soc_name_decode (void );bool soc_detection (void ); + +int ft_common_board_setup (void *blob,struct bd_info *bd);#endif /* BOARD_XILINX_COMMON_BOARD_H */ board/xilinx/mbv/board.c +5
-0@@ -5,7 +5,16 @@* Michal Simek <[email protected]> */ +#include "../common/board.h" +int board_init (void ) {return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd)
Quoted 8 lines
board/xilinx/mbv/board.c line 20
Quoted 4 lines
board/xilinx/mbv/board.c +4
-0+{ +return ft_common_board_setup (blob, bd); +} +#endif Any reason not to put directly to
board/xilinx/common/board.c? All xilinx boards are kept in sync from user perspective that's why generic pieces should be added to common location.
I assumed the device tree node "arm,pl353-nand-r2p1" was specific to boards using xilinx/zynq/board.c since it seemed only those were the only ones to use that node. Have any idea if that assumption is accurate?
Quoted 66 lines
Quoted 50 lines
board/xilinx/versal-net/board.c +7
-0@@ -371,3 +371,10 @@ int dram_init(void)void reset_cpu (void ) { } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif board/xilinx/versal/board.c +7
-0@@ -320,3 +320,10 @@ enum env_location env_get_location(enum env_operation op, int prio)return ENVL_NOWHERE ; } } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +return ft_common_board_setup (blob, bd); +} +#endif board/xilinx/zynq/board.c +2
-0@@ -13,10 +13,12 @@#include <env.h> #include <env_internal.h> #include <fdtdec.h> +#include <fdt_support.h> #include <fpga.h> #include <malloc.h> #include <memalign.h> #include <mmc.h> +#include <mtd_node.h> #include <watchdog.h> #include <wdt.h> #include <zynqpl.h> board/xilinx/zynq/board.c void set_dfu_alt_info(char *interface, char *devstr) · line 212
Quoted 10 lines
board/xilinx/zynq/board.c +7
-0@@ -201,3 +203,18 @@ void set_dfu_alt_info(char *interface, char *devstr)puts ("DFU alt info setting: done\n" ); }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd) +{ +#ifdef CONFIG_FDT_FIXUP_PARTITIONS +static const struct node_info nodes[] = { + { "arm,pl353-nand-r2p1", MTD_DEV_TYPE_NAND, },Very likely also depends on
CONFIG_NAND_ZYNQ. It means pretty much you can move this code directly tocommon/board.cbecause only Zynq uses this symbol.Thanks,
Michal
Michal Simek
maintainerQuoted 81 lines · James Hilliard
Quoted 71 lines · Michal Simek
Quoted 1 line · James Hilliard
There are situations where we may want to let U-Boot modify the FDT
please use imperative mood.
Quoted 63 lines
nand partitions for the kernel, such as when supporting multiple sizes of NAND chips.
Lets also refactor xilinx common board support to have a
ft_common_board_setupwhich gets called by theft_board_setupfor each specific board so that we can add non-common functionality to eachft_board_setuplikeFDT_FIXUP_PARTITIONSas needed.This pattern is modeled after the one used by
tdx-common.c.Signed-off-by James Hilliard <[email protected]>--- board/xilinx/common/board.c | 2 +- board/xilinx/common/board.h | 2 ++ board/xilinx/mbv/board.c | 9 +++++++++ board/xilinx/versal-net/board.c | 7 +++++++ board/xilinx/versal/board.c | 7 +++++++ board/xilinx/zynq/board.c | 17 +++++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 7 +++++++ board/xilinx/zynqmp_r5/board.c | 8 ++++++++ 8 files changed, 58 insertions(+), 1 deletion(-)board/xilinx/common/board.c +1
-1@@ -686,7 +686,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)#ifdef CONFIG_OF_BOARD_SETUP #define MAX_RAND_SIZE 8 -int ft_board_setup (void *blob,struct bd_info *bd) +int ft_common_board_setup (void *blob,struct bd_info *bd) {size_t n =MAX_RAND_SIZE ;struct udevice *dev;board/xilinx/common/board.h +2
-0@@ -18,4 +18,6 @@ bool board_detection(void);char *soc_name_decode (void );bool soc_detection (void ); + +int ft_common_board_setup (void *blob,struct bd_info *bd);#endif /* BOARD_XILINX_COMMON_BOARD_H */ board/xilinx/mbv/board.c +5
-0@@ -5,7 +5,16 @@* Michal Simek <[email protected]> */ +#include "../common/board.h" +int board_init (void ) {return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd)Quoted 8 lines
board/xilinx/mbv/board.c line 20
Quoted 4 lines
board/xilinx/mbv/board.c +4
-0+{ +return ft_common_board_setup (blob, bd); +} +#endif Any reason not to put directly to
board/xilinx/common/board.c? All xilinx boards are kept in sync from user perspective that's why generic pieces should be added to common location.
Quoted 3 lines
I assumed the device tree node "arm,pl353-nand-r2p1" was specific to boards using
xilinx/zynq/board.csince it seemed only those were the only ones to use that node. Have any idea if that assumption is accurate?
Configuration around xilinx boards are quite generic. Normally nand controller is by default connected on Zynq SOC. But because chips are highly configurable you can connect it also from Microblaze or Risc-V but
I think you can simply do changes in common location and put there proper ifs and it should be fine. Also keep in mind that you should avoid using #ifdef as much as possible and use
if (IS_ENABLED(...)) instead.
M
Quoted 89 lines · Michal Simek
Quoted 81 lines · James Hilliard
Quoted 71 lines · Michal Simek
Quoted 1 line · James Hilliard
There are situations where we may want to let U-Boot modify the FDT
please use imperative mood.
Quoted 63 lines
nand partitions for the kernel, such as when supporting multiple sizes of NAND chips.
Lets also refactor xilinx common board support to have a
ft_common_board_setupwhich gets called by theft_board_setupfor each specific board so that we can add non-common functionality to eachft_board_setuplikeFDT_FIXUP_PARTITIONSas needed.This pattern is modeled after the one used by
tdx-common.c.Signed-off-by James Hilliard <[email protected]>--- board/xilinx/common/board.c | 2 +- board/xilinx/common/board.h | 2 ++ board/xilinx/mbv/board.c | 9 +++++++++ board/xilinx/versal-net/board.c | 7 +++++++ board/xilinx/versal/board.c | 7 +++++++ board/xilinx/zynq/board.c | 17 +++++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 7 +++++++ board/xilinx/zynqmp_r5/board.c | 8 ++++++++ 8 files changed, 58 insertions(+), 1 deletion(-)board/xilinx/common/board.c +1
-1@@ -686,7 +686,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)#ifdef CONFIG_OF_BOARD_SETUP #define MAX_RAND_SIZE 8 -int ft_board_setup (void *blob,struct bd_info *bd) +int ft_common_board_setup (void *blob,struct bd_info *bd) {size_t n =MAX_RAND_SIZE ;struct udevice *dev;board/xilinx/common/board.h +2
-0@@ -18,4 +18,6 @@ bool board_detection(void);char *soc_name_decode (void );bool soc_detection (void ); + +int ft_common_board_setup (void *blob,struct bd_info *bd);#endif /* BOARD_XILINX_COMMON_BOARD_H */ board/xilinx/mbv/board.c +5
-0@@ -5,7 +5,16 @@* Michal Simek <[email protected]> */ +#include "../common/board.h" +int board_init (void ) {return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd)Quoted 8 lines
board/xilinx/mbv/board.c line 20
Quoted 4 lines
board/xilinx/mbv/board.c +4
-0+{ +return ft_common_board_setup (blob, bd); +} +#endif Any reason not to put directly to
board/xilinx/common/board.c? All xilinx boards are kept in sync from user perspective that's why generic pieces should be added to common location.Quoted 3 lines
I assumed the device tree node "arm,pl353-nand-r2p1" was specific to boards using
xilinx/zynq/board.csince it seemed only those were the only ones to use that node. Have any idea if that assumption is accurate?
Quoted 8 lines
Configuration around xilinx boards are quite generic. Normally nand controller is by default connected on Zynq SOC. But because chips are highly configurable you can connect it also from Microblaze or Risc-V but
I think you can simply do changes in common location and put there proper ifs and it should be fine.
Also keep in mind that you should avoid using #ifdef as much as possible and use if (IS_ENABLED(...)) instead.
Is there a way to do that with the static const struct node_info nodes[] part?
Quoted 3 lines
M
Michal Simek
maintainerQuoted 94 lines · James Hilliard
Quoted 93 lines · Michal Simek
Quoted 81 lines · James Hilliard
Quoted 71 lines · Michal Simek
Quoted 1 line · James Hilliard
There are situations where we may want to let U-Boot modify the FDT
please use imperative mood.
Quoted 63 lines
nand partitions for the kernel, such as when supporting multiple sizes of NAND chips.
Lets also refactor xilinx common board support to have a
ft_common_board_setupwhich gets called by theft_board_setupfor each specific board so that we can add non-common functionality to eachft_board_setuplikeFDT_FIXUP_PARTITIONSas needed.This pattern is modeled after the one used by
tdx-common.c.Signed-off-by James Hilliard <[email protected]>--- board/xilinx/common/board.c | 2 +- board/xilinx/common/board.h | 2 ++ board/xilinx/mbv/board.c | 9 +++++++++ board/xilinx/versal-net/board.c | 7 +++++++ board/xilinx/versal/board.c | 7 +++++++ board/xilinx/zynq/board.c | 17 +++++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 7 +++++++ board/xilinx/zynqmp_r5/board.c | 8 ++++++++ 8 files changed, 58 insertions(+), 1 deletion(-)board/xilinx/common/board.c +1
-1@@ -686,7 +686,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)#ifdef CONFIG_OF_BOARD_SETUP #define MAX_RAND_SIZE 8 -int ft_board_setup (void *blob,struct bd_info *bd) +int ft_common_board_setup (void *blob,struct bd_info *bd) {size_t n =MAX_RAND_SIZE ;struct udevice *dev;board/xilinx/common/board.h +2
-0@@ -18,4 +18,6 @@ bool board_detection(void);char *soc_name_decode (void );bool soc_detection (void ); + +int ft_common_board_setup (void *blob,struct bd_info *bd);#endif /* BOARD_XILINX_COMMON_BOARD_H */ board/xilinx/mbv/board.c +5
-0@@ -5,7 +5,16 @@* Michal Simek <[email protected]> */ +#include "../common/board.h" +int board_init (void ) {return 0 ; } + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,struct bd_info *bd)Quoted 8 lines
board/xilinx/mbv/board.c line 20
Quoted 4 lines
board/xilinx/mbv/board.c +4
-0+{ +return ft_common_board_setup (blob, bd); +} +#endif Any reason not to put directly to
board/xilinx/common/board.c? All xilinx boards are kept in sync from user perspective that's why generic pieces should be added to common location.Quoted 3 lines
I assumed the device tree node "arm,pl353-nand-r2p1" was specific to boards using
xilinx/zynq/board.csince it seemed only those were the only ones to use that node. Have any idea if that assumption is accurate?Configuration around xilinx boards are quite generic. Normally nand controller is by default connected on Zynq SOC. But because chips are highly configurable you can connect it also from Microblaze or Risc-V but
Quoted 6 lines
Quoted 4 lines
I think you can simply do changes in common location and put there proper ifs and it should be fine.
Also keep in mind that you should avoid using #ifdef as much as possible and use if (IS_ENABLED(...)) instead.Is there a way to do that with the static const struct
node_infonodes[] part?
Just like this:
int ft_board_setup(void *blob, struct bd_info *bd)
{
static const struct node_info nodes[] = {
{ "arm,pl353-nand-r2p1", MTD_DEV_TYPE_NAND, },
};
if (IS_ENABLED(FDT_FIXUP_PARTITIONS) && IS_ENABLED(NAND_ZYNQ))
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
return ft_common_board_setup(blob, bd);
}M