board: topic: Detect RAM size at boot
PATCH 1/1 board: topic: Detect RAM size at boot
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)
board/topic/zynq/board.c +39 -0
@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size() +#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{ +fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +} + +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size = gd->ram_size; +} + +unsigned int topic_get_sdram_size (void ) +{ +/* Detect and fix ram size */ +return get_ram_size ((void *)CONFIG_SYS_SDRAM_BASE , +CONFIG_SYS_SDRAM_SIZE_MAX ); +}
configs/topic_miami_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=y
configs/topic_miamiplus_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=y
Signature · 1 line
1.9.1
PATCH 1/1 board: topic: Detect RAM size at boot
Hi Mike,
Quoted 74 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +39
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size() +#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{ +fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +} + +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size = gd->ram_size; +} + +unsigned int topic_get_sdram_size (void ) +{ +/* Detect and fix ram size */ +return get_ram_size ((void *)CONFIG_SYS_SDRAM_BASE , +CONFIG_SYS_SDRAM_SIZE_MAX ); +}configs/topic_miami_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=yconfigs/topic_miamiplus_defconfig +0
-0
configs/topic_miamiplus_defconfig CONFIG_CMD_EXT4=y · line 30
Quoted 7 lines
configs/topic_miamiplus_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=y
Sorry I am not getting this. I can't see that detection algorithm above and just looking at above description again that you have 256, 512 and 1G why not just run u-boot with 256MB - it should be enough for boot images and u-boot self, disable ARCH_FIXUP_FDT and update your bootscript to detect ram size and update dts by fdt commands?
This will be much cleaner solution than code above.
Thanks,
Michal
Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161121/fb55f003/attachment.sig>
PATCH 1/1 board: topic: Detect RAM size at boot
Quoted 83 lines · Michal Simek
Hi Mike,
Quoted 80 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +39
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size() +#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{ +fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +} + +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size = gd->ram_size; +} + +unsigned int topic_get_sdram_size (void ) +{ +/* Detect and fix ram size */ +return get_ram_size ((void *)CONFIG_SYS_SDRAM_BASE , +CONFIG_SYS_SDRAM_SIZE_MAX ); +}configs/topic_miami_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=yconfigs/topic_miamiplus_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=y
Quoted 8 lines
Quoted 1 line
Sorry I am not getting this. I can't see that detection algorithm above and just looking at above description again that you have 256, 512 and 1G why not just run u-boot with 256MB - it should be enough for boot images and u-boot self, disable
ARCH_FIXUP_FDTand update your bootscript to detect ram size and update dts by fdt commands?
Lack of knowledge is one part.
The only difference between the boards is the RAM chip installed on it. There's nothing else to detect which board you're running on.
As far as I can see, it would be more difficult to perform this in a bootscript. I'd be happy to be proven wrong though.
Plus, this way u-boot tells the truth at boot. Customers will yell at me if the bootloader reports only 256M at boot.
Quoted 1 line
This will be much cleaner solution than code above.
I only need 3 lines of code here to determine the memory configuration from the actual hardware. They look nice and clean to me. The original code in zynq/board.c needs a few dozen lines to fetch it from a devicetree.
It could be made cleaner by replacing the 0x40000000 constant with reading the DDR config registers, but that'd be overkill and probably take more cycles than just running the test. And, from reading the documentation, calling get_ram_size is actually a good thing to do since it verifies that the memory actually works before using it.
At this point I don't know how to proceed here.
Mike.
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
PATCH 1/1 board: topic: Detect RAM size at boot
Quoted 118 lines · Mike Looijmans
Quoted 91 lines · Michal Simek
Hi Mike,
Quoted 88 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring
separate bootloaders for each variant, just detect the RAM size at boot time
instead of relying on the devicetree information.Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +8
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing
+ * separate bootloaders for each variant, just detect the RAM size at boot time
+ * instead of relying on the devicetree information.
+ */board/topic/zynq/board.c +12
-0+#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size() +#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{ + fdt_fixup_memory(blob, (u64)CONFIG_SYS_SDRAM_BASE,(u64)gd->ram_size);
board/topic/zynq/board.c +16
-0+ +return 0 ; +} + +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size = gd->ram_size; +} + +unsigned int topic_get_sdram_size (void ) +{ +/* Detect and fix ram size */ +return get_ram_size ((void *)CONFIG_SYS_SDRAM_BASE , +CONFIG_SYS_SDRAM_SIZE_MAX ); +}configs/topic_miami_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=yconfigs/topic_miamiplus_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_EMBED=y +CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_ZYNQ_SDHCI=y CONFIG_SPI_FLASH=yQuoted 8 lines
Quoted 1 line
Sorry I am not getting this. I can't see that detection algorithm above and just looking at above description again that you have 256, 512 and 1G why not just run u-boot with 256MB - it should be enough for boot images and u-boot self, disable
ARCH_FIXUP_FDTand update your bootscript to detect ram size and update dts by fdt commands?Lack of knowledge is one part.
The only difference between the boards is the RAM chip installed on it. There's nothing else to detect which board you're running on.
As far as I can see, it would be more difficult to perform this in a bootscript. I'd be happy to be proven wrong though.
Plus, this way u-boot tells the truth at boot. Customers will yell at me if the bootloader reports only 256M at boot.
Quoted 1 line
This will be much cleaner solution than code above.
I only need 3 lines of code here to determine the memory configuration from the actual hardware. They look nice and clean to me. The original code in
zynq/board.cneeds a few dozen lines to fetch it from a devicetree.
Quoted 7 lines
It could be made cleaner by replacing the
0x40000000constant with reading the DDR config registers, but that'd be overkill and probably take more cycles than just running the test. And, from reading the documentation, callingget_ram_sizeis actually a good thing to do since it verifies that the memory actually works before using it.At this point I don't know how to proceed here.
Let me go back to origin patch and clear some things there.
Thanks,
Michal
Signature · 15 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161122/d84c48cb/attachment.sig>
PATCH 1/1 board: topic: Detect RAM size at boot
In reply to Mike LooijmansQuoted 19 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +3
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +*
board/topic/zynq/board.c line 13
Quoted 10 lines
board/topic/zynq/board.c +10
-0+* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size()
I am not happy with this but I see where you go.
Quoted 4 lines
board/topic/zynq/board.c +4
-0+#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +
board/topic/zynq/board.c line 27
Quoted 10 lines
board/topic/zynq/board.c +9
-0#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{ +fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +}
This action is taken at arch_fixup_fdt(). Can you please confirm that this is really needed? And it is not done there? That you don't duplicate stuff here.
board/topic/zynq/board.c line 33
Quoted 6 lines
board/topic/zynq/board.c +6
-0+ +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size = gd->ram_size; +}
This should be fine.
board/topic/zynq/board.c line 39
Quoted 6 lines
board/topic/zynq/board.c +6
-0+ +unsigned int topic_get_sdram_size (void ) +{ +/* Detect and fix ram size */ +return get_ram_size ((void *)CONFIG_SYS_SDRAM_BASE , +CONFIG_SYS_SDRAM_SIZE_MAX );
In the first look I didn't know that get_ram_size is u-boot function for memsize detection.
Thanks,
Michal
Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161122/85e6e277/attachment.sig>
PATCH 1/1 board: topic: Detect RAM size at boot
Quoted 24 lines · Michal Simek
Quoted 23 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +7
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +/*
Quoted 8 lines
board/topic/zynq/board.c line 13
Quoted 6 lines
board/topic/zynq/board.c +6
-0+* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size()I am not happy with this but I see where you go.
Of the several options I tried to "overload" the memory init functions, this was basically the lesser evil...
Maybe it would be possible to make some changes to the generic Zynq board.c file to facilitate overlaying the code?
Note that the memory detection would work on any board, not just the Topic boards. I agree that devicetree is considered the best thing since frozen pizza, but for the Zynq it looks as though detection is much simpler than static configuration.
Quoted 11 lines
Quoted 11 lines
board/topic/zynq/board.c +9
-0+#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{
Quoted 8 lines
board/topic/zynq/board.c line 27
Quoted 4 lines
board/topic/zynq/board.c +4
-0+fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +}This action is taken at
arch_fixup_fdt(). Can you please confirm that this is really needed? And it is not done there? That you don't duplicate stuff here.
If I omitted this step, the Linux devicetree would not be adjusted (during bootm) and would still report its default. I needed both arch_fixup_fdt and this extra line to properly adjust the Linux devicetree for booting.
Quoted 10 lines
board/topic/zynq/board.c line 33
Quoted 7 lines
board/topic/zynq/board.c +6
-0+ +void dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size = gd->ram_size; +}This should be fine.
A note here, if you compile for Zynq with CONFIG_SYS_SDRAM_BASE and CONFIG_SYS_SDRAM_SIZE set, there will be no implementation of 'dram_init_banksize' and the system will fail to boot.
It might be wise to put this snippet into the zynq/board.c in the "#else" clause. I'll send a separate patch for that if you agree.
Quoted 9 lines
board/topic/zynq/board.c line 39
Quoted 6 lines
board/topic/zynq/board.c +6
-0+ +unsigned int topic_get_sdram_size (void ) +{ +/* Detect and fix ram size */ +return get_ram_size ((void *)CONFIG_SYS_SDRAM_BASE , +CONFIG_SYS_SDRAM_SIZE_MAX );In the first look I didn't know that
get_ram_sizeis u-boot function for memsize detection.
Indeed, the name "get_ram_size" doesn't really match what it actually does, but the function's documentation is quite good.
I found "get_ram_size" and "ft_board_setup" while browsing the code of other boards to see how they handled dynamic configuration.
Quoted 3 lines
Thanks,
Michal
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
PATCH 1/1 board: topic: Detect RAM size at boot
In reply to Michal SimekHi Mike,
Quoted 43 lines · Michal Simek
Quoted 19 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +3
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* board/topic/zynq/board.c line 13
Quoted 10 lines
board/topic/zynq/board.c +10
-0+* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size()I am not happy with this but I see where you go.
Quoted 10 lines
board/topic/zynq/board.c +9
-0+#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{
Quoted 8 lines
board/topic/zynq/board.c line 27
Quoted 4 lines
board/topic/zynq/board.c +4
-0+fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +}This action is taken at
arch_fixup_fdt(). Can you please confirm that this is really needed? And it is not done there? That you don't duplicate stuff here.
Did you check this?
Thanks,
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161212/9c52fe4e/attachment.sig>
PATCH 1/1 board: topic: Detect RAM size at boot
In reply to Mike LooijmansQuoted 77 lines · Mike Looijmans
Quoted 13 lines · Michal Simek
Quoted 12 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]> ---
board/topic/zynq/board.c| 39
+++++++++++++++++++++++++++++++++++++++configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41insertions(+)
Quoted 12 lines
Quoted 10 lines
board/topic/zynq/board.c +0
-0
b/board/topic/zynq/board.c@@ -1 +1,40 @@ +/* + * (C) Copyright 2016 Topic Embedded Products + * + * SPDX-License-Identifier:
GPL-2.0+ + */ + +/* + * Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing + * separate bootloaders for each variant, just detect the RAM size at boot time + * instead of relying on the devicetree information. + */ +#defineCONFIG_SYS_SDRAM_BASE0 +#defineCONFIG_SYS_SDRAM_SIZEtopic_get_sdram_size()I am not happy with this but I see where you go.
Of the several options I tried to "overload" the memory init functions, this was basically the lesser evil...
Maybe it would be possible to make some changes to the generic Zynq
board.cfile to facilitate overlaying the code?Note that the memory detection would work on any board, not just the Topic boards. I agree that devicetree is considered the best thing since frozen pizza, but for the Zynq it looks as though detection is much simpler than static configuration.
Quoted 11 lines
Quoted 7 lines
+#define
CONFIG_SYS_SDRAM_SIZE_MAX0x40000000u+ +static unsigned inttopic_get_sdram_size(void); + #include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +intft_board_setup(void *blob, bd_t *bd)+{ + fdt_fixup_memory(blob, (u64)CONFIG_SYS_SDRAM_BASE,
(u64)gd->ram_size); + + return 0; +}This action is taken at
arch_fixup_fdt(). Can you please confirm that this is really needed? And it is not done there? That you don't duplicate stuff here.If I omitted this step, the Linux devicetree would not be adjusted (during bootm) and would still report its default. I needed both
arch_fixup_fdtand this extra line to properly adjust the Linux devicetree for booting.Quoted 7 lines
Quoted 4 lines
+ +void
dram_init_banksize(void)+{ + gd->bd->bi_dram[0].start
=CONFIG_SYS_SDRAM_BASE; + gd->bd->bi_dram[0].size =gd->ram_size; +}This should be fine.
A note here, if you compile for Zynq with
CONFIG_SYS_SDRAM_BASEandCONFIG_SYS_SDRAM_SIZEset, there will be no implementation of 'dram_init_banksize' and the system will fail to boot.It might be wise to put this snippet into the
zynq/board.cin the "#else" clause. I'll send a separate patch for that if you agree.Quoted 5 lines
Quoted 4 lines
+ +unsigned int
topic_get_sdram_size(void)+{ + /* Detect and
fix ram size */ + return get_ram_size((void
*)CONFIG_SYS_SDRAM_BASE, +CONFIG_SYS_SDRAM_SIZE_MAX);
Quoted 8 lines
Quoted 2 lines
In the first look I didn't know that
get_ram_sizeis u-boot function for memsize detection.Indeed, the name "
get_ram_size" doesn't really match what it actually does, but the function's documentation is quite good.I found "
get_ram_size" and "ft_board_setup" while browsing the code of other boards to see how they handled dynamic configuration.
+1
That's how things works in U-Boot for years...
Signature · 2 lines
Regards, Igor.
PATCH 1/1 board: topic: Detect RAM size at boot
In reply to Michal SimekQuoted 55 lines · Michal Simek
Hi Mike,
Quoted 43 lines · Michal Simek
Quoted 19 lines · Mike Looijmans
Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent requiring separate bootloaders for each variant, just detect the RAM size at boot time instead of relying on the devicetree information.
Signed-off-by Mike Looijmans <[email protected]>--- board/topic/zynq/board.c | 39 +++++++++++++++++++++++++++++++++++++++ configs/topic_miami_defconfig | 1 + configs/topic_miamiplus_defconfig | 1 + 3 files changed, 41 insertions(+)board/topic/zynq/board.c +3
-0@@ -1 +1,40 @@ +/* +* (C) Copyright 2016 Topic Embedded Products +* board/topic/zynq/board.c line 13
Quoted 10 lines
board/topic/zynq/board.c +10
-0+* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* +* Miami boards can have memory sizes of 256M, 512M or 1GB. To prevent needing +* separate bootloaders for each variant, just detect the RAM size at boot time +* instead of relying on the devicetree information. +*/ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_SDRAM_SIZE topic_get_sdram_size()I am not happy with this but I see where you go.
Quoted 10 lines
board/topic/zynq/board.c +9
-0+#define CONFIG_SYS_SDRAM_SIZE_MAX 0x40000000u + +static unsigned int topic_get_sdram_size (void ); +#include "../../xilinx/zynq/board.c" + +#include <fdt_support.h> + +int ft_board_setup (void *blob,bd_t *bd) +{Quoted 8 lines
board/topic/zynq/board.c line 27
Quoted 4 lines
board/topic/zynq/board.c +4
-0+fdt_fixup_memory (blob, (u64 )CONFIG_SYS_SDRAM_BASE , (u64 )gd->ram_size); + +return 0 ; +}This action is taken at
arch_fixup_fdt(). Can you please confirm that this is really needed? And it is not done there? That you don't duplicate stuff here.
Quoted 1 line
Did you check this?
Well, if omitted, the linux devicetree doesn't get updated with the proper memory size, and the system malfunctions if the size differs. Apparently, the internal u-boot DT gets updated by the other routines, but this routine is required to patch the devicetree as it will be transferred to Linux.
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