History log of /u-boot/arch/arm/include/asm/global_data.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# d678a59d 18-May-2024 Tom Rini <trini@konsulko.com>

Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""

When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay
Ethernet"' I failed to notice that b4 noticed it was based on next and
so took that as the base commit and merged that part of next to master.

This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing
changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 6a718588 30-Apr-2024 Tom Rini <trini@konsulko.com>

global: Make <asm/global_data.h> include <asm/u-boot.h>

This follows the example of RISC-V where <asm/global_data.h> includes
<asm/u-boot.h> directly as "gd" includes a reference to bd_info already
and so the first must include the second anyhow. We then remove
<asm/u-boot.h> from all of the places which include references to "gd"
an so have <asm/global_data.h> already.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 22fcd1da 19-Dec-2023 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: add ACPI fields to global data

Add fields for the location of ACPI tables to the global data.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 78e326d6 14-Dec-2023 Tom Rini <trini@konsulko.com>

arm: Remove <asm/types.h> from asm/global_data.h

We need and include <linux/types.h> and this in turn already includes
<asm/types.h>, so drop it here.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 0585c28f 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use FEAT_HAFDBS to track dirty pages when available"

This reverts commit 6cdf6b7a340db4ddd008516181de7e08e3f8c213. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# eed8294b 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present"

This reverts commit 836b8d4b205d2175b57cb9ef271e638b0c116e89. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# 50834884 19-Sep-2023 Simon Glass <sjg@chromium.org>

Record the position of the SMBIOS tables

Remember where these end up so that we can pass this information on to
the EFI layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# d3ee9dbd 15-Jun-2023 Peng Fan <peng.fan@nxp.com>

imx: use generic name ele(EdgeLockSecure Enclave)

Per NXP requirement, we rename all the NXP EdgeLock Secure Enclave
code including comment, folder and API name to ELE to align.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <masahiroy@kernel.org>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 6a718588 30-Apr-2024 Tom Rini <trini@konsulko.com>

global: Make <asm/global_data.h> include <asm/u-boot.h>

This follows the example of RISC-V where <asm/global_data.h> includes
<asm/u-boot.h> directly as "gd" includes a reference to bd_info already
and so the first must include the second anyhow. We then remove
<asm/u-boot.h> from all of the places which include references to "gd"
an so have <asm/global_data.h> already.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 22fcd1da 19-Dec-2023 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: add ACPI fields to global data

Add fields for the location of ACPI tables to the global data.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 78e326d6 14-Dec-2023 Tom Rini <trini@konsulko.com>

arm: Remove <asm/types.h> from asm/global_data.h

We need and include <linux/types.h> and this in turn already includes
<asm/types.h>, so drop it here.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 0585c28f 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use FEAT_HAFDBS to track dirty pages when available"

This reverts commit 6cdf6b7a340db4ddd008516181de7e08e3f8c213. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# eed8294b 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present"

This reverts commit 836b8d4b205d2175b57cb9ef271e638b0c116e89. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# 50834884 19-Sep-2023 Simon Glass <sjg@chromium.org>

Record the position of the SMBIOS tables

Remember where these end up so that we can pass this information on to
the EFI layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# d3ee9dbd 15-Jun-2023 Peng Fan <peng.fan@nxp.com>

imx: use generic name ele(EdgeLockSecure Enclave)

Per NXP requirement, we rename all the NXP EdgeLock Secure Enclave
code including comment, folder and API name to ELE to align.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <masahiroy@kernel.org>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 22fcd1da 19-Dec-2023 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: add ACPI fields to global data

Add fields for the location of ACPI tables to the global data.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 78e326d6 14-Dec-2023 Tom Rini <trini@konsulko.com>

arm: Remove <asm/types.h> from asm/global_data.h

We need and include <linux/types.h> and this in turn already includes
<asm/types.h>, so drop it here.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 0585c28f 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use FEAT_HAFDBS to track dirty pages when available"

This reverts commit 6cdf6b7a340db4ddd008516181de7e08e3f8c213. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# eed8294b 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present"

This reverts commit 836b8d4b205d2175b57cb9ef271e638b0c116e89. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# 50834884 19-Sep-2023 Simon Glass <sjg@chromium.org>

Record the position of the SMBIOS tables

Remember where these end up so that we can pass this information on to
the EFI layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# d3ee9dbd 15-Jun-2023 Peng Fan <peng.fan@nxp.com>

imx: use generic name ele(EdgeLockSecure Enclave)

Per NXP requirement, we rename all the NXP EdgeLock Secure Enclave
code including comment, folder and API name to ELE to align.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <masahiroy@kernel.org>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 0585c28f 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use FEAT_HAFDBS to track dirty pages when available"

This reverts commit 6cdf6b7a340db4ddd008516181de7e08e3f8c213. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# eed8294b 26-Oct-2023 Chris Packham <judge.packham@gmail.com>

Revert "arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present"

This reverts commit 836b8d4b205d2175b57cb9ef271e638b0c116e89. This is
part of a series trying to make use of the arm64 hardware features for
tracking dirty pages. Unfortunately this series causes problems for the
AC5/AC5X SoCs. Having exhausted other options the consensus seems to be
reverting this series is the best course of action.

Signed-off-by: Chris Packham <judge.packham@gmail.com>

# 50834884 19-Sep-2023 Simon Glass <sjg@chromium.org>

Record the position of the SMBIOS tables

Remember where these end up so that we can pass this information on to
the EFI layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# d3ee9dbd 15-Jun-2023 Peng Fan <peng.fan@nxp.com>

imx: use generic name ele(EdgeLockSecure Enclave)

Per NXP requirement, we rename all the NXP EdgeLock Secure Enclave
code including comment, folder and API name to ELE to align.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <masahiroy@kernel.org>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 50834884 19-Sep-2023 Simon Glass <sjg@chromium.org>

Record the position of the SMBIOS tables

Remember where these end up so that we can pass this information on to
the EFI layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# d3ee9dbd 15-Jun-2023 Peng Fan <peng.fan@nxp.com>

imx: use generic name ele(EdgeLockSecure Enclave)

Per NXP requirement, we rename all the NXP EdgeLock Secure Enclave
code including comment, folder and API name to ELE to align.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <masahiroy@kernel.org>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# d3ee9dbd 15-Jun-2023 Peng Fan <peng.fan@nxp.com>

imx: use generic name ele(EdgeLockSecure Enclave)

Per NXP requirement, we rename all the NXP EdgeLock Secure Enclave
code including comment, folder and API name to ELE to align.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 836b8d4b 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present

In order to make invalidation by VA more efficient, set the largest
block mapping to 2MB, mapping it onto level-2. This has no material
impact on u-boot's runtime performance, and allows a huge speedup
when cleaning the cache.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8

# 6cdf6b7a 17-Mar-2023 Marc Zyngier <maz@kernel.org>

arm64: Use FEAT_HAFDBS to track dirty pages when available

Some recent arm64 cores have a facility that allows the page
table walker to track the dirty state of a page. This makes it
really efficient to perform CMOs by VA as we only need to look
at dirty pages.

Signed-off-by: Marc Zyngier <maz@kernel.org>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/3c433724e6f830a6b2edd5ec3d4a504794887263

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 8b956bdd 31-Jan-2023 Ye Li <ye.li@nxp.com>

imx: imx8ulp: Adjust handshake to sync TRDC and XRDC completion

To fit the DBD_EN fused part, we re-design the TRDC and XRDC assignment.
M33 will be the TRDC owner and needs to configure TRDC. A35 is the
XRDC owner, ATF will configure XRDC.

The handshake between U-boot and M33 image is used to sync TRDC and
XRDC configuration completion. Once the handshake is done, A35 and M33
can access the allowed resources in others domain.

The handshake is needed when M33 is booted or DBD_EN fused, because both
cases will enable the TRDC. If handshake is timeout, the boot will hang.
We use SIM GPR0 to pass the info from SPL to u-boot, because before the
handshake, u-boot can't access SEC SIM and FSB.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 65cc0e2a 16-Nov-2022 Tom Rini <trini@konsulko.com>

global: Move remaining CONFIG_SYS_* to CFG_SYS_*

The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# a55014d0 03-Aug-2022 Simon Glass <sjg@chromium.org>

Makefile: Allow LTO to be disabled for a build

LTO (Link-Time Optimisation) is an very useful feature which can
significantly reduce the size of U-Boot binaries. So far it has been
made available for selected ARM boards and sandbox.

However, incremental builds are much slower when LTO is used. For example,
an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
seconds with LTO enabled.

Add a NO_LTO parameter to the build, similar to NO_SDL, so it can be
disabled during development if needed, for faster builds.

Add some documentation about LTO while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 989f7393 26-Jul-2022 Peng Fan <peng.fan@nxp.com>

imx: imx9: Get the chip revision through S400 API

Update the get chip revision methond to use S400 API, also record
other information like lifecycle and UID to global data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 03fcf966 26-Jul-2022 Ye Li <ye.li@nxp.com>

misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <kabel@kernel.org>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 0c00d03a 07-Aug-2021 Ye Li <ye.li@nxp.com>

driver: misc: Add MU and S400 API to communicate with Sentinel

Add MU driver and S400 API. Need enable MISC driver to work

Signed-off-by: Ye Li <ye.li@nxp.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <marek.behun@nic.cz>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <marek.behun@nic.cz>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 076c7bfb 03-Jun-2021 Tom Rini <trini@konsulko.com>

global_data: Ensure we have <config.h> when symbols are not in Kconfig yet

All symbols that are defined in Kconfig will always be defined (or not)
prior to preprocessing due to the -include directive while building.
However, symbols which are not yet migrated will only be defined (or
not) once the board config.h is included, via <config.h>. While the end
goal must be to migrate all symbols, today we have cases where the size
of gd will get mismatched within the build, based on include order.
Mitigate this by making sure that any <asm/global_data.h> that uses
symbols not in Kconfig does start with <config.h>. Remove this when not
needed.

Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Huan Wang <alison.wang@nxp.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 86c5e210 20-May-2021 Marek Behún <marek.behun@nic.cz>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <marek.behun@nic.cz>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 86c5e210 20-May-2021 Marek Behún <marek.behun@nic.cz>

ARM: make gd a function call for LTO and set via set_gd()

On ARM, the gd pointer is stored in registers r9 / x18. For this the
-ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
register variables causes errors when building with LTO, and these
errors are very difficult to overcome.

Richard Biener says [1]:
Note that global register vars shouldn't be used with LTO and if they
are restricted to just a few compilation units the recommended fix is
to build those CUs without -flto.

We cannot do this for U-Boot since all CUs use -ffixed-reg flag.

It seems that with LTO we could in fact store the gd pointer differently
and gain performance or size benefit by allowing the compiler to use
r9 / x18. But this would need more work.

So for now, when building with LTO, go the clang way, and instead of
declaring gd a global register variable, we make it a function call via
macro.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 82b63e95 20-May-2021 Marek Behún <marek.behun@nic.cz>

ARM: global_data: make set_gd() work for armv5 and armv6

The Thumb instruction `ldr` is able to move high registers only from
armv7. For armv5 and armv6 we have to use `mov`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 2f7aa897 22-Feb-2021 Siew Chin Lim <elly.siew.chin.lim@intel.com>

common: Add "ifndef __ASSEMBLY__" in asm/global_data.h

Commit "common: Drop asm/global_data.h from common header" added
asm/global_data.h into secure.h. However, secure.h will be included
by psci.S. Adding asm/global_data.h has caused compilation failure in
pcsi.S. Add "ifndef __ASSEMBLY__" in asm/global_data.h.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 401d1c4f 30-Oct-2020 Simon Glass <sjg@chromium.org>

common: Drop asm/global_data.h from common header

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>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# b87d8d6a 27-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

arm: remove outdated comment concerning -ffixed-x18

Clang 9 supports -ffixed-x18.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 4f7dc5f6 26-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: allow compiling with clang

On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.

In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.

Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# ac76dd08 19-Dec-2019 Yangbo Lu <yangbo.lu@nxp.com>

Add global variable sdhc_per_clk for arm/powerpc

The QorIQ eSDHC controller supports two reference clocks. They are
platform clock and periperhal clock. The global variable sdhc_clk
has already been used for platform clock.
This patch is to add another global variable sdhc_per_clk for
periperhal clock, which provides higher frequency and is required
to be used for SD UHS and eMMC HS200/HS400 speed modes.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@csgraf.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# e37ac717 20-Jun-2019 Yangbo Lu <yangbo.lu@nxp.com>

Convert to use fsl_esdhc_imx for i.MX platforms

Converted to use fsl_esdhc_imx for i.MX platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Martyn Welch <martyn.welch@collabora.com>
Acked-by: Jason Liu <Jason.hui.liu@nxp.com>

# 10015025 03-May-2019 Trevor Woerner <trevor@toganlabs.com>

CONFIG_SPL_SYS_[DI]CACHE_OFF: add

While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
where these configuration items are conditional on SPL. This commit adds SPL
variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
the configurations as required.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
[trini: Make the default depend on the setting for full U-Boot, update
more zynq hardware]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>

# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>

# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@suse.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@suse.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>

# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>

# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>

# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>

# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>

# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>

# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>

# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>

# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>

# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>

# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>

# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>

# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message

# 9623c158 23-Jun-2011 Wolfgang Denk <wd@denx.de>

Merge branch 'master' of git://git.denx.de/u-boot-arm

* 'master' of git://git.denx.de/u-boot-arm:
run arm_pci_init after relocation
IXP42x PCI rewrite
update/fix PDNB3 board
update/fix IXDP425 / IXDPG425 boards
add dvlhost (dLAN 200 AV Wireless G) board
IXP NPE: add support for fixed-speed MII ports
update/fix AcTux4 board
update/fix AcTux3 board
update/fix AcTux2 board
update/fix AcTux1 board
use -ffunction-sections / --gc-sections on IXP42x
support CONFIG_SYS_LDSCRIPT on ARM
fix "depend" target in npe directory
Fix IXP code to work after relocation was added
trigger hardware watchdog in IXP42x serial driver
add support for IXP42x Rev. B1 and newer
add XScale sub architecture (IXP/PXA) to maintainer list

Conflicts:
arch/arm/lib/board.c

Signed-off-by: Wolfgang Denk <wd@denx.de>


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>

# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>

# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>

# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>

# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>

# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>

# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>

# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>

# 60b9de4f 18-Oct-2018 Peng Fan <peng.fan@nxp.com>

arm: global_data: add scu_dev for i.MX8

Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>


# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>


# 8fbbb6c2 08-May-2017 Peng Fan <peng.fan@nxp.com>

arm: change tbu/l type to unsigned int

Change tbu/l type to unsigned int.
>From the timer file for arm,
"(((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;" is used,
This piece code is based on tbu/tbl is 32bits, so change the type to
unsigned int.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>


# a93fbf4a 24-Apr-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

ARM: omap2+: rename config to ARCH_OMAP2PLUS and consolidate Kconfig

In Linux, CONFIG_ARCH_OMAP2PLUS is used for OMAP2 or later SoCs.
Rename CONFIG_ARCH_OMAP2 to CONFIG_ARCH_OMAP2PLUS to follow this
naming.

Move the OMAP2+ board/SoC choice down to mach-omap2/Kconfig to slim
down the arch/arm/Kconfig level.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>


# f2ccf7f7 06-Mar-2017 York Sun <york.sun@nxp.com>

armv8: Add global variable resv_ram

Use gd->arch.resv_ram to track reserved memory allocation.

Signed-off-by: York Sun <york.sun@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>


# 187f9dc3 07-Nov-2016 Tom Rini <trini@konsulko.com>

TI: Remove CONFIG_OMAP_COMMON in favor of CONFIG_ARCH_OMAP2

With the move to arch/arm/mach-omap2 there are now very few uses of
CONFIG_OMAP_COMMON and further they can all be replaced with
CONFIG_ARCH_OMAP2, so do so.

Signed-off-by: Tom Rini <trini@konsulko.com>


# 50e93b95 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Add tlb_allocated to arch global data

When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun <york.sun@nxp.com>


# e61a7534 24-Jun-2016 York Sun <york.sun@nxp.com>

armv8: Move secure_ram variable out of generic global data

Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun <york.sun@nxp.com>


# 7985cdf7 03-Mar-2016 Alexander Graf <agraf@suse.de>

arm64: Remove non-full-va map code

By now the code to only have a single page table level with 64k page
size and 42 bit address space is no longer used by any board in tree,
so we can safely remove it.

To clean up code, move the layerscape mmu code to the new defines,
removing redundant field definitions.

Signed-off-by: Alexander Graf <agraf@suse.de>


# 5e2ec773 03-Mar-2016 Alexander Graf <agraf@suse.de>

arm64: Make full va map code more dynamic

The idea to generate our pages tables from an array of memory ranges
is very sound. However, instead of hard coding the code to create up
to 2 levels of 64k granule page tables, we really should just create
normal 4k page tables that allow us to set caching attributes on 2M
or 4k level later on.

So this patch moves the full_va mapping code to 4k page size and
makes it fully flexible to dynamically create as many levels as
necessary for a map (including dynamic 1G/2M pages). It also adds
support to dynamically split a large map into smaller ones when
some code wants to set dcache attributes.

With all this in place, there is very little reason to create your
own page tables in board specific files.

Signed-off-by: Alexander Graf <agraf@suse.de>


# 94f7ff36 14-Oct-2015 Sergey Temerkhanov <s.temerkhanov@gmail.com>

armv8: New MMU setup code allowing to use 48+ bits PA/VA

This patch adds code which sets up 2-level page tables on ARM64 thus
extending available VA space. CPUs implementing 64k translation
granule are able to use direct PA-VA mapping of the whole 48 bit
address space.
It also adds the ability to reset the SCTRL register at the very beginning
of execution to avoid interference from stale mappings set up by early
firmware/loaders/etc.

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>


# 44937214 09-Nov-2015 Prabhakar Kushwaha <prabhakar@freescale.com>

armv8: LS2080A: Rename LS2085A to reflect LS2080A

LS2080A is a prime personality of Freescale’s LS2085A. It is a non-AIOP
personality without support of DP-DDR, L2 switch, 1588, PCIe endpoint etc.
So renaming existing LS2085A code base to reflect LS2080A (Prime personality)

Signed-off-by: Pratiyush Mohan Srivastava <pratiyush.srivastava@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
[York Sun: Dropped #ifdef in cpu.c for cpu_type_list]
Reviewed-by: York Sun <yorksun@freescale.com>


# 60c7c30a 15-Jul-2015 Paul Kocialkowski <contact@paulk.fr>

omap-common: Common boot code OMAP3 support and cleanup

This introduces OMAP3 support for the common omap boot code, as well as a
major cleanup of the common omap boot code.

First, the omap_boot_parameters structure becomes platform-specific, since its
definition differs a bit across omap platforms. The offsets are removed as well
since it is U-Boot's coding style to use structures for mapping such kind of
data (in the sense that it is similar to registers). It is correct to assume
that romcode structure encoding is the same as U-Boot, given the description
of these structures in the TRMs.

The original address provided by the bootrom is passed to the U-Boot binary
instead of a duplicate of the structure stored in global data. This allows to
have only the relevant (boot device and mode) information stored in global data.
It is also expected that the address where the bootrom stores that information
is not overridden by the U-Boot SPL or U-Boot.

The save_omap_boot_params is expected to handle all special cases where the data
provided by the bootrom cannot be used as-is, so that spl_boot_device and
spl_boot_mode only return the data from global data.

All of this is only relevant when the U-Boot SPL is used. In cases it is not,
save_boot_params should fallback to its weak (or board-specific) definition.
save_omap_boot_params should not be called in that context either.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>


# b87e6f88 06-Jan-2015 York Sun <yorksun@freescale.com>

armv8/fsl-lsch3: Add support for second DDR clock

FSL-LSCH3 platforms can have multiple DDR clocks. LS2085A has one clock for
general DDR controlers, and another clock for DP-DDR. DDR driver needs to
change to support multiple clocks.

Signed-off-by: York Sun <yorksun@freescale.com>


# 93d33204 24-Sep-2014 Zhao Qiang <B45475@freescale.com>

qe: add u-qe support to arm board

ls1021 is arm-core and support qe which is u-qe.
add u-qe init for arm board.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
[York Sun: Fix compiling error caused by u_qe_init()]
Reviewed-by: York Sun <yorksun@freescale.com>


# c65a2abb 30-Jul-2014 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: make gd a function for clang

"clang does not support global register variables; this is
unlikely to be implemented soon because it requires additional
LLVM backend support" [1]

Workaround it by obtaining the value of gd/r9 by an inline
asm routine. Note there is no set routine added for ARM at the
moment, since most if not all updates of gd from c are actually
not needed for ARM.

[1] http://clang.llvm.org/docs/UsersManual.html

cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>


# c8d4b2f8 27-Jan-2014 Marek Vasut <marex@denx.de>

ARM: IXP: Remove the IXP architecture support

The architecture is unmaintained and dead, remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Michael Schwingen <michael@schwingen.org>
Cc: Tom Rini <trini@ti.com>


# 0ae76531 13-Dec-2013 David Feng <fenghua@phytium.com.cn>

arm64: core support

Relocation code based on a patch by Scott Wood, which is:
Signed-off-by: Scott Wood <scottwood@freescale.com>

Signed-off-by: David Feng <fenghua@phytium.com.cn>


# fe1378a9 21-Sep-2013 Jeroen Hofstee <jeroen@myspectrum.nl>

ARM: use r9 for gd

To be more EABI compliant and as a preparation for building
with clang, use the platform-specific r9 register for gd
instead of r8.

note: The FIQ is not updated since it is not used in u-boot,
and under discussion for the time being.

The following checkpatch warning is ignored:
WARNING: Use of volatile is usually wrong: see
Documentation/volatile-considered-harmful.txt

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
cc: Albert ARIBAUD <albert.u.boot@aribaud.net>


# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>


# fda06812 23-Apr-2013 SRICHARAN R <r.sricharan@ti.com>

ARM: OMAP: Correct save_boot_params and replace with 'C' function

Currently save_boot_params saves the boot parameters passed
from romcode. But this is not stored in a writable location
consistently. So the current code would not work for a
'XIP' boot. Change this by saving the boot parameters in
'gd' which is always writable. Also add a 'C' function
instead of an assembly code that is more readable.

Signed-off-by: Sricharan R <r.sricharan@ti.com>


# baa1e536 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Use generic global_data

Signed-off-by: Simon Glass <sjg@chromium.org>


# e9adeca3 13-Dec-2012 Simon Glass <sjg@chromium.org>

ppc: arm: Move sdhc_clk into arch_global_data

This is used by both powerpc and arm, but I think it still qualifies as
architecture-specific.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 34fd5d25 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tlb_addr and tlb_size to arch_global_data

Move these fields into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Address tlb_size in this patch as well]
Signed-off-by: Tom Rini <trini@ti.com>


# b4d51db8 13-Dec-2012 Simon Glass <sjg@chromium.org>

ixp: Move timestamp to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 5f70714c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_reset_value to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 582601da 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move lastinc to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 66ee6923 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbl to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 8ff43b03 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move tbu to arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>


# b339051c 13-Dec-2012 Simon Glass <sjg@chromium.org>

arm: Move timer_rate_hz into arch_global_data

Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>


# f47e6ecd 13-Dec-2012 Simon Glass <sjg@chromium.org>

at91: Move at91 global data into arch_global_data

Move these fields into arch_global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 5cb48582 13-Dec-2012 Simon Glass <sjg@chromium.org>

Add architecture-specific global data

We plan to move architecture-specific data into a separate structure so
that we can make the rest of it common.

As a first step, create struct arch_global_data to hold these fields.
Initially it is empty.

This patch applies to all archs at once. I can split it if this is really
a pain.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 724cdffc 30-Nov-2012 Gabe Black <gabeblack@chromium.org>

arm: Keep track of the tlb size as well as its location

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>


# e46e31a8 12-Oct-2012 Simon Glass <sjg@chromium.org>

arm: Change global data baudrate to int

This does not need to be a long, so change it.

Also adjust bi_baudrate to be unsigned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@ti.com>


# 47fde91f 18-Mar-2012 Mike Frysinger <vapier@gentoo.org>

global_data: unify global flag defines

All the global flag defines are the same across all arches. So unify them
in one place, and add a simple way for arches to extend for their needs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>


# 45ba8077 14-Oct-2011 Simon Glass <sjg@chromium.org>

fdt: ARM: Add device tree control of U-Boot (CONFIG_OF_CONTROL)

This adds a device tree pointer to the global data. It can be set by
board code. A later commit will add support for making a device
tree binary blob available to U-Boot for run-time configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 79843950 02-Aug-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST: add post_log_res field for post results in global data

The current post_log_word in global data is currently split into 2x
16 bits: half for the test start, half for the test success.
Since we alredy have more than 16 POST tests defined and more could
be defined, this may result in an overflow and the post_output_backlog
would not work for the tests defined further of these 16 positions.

An additional field is added to global data so that we can now support up
to 32 (depending of architecture) tests. The post_log_word is only used
to record the start of the test and the new field post_log_res for the
test success (or failure). The post_output_backlog is for this change
also adapted.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>


# ea3681a6 01-Sep-2011 Valentin Longchamp <valentin.longchamp@keymile.com>

POST/arm: adaptations needed for POST on ARM to work

For post to run on ARM, 3 things are needed:
- post_log_word to be defined in gd
- a post.h include in arch/arm/lib/board.c

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>


# 9558b48a 31-Aug-2011 Graeme Russ <graeme.russ@gmail.com>

console: Implement pre-console buffer

Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
- CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
- CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
- CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.


# f9a78b8d 14-Jul-2011 Michael Jones <michael.jones@matrix-vision.de>

cosmetic: spell fixes etc.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Detlev Zundel <dzu@denx.de>


# e47f2db5 16-Jun-2011 Aneesh V <aneesh@ti.com>

armv7: rename cache related CONFIG flags

Replace the cache related CONFIG flags with more meaningful
names. Following are the changes:

CONFIG_L2_OFF -> CONFIG_SYS_L2CACHE_OFF
CONFIG_SYS_NO_ICACHE -> CONFIG_SYS_ICACHE_OFF
CONFIG_SYS_NO_DCACHE -> CONFIG_SYS_DCACHE_OFF

Signed-off-by: Aneesh V <aneesh@ti.com>
V2:
* Changed CONFIG_L2_OFF -> CONFIG_SYS_NO_L2CACHE
V4:
* Changed all three flags to the final names suggested as above
and accordingly changed the commit message


# ce04bb41 22-May-2011 Michael Schwingen <michael@schwingen.org>

Fix IXP code to work after relocation was added

- jump to real flash location after reset before turning off flash mirror
- fix timer system to use HZ == 1000, remove broken interrupt-based code

Signed-off-by: Michael Schwingen <michael@schwingen.org>


# 566e5cf4 01-May-2011 Wolfgang Denk <wd@denx.de>

ARM: drop unsupported 'trab' board

The 'trab' board configuration is broken, and there is nobody who is
interested and willing to fix it. Drop it.

This includes support for VFD displays which have always been used by
this board only.

Signed-off-by: Wolfgang Denk <wd@denx.de>


# f9de0997 01-Dec-2010 Prafulla Wadaskar <prafulla@marvell.com>

ARM: make timer variables in gt_t available for all ARM platforms

All code that attemots to access variables in BSS before relocation
(for example directly or indirectly by board_init_f()) needs to be
fixed. Especially timer.c needs to fix on most of the ARM platforms.

This patch makes timer related variables in gd_t available for
all ARM implementations.

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>

Edited commit message.
Signed-off-by: Wolfgang Denk <wd@denx.de>


# a429db7e 30-Nov-2010 Andreas Bießmann <andreas.devel@googlemail.com>

arm920t/at91/timer: replace bss variables by gd

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc
bss values in arm920t/at91/timer driver.
The usage of bss values in driver before initialisation of bss is
forbidden. In that special case some data in .rel.dyn gets corrupted by
the arm920t/at91/timer driver.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>


# a9aa3926 28-Oct-2010 Wolfgang Denk <wd@denx.de>

Drop support for CONFIG_SYS_ARM_WITHOUT_RELOC

When this define was introduced, the idea was to provide a soft
migration path for ARM boards to get adapted to the new relocation
support. However, other recent changes led to a different
implementation (ELF relocation), where this no longer works. By now
CONFIG_SYS_ARM_WITHOUT_RELOC does not only not help any more, but it
actually hurts because it obfuscates the actual code by sprinkling it
with lots of dead and non-working debris.

So let's make a clean cut and drop CONFIG_SYS_ARM_WITHOUT_RELOC.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>


# 25ddd1fb 26-Oct-2010 Wolfgang Denk <wd@denx.de>

Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

CONFIG_SYS_GBL_DATA_SIZE has always been just a bad workarond for not
being able to use "sizeof(struct global_data)" in assembler files.
Recent experience has shown that manual synchronization is not
reliable enough. This patch renames CONFIG_SYS_GBL_DATA_SIZE into
GENERATED_GBL_DATA_SIZE which gets automatically generated by the
asm-offsets tool. In the result, all definitions of this value can be
deleted from the board config files. We have to make sure that all
files that reference such data include the new <asm-offsets.h> file.

No other changes have been done yet, but it is obvious that similar
changes / simplifications can be done for other, related macro
definitions as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>


# 5dca710a 05-Oct-2010 Reinhard Meyer <u-boot@emk-elektronik.de>

AT91 clock/timer: move static data to global_data struct

clock.c / timer.c used static data and are called before relocation.
Move all static variables into global_data structure. Also cleanup
timer.c from unused stubs and make it truly use 64 bit tick values.

Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>


# f1d2b313 17-Sep-2010 Heiko Schocher <hs@denx.de>

ARM: add relocation support

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

Fix boot from NAND for non-ARM systems
Signed-off-by: Wolfgang Denk <wd@denx.de>


# ea882baf 20-Jun-2010 Wolfgang Denk <wd@denx.de>

New implementation for internal handling of environment variables.

Motivation:

* Old environment code used a pessimizing implementation:
- variable lookup used linear search => slow
- changed/added variables were added at the end, i. e. most
frequently used variables had the slowest access times => slow
- each setenv() would calculate the CRC32 checksum over the whole
environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
or to select one out of several pre-defined (previously saved) sets
of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

I didn't find any such variable names being used; it is highly
recommended to follow standard conventions and start variable names
with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
lines of a multi-line variable value.

Multi-line variables have never been formally defined, allthough
there is no reason not to use them. Now we define rules how to deal
with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
At the moment this is causing build problems for the only user of
this code (schmoogie - which has no entry in MAINTAINERS); may be
fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
"printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

- env print [arg ...]

same as "printenv": print environment

- env set [-f] name [arg ...]

same as "setenv": set (and delete) environment variables

["-f" - force setting even for read-only variables - not
implemented yet.]

- end delete [-f] name

not implemented yet

["-f" - force delete even for read-only variables]

- env save

same as "saveenv": save environment

- env export [-t | -b | -c] addr [size]

export internal representation (hash table) in formats usable for
persistent storage or processing:

-t: export as text format; if size is given, data will be
padded with '\0' bytes; if not, one terminating '\0'
will be added (which is included in the "filesize"
setting so you can for exmple copy this to flash and
keep the termination).
-b: export as binary format (name=value pairs separated by
'\0', list end marked by double "\0\0")
-c: export as checksum protected environment format as
used for example by "saveenv" command
addr: memory address where environment gets stored
size: size of output buffer

With "-c" and size is NOT given, then the export command will
format the data as currently used for the persistent storage,
i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
prepend a valid CRC32 checksum and, in case of resundant
environment, a "current" redundancy flag. If size is given, this
value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
checksum and redundancy flag will be inserted.

With "-b" and "-t", always only the real data (including a
terminating '\0' byte) will be written; here the optional size
argument will be used to make sure not to overflow the user
provided buffer; the command will abort if the size is not
sufficient. Any remainign space will be '\0' padded.

On successful return, the variable "filesize" will be set.
Note that filesize includes the trailing/terminating '\0'
byte(s).

Usage szenario: create a text snapshot/backup of the current
settings:

=> env export -t 100000
=> era ${backup_addr} +${filesize}
=> cp.b 100000 ${backup_addr} ${filesize}

Re-import this snapshot, deleting all other settings:

=> env import -d -t ${backup_addr}

- env import [-d] [-t | -b | -c] addr [size]

import external format (text or binary) into hash table,
optionally deleting existing values:

-d: delete existing environment before importing;
otherwise overwrite / append to existion definitions
-t: assume text format; either "size" must be given or the
text data must be '\0' terminated
-b: assume binary format ('\0' separated, "\0\0" terminated)
-c: assume checksum protected environment format
addr: memory address to read from
size: length of input data; if missing, proper '\0'
termination is mandatory

- env default -f

reset default environment: drop all environment settings and load
default environment

- env ask name [message] [size]

same as "askenv": ask for environment variable

- env edit name

same as "editenv": edit environment variable

- env run

same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
initialization instead (eventually using several text files to
incrementally build it from common blocks) and a tool to convert it
into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
variables; this is needed for variable name auto-completion,
but it would also be nice to be able to say "printenv ip*" or
"printenv *addr*"

- Some boards don't link any more due to the grown code size:
DU405, canyonlands, sequoia, socrates.

=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Stefan Roese <sr@denx.de>,
Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>


# 91a76751 24-Jul-2010 Wolfgang Denk <wd@denx.de>

Make getenv() work before relocation.

So far, getenv() would work before relocation is most cases, even
though it was not intended to be used that way. When switching to a
hash table based implementation, this would break a number of boards.

For convenience, we make getenv() check if it's running before
relocation and, if so, use getenv_f() internally.

Note that this is limited to simple cases, as we use a small static
buffer (32 bytes) in the global data for this purpose.

For this reason, it is also not a good idea to convert all current
uses of getenv_f() into getenv() - some of the existing use cases need
to be able to deal with longer variable values, so getenv_f() is still
needed and recommended for use before relocation.

Signed-off-by: Wolfgang Denk <wd@denx.de>


# 819833af 12-Apr-2010 Peter Tyser <ptyser@xes-inc.com>

Move architecture-specific includes to arch/$ARCH/include/asm

This helps to clean up the include/ directory so that it only contains
non-architecture-specific headers and also matches Linux's directory
layout which many U-Boot developers are already familiar with.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>