summaryrefslogtreecommitdiffstats
path: root/common/board_f.c
Commit message (Collapse)AuthorAgeFilesLines
* board_f: cosmetic: change the debug trace to KB in reserve_videoPatrick Delaunay2021-04-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | Update the debug trace for the reserved video memory to KB as indicated in the message with "%luk"; before the patch the computed size gd->relocaddr - addr is in bytes. This patch aligns the debug trace in reserve_video() with others functions, for example on stm32mp157c-dk2: - Reserving 3080192k for video at: dfd00000 + Reserving 3008k for video at: dfd00000 Reserving 873k for U-Boot at: dfc25000 Reserving 32776k for malloc() at: ddc23000 Reserving 72 Bytes for Board Info at: ddc22fb0 Reserving 280 Bytes for Global Data at: ddc22e90 Reserving 119072 Bytes for FDT at: ddc05d70 Reserving 0x278 Bytes for bootstage at: ddc05af0 Fixes: 5630d2fbc50f3035 ("board: Show memory for frame buffers") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: Drop asm/global_data.h from common headerSimon Glass2021-02-021-0/+1
| | | | | | | | | | | | Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* bloblist: Support relocating to a larger spaceSimon Glass2021-01-271-4/+6
| | | | | | | | | | Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may want to add a lot more to it, such as ACPI tables. Add a way to expand the bloblist by relocating it in U-Boot proper, along with the other relocation activities. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: board_f: Use IS_ENABLED(CONFIG_OF_EMBED) in reserve_fdt, reloc_fdtOvidiu Panait2021-01-151-20/+21
| | | | | | | | Use IS_ENABLED(CONFIG_OF_EMBED) in instead of #ifdefs in reserve_fdt, reloc_fdt functions. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: board_f: Move setup_machine code to setup_bdinfoOvidiu Panait2021-01-151-9/+4
| | | | | | | | | setup_bdinfo is used to populate various bdinfo fields, so move setup_machine code there, as all it does is setting gd->bd->bi_arch_number. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: board_f: Use IS_ENABLED(CONFIG_TIMER_EARLY) in initf_dmOvidiu Panait2021-01-151-5/+6
| | | | | | | | Use IS_ENABLED(CONFIG_TIMER_EARLY) instead of #ifdef in initf_dm. Also, move timer code to the main ifdef, so that ret is defined. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: board_f: Drop initf_console_record wrapperOvidiu Panait2021-01-151-9/+3
| | | | | | | Drop initf_console_record wrapper and call console_record_init directly. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: Kconfig: Introduce CONFIG_CONSOLE_RECORD_INIT_FOvidiu Panait2021-01-151-4/+3
| | | | | | | | | | | | Currently, the following #ifdef construct is used to check whether to run console_record_init() during pre-relocation init: defined(CONFIG_CONSOLE_RECORD) && CONFIG_VAL(SYS_MALLOC_F_LEN) Introduce CONFIG_CONSOLE_RECORD_INIT_F Kconfig option to get rid of the complex ifdef check. Also, use IS_ENABLED() instead of #ifdef. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* board: Show memory for frame buffersSimon Glass2020-10-221-0/+2
| | | | | | | When debugging is enabled, show the memory allocated to video frame buffers. Signed-off-by: Simon Glass <sjg@chromium.org>
* bloblist: Place on a 4KB boundarySimon Glass2020-10-221-1/+3
| | | | | | | It is much easier to read the bloblist addresses if it starts on a 4KB boundary. Update it to align it accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
* board_f: Add default values for bi_dram[] in dram_init_banksize()Stefan Roese2020-08-261-6/+1
| | | | | | | | | | Remove the bi_memstart / bi_memsize assignment in setup_bdinfo() and make sure, that bd_dram[] is always configured in the weak default implementation of dram_init_banksize(), when CONFIG_SYS_SDRAM_BASE is not set. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always definedStefan Roese2020-08-261-6/+1
| | | | | | | | | | | | | | Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") & commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"), CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Pali Rohár <pali@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* board_f: Remove dead code from init_func_i2cOvidiu Panait2020-08-221-4/+0
| | | | | | | | | | | | | | | | | | | | | | | Since commit 69153988a6f4 ("i2c: Finish dropping use of CONFIG_I2C_HARD") init_func_i2c is wrapped only by "#if defined(CONFIG_SYS_I2C)". Because of this, the second ifdef within becomes pointless: #if defined(CONFIG_SYS_I2C) static int init_func_i2c(void) <snip> #ifdef CONFIG_SYS_I2C ... #else ... #endif <snip> } #endif Remove the dead #else preprocessor code. Fixes: 69153988a6f ("i2c: Finish dropping use of CONFIG_I2C_HARD") Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* common/board_f: make sure to call fix_fdt() before reserve_fdt()Pragnesh Patel2020-08-141-3/+3
| | | | | | | | | | | | | There may be a chance that board specific fix_fdt() will change the size of FDT blob so it's safe to call reserve_fdt() after fix_fdt() otherwise global data (gd) will overwrite with FDT blob values. Fixes: a8492e25ac71 ("riscv: Expand the DT size before copy reserved memory node") Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Rick Chen <rick@andestech.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
* board_f: Remove setup_board_part1Ovidiu Panait2020-08-061-11/+1
| | | | | | | | Now that all arch specific code was converted to setup_bdinfo, we can remove setup_board_part1. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* board_f: ppc: Factor out ppc-specific bdinfo setupOvidiu Panait2020-08-061-34/+2
| | | | | | | | Factor out ppc-specific bdinfo setup from generic init sequence to arch_setup_bdinfo in arch/powerpc/lib/bdinfo.c. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* board_f: m68k: Factor out m68k-specific bdinfo setupOvidiu Panait2020-08-061-15/+4
| | | | | | | | | Factor out m68k-specific bdinfo setup to arch_setup_bdinfo in arch/m68k/lib/bdinfo.c. Also, use if(IS_ENABLED()) instead of #ifdef where possible. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* board_f: Move sram bdinfo assignments to generic codeOvidiu Panait2020-08-061-5/+5
| | | | | | | | | Move sram related bdinfo from arch-specific setup_board_part1 to generic code in setup_bdinfo. Also use "if (IS_ENABLED(CONFIG_SYS_HAS_SRAM))" instead of "#ifdef CONFIG_SYS_SRAM_BASE". Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* board_f: Factor out bdinfo bi_mem{start, size} to setup_bdinfoOvidiu Panait2020-08-061-6/+5
| | | | | | | | | | | | | | | | | | Move all assignments to gd->bd->bi_mem{start,size} to generic code in setup_bdinfo. Xtensa architecture is special in this regard as it defines its own handling of gd->bd->bi_mem{start,size} fields. In order to avoid defining a weak SDRAM function, let arch_setup_bdinfo overwrite the generic flags. For ARC architecture, remove ARCH_EARLY_INIT_R from Kconfig since it is not needed anymore. Also, use gd->ram_base to populate bi_memstart to avoid an ifdef. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Acked-by: Alexey Brodkin <abrokdin@synopsys.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* board_f: Introduce arch_setup_bdinfo initcallOvidiu Panait2020-08-061-1/+6
| | | | | | | | | | | | | | Certain architectures (ppc, mips, sh, m68k) use setup board_part1 and setup_board_part2 calls during pre-relocation init to populate gd->bd boardinfo fields. This makes the generic init sequence cluttered with arch-specific ifdefs. In order to clean these arch-specific sequences from generic init, introduce arch_setup_bdinfo weak initcall so that everyone can define their own bdinfo setup routines. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* board_f: Introduce setup_bdinfo initcallOvidiu Panait2020-08-061-0/+6
| | | | | | | | Introduce setup_bdinfo initcall as a generic routine to populate bdinfo fields. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* treewide: convert bd_t to struct bd_info by coccinelleMasahiro Yamada2020-07-171-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Linux coding style guide (Documentation/process/coding-style.rst) clearly says: It's a **mistake** to use typedef for structures and pointers. Besides, using typedef for structures is annoying when you try to make headers self-contained. Let's say you have the following function declaration in a header: void foo(bd_t *bd); This is not self-contained since bd_t is not defined. To tell the compiler what 'bd_t' is, you need to include <asm/u-boot.h> #include <asm/u-boot.h> void foo(bd_t *bd); Then, the include direcective pulls in more bloat needlessly. If you use 'struct bd_info' instead, it is enough to put a forward declaration as follows: struct bd_info; void foo(struct bd_info *bd); Right, typedef'ing bd_t is a mistake. I used coccinelle to generate this commit. The semantic patch that makes this change is as follows: <smpl> @@ typedef bd_t; @@ -bd_t +struct bd_info </smpl> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* common/board_f: Respect original FDT size while relocatingOleksandr Andrushchenko2020-07-071-1/+1
| | | | | | | | | | While relocating FDT we reserve some memory for the new FDT and set the size of the FDT with that respect. But FDT may be placed at the end of the RAM leading to memory access beyond it. Fix this by copying exact FDT size bytes, not the reserved size. Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: fdt: Remove additional 4k space for fdt allocationAshok Reddy Soma2020-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | There is no technical reason to add additional 4k space for FDT. This space is completely unused and just increase memory requirements. This is problematic on systems with limited memory resources as Xilinx Zynq CSE/ZynqMP mini and Versal mini configurations. The patch is removing additional 4k space. EFI code is using copy_fdt() which copy FDT to different location. And all boot commands in case of using U-Boot's FDT pointed by $fdtcontroladdr are copying FDT to different locations by image_setup_libfdt(). That's why in proper flow none should modified DTB used by U-Boot that's why there is no need for additional space. Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Acked-by: Stephen Warren <swarren@nvidia.com>
* common: Drop log.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop bootstage.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this fairly uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootstage: Use BOOTSTAGE instead of BOOTSTATESimon Glass2020-05-181-2/+2
| | | | | | Some of the enum members are wrong. Fix them. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop net.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | | | | | | Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
* common/board_f: avoid -Wtype-limits warningHeinrich Schuchardt2020-05-151-1/+1
| | | | | | | | CONFIG_SYS_SDRAM_BASE maybe zero. Avoid a build warning when compiling with -Wtype-limits. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* common: board_f: Use cpu_get_current_dev in print_cpuinfoYe Li2020-05-031-5/+5
| | | | | | | | | | | Current print_cpuinfo gets the first udevice in CPU class to return the cpu info. This has problem if the boot CPU is not fixed. Changing to use new API cpu_get_current_dev to fix the issue. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
* common/board_f: Make reserve_mmu genericOvidiu Panait2020-04-241-3/+6
| | | | | | | | Introduce arch_reserve_mmu to allow for architecture-specific reserve_mmu routines. Also, define a weak nop stub for it. Signed-off-by: Ovidiu Panait <ovpanait@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* common/board_f: Move arm-specific reserve_mmu to arch/arm/lib/cache.cOvidiu Panait2020-04-241-28/+0
| | | | | | | | Move the ARM-specific reserve_mmu definition from common/board_f.c to arch/arm/lib/cache.c. Signed-off-by: Ovidiu Panait <ovpanait@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* board_f.c: Ensure 16 alignment of start_addr_sp and reserved memoryPatrick Delaunay2020-04-161-14/+18
| | | | | | | | | | | | | | | | | Add a function reserve_stack_aligned() to reserved memory with 16 bits alignment after the stack pointer (gd->start_addr_sp) and use this new function in board_f.c to reserve all the memory area (malloc, board, gd, fdt, bootstage, stacks). This 16 byte alignment is needed for cast on struct pointer for the reserved memory, for example: + x86_64 ABI: https://reviews.llvm.org/D30049: 16 bytes + ARMv8 Instruction Set Overview: quad word, 16 bytes An other alignment value could be needed for other architecture. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Acked-by: Stephen Warren <swarren@nvidia.com>
* board_f.c: Ensure gd->new_bootstage alignmentPatrice Chotard2020-04-161-0/+5
| | | | | | | | | | | | | | | | | | | In reserve_bootstage(), in case size is odd, gd->new_bootstage is not aligned. In bootstage_relocate(), the platform hangs when getting access to data->record[i].name. To avoid this issue, make gd->new_bootstage 16 byte aligned. To ensure that new_bootstage is 16 byte aligned (at least needed for x86_64 and ARMv8) and new_bootstage starts down to get enough space, ALIGN_DOWN macro is used. Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm") Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com> Tested-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* board_f: Make clear_bss genericOvidiu Panait2020-02-131-3/+5
| | | | | | | | clear_bss is already used by 3 arches (x86, arc, xtensa), so make it generic and provide a weak nop stub for it. This also removes arch-specific ifdef duplications around clear_bss. Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
* common/board_f.c: Remove arch-specific checks for cpucheckOvidiu Panait2020-01-301-2/+5
| | | | | | | This removes the arch-specific checks for "checkcpu" function from the init sequence. Make "checkcpu" generic and provide a weak nop stub instead. Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
* common: Move hang() to the same header as panic()Simon Glass2020-01-171-0/+1
| | | | | | | | | | At present panic() is in the vsprintf.h header file. That does not seem like an obvious choice for hang(), even though it relates to panic(). So let's put hang() in its own header. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Migrate a few more files] Signed-off-by: Tom Rini <trini@konsulko.com>
* common: Move clock functions into a new fileSimon Glass2020-01-171-0/+1
| | | | | | | These three clock functions don't use driver model and should be migrated. In the meantime, create a new file to hold them. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Move board_get_usable_ram_top() out of common.hSimon Glass2019-12-021-0/+1
| | | | | | | | | Move this function into init.h which seems to be designed for this sort of thing. Also update the header to declare struct global_data so that it can be included without global_data.h being needed. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* common: Move checkcpu() out of common.hSimon Glass2019-12-021-0/+1
| | | | | | | This function belongs in cpu_func.h so move it over. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* common: Move serial functions out of common.hSimon Glass2019-12-021-0/+1
| | | | | | | These functions belong in serial.h so move them over. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* bootstage: Correct relocation algorithmSimon Glass2019-10-271-0/+1
| | | | | | | | | | | | | | | | At present bootstage relocation assumes that it is possible to point back to memory available before relocation, so it does not relocate the strings. However this is not the case on some platforms, such as x86 which uses the cache as RAM and loses access to this when the cache is enabled. Move the relocation step to before U-Boot relocates, expand the allocated region to include space for the strings and relocate the strings at the same time as the bootstage records. This ensures that bootstage data can remain accessible from TPL through SPL to U-Boot before/after relocation. Signed-off-by: Simon Glass <sjg@chromium.org>
* bloblist: Reserve an aligned baseSimon Glass2019-10-271-0/+1
| | | | | | | Make sure that the bloblist starts on an aligned boundary. This protects against one of the early allocating causing the alignment to be lost. Signed-off-by: Simon Glass <sjg@chromium.org>
* board_f: fix noncached reservation calculationStephen Warren2019-08-301-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code in reserve_noncached() has two issues: 1) The first update of gd->start_addr_sp always rounds down to a section start. However, the equivalent calculation in cache.c:noncached_init() always first rounds up to a section start, then subtracts a section size. These two calculations differ if the initial value is already rounded to section alignment. 2) The second update of gd->start_addr_sp subtracts exactly CONFIG_SYS_NONCACHED_MEMORY, whereas the equivalent calculation in cache.c:noncached_init() rounds the noncached size up to section alignment before subtracting it. The two calculations differ if the noncached region size is not a multiple of the MMU section size. In practice, one/both of those issues causes a practical problem on Jetson TX1; U-Boot triggers a synchronous abort during initialization, likely due to overlapping use of some memory region. This change fixes both these issues by duplicating the exact calculations from noncached_init() into reserve_noncached(). However, this fix assumes that gd->start_addr_sp on entry to reserve_noncached() exactly matches mem_malloc_start on entry to noncached_init(). I haven't traced the code to see whether it absolutely guarantees this in all (or indeed any!) cases. Consequently, I added some comments in the hope that this condition will continue to be true. Fixes: 5f7adb5b1c02 ("board_f: reserve noncached space below malloc area") Cc: Vikas Manocha <vikas.manocha@st.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
* board_f: reserve noncached space below malloc areaVikas Manocha2019-08-261-0/+17
| | | | | | | | Noncached area at present is being initialized to random space after malloc area. It works in most the cases as it goes to stack area & stack is not overwriting it being far from it. Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
* env: Rename environment.h to env_internal.hSimon Glass2019-08-111-1/+1
| | | | | | | | | | | | | | This file contains lots of internal details about the environment. Most code can include env.h instead, calling the functions there as needed. Rename this file and add a comment at the top to indicate its internal nature. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> [trini: Fixup apalis-tk1.c] Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Move env_init() to env.hSimon Glass2019-08-111-0/+1
| | | | | | | Move env_init() over to the new header file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* common: Remove video_setmem()Simon Glass2019-08-111-7/+0
| | | | | | | This function is no-longer defined in U-Boot. Drop the declaration from common.h Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Move lcd_setmem() to lcd.hSimon Glass2019-08-111-0/+1
| | | | | | | This function relates to lcd.h and is about to become obsolete with the driver-model conversion. Move it out of common.h Signed-off-by: Simon Glass <sjg@chromium.org>
* trace: trace buffer may exceed 2GiBHeinrich Schuchardt2019-07-101-2/+2
| | | | | | | | Correct the debug output for the trace buffer size to accommodate trace buffers exceeding 2GiB. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>