platform/kernel/u-boot.git
4 years agoARM: dts: rename stm32mp15xx-avenger96 ethernet0_rgmii_pins
Patrick Delaunay [Mon, 6 Jul 2020 11:26:51 +0000 (13:26 +0200)]
ARM: dts: rename stm32mp15xx-avenger96 ethernet0_rgmii_pins

Alignment with pins name used in Linux kernel v5.8.

It is a preleminary step for device tree alignment.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoconfigs: stm32mp15: activate CMD_ADTIMG
Patrick Delaunay [Mon, 6 Jul 2020 13:00:46 +0000 (15:00 +0200)]
configs: stm32mp15: activate CMD_ADTIMG

Activate the support of the command adtimg to handle android images.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agophy: usbphyc: use regulator_set_enable_if_allowed for disabling vdd supply
Patrick Delaunay [Fri, 3 Jul 2020 17:13:02 +0000 (19:13 +0200)]
phy: usbphyc: use regulator_set_enable_if_allowed for disabling vdd supply

Use regulator_set_enable_if_allowed() api instead of regulator_set_enable()
while disabling vdd supply. This way the driver doesn't see an error
when disabling an always-on regulator.

This patch is needed since the commit f93fab312615 ("Revert 'power:
regulator: Return success on attempt to disable an always-on regulator'")
and use the API introduced by commit cc4a224af226 ("power: regulator:
Introduce regulator_set_enable_if_allowed api").

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoarm: stm32mp: stm32prog: check result of find_mmc_device
Patrick Delaunay [Mon, 6 Jul 2020 11:20:58 +0000 (13:20 +0200)]
arm: stm32mp: stm32prog: check result of find_mmc_device

Check result of find_mmc_device() before calling mmc_init().

This patch avoid a data abort when the command try to acces
to sd/mmc device deactivated in device tree.

Fixes: aff4c5dd8265 ("stm32mp: stm32prog: add MMC device")
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoboard: update test on misc_read result in board_late_init
Patrick Delaunay [Fri, 3 Jul 2020 15:45:07 +0000 (17:45 +0200)]
board: update test on misc_read result in board_late_init

Update management of misc_read, which now return length of data
after the commit 8729b1ae2cbd ("misc: Update read() and write()
methods to return bytes xfered")

Fixes: 8b8b3d6b55b9 ("stm32mp1: board: add environment variable for board id and board rev")

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoboard: dh_stm32mp1: remove env location override
Jakob Riepler [Mon, 27 Jul 2020 12:18:29 +0000 (14:18 +0200)]
board: dh_stm32mp1: remove env location override

Overriding the environment location is not necessary as the defconfig
for the relevant boards only enable SPI flash and nowhere sources which
are in the same order per default but having this explicit override
prevents using eMMC or SD card (or EXT4) as environment source.

Signed-off-by: Jakob Riepler <jakob.riepler@aviloo.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agostm32mp1: use the command env info -q in env_check
Patrick Delaunay [Thu, 2 Jul 2020 16:48:02 +0000 (18:48 +0200)]
stm32mp1: use the command env info -q in env_check

Activate the new option -q in command "env info"
to avoid unnecessary trace during boot.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoconfigs:stm32mp1: activate env config in SPL
Patrick Delaunay [Mon, 15 Jun 2020 09:18:24 +0000 (11:18 +0200)]
configs:stm32mp1: activate env config in SPL

Activate env config in SPL with CONFIG_SPL_ENV_SUPPORT
and use CONFIG_IS_ENABLED macro to test the activated
CONFIG_$(SPL_)ENV_IS_IN_... in env_get_location.

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agostm32mp1: use a specific SD/eMMC partition for U-Boot enviromnent
Patrick Delaunay [Mon, 15 Jun 2020 09:18:23 +0000 (11:18 +0200)]
stm32mp1: use a specific SD/eMMC partition for U-Boot enviromnent

Save the environment at the end of the U-Boot partition, the GPT
partition named "ssbl" in SD card or eMMC and avoid requirements
on the "bootfs" file system generated via specific raw tools
(like wic and genimage).

With the previous configuration of the U-Boot environment saved in ext4
file, U-Boot need to create/modify the file uenv.txt in the ext4 file
system; so this EXT4 file system need to be generated without some
functionality, like metadata_csum and dir_index, because they are not
supported by U-Boot.

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agostm32mp1: board: add support of CONFIG_ENV_IS_IN_MMC
Patrick Delaunay [Mon, 15 Jun 2020 09:18:22 +0000 (11:18 +0200)]
stm32mp1: board: add support of CONFIG_ENV_IS_IN_MMC

Add support of CONFIG_ENV_IS_IN_MMC in env_get_location, used for
all mmc device (SD card and eMMC).
The 2 configs CONFIG_ENV_IS_IN_MMC and CONFIG_ENV_IS_IN_EXT4 are
incompatible.

Add the weak function mmc_get_env_dev to select the mmc boot instance.

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agostm32mp1: mmu_set_region_dcache_behaviour
Patrick Delaunay [Fri, 24 Jul 2020 09:21:51 +0000 (11:21 +0200)]
stm32mp1: mmu_set_region_dcache_behaviour

Since commit d877f8fd0f09 ("arm: provide a function for boards init
code to modify MMU virtual-physical map") the parameter of
mmu_set_region_dcache_behaviour need to be MMU_SECTION_SIZE
aligned.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoarm: stm32mp: move dbgmcu_init call when DT is ready
Patrick Delaunay [Fri, 24 Jul 2020 09:13:31 +0000 (11:13 +0200)]
arm: stm32mp: move dbgmcu_init call when DT is ready

As the dbgmcu_init use the function bsec_dbgswenable which is based
on the DM and DT, its call can't be done before the spl is initialized
(driver model, DT and malloc) in board_init_f::spl_early_init().

This function call is moved later in spl_board_init().

Fixes: bd3f60d29c24 ("arm: stm32mp: protect DBGMCU_IDC access with BSEC")

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoPrepare v2020.10-rc1
Tom Rini [Tue, 28 Jul 2020 02:46:03 +0000 (22:46 -0400)]
Prepare v2020.10-rc1

Signed-off-by: Tom Rini <trini@konsulko.com>
4 years agoMerge tag 'u-boot-amlogic-20200727' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Tue, 28 Jul 2020 01:40:26 +0000 (21:40 -0400)]
Merge tag 'u-boot-amlogic-20200727' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic

- Handle errors in Meson serial driver
- Enable HDMI, keyboard and ADC for Odroid-C2

4 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
Tom Rini [Mon, 27 Jul 2020 19:18:15 +0000 (15:18 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq

- Bug fixes and updates on ls2088a,ls1028a, ls1046a, ls1043a, ls1012a
- lx2-watchdog support
- layerscape: pci-endpoint support, spin table relocation fixes and
  cleanups
- fsl-crypto: RNG support and bug fixes

4 years agotravis: Install pyelftools via pip
Tom Rini [Mon, 27 Jul 2020 15:11:27 +0000 (11:11 -0400)]
travis: Install pyelftools via pip

With the migration to python3 for all of our tests, we need to install
pyelftools via pip now rather than the system tools as they will
otherwise not be present in our virtualenv.

Signed-off-by: Tom Rini <trini@konsulko.com>
---
Changes in v2: Switch to pip

4 years agoMerge tag 'dm-pull-20jul20-take2a' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Mon, 27 Jul 2020 15:15:37 +0000 (11:15 -0400)]
Merge tag 'dm-pull-20jul20-take2a' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm

binman support for FIT
new UCLASS_SOC
patman switch 'test' command
minor fdt fixes
patman usability improvements

4 years agoconfigs: odroid-c2: update for HDMI output, ADC & USB keyboard
Anand Moon [Thu, 23 Jul 2020 08:06:35 +0000 (08:06 +0000)]
configs: odroid-c2: update for HDMI output, ADC & USB keyboard

Enable options to permit HDMI output on Odroid-C2 GXBB boards.
Enable VPU Power Domain.
Enable ADC and USB_KERBOARD.

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
4 years agoserial: meson: handle RX errors
Neil Armstrong [Tue, 21 Jul 2020 11:41:14 +0000 (13:41 +0200)]
serial: meson: handle RX errors

This checks and handles RX errors on the Amlogic UART controller
after experiencing errors on the Khadas VIM3 & VIM3L when UART AO A
lines are not connected.

When the RX line is not connected, the first byte is erroneous and breaks
the U-Boot autoboot, breaking automatic boot.

This checks and drops any erroneous RX byte on pending and getc callbacks
to avoid returning true to pending when an error byte is in the FIFO.

Fixes: bfcef28ae4 ("arm: add initial support for Amlogic Meson and ODROID-C2")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Guillaume La Roque <glaroque@baylibre.com>
4 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-sh
Tom Rini [Mon, 27 Jul 2020 13:41:18 +0000 (09:41 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-sh

- R8A774A1 / Beacon EmbeddedWorks RZG2M Dev Kit support

4 years agoMerge branch 'net' of https://gitlab.denx.de/u-boot/custodians/u-boot-sh
Tom Rini [Mon, 27 Jul 2020 13:40:06 +0000 (09:40 -0400)]
Merge branch 'net' of https://gitlab.denx.de/u-boot/custodians/u-boot-sh

- Convert dc2114x driver to DM.

4 years agoMerge branch '2020-07-27-misc-env-improvements'
Tom Rini [Mon, 27 Jul 2020 13:25:53 +0000 (09:25 -0400)]
Merge branch '2020-07-27-misc-env-improvements'

- Assorted environment fixes.
- Enhance environment in MMC and controlled via OF_CONTROL
- Allow for environment in FAT to use the same device we boot from
  rather than be hard-coded.

4 years agoconfigs: ls2088a: Restore CONFIG_ENV_ADDR to IFC-NOR
Kuldeep Singh [Wed, 22 Jul 2020 09:35:44 +0000 (15:05 +0530)]
configs: ls2088a: Restore CONFIG_ENV_ADDR to IFC-NOR

Restore CONFIG_ENV_ADDR value to fix boot hang with IFC-NOR
which is default boot source.

Signed-off-by: Ashish Kumar <ashish.kumar@nxp.com>
Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarm: dts: ls1028a: Add dspi flash device node to qds
Zhao Qiang [Tue, 14 Jul 2020 05:53:36 +0000 (13:53 +0800)]
arm: dts: ls1028a: Add dspi flash device node to qds

Add dspi flash device node to fsl-ls1028a-qds.dtsi

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoconfigs: lx2160a: Enable Watchdog support
Zhao Qiang [Fri, 10 Jul 2020 08:55:20 +0000 (16:55 +0800)]
configs: lx2160a: Enable Watchdog support

Enable support to compile SBSA driver.

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarm64: lx2160a: dts: Add watchdog node
Zhao Qiang [Fri, 10 Jul 2020 08:55:19 +0000 (16:55 +0800)]
arm64: lx2160a: dts: Add watchdog node

Add watchdog node which is sbsa into lx2160a dtsi

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoWatchdog: introduce ARM SBSA watchdog driver
Zhao Qiang [Fri, 10 Jul 2020 08:55:18 +0000 (16:55 +0800)]
Watchdog: introduce ARM SBSA watchdog driver

According to Server Base System Architecture (SBSA) specification,
the SBSA Generic Watchdog has two stage timeouts: the first signal
(WS0) is for alerting the system by interrupt, the second one (WS1) is a
real hardware reset.
More details about the hardware specification of this device:
ARM DEN0029B - Server Base System Architecture (SBSA)

This driver can operate ARM SBSA Generic Watchdog as a single stage
In the single stage mode, when the timeout is reached, your system
will be reset by WS1. The first signal (WS0) is ignored.

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci: layerscape: Add specific config entry for RC and EP mode driver
Hou Zhiqiang [Thu, 9 Jul 2020 15:31:42 +0000 (23:31 +0800)]
pci: layerscape: Add specific config entry for RC and EP mode driver

Add Root Complex and Endpoint mode specific config entries, such that
it's feasible to enable the RC and/or EP mode driver indepently.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci_ep: layerscape: Add the PCIe EP mode support for lx2160a-v2
Xiaowei Bao [Thu, 9 Jul 2020 15:31:41 +0000 (23:31 +0800)]
pci_ep: layerscape: Add the PCIe EP mode support for lx2160a-v2

Add the PCIe EP mode support for lx2160a-v2 platform.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci: layerscape: Modify the ls_pcie_dump_atu function
Xiaowei Bao [Thu, 9 Jul 2020 15:31:40 +0000 (23:31 +0800)]
pci: layerscape: Modify the ls_pcie_dump_atu function

Modify the ls_pcie_dump_atu function, make it can print the INBOUND
windows registers.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci_ep: layerscape: Add the SRIOV VFs of PF support
Xiaowei Bao [Thu, 9 Jul 2020 15:31:39 +0000 (23:31 +0800)]
pci_ep: layerscape: Add the SRIOV VFs of PF support

Add the INBOUND configuration for VFs of PF.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci_ep: layerscape: Add Support for ls2085a and ls2080a EP mode
Xiaowei Bao [Thu, 9 Jul 2020 15:31:38 +0000 (23:31 +0800)]
pci_ep: layerscape: Add Support for ls2085a and ls2080a EP mode

Due to the ls2085a and ls2080a use different way to set the BAR size,
so add the BAR size init code here.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci_ep: layerscape: Add the workaround for errata A-009460
Xiaowei Bao [Thu, 9 Jul 2020 15:31:37 +0000 (23:31 +0800)]
pci_ep: layerscape: Add the workaround for errata A-009460

The VF_BARn_REG register's Prefetchable and Type bit fields
are overwritten by a write to VF's BAR Mask register.
workaround: Before writing to the VF_BARn_MASK_REG register,
write 0b to the PCIE_MISC_CONTROL_1_OFF register.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopcie_ep: layerscape: Add the multiple function support
Xiaowei Bao [Thu, 9 Jul 2020 15:31:36 +0000 (23:31 +0800)]
pcie_ep: layerscape: Add the multiple function support

Add the multiple function support for Layerscape platform, some PEXs
of Layerscaple platform have more than one PF.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: dts: ls1046a: Add the PCIe EP node
Xiaowei Bao [Thu, 9 Jul 2020 15:31:35 +0000 (23:31 +0800)]
armv8: dts: ls1046a: Add the PCIe EP node

Add the PCIe EP node for ls1046a.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci_ep: Add the init function
Xiaowei Bao [Thu, 9 Jul 2020 15:31:34 +0000 (23:31 +0800)]
pci_ep: Add the init function

Some EP deivces need to initialize before RC scan it, e.g. NXP
layerscape platform, so add the init function in pci_ep uclass.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agopci: layerscape: Split the EP and RC driver
Xiaowei Bao [Thu, 9 Jul 2020 15:31:33 +0000 (23:31 +0800)]
pci: layerscape: Split the EP and RC driver

Split the RC and EP driver, and reimplement the EP driver base on
the EP framework.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarm: dts: lx2160a: Increase configuration window size
Wasim Khan [Thu, 9 Jul 2020 08:51:08 +0000 (14:21 +0530)]
arm: dts: lx2160a: Increase configuration window size

lx2160a rev2 requires 4KB space for type0 and 4KB
space for type1 iATU window. Increase configuration
size to 8KB to have sufficient space for type0
and type1 window.

Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoconfigs:ls1046afrwy: Add tfa secure boot defonfig
Manish Tomar [Wed, 8 Jul 2020 09:25:03 +0000 (14:55 +0530)]
configs:ls1046afrwy: Add tfa secure boot defonfig

Add TFA secure boot defconfig and Enables secure boot related
configs in it.

Signed-off-by: Manish Tomar <manish.tomar@nxp.com>
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agofreescale: ls1043aqds: drop ifdef CONFIG_SYS_I2C
Biwen Li [Thu, 2 Jul 2020 03:13:04 +0000 (11:13 +0800)]
freescale: ls1043aqds: drop ifdef CONFIG_SYS_I2C

- Drop ifdef CONFIG_SYS_I2C to initialize
  baudrate of i2c

- Drop warning of i2c_early_init_f as follows,
  warning: implicit declaration of function 'i2c_early_init_f'; did you
  mean 'arch_early_init_r'? [-Wimplicit-function-declaration]

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agofreescale: ls1043aqds: enable secure system counter
Biwen Li [Thu, 2 Jul 2020 03:13:03 +0000 (11:13 +0800)]
freescale: ls1043aqds: enable secure system counter

Enable secure system counter in board_early_init_f for udelay()
to fix a bug that always return 0 by timer_read_counter()
when boot from qspi(No TFA)

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agofreescale: ls1046aqds: drop ifdef CONFIG_SYS_I2C
Biwen Li [Thu, 2 Jul 2020 03:13:02 +0000 (11:13 +0800)]
freescale: ls1046aqds: drop ifdef CONFIG_SYS_I2C

- Drop ifdef CONFIG_SYS_I2C to initialize
  baudrate of i2c

- Drop warning of i2c_early_init_f as follows,
  warning: implicit declaration of function 'i2c_early_init_f'; did you
  mean 'arch_early_init_r'? [-Wimplicit-function-declaration]

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agofreescale: ls1046aqds: enable secure system counter
Biwen Li [Thu, 2 Jul 2020 03:13:01 +0000 (11:13 +0800)]
freescale: ls1046aqds: enable secure system counter

Enable secure system counter in board_early_init_f for udelay()
to fix a bug that always return 0 by timer_read_counter()
when boot from qspi(No TFA)

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoi2c: mxc: move i2c_early_init_f to common function
Biwen Li [Thu, 2 Jul 2020 03:13:00 +0000 (11:13 +0800)]
i2c: mxc: move i2c_early_init_f to common function

Move i2c_early_init_f to common function
to initialize baudrate of i2c

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: add RNG support
Michael Walle [Sat, 27 Jun 2020 20:58:53 +0000 (22:58 +0200)]
crypto/fsl: add RNG support

Register the random number generator with the rng subsystem in u-boot.
This way it can be used by EFI as well as for the 'rng' command.

Signed-off-by: Michael Walle <michael@walle.cc>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: instantiate the RNG with prediciton resistance
Michael Walle [Sat, 27 Jun 2020 20:58:52 +0000 (22:58 +0200)]
crypto/fsl: instantiate the RNG with prediciton resistance

If it is already instantiated tear it down first and then reinstanciate
it again with prediction resistance.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: don't regenerate secure keys
Michael Walle [Sat, 27 Jun 2020 20:58:51 +0000 (22:58 +0200)]
crypto/fsl: don't regenerate secure keys

The secure keys (TDKEK, JDKEK, TDSK) can only be generated once after a
POR. Otherwise the RNG4 will throw an error.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: support newer SEC modules
Michael Walle [Sat, 27 Jun 2020 20:58:50 +0000 (22:58 +0200)]
crypto/fsl: support newer SEC modules

Since Era 10, the version registers changed. Add the version registers
and use them on newer modules.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: export caam_get_era()
Michael Walle [Sat, 27 Jun 2020 20:58:49 +0000 (22:58 +0200)]
crypto/fsl: export caam_get_era()

We need the era in other modules, too. For example, to get the RNG
version.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: make SEC%u status line consistent
Michael Walle [Sat, 27 Jun 2020 20:58:48 +0000 (22:58 +0200)]
crypto/fsl: make SEC%u status line consistent

Align the status line with all the other output in U-Boot.

Before the change:
DDR    3.9 GiB (DDR3, 32-bit, CL=11, ECC on)
SEC0: RNG instantiated
WDT:   Started with servicing (60s timeout)

After the change:
DDR    3.9 GiB (DDR3, 32-bit, CL=11, ECC on)
SEC0:  RNG instantiated
WDT:   Started with servicing (60s timeout)

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: unused value in caam_hash_update()
Heinrich Schuchardt [Sat, 27 Jun 2020 08:13:55 +0000 (10:13 +0200)]
crypto/fsl: unused value in caam_hash_update()

The value 0 assigned to final is overwritten before ever being used.

Remove the assignment.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: correct printf() statement.
Heinrich Schuchardt [Sat, 27 Jun 2020 08:08:49 +0000 (10:08 +0200)]
crypto/fsl: correct printf() statement.

The sequence of arguments should match the format string.
For printing unsigned numbers we should use %u.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarm64: ls1043a: Remove the workaround of erratum A-009929
Hou Zhiqiang [Thu, 25 Jun 2020 14:23:53 +0000 (22:23 +0800)]
arm64: ls1043a: Remove the workaround of erratum A-009929

The workaround has been implemented in PBI phase, so remove
the duplicated implementation from U-Boot.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoconfigs: ls1012a: Increase CONFIG_SYS_MALLOC_LEN value
Kuldeep Singh [Thu, 25 Jun 2020 07:26:22 +0000 (12:56 +0530)]
configs: ls1012a: Increase CONFIG_SYS_MALLOC_LEN value

Previous attempt to increase CONFIG_SYS_MALLOC_LEN was done in commit
c084a8edf4e2 ("configs: ls1012a: Increase CONFIG_SYS_MALLOC_LEN size")
which increased malloc memory to ~1M.

PFE firmware alone requires 3M of dynamic memory allocation and
therefore, increase the config value to a larger value i.e 5M. This size
should be enough as of now to accommodate further memory requirements.

Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoconfigs: lx2160aqds: enable CONFIG_BOARD_EARLY_INIT_R
Yangbo Lu [Wed, 17 Jun 2020 10:09:00 +0000 (18:09 +0800)]
configs: lx2160aqds: enable CONFIG_BOARD_EARLY_INIT_R

Enable CONFIG_BOARD_EARLY_INIT_R for SDHC adapter card
identification and configuration.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoboard: fsl: lx2160aqds: identify SDHC adapter during board init
Yangbo Lu [Wed, 17 Jun 2020 10:08:59 +0000 (18:08 +0800)]
board: fsl: lx2160aqds: identify SDHC adapter during board init

Add support for SDHC adapter identification and configuration
during board init.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoMove eSDHC adapter card identification to board files
Yangbo Lu [Wed, 17 Jun 2020 10:08:58 +0000 (18:08 +0800)]
Move eSDHC adapter card identification to board files

The eSDHC adapter card identification and multiplexing configuration
through FPGA had been implemented in both common mmc driver and
fsl_esdhc driver. However it is proper to move these code to board
files and do it during board initialization. The FPGA registers are
also board specific.

This patch is to move eSDHC adapter card identification and
multiplexing configuration from mmc driver to specific board files.
And the option CONFIG_FSL_ESDHC_ADAPTER_IDENT is no longer needed.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
[Rebased, Removed T1040QDS change as board does not exist]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoDrop global data sdhc_adapter for powerpc
Yangbo Lu [Wed, 17 Jun 2020 10:08:57 +0000 (18:08 +0800)]
Drop global data sdhc_adapter for powerpc

The sdhc_adapter of global data has not been used, and we
do not have to use it as global data even we may need it
in the future.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: ls1028ardb: add xspi parameter to qixis command
Yuantian Tang [Wed, 10 Jun 2020 08:13:50 +0000 (16:13 +0800)]
armv8: ls1028ardb: add xspi parameter to qixis command

Add xspi boot source to qixis command to let the soc boot from
flex-nor flash chip.

Signed-off-by: Yuantian Tang <andy.tang@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: ls1012a: RGMII ports require internal delay
Chaitanya Sakinam [Tue, 9 Jun 2020 10:51:48 +0000 (16:21 +0530)]
armv8: ls1012a: RGMII ports require internal delay

The correct setting for the RGMII ports on LS1012ARDB is to
enable delay on both Rx and Tx so the interface mode used should
be PHY_INTERFACE_MODE_RGMII_ID

Signed-off-by: Chaitanya Sakinam <chaitanya.sakinam@nxp.com>
Signed-off-by: Anji J <anji.jagarlmudi@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoinclude/configs: ls1012a: Remove fdt_high env variable
Udit Agarwal [Mon, 8 Jun 2020 13:25:44 +0000 (18:55 +0530)]
include/configs: ls1012a: Remove fdt_high env variable

Remove "fdt_high" environment variable to use the bootm_size
to safely contain a kernel, device tree and initrd for
relocation.

Signed-off-by: Udit Agarwal <udit.agarwal@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoconfig: lx2160/2a: enable dspi
Zhao Qiang [Mon, 8 Jun 2020 03:28:25 +0000 (11:28 +0800)]
config: lx2160/2a: enable dspi

Enable dspi in lx2160aqds tfa defconfig
Enable CONFIG_SPI_FLASH_SST/EON in config file.

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: dts: fsl-lx2160a: add flash node under dspi to qds dts
Zhao Qiang [Mon, 8 Jun 2020 03:28:24 +0000 (11:28 +0800)]
armv8: dts: fsl-lx2160a: add flash node under dspi to qds dts

Add flash node under dspi into fsl-lx2160a-qds.dtsi

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agocrypto/fsl: fix unaligned access
Michael Walle [Thu, 4 Jun 2020 19:05:33 +0000 (21:05 +0200)]
crypto/fsl: fix unaligned access

On aarch64 running with dcache off, will result in an unaligned access
exception:

   => dcache off
   => hash sha1 $kernel_addr_r 100
   "Synchronous Abort" handler, esr 0x96000061
   elr: 00000000960317d8 lr : 00000000960316a4 (reloc)
   elr: 00000000fbd787d8 lr : 00000000fbd786a4
   [..]

The compiler emits a "stur x1, [x0, #12]". x1 is might just be 32 bit
aligned pointer. Remove the unused u64 element from the union to drop
the minimal alignment to 32 bit. Also remove the union, because it is
no more needed.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoI2C: ls1043a, ls1046a: enable SYS_I2C_MXC
Biwen Li [Thu, 4 Jun 2020 10:42:14 +0000 (18:42 +0800)]
I2C: ls1043a, ls1046a: enable SYS_I2C_MXC

This enables SYS_I2C_MXC to fix a bug that
failed to boot from sd card with
image u-boot-with-spl-pbl.bin

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: rework spin table
Michael Walle [Mon, 1 Jun 2020 19:53:36 +0000 (21:53 +0200)]
armv8: layerscape: rework spin table

There are two issues:

 (1) The spin table doesn't convert the endianness of the jump address.
     Although there is code for it, the result isn't used at all (x0).
 (2) If something goes wrong, the function returns. But that doesn't
     make sense at all.

Use the actual converted jump address as destination to fix. If
there is an error, jump to a trap loop. And rearrange the code exception
level switching code to make it smaller and clearer.

This reduces the size of the spin table code section from 696 bytes to
424 bytes. If CONFIG_ARMV8_SWITCH_TO_EL1 the code size reduced from 696
bytes to 632 bytes.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: relocate spin table if EFI_LOADER is enabled
Michael Walle [Mon, 1 Jun 2020 19:53:35 +0000 (21:53 +0200)]
armv8: layerscape: relocate spin table if EFI_LOADER is enabled

On ARM64, a 64kb region is reserved for the runtime services code.
Unfortunately, this code overlaps with the spin table code, which also
needs to be reserved. Thus now that the code is relocatable, allocate a
new page from EFI, copy the spin table code into it, update any pointers
to the old region and the start the secondary CPUs.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: clean exported symbols in spintable.S
Michael Walle [Mon, 1 Jun 2020 19:53:34 +0000 (21:53 +0200)]
armv8: layerscape: clean exported symbols in spintable.S

Add a new variable secondary_boot_code_start, which holds a pointer to
the start of the spin table code. This will help to relocate the code
section. While at it, move the size variable from the end to the
beginning so there is a common section for the variables. Remove any
other symbols.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: drop first .ltorg directive in spintable.S
Michael Walle [Mon, 1 Jun 2020 19:53:33 +0000 (21:53 +0200)]
armv8: layerscape: drop first .ltorg directive in spintable.S

Now that the spin table is in a separate module, this is no longer
necessary. Drop it.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: make wake_secondary_core_n() static
Michael Walle [Mon, 1 Jun 2020 19:53:32 +0000 (21:53 +0200)]
armv8: layerscape: make wake_secondary_core_n() static

This function is not used outside the module. Make it static.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: simplify get_spin_tbl_addr() calls
Michael Walle [Mon, 1 Jun 2020 19:53:31 +0000 (21:53 +0200)]
armv8: layerscape: simplify get_spin_tbl_addr() calls

There is no need to cast around. Assign the address to the local
variable and use it.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: remove determine_mp_bootpg()
Michael Walle [Mon, 1 Jun 2020 19:53:30 +0000 (21:53 +0200)]
armv8: layerscape: remove determine_mp_bootpg()

Only the PowerPC architecture needs this function. Remove it.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: fix alignment for spin table
Michael Walle [Mon, 1 Jun 2020 19:53:29 +0000 (21:53 +0200)]
armv8: layerscape: fix alignment for spin table

Fix the alignment so it will match the comments. The spin table has to
be 8 byte aligned, so ".align 3" is enough.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: load function pointer using ADR
Michael Walle [Mon, 1 Jun 2020 19:53:28 +0000 (21:53 +0200)]
armv8: layerscape: load function pointer using ADR

Don't use LDR to load a pointer to a function. This will generate a
literal which cannot be relocated. Use ADR which is PC-relative and
therefore can easily be relocated.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: move spin table into own module
Michael Walle [Mon, 1 Jun 2020 19:53:27 +0000 (21:53 +0200)]
armv8: layerscape: move spin table into own module

Move it out of lowlevel.S into spintable.S. On layerscape, the secondary
CPUs are brought up in main u-boot. This will make it possible to only
compile the spin table code for the main u-boot and omit it in SPL.

This saves about 720 bytes in the SPL.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: properly use CPU_RELEASE_ADDR
Michael Walle [Mon, 1 Jun 2020 19:53:26 +0000 (21:53 +0200)]
armv8: layerscape: properly use CPU_RELEASE_ADDR

The generic armv8 code already has support to bring up the secondary
cores. Thus, don't hardcode the jump in the layerscape lowlevel_init to
the spin table code; instead just return early and let the common armv8
code handle the jump. This way we can actually use the CPU_RELEASE_ADDR
feature.

Signed-off-by: Michael Walle <michael@walle.cc>
[Rebased, Removed kontron_sl28.h change as file does not exist]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: pretty print info about SMP cores
Michael Walle [Mon, 1 Jun 2020 19:53:25 +0000 (21:53 +0200)]
armv8: layerscape: pretty print info about SMP cores

Make the print of the starting address a debug output and pretty print
the info about online cores.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: layerscape: fix spin-table support
Michael Walle [Mon, 1 Jun 2020 19:53:24 +0000 (21:53 +0200)]
armv8: layerscape: fix spin-table support

Spin tables are broken with bootefi. This is because - in contrast to
the booti call chain - there is no call to smp_kick_all_cpus(). Due to
this missing call the secondary CPUs are never released from their "wait
for interrupt state", see secondary_boot_func() in lowlevel.S.

Originally, this "wait for interrupt" is there to make sure, the spin
table is cleared before the secondary cores read it for the first time.
But the boot flow for the layerscape architecture is different from
that. The CPUs are release from their BootROM _after_ U-Boot's
spin-table is cleared, see fsl_layerscape_wake_seconday_cores() in mp.c.
Thus, there is no need to wait for this interrupt and no need for
kicking all cores on cpu_release. An atomic 64bit write to the
spin-table and a "sev" is sufficient.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agonet: pfe_eth: Use spi_flash_read API to access flash memory
Kuldeep Singh [Thu, 28 May 2020 06:12:53 +0000 (11:42 +0530)]
net: pfe_eth: Use spi_flash_read API to access flash memory

Current PFE firmware access spi-nor memory directly. New spi-mem
framework does not support direct memory access. So, let's use
spi_flash_read API to access memory instead of directly using it.

Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agodm: armv8: gpio: include <asm/arch/gpio.h> for fsl-layerscape
hui.song [Wed, 20 May 2020 10:40:19 +0000 (18:40 +0800)]
dm: armv8: gpio: include <asm/arch/gpio.h> for fsl-layerscape

Enable the gpio feature on fsl-layerscape platform.

Signed-off-by: hui.song <hui.song_1@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: gpio: add gpio feature
hui.song [Wed, 20 May 2020 10:40:18 +0000 (18:40 +0800)]
armv8: gpio: add gpio feature

add one struct mpc8xxx_gpio_plat to enable gpio feature.

Signed-off-by: hui.song <hui.song_1@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoconfigs: ls1088ardb: Add support for usb boot target
Era Tiwari [Fri, 15 May 2020 07:18:39 +0000 (12:48 +0530)]
configs: ls1088ardb: Add support for usb boot target

LS1088A-RDB has MMC, SCSI, DHCP as boot targets,
but the USB support was missing.
Add support for USB as Boot_targets_devices.

Signed-off-by: Era Tiwari <era.tiwari@nxp.com>
Signed-off-by: Pramod Kumar <pramod.kumar_1@nxp.com>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agoarmv8: ls1028a: move FSL_LAYERSCAPE to kconfig
Michael Walle [Sat, 9 May 2020 23:20:11 +0000 (01:20 +0200)]
armv8: ls1028a: move FSL_LAYERSCAPE to kconfig

CONFIG_FSL_LAYERSCAPE is available in kconfig. There is no need to
define it per board; the ls1028a_common.h is really board dependent and
only fits to the NXP eval boards. Instead select CONFIG_FSL_LAYERSCAPE
when ARCH_LS1028A is selected.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agofsl_dspi: Introduce DT bindings for CS-SCK and SCK-CS delays
Vladimir Oltean [Mon, 4 May 2020 08:24:26 +0000 (11:24 +0300)]
fsl_dspi: Introduce DT bindings for CS-SCK and SCK-CS delays

Communication with some SPI slaves just won't cut it if these delays
(before the beginning, and after the end of a transfer) are not added to
the Chip Select signal.

These are a straight copy from Linux:
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt
drivers/spi/spi-fsl-dspi.c

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
4 years agobinman: Re-enable concurrent tests
Simon Glass [Fri, 10 Jul 2020 00:39:34 +0000 (18:39 -0600)]
binman: Re-enable concurrent tests

With the change to absolute imports the concurrent tests feature
unfortunately broke. Fix it.

We cannot easy add a warning, since the output messes up tests which check
the output.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Don't change the descriptor in tests
Simon Glass [Sat, 25 Jul 2020 21:11:19 +0000 (15:11 -0600)]
binman: Don't change the descriptor in tests

At present testPackX86RomMeNoDesc removes the contents of the
descriptor.bin file and testPackX86RomMeMissingDesc removes the file
completely.

If a test that relies on this file happens to run after it is removed, it
will not work. Since we have no control over the selecting of tests that
run in parallel and series, we must avoid changing the files.

Update this tests to use separate files instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agoenv: mmc: add redundancy support in mmc_offset_try_partition
Patrick Delaunay [Mon, 15 Jun 2020 08:38:57 +0000 (10:38 +0200)]
env: mmc: add redundancy support in mmc_offset_try_partition

Manage 2 copy at the end of the partition selected by config
"u-boot,mmc-env-partition" to save the U-Boot environment,
with CONFIG_ENV_SIZE and 2*CONFIG_ENV_SIZE offset.

This patch allows to support redundancy (CONFIG_ENV_OFFSET_REDUND).

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoenv: mmc: correct the offset returned by mmc_offset_try_partition
Patrick Delaunay [Mon, 15 Jun 2020 08:38:56 +0000 (10:38 +0200)]
env: mmc: correct the offset returned by mmc_offset_try_partition

The output of the function mmc_offset_try_partition must be a
byte offset in mmc and not a multiple of blksz.

This function is used in mmc_offset(), called by mmc_get_env_addr()
and the offset is used in write_env(), erase_env() and read_env().

In these function, blk_start = offset / mmc->read_bl_len
or /write_bl_len so this offset is not a multiple of blksz.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoenv: mmc: allow support of mmc_get_env_dev with OF_CONTROL
Patrick Delaunay [Mon, 15 Jun 2020 08:38:55 +0000 (10:38 +0200)]
env: mmc: allow support of mmc_get_env_dev with OF_CONTROL

Use the weak function mmc_get_env_dev in mmc_offset_try_partition
function to allow dynamic selection of mmc device to use
and no more use directly the define CONFIG_SYS_MMC_ENV_DEV.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agotest: env: add test for env info sub-command
Patrick Delaunay [Fri, 19 Jun 2020 12:03:37 +0000 (14:03 +0200)]
test: env: add test for env info sub-command

Add a pytest for testing the env info sub-command:

test_env_info: test command with several option that
can be executed on real hardware device without assumption

test_env_info_sandbox: test the result on sandbox
with a known ENV configuration: ready & default & persistent

The quiet option '-q' is used for support in shell test;
for example:
  if env info -p -d -q; then env save; fi

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
4 years agoconfigs: sandbox: Enable sub command 'env info'
Patrick Delaunay [Fri, 19 Jun 2020 12:03:36 +0000 (14:03 +0200)]
configs: sandbox: Enable sub command 'env info'

Enable support for sub command 'env info' in sandbox
with CONFIG_CMD_NVEDIT_INFO. This is aimed primarily
at adding unit test.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agocmd: env: check real location for env info command
Patrick Delaunay [Fri, 19 Jun 2020 12:03:35 +0000 (14:03 +0200)]
cmd: env: check real location for env info command

Check the current ENV location, dynamically provided by the weak
function env_get_location to be sure that the environment can be
persistent.

The compilation flag ENV_IS_IN_DEVICE is not enough when the board
dynamically select the available storage location (according boot
device for example).

This patch solves issue for stm32mp1 platform, when the boot device
is USB.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
4 years agocmd: env: add option for quiet output on env info
Patrick Delaunay [Fri, 19 Jun 2020 12:03:34 +0000 (14:03 +0200)]
cmd: env: add option for quiet output on env info

The "env info" can be use for test with -d and -p parameter,
in scripting case the output of the command is not needed.

This patch allows to deactivate this output with a new option "-q".

For example, we can save the environment if default
environment is used and persistent storage is managed with:
  if env info -p -d -q; then env save; fi

Without the quiet option, I have the unnecessary traces
First boot:
      Default environment is used
      Environment can be persisted
      Saving Environment to EXT4... File System is consistent

Next boot:
      Environment was loaded from persistent storage
      Environment can be persisted

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
4 years agoenv: add failing trace in env_save
Patrick Delaunay [Wed, 24 Jun 2020 08:17:50 +0000 (10:17 +0200)]
env: add failing trace in env_save

Add trace in env save to indicate any errors to end user and avoid
silent output when the command 'env save' is not executed.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoenv: correct overflow check of env_has_init size
Patrick Delaunay [Wed, 24 Jun 2020 07:27:25 +0000 (09:27 +0200)]
env: correct overflow check of env_has_init size

Correct the overflow check of the bit-field env_has_init with
the max value of env_location= ENVL_COUNT and no more with the
size of env_locations.

This bit-field is indexed by this enumerate and not by the position in
the env_locations (only used in env_get_location) and the
2 values are different, depending of thea ctivated CONFIG_ENV_IS_ options.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoenv/fat.c: allow loading from a FAT partition on the MMC boot device
David Woodhouse [Fri, 19 Jun 2020 22:07:17 +0000 (23:07 +0100)]
env/fat.c: allow loading from a FAT partition on the MMC boot device

I don't want to have to specify the device; only the partition.

This allows me to use the same image on internal eMMC or SD card for
Banana Pi R2, and it finds its own environment either way.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
[trini: Add #if/#else/#endif logic around CONFIG_SYS_MMC_ENV_DEV usage,
        whitespace changes]
Signed-off-by: Tom Rini <trini@konsulko.com>
4 years agotreewide: convert devfdt_get_addr() to dev_read_addr()
Masahiro Yamada [Fri, 17 Jul 2020 05:36:48 +0000 (14:36 +0900)]
treewide: convert devfdt_get_addr() to dev_read_addr()

When you enable CONFIG_OF_LIVE, you will end up with a lot of
conversions.

To generate this commit, I used coccinelle excluding drivers/core/,
include/dm/, and test/

The semantic patch that makes this change is as follows:

  <smpl>
  @@
  expression dev;
  @@
  -devfdt_get_addr(dev)
  +dev_read_addr(dev)
  </smpl>

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agotreewide: remove (phys_addr_t) casts from devfdt_get_addr()
Masahiro Yamada [Fri, 17 Jul 2020 05:36:47 +0000 (14:36 +0900)]
treewide: remove (phys_addr_t) casts from devfdt_get_addr()

This cast is unneeded.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agotreewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()
Masahiro Yamada [Fri, 17 Jul 2020 05:36:46 +0000 (14:36 +0900)]
treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()

Use the _ptr suffixed variant instead of casting. Also, convert it to
dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE.

One curious part is an error check like follows in
drivers/watchdog/omap_wdt.c:

    priv->regs = (struct wd_timer *)devfdt_get_addr(dev);
    if (!priv->regs)
            return -EINVAL;

devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error.
So, this code does not catch any error in DT parsing.

dev_read_addr_ptr() returns NULL on error, so this error check
will work.

I generated this commit by the following command:

 $ find . -name .git -prune -o -name '*.[ch]' -type f -print | \
   xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/'

I manually fixed drivers/usb/host/ehci-mx6.c

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agofdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts()
Masahiro Yamada [Fri, 17 Jul 2020 01:46:19 +0000 (10:46 +0900)]
fdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts()

Currently, fdt_fixup_mtdparts() only checks the compatible property.
It is pointless to fix up the disabled node.

Skip the node if it has the property:

  status = "disabled"

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>