platform/kernel/u-boot.git
3 years agoMerge tag 'video-for-v2021.04-rc3' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Mon, 22 Feb 2021 14:11:27 +0000 (09:11 -0500)]
Merge tag 'video-for-v2021.04-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-video

 - splash_source warning fix when building with 64-bit toolchains
 - lq123p1jx31 and nv101wxmn51 compatible in simple panel driver
 - remove not used mb862xx driver
 - add Himax HX8238D panel driver
 - s/video_uc_platdata/video_uc_plat/

3 years agoMerge branch '2021-02-21-mpc83xx-updates'
Tom Rini [Mon, 22 Feb 2021 14:06:36 +0000 (09:06 -0500)]
Merge branch '2021-02-21-mpc83xx-updates'

- mpc8379erdb DM_MMC conversion
- kmeter1 updates
- qe_uec fixes

3 years agouec.h: fix COFIG_DM typo
Rasmus Villemoes [Mon, 5 Oct 2020 13:15:18 +0000 (15:15 +0200)]
uec.h: fix COFIG_DM typo

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agodm_qe_uec.c: fix indentation in uec_set_mac_if_mode()
Rasmus Villemoes [Mon, 5 Oct 2020 13:15:17 +0000 (15:15 +0200)]
dm_qe_uec.c: fix indentation in uec_set_mac_if_mode()

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agomdio-uclass.c: support fixed-link subnodes
Rasmus Villemoes [Mon, 5 Oct 2020 13:15:16 +0000 (15:15 +0200)]
mdio-uclass.c: support fixed-link subnodes

When trying to port our mpc8309-based board to DM_ETH, on top of
Heiko's patches, I found that nothing in mdio-uclass.c seems to
support the use of a fixed-link subnode of the ethernet DT node. That
is, the ethernet node looks like

enet0: ethernet@2000 {
device_type = "network";
compatible = "ucc_geth";
...
fixed-link {
reg = <0xffffffff>;
speed = <100>;
full-duplex;
};

but the current code expects there to be phy-handle property. Adding
that, i.e.

phy-handle = <&enet0phy>;
enet0phy: fixed-link {

just makes the code break a few lines later since a fixed-link node
doesn't have a reg property. Ignoring the dtc complaint and adding a
dummy reg property, we of course hit "can't find MDIO bus for node
ethernet@2000" since indeed, the parent node of the phy node does not
represent an MDIO bus. So that's obviously the wrong path.

Now, in linux, it seems that the fixed link case is treated specially;
in the of_phy_get_and_connect() which roughly corresponds to
dm_eth_connect_phy_handle() we have

    if (of_phy_is_fixed_link(np)) {
        ret = of_phy_register_fixed_link(np);
        ...
    } else {
        phy_np = of_parse_phandle(np, "phy-handle", 0);
...
    }

    phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);

And U-Boot's phy_connect() does have support for fixed-link
subnodes. Calling phy_connect() directly with NULL bus and a dummy
address does seem to make the ethernet work.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agompc83xx: kmeter1: increase malloc_f space
Heiko Schocher [Fri, 2 Oct 2020 07:23:22 +0000 (09:23 +0200)]
mpc83xx: kmeter1: increase malloc_f space

make malloc space before relocation bigger, set

CONFIG_SYS_MALLOC_F_LEN=0x800

Signed-off-by: Heiko Schocher <hs@denx.de>
3 years agompc83xx: kmeter1_defconfig add missing BAT4 config
Heiko Schocher [Fri, 2 Oct 2020 07:23:21 +0000 (09:23 +0200)]
mpc83xx: kmeter1_defconfig add missing BAT4 config

BAT4 setup missed in defconfig, add it.

Signed-off-by: Heiko Schocher <hs@denx.de>
3 years agompc8379erdb: Convert to DM_MMC
Sinan Akman [Sat, 4 Apr 2020 05:16:47 +0000 (01:16 -0400)]
mpc8379erdb: Convert to DM_MMC

Signed-off-by: Sinan Akman <sinan@writeme.com>
3 years agompc8379erdb: Add device tree
Sinan Akman [Sat, 4 Apr 2020 05:16:46 +0000 (01:16 -0400)]
mpc8379erdb: Add device tree

Signed-off-by: Sinan Akman <sinan@writeme.com>
3 years agoMerge tag 'efi-2021-04-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sun, 21 Feb 2021 16:17:30 +0000 (11:17 -0500)]
Merge tag 'efi-2021-04-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2021-04-rc3

Bug fixes:

* Let EFI simple file protocol access last block of partition
* Correct conversion of multi-part device paths in
  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText()

Documentation:

* booti and qfw man-pages

3 years agoMerge tag 'for-v2021.04' of https://gitlab.denx.de/u-boot/custodians/u-boot-i2c
Tom Rini [Sun, 21 Feb 2021 16:17:07 +0000 (11:17 -0500)]
Merge tag 'for-v2021.04' of https://gitlab.denx.de/u-boot/custodians/u-boot-i2c

i2c changes for v2021.04

new feature:
- Allow disabling driver model for I2C in SPL

fixes:
- i2c-gpio: Fix GPIO output
- at91: fix crash when using 'i2c probe'

3 years agoMerge branch 'master' of git://git.denx.de/u-boot-sh
Tom Rini [Sun, 21 Feb 2021 16:16:38 +0000 (11:16 -0500)]
Merge branch 'master' of git://git.denx.de/u-boot-sh

- RCar Gen3 updates

3 years agodoc: qfw man-page
Heinrich Schuchardt [Sat, 20 Feb 2021 09:00:19 +0000 (10:00 +0100)]
doc: qfw man-page

Provide a man-page for the qfw command.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: multi part device paths to text
Heinrich Schuchardt [Thu, 18 Feb 2021 17:30:43 +0000 (18:30 +0100)]
efi_loader: multi part device paths to text

Our current implementation of
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() truncates multi
part device paths after the first part. We should convert all parts.

Render device path instance ends as commas. This is not explicitly
described in the UEFI spec but mimics what EDK II does.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_selftest: multi part device path to text
Heinrich Schuchardt [Thu, 18 Feb 2021 17:30:44 +0000 (18:30 +0100)]
efi_selftest: multi part device path to text

Test EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() for a multi
part device path.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_selftest: compiler flags for dtbdump.o
Heinrich Schuchardt [Thu, 18 Feb 2021 06:34:44 +0000 (07:34 +0100)]
efi_selftest: compiler flags for dtbdump.o

Fix a typo. Apply the correct compiler flags to dtbdump.o.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodoc: booti man-page
Heinrich Schuchardt [Wed, 17 Feb 2021 11:19:35 +0000 (12:19 +0100)]
doc: booti man-page

Provide a man-page for the booti command.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agodoc/README.distro: kernel_comp_addr_r
Heinrich Schuchardt [Wed, 17 Feb 2021 07:06:05 +0000 (08:06 +0100)]
doc/README.distro: kernel_comp_addr_r

Add missing articles and preposition.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodoc: Add reference to U-Boot project in conf.py
Heinrich Schuchardt [Tue, 16 Feb 2021 17:20:54 +0000 (18:20 +0100)]
doc: Add reference to U-Boot project in conf.py

With the last update of conf.py the references to U-Boot where replaced by
references to Linux.

Fix the project references in the generated documentation.

Reported-by: Simon Glass <sjg@chromium.org>
Reported-by: Bin Meng <bmeng.cn@gmail.com>
Fixes: 98f01cf7a22e ("doc: update Kernel documentation build system")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoAllow last block to be read
Jesper Schmitz Mouridsen [Tue, 9 Feb 2021 16:17:17 +0000 (17:17 +0100)]
Allow last block to be read

The last block is of size media->block_size

Signed-off-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer>
Simplify expression.
Apply same change to efi_disk_write_blocks().

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodm: i2c: use CONFIG_IS_ENABLED macro for DM_I2C/DM_I2C_GPIO
Igor Opaniuk [Tue, 9 Feb 2021 11:52:45 +0000 (13:52 +0200)]
dm: i2c: use CONFIG_IS_ENABLED macro for DM_I2C/DM_I2C_GPIO

Use CONFIG_IS_ENABLED() macro, which provides more convenient
way to check $(SPL)DM_I2C/$(SPL)DM_I2C_GPIO configs
for both SPL and U-Boot proper.

CONFIG_IS_ENABLED(DM_I2C) expands to:
- 1 if CONFIG_SPL_BUILD is undefined and CONFIG_DM_I2C is set to 'y',
- 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_DM_I2C is set to 'y',
- 0 otherwise.

All occurences were replaced automatically using these bash cmds:
$ find . -type f -exec sed -i
     's/ifndef CONFIG_DM_I2C/if !CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/ifdef CONFIG_DM_I2C/if CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/defined(CONFIG_DM_I2C)/CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/ifndef CONFIG_DM_I2C_GPIO/if !CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +
$ find . -type f -exec sed -i
    's/ifdef CONFIG_DM_I2C_GPIO/if CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +
$ find . -type f -exec sed -i
    's/defined(CONFIG_DM_I2C_GPIO)/CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +

Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: freescale: drop CONFIG_DM_I2C undefs
Igor Opaniuk [Tue, 9 Feb 2021 11:52:44 +0000 (13:52 +0200)]
board: freescale: drop CONFIG_DM_I2C undefs

Drop CONFIG_DM_I2C undefs from board header files, and make them
disabled on these boards in defconfigs instead.

Disabling on Kconfig symbol was done automatically with this script:

cd configs
files=(*ls1046a*)
files2=(*T104*RDB*)
files3=(ls1021atwr_*)
files4=("imx8mp_evk_defconfig phycore-imx8mp_defconfig")
combine=("${files[@]}" "${files2[@]}" "${files3[@]}" "${files4[@]}")
cd ..

for item in ${combine[*]}
do
   echo "Adjusting  $item"
   echo "# CONFIG_SPL_DM_I2C is not set" >> configs/$item
   make $item && make savedefconfig && cp defconfig configs/$item
done

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Tom Rini <trini@konsulko.com>
3 years agodm: i2c: allow disabling driver model in SPL
Igor Opaniuk [Tue, 9 Feb 2021 11:52:43 +0000 (13:52 +0200)]
dm: i2c: allow disabling driver model in SPL

At present if U-Boot proper uses driver model for I2C, then SPL has to
also. While this is desirable, it places a significant barrier to moving
to driver model in some cases. For example, with a space-constrained SPL
it may be necessary to enable CONFIG_SPL_OF_PLATDATA which involves
adjusting some drivers.

This patch introduces a separate Kconfig symbols for enabling DM_I2C and
DM_I2C_GPIO support in SPL.

This will also help to get away from dirty workarounds to
achieve non-DM I2C support for SPL, which is currently used in some
board header files like:

ifdef CONFIG_SPL_BUILD
undef CONFIG_DM_I2C
endif

Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Tom Rini <trini@konsulko.com>
3 years agoi2c: at91: fix crash when using 'i2c probe'
Eugen Hristev [Fri, 4 Dec 2020 16:06:55 +0000 (18:06 +0200)]
i2c: at91: fix crash when using 'i2c probe'

When issuing 'i2c probe', the driver was crashing, because at probe
there is a request with zero length buffer to write to i2c bus.
The xfer_msg function assumes the buffer is always there, and never
checks for the buffer length.

=> i2c dev 0
Setting bus to 0
=> i2c probe
Valid chip addresses:
data abort
pc : [<7ffa97dc>]          lr : [<7ffa96f8>]
reloc pc : [<66f277dc>]    lr : [<66f276f8>]
sp : 7fb7c110  ip : 7ff87a28     fp : 7ff99938
r10: 00000002  r9 : 7fb7dec0     r8 : 00000000
r7 : e181c600  r6 : 7fb88c20     r5 : 00000000  r4 : 7fb7c128
r3 : 00000000  r2 : 00000001     r1 : 00000000  r0 : 00000009
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
Code: eb0092f4 e1a00005 e8bd81f0 e594300c (e5d33000)
Resetting CPU ...

Fixes: 8800e0fa20 ("i2c: atmel: add i2c driver")
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
3 years agoi2c: i2c-gpio: Fix GPIO output
Harm Berntsen [Sun, 29 Nov 2020 09:47:15 +0000 (09:47 +0000)]
i2c: i2c-gpio: Fix GPIO output

The dm_gpio_set_dir_flags function cannot be used to update the
configuration of a GPIO pin because it does a bitwise OR with the
existing flags. Looks like commit 788ea834124b ("gpio: add function
_dm_gpio_set_dir_flags") has introduced this behaviour and the i2c-gpio
driver has been broken since.

Signed-off-by: Harm Berntsen <harm.berntsen@nedap.com>
CC: Heiko Schocher <hs@denx.de>
CC: Patrick Delaunay <patrick.delaunay@st.com>
3 years agoARM: rmobile: Enable CONFIG_PCI_REGION_MULTI_ENTRY on RCar3
Marek Vasut [Fri, 15 Jan 2021 23:27:50 +0000 (00:27 +0100)]
ARM: rmobile: Enable CONFIG_PCI_REGION_MULTI_ENTRY on RCar3

R-Car3 can have multiple regions of type memory in DT, enable
CONFIG_PCI_REGION_MULTI_ENTRY to handle those instead of using
just one of the memory regions.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
3 years agopci: renesas: Fix BAR mapping on Gen3
Marek Vasut [Fri, 15 Jan 2021 23:33:17 +0000 (00:33 +0100)]
pci: renesas: Fix BAR mapping on Gen3

Because the first PCIExAR(n) register is configured with the mapping,
It is the second PCIExAR(n) register that must be written with 0, not
the last one. Update the n from 4 to 1 to select the correct register.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
3 years agopci: renesas: Make map address and mask power of two on Gen3
Marek Vasut [Sun, 24 Jan 2021 17:37:11 +0000 (18:37 +0100)]
pci: renesas: Make map address and mask power of two on Gen3

Both the map address and mask must be power of two per documentation,
adjust the code accordingly.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
3 years agopci: renesas: Add root bus handling on Gen3
Marek Vasut [Fri, 15 Jan 2021 23:28:18 +0000 (00:28 +0100)]
pci: renesas: Add root bus handling on Gen3

Add code to access the PCIe root bus space and configure it.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
3 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Sat, 20 Feb 2021 02:06:16 +0000 (21:06 -0500)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-sunxi

- H616 clock fix to enable video PLL
- sunxi-common.h cleanups
- support for UART1 as the console on sun8i
- removing wrong linux,stdout-path from DTs

3 years agofdt/sunxi: Remove OF_STDOUT_PATH
Andre Przywara [Sun, 14 Feb 2021 10:35:18 +0000 (10:35 +0000)]
fdt/sunxi: Remove OF_STDOUT_PATH

OF_STDOUT_PATH was meant to hold the devicetree path to the serial
console, to be put into the linux,stdout-path property of the chosen node.

The only user of that was sunxi, and it was actually wrong for years
there: the paths hardcoded in sunxi_common.h were not matching the DTs,
evident by the leading 0's in nodenames, which have been removed years
ago.

On top of that, "linux,stdout-path" is now deprecated for a while (Linux
commit 2a9d832cc9aae from November 2014), and also all modern DTs
(including those included in U-Boot) carry a "stdout-path" property
already.

So remove the stanza from sunxi_common.h, and, since this was the last
user, also remove the associated bits from the rest of U-Boot.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agosunxi: support boot console on uart1 for sun8i
Tobias Schramm [Sun, 14 Feb 2021 23:19:58 +0000 (00:19 +0100)]
sunxi: support boot console on uart1 for sun8i

The A23, A33, H3, H5, A83T, V3 and Sochip S3 sun8i SoCs can mux uart1 on
GPIOs PG6 and PG7. This patch adds support for using uart1 on those pins
as boot console.

Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: Remove dead ifdefs in sunxi-common.h
Samuel Holland [Mon, 8 Feb 2021 06:04:57 +0000 (00:04 -0600)]
sunxi: Remove dead ifdefs in sunxi-common.h

As variables were moved to Kconfig, some of the surrounding ifdefs were
left around, even though they were empty. Clean them up.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: spl: Fix H616 clock initialization
Jernej Skrabec [Mon, 1 Feb 2021 17:25:57 +0000 (18:25 +0100)]
sunxi: spl: Fix H616 clock initialization

It turns out that there is a magic bit in PRCM region which seemingly
makes PLLs work if it's enabled. Sadly, there is no documentation what
it does exactly, so we'll just mimick BSP boot0 behaviour and enable it
before any clock is set up.

Fixes: b18bd53d6cde ("sunxi: introduce support for H616 clocks")
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agodrivers: video: Add Support for Himax HX8238D Panel
Moses Christopher [Wed, 6 Jan 2021 15:31:35 +0000 (15:31 +0000)]
drivers: video: Add Support for Himax HX8238D Panel

* SPI based initialization for HX8238D
* Resolution: 320x240
* Color-Mode: RGB

* Initial Work is done by Sjoerd Simons
  https://gitlab.apertis.org/packaging/u-boot/-/blob\
  /5f259720e3e64965d50da89a841ad6eb256a47df/debian/patches\
  /apertis/powertools/0005-video-Add-Himax-HX8238-D-driver.patch

* Tested on Bosch Guardian Board

Cc: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Moses Christopher <BollavarapuMoses.Christopher@in.bosch.com>
3 years agoReplace video_uc_platdata with video_uc_plat
Dario Binacchi [Sat, 23 Jan 2021 18:43:52 +0000 (19:43 +0100)]
Replace video_uc_platdata with video_uc_plat

The video_uc_platdata structure no longer exists. It has been renamed
video_uc_plat.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
3 years agovideo: remove unused include/mb862xx.h
Heinrich Schuchardt [Tue, 29 Dec 2020 11:52:51 +0000 (12:52 +0100)]
video: remove unused include/mb862xx.h

CONFIG_VIDEO_MB862xx cannot be selected by any configuration.
So we can eliminate include/mb862xx.h.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agovideo: eliminate unused drivers/video/mb862xx.c
Heinrich Schuchardt [Tue, 29 Dec 2020 11:52:50 +0000 (12:52 +0100)]
video: eliminate unused drivers/video/mb862xx.c

The mb862xx driver does not conform to the driver model and is unused.
Eliminate it.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agovideo: simple_panel: Add boe,nv101wxmn51 display
Alper Nebi Yasak [Tue, 27 Oct 2020 21:41:55 +0000 (00:41 +0300)]
video: simple_panel: Add boe,nv101wxmn51 display

Add "boe,nv101wxmn51" to the compatible node. This is the panel for
chromebook_bob.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agovideo: simple_panel: Add sharp,lq123p1jx31 display
Alper Nebi Yasak [Tue, 27 Oct 2020 21:41:54 +0000 (00:41 +0300)]
video: simple_panel: Add sharp,lq123p1jx31 display

Add "sharp,lq123p1jx31" to the compatible node. This is the panel for
chromebook_kevin.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocommon: splash_source: fix -Wint-to-pointer-cast warning
Jaehoon Chung [Mon, 7 Dec 2020 08:18:51 +0000 (17:18 +0900)]
common: splash_source: fix -Wint-to-pointer-cast warning

Fix -Wint-to-pointer-cast warning

common/splash_source.c: In function 'splash_load_raw':
common/splash_source.c:100:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  100 |  bmp_hdr = (struct bmp_header *)bmp_load_addr;
      |            ^
common/splash_source.c: In function 'splash_sf_read_raw':
common/splash_source.c:39:47: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   39 |  return spi_flash_read(sf, offset, read_size, (void *)bmp_load_addr);
      |                                               ^

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoMerge tag 'mmc-2021-2-19' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc
Tom Rini [Fri, 19 Feb 2021 16:56:14 +0000 (11:56 -0500)]
Merge tag 'mmc-2021-2-19' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc

- mmc_spi improvement
- added mmc-pwrseq to remove duplicated code
- fix response timeout after switch command
- sdhci: skip cache invalidation if DMA is not used

3 years agoconfigs: enable CONFIG_MMC_PWRSEQ configuration
Jaehoon Chung [Tue, 16 Feb 2021 01:16:56 +0000 (10:16 +0900)]
configs: enable CONFIG_MMC_PWRSEQ configuration

Enable CONFIG_MMC_PWRSEQ configuration about boards that is using
rockchip_dw_mmc driver.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agoARM: mach-meson: select MMC_PWRSEQ config
Jaehoon Chung [Tue, 16 Feb 2021 01:16:55 +0000 (10:16 +0900)]
ARM: mach-meson: select MMC_PWRSEQ config

Before time, PWRSEQ is selected since below commit.
commit 262d34363373 ("board: amlogic: select PWRSEQ for all amlogic platform")
Select MMC_PWRSEQ config because of introducing CONFIG_MMC_PWRSEQ for
only eMMC module.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: rockchip_dw_mmc: use mmc_pwrseq instead of rockchip_mmc_pwrseq
Jaehoon Chung [Tue, 16 Feb 2021 01:16:54 +0000 (10:16 +0900)]
mmc: rockchip_dw_mmc: use mmc_pwrseq instead of rockchip_mmc_pwrseq

Use mmc_pwrseq instead of rockchip_mmc_pwrseq.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: meson_gx_mmc: use mmc_pwrseq instead of meson_mmc_pwrseq
Jaehoon Chung [Tue, 16 Feb 2021 01:16:53 +0000 (10:16 +0900)]
mmc: meson_gx_mmc: use mmc_pwrseq instead of meson_mmc_pwrseq

Use mmc_pwrseq instead of meson_mmc_pwrseq.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agommc: pwrseq: add mmc-pwrseq file to provide a generic interface
Jaehoon Chung [Tue, 16 Feb 2021 01:16:52 +0000 (10:16 +0900)]
mmc: pwrseq: add mmc-pwrseq file to provide a generic interface

Add mmc-pwrseq file to provide a generic interface.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: mmc_spi: Document the 3 local functions
Bin Meng [Tue, 2 Feb 2021 02:48:48 +0000 (10:48 +0800)]
mmc: mmc_spi: Document the 3 local functions

mmc_spi_sendcmd(), mmc_spi_readdata() and mmc_spi_writedata() are
currently undocumented. Add comment blocks to explain the arguments
and the return value.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: mmc_spi: Fix potential spec violation in receiving card response
Bin Meng [Tue, 2 Feb 2021 02:48:47 +0000 (10:48 +0800)]
mmc: mmc_spi: Fix potential spec violation in receiving card response

After command is sent and before card response shows up on the line,
there is a variable number of clock cycles in between called Ncr.
The spec [1] says the minimum is 1 byte and the maximum is 8 bytes.

Current logic in mmc_spi_sendcmd() has a flaw that it could only work
with certain SD cards with their Ncr being just 1 byte.

When resp_match is false, the codes try to receive only 1 byte from
the SD card. On the other hand when resp_match is true, the logic
happens to be no problem as it loops until timeout to receive as many
bytes as possible to see a match of the expected resp_match_value.
However not every call to mmc_spi_sendcmd() is made with resp_match
being true hence this exposes a potential issue with SD cards that
have a larger Ncr value.

Given no issue was reported as of today, we can reasonably conclude
that all cards being used on the supported boards happen to have a 1
byte Ncr timing requirement. But a broken case can be triggered by
utilizing QEMU to emulate a larger value of Ncr (by default 1 byte
Ncr is used on QEMU). This commit fixes such potential spec violation
to improve the card compatibility.

[1] "Physical Layer Specification Version 8.00"
     chapter 7.5.1: Command / Response
     chapter 7.5.4: Timing Values

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: mmc_spi: Move argument check to the beginning of mmc_spi_sendcmd()
Bin Meng [Tue, 2 Feb 2021 02:48:46 +0000 (10:48 +0800)]
mmc: mmc_spi: Move argument check to the beginning of mmc_spi_sendcmd()

The argument check should happen before any transfer on the SPI lines.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: mmc_spi: Print verbose debug output when crc16 check fails
Bin Meng [Tue, 2 Feb 2021 02:32:48 +0000 (10:32 +0800)]
mmc: mmc_spi: Print verbose debug output when crc16 check fails

Add some verbose debug output when crc16 check fails.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: fix response timeout after switch command
Stefan Bosch [Sat, 23 Jan 2021 12:37:41 +0000 (13:37 +0100)]
mmc: fix response timeout after switch command

After issuing the switch command: Wait until 'current state' of the card
status becomes 'tran'. This prevents from response timeout at the next
command because of 'current state' = 'data'.

Signed-off-by: Stefan Bosch <stefan_b@posteo.net>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: sdhci: skip cache invalidation if DMA is not used
Yuezhang.Mo@sony.com [Thu, 14 Jan 2021 05:46:50 +0000 (05:46 +0000)]
mmc: sdhci: skip cache invalidation if DMA is not used

If DMA(SDMA or ADMA) is not used, the cache invalidation
after reading is no need, should be skipped. Otherwise
U-Boot may hang at the cache invalidation.

Found this issue and tested this fix on DragonBoard 410c.

Fixes: commit 4155ad9aac94 ("mmc: sdhci: fix missing cache invalidation after reading by DMA")

Signed-off-by: Yuezhang.Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
3 years agocmd: mmc: update the mmc command's usage about argument
Jaehoon Chung [Tue, 15 Dec 2020 22:24:50 +0000 (07:24 +0900)]
cmd: mmc: update the mmc command's usage about argument

It's confusing whether arguments are optional or mandatory.
Update the command's usage to clarify how to use.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agommc: initialize an err variable
Jaehoon Chung [Thu, 3 Dec 2020 21:36:00 +0000 (06:36 +0900)]
mmc: initialize an err variable

Initialize an err variable to 0.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reported-by: Coverity (CID: 313548)
Reviewed-by: Tom Rini <trini@konsulko.com>
3 years agoMerge branch '2021-02-18-SPL-FIT-OP-TEE-Linux-improvements'
Tom Rini [Thu, 18 Feb 2021 17:02:11 +0000 (12:02 -0500)]
Merge branch '2021-02-18-SPL-FIT-OP-TEE-Linux-improvements'

- Improve interactions between SPL / OP-TEE and Linux in FIT images

3 years agonet: tftp: Avoid sending extra ack on completion
Ramon Fried [Wed, 3 Feb 2021 19:28:59 +0000 (21:28 +0200)]
net: tftp: Avoid sending extra ack on completion

in tftpboot, if ack was already sent previously for this
packet, don't send again.

Fixes: cc6b87ecaa96 ("net: tftp: Add client support for RFC 7440")

Reported-by: Suneel Garapati <suneelglinux@gmail.com>
Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Tested-by: Suneel Garapati <suneelglinux@gmail.com>
Tested-by: Oliver Graute <oliver.graute@kococonnector.com>
3 years agoMerge tag 'rpi-next-2021.04' of https://gitlab.denx.de/u-boot/custodians/u-boot-raspb...
Tom Rini [Thu, 18 Feb 2021 13:06:26 +0000 (08:06 -0500)]
Merge tag 'rpi-next-2021.04' of https://gitlab.denx.de/u-boot/custodians/u-boot-raspberrypi

- add iProc RNG2000 driver for RPi4
- add support for CM4 and RPi400

3 years agovideo: arm: rpi: Add brcm,bcm2711-hdmi0 compatible
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:31 +0000 (13:55 +0100)]
video: arm: rpi: Add brcm,bcm2711-hdmi0 compatible

The 'brcm,bcm2711-hdmi0' compatible string is used on RPi4 instead of
'brcm,bcm2835-hdmi' since the IP core was upgraded (now called VC6
instead of VC4). This has no functional change as far as u-boot driver
is concerned. So simply add the compatible string.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoconfigs: rpi4: Enable DM_DMA across all RPi4 configurations
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:30 +0000 (13:55 +0100)]
configs: rpi4: Enable DM_DMA across all RPi4 configurations

The DM_DMA option is needed in order to translate physical address into
bus addresses on a per-device basis.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agommc: Introduce mmc_phys_to_bus()/mmc_bus_to_phys()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:29 +0000 (13:55 +0100)]
mmc: Introduce mmc_phys_to_bus()/mmc_bus_to_phys()

This will allow us to use DM variants of phys_to_bus()/bus_to_phys()
when relevant.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoxhci: translate virtual addresses into the bus's address space
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:28 +0000 (13:55 +0100)]
xhci: translate virtual addresses into the bus's address space

So far we've been content with passing physical addresses when
configuring memory addresses into XHCI controllers, but not all
platforms have buses with transparent mappings. Specifically the
Raspberry Pi 4 might introduce an offset to memory accesses incoming
from its PCIe port.

Introduce xhci_virt_to_bus() and xhci_bus_to_virt() to cater with these
limitations, and make sure we don't break non DM users.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
[mb: fix compilation for 32 bit]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
fix from nicolas

3 years agodm: test: Add test case for dev_phys_to_bus()/dev_bus_to_phys()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:27 +0000 (13:55 +0100)]
dm: test: Add test case for dev_phys_to_bus()/dev_bus_to_phys()

By reusing DT nodes already available in sandbox's test DT introduce a
test to validate dev_phys_to_bus()/dev_bus_to_phys().

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: Introduce dev_phys_to_bus()/dev_bus_to_phys()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:26 +0000 (13:55 +0100)]
dm: Introduce dev_phys_to_bus()/dev_bus_to_phys()

These functions, instead of relying on hard-coded platform-specific
address translations, make use of the DMA constraints provided by the DM
core. This allows for per-device translations.

We can't yet get rid of the legacy phys_to_bus()/bus_to_phys()
implementations as some of its users are not integrated into the
device model.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: test: Add test case for dev->dma_offset
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:25 +0000 (13:55 +0100)]
dm: test: Add test case for dev->dma_offset

Add test to validate dev->dma_offset is properly set on devices.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: Introduce DMA constraints into the core device model
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:24 +0000 (13:55 +0100)]
dm: Introduce DMA constraints into the core device model

Calculating the DMA offset between a bus address space and CPU's every
time we call phys_to_bus() and bus_to_phys() isn't ideal performance
wise, as it implies traversing the device tree from the device's node up
to the root. Since this information is static and available before the
device's initialization, parse it before the probe call an provide the
DMA offset in 'struct udevice' for the address translation code to use
it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: test: Add test case for dev_get_dma_ranges()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:23 +0000 (13:55 +0100)]
dm: test: Add test case for dev_get_dma_ranges()

Introduce some new nodes in sandbox's test device-tree and dm tests in
order to validate dev_get_dma_range().

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: Introduce xxx_get_dma_range()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:22 +0000 (13:55 +0100)]
dm: Introduce xxx_get_dma_range()

Add the following functions to get a specific device's DMA ranges:
 - dev_get_dma_range()
 - ofnode_get_dma_range()
 - of_get_dma_range()
 - fdt_get_dma_range()
They are specially useful in oder to be able validate a physical address
space range into a bus's and to convert addresses from and to address
spaces.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agopci: pcie-brcmstb: Fix inbound window configurations
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:21 +0000 (13:55 +0100)]
pci: pcie-brcmstb: Fix inbound window configurations

So far we've assumed a fixed configuration for inbound windows as we had
a single user for this controller. But the controller's DMA constraints
were improved starting with BCM2711's B1 revision of the SoC, notably
available in CM4 and Pi400. They allow for wider inbound windows. We can
now cover the whole address space, whereas before we where limited to
the lower 3GB.

This information is passed to us through DT's 'dma-ranges' property and
it's specially important for us to honor it since some interactions with
the board's co-processor assume we're doing so (specifically the XHCI
firmware load operation, which is handled by the co-processor after
u-boot has correctly configured the PCIe controller).

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorpi: Add identifier for the new CM4
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:20 +0000 (13:55 +0100)]
rpi: Add identifier for the new CM4

The Raspberry Pi Foundation released the new Compute Module 4 which we
want to detect, so we can enable Ethernet on it and know the correct
device tree file name.

Note that this sets the Ethernet option to true since the official CM4
IO board has an Ethernet port. But that might not be the case when using
custom ones.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorpi: Add identifier for the new RPi400
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:19 +0000 (13:55 +0100)]
rpi: Add identifier for the new RPi400

The Raspberry Pi Foundation released the new RPi400 which we want to
detect, so we can enable Ethernet on it and know the correct device tree
file name.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE
Marek Szyprowski [Mon, 1 Feb 2021 11:16:33 +0000 (12:16 +0100)]
rpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE

When RPi4 is booted from USB Mass Storage, the firmware reports 947MiB of
the ARM memory (948 in case of the standard SD-card boot). This value is
not MMU_SECTION_SIZE aligned, so the dram_bank_mmu_setup() skips mapping
of the last 1MiB. This later causes u-boot in ARM 32bit mode to freeze,
because it relocated itself into that unmapped memory and fails to
execute.

Fix this by limiting the size of the first bank to the multiple of
MMU_SECTION_SIZE.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agopci: brcmstb: Cleanup controller state before handover
Nicolas Saenz Julienne [Thu, 14 Jan 2021 15:49:01 +0000 (16:49 +0100)]
pci: brcmstb: Cleanup controller state before handover

Make sure we handover the PCIe controller in a clean state. Some of the
devices hanging from the PCIe bus might need to be properly reset
through #PERST in order for Linux to be able to initialize them.

This is specially important in order to properly initialize Raspberry Pi
4 B and 400's USB chip.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agousb: xhci-pci: Add DM_FLAG_OS_PREPARE flag
Nicolas Saenz Julienne [Thu, 14 Jan 2021 15:49:00 +0000 (16:49 +0100)]
usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag

The PCIe bus the controller is connected to might need to be removed
prior the handover. Make sure xhci-pci is also removed so as to avoid
unexpected timeouts or hangs.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoconfig: Enable iProc RNG200 driver in RPi4 configs
Matthias Brugger [Tue, 15 Dec 2020 09:49:24 +0000 (10:49 +0100)]
config: Enable iProc RNG200 driver in RPi4 configs

We find the iProc RNG200 in the Raspberry Pi 4. Add it to all it's
config so that it can be used.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
[mb: drop rpi_4_32b_defconfig]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agospl: fit: Load devicetree when a Linux payload is found
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:56 +0000 (10:46 -0600)]
spl: fit: Load devicetree when a Linux payload is found

When a FIT config specifies a devicetree, we should load it, no
questions asked. In the case of the "simple" FIT loading path, a
difficulty arises in selecting the load address of the FDT.

The default FDT location is right after the "kernel" or "firmware"
image. However, if that is an OP-TEE image, then the FDT may end up in
secure DRAM, and not be accessible to normal world kernels.

Although the best solution is to be more careful about the FDT
address, a viable workaround is to only append the FDT after a u-boot
or Linux image. This is identical to the previous logic, except that
FDT loading is extended to IH_OS_LINUX images.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agospl: fit: Replace #ifdef blocks with more readable constructs
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:55 +0000 (10:46 -0600)]
spl: fit: Replace #ifdef blocks with more readable constructs

Use the IS_ENABLED() macro to control code flow, instead of the
caveman approach of sprinkling #ifdefs. Code size is not affected, as
the linker garbage-collects unused functions. However, readability is
improved significantly.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Do not #if guard board_fit_image_post_process() prototype
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:54 +0000 (10:46 -0600)]
image: Do not #if guard board_fit_image_post_process() prototype

There's no point in guarding function prototypes with #ifdefs. If a
function is not defined, the linker will notice. Having the prototype
does not affect code size.

What the #if guard takes away is the ability to use IS_ENABLED:

if (CONFIG_IS ENABLED(FIT_IMAGE_POST_PROCESS))
board_fit_image_post_process(...)

When the prototype is guarded, the above form cannot be used. This
leads to the proliferation of #ifdefs, and unreadable code. The
opportunity cost of the #if guard outweighs any benefits. Remove it.

Since the original version of this patch, an empty definition was
added by commit f14e6eec6c7f ("image: cleanup pre-processor usage").
The empty definition can cause silent failures, when an implementation
of board_fit_image_post_process() is expected because the linker will
not catch the missing function. Thus this patch removes this empty
inline declaration.

Fixes: f14e6eec6c7f ("image: cleanup pre-processor usage")
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agospl: fit: Only look up FIT configuration node once
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:53 +0000 (10:46 -0600)]
spl: fit: Only look up FIT configuration node once

The configuration node a sub node under "/configurations", which
describes the components to load from "/images". We only need to
locate this node once.

However, for each component, spl_fit_get_image_name() would parse the
FIT image, looking for the correct node. Such work duplication is not
necessary. Instead, once the node is found, cache it, and re-use it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agospl: fit: Remove useless loop in spl_fit_get_image_name()
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:52 +0000 (10:46 -0600)]
spl: fit: Remove useless loop in spl_fit_get_image_name()

When a desired configuration is not found, conf_node will have a
negative value. Thus the for loop will start at the root "/" node of
the image, print the "/description" property, and stop.

It appears the intent of the loop was to print the names of the
subnodes under "/configurations". We would need the offset to the
"/configurations" node, which is abstracted by fit_find_config_node().

This change agrees that abstracting the node offset is the correct
design, and we shouldn't be parsing the configurations manually. Thus
the loop in spl_fit_get_image_name() is useless. Remove it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agospl: fit: Pass FIT context via a structure pointer
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:51 +0000 (10:46 -0600)]
spl: fit: Pass FIT context via a structure pointer

Several loose arguments describe the FIT image. They are thus related,
and it makes sense to pass them together, in a structure. Examples
include the FIT blob pointer, offset to FDT nodes, and the offset to
external data.

Use a spl_fit_info structure to group these parameters.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agospl: fit: Factor out FIT parsing and use a context struct
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:50 +0000 (10:46 -0600)]
spl: fit: Factor out FIT parsing and use a context struct

The logical steps in spl_load_simple_fit() are difficult to follow.
I think the long comments, ifdefs, and ungodly number of variables
seriously affect the readability. In particular, it violates section 6
of the coding style, paragraphs (3), and (4).

The purpose of this patch is to improve the situation by
  - Factoring out initialization and parsing to separate functions
  - Reduce the number of variables by using a context structure
This change introduces no functional changes.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agospl: fit: Drop 'length' argument to board_spl_fit_post_load()
Alexandru Gagniuc [Wed, 20 Jan 2021 16:46:49 +0000 (10:46 -0600)]
spl: fit: Drop 'length' argument to board_spl_fit_post_load()

The size is derived from the FIT image itself. Any alignment
requirements are machine-specific and known by the board code. Thus
the total length can be derived from the FIT image and knowledge of
the platform. The 'length' argument is redundant. Remove it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
CC: Matt Porter <mporter@konsulko.com>
3 years agorng: Add iProc RNG200 driver
Matthias Brugger [Tue, 15 Dec 2020 09:49:23 +0000 (10:49 +0100)]
rng: Add iProc RNG200 driver

Add support for random number generator RNG200.
This is for example found on RPi4.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
[mb: adapt to new struct driver memebers]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoMerge branch '2021-02-16-assorted-improvements'
Tom Rini [Tue, 16 Feb 2021 20:14:34 +0000 (15:14 -0500)]
Merge branch '2021-02-16-assorted-improvements'

- DSA switch support (Layerscape platforms)
- IOMUX cleanup / fixes
- i2c OP-TEE trampoline driver

3 years agoconfigs: ls1028a: Enable the Ethernet switch driver in defconfig
Alex Marginean [Mon, 25 Jan 2021 12:23:57 +0000 (14:23 +0200)]
configs: ls1028a: Enable the Ethernet switch driver in defconfig

The switch driver for LS1028A Ethernet switch is now compiled in for
the NXP LS1028A reference design boards and for the Kontron SMARC-sAL28.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Michael Walle <michael@walle.cc>
3 years agoarm: dts: ls1028a: Add Ethernet switch node and dependencies
Alex Marginean [Mon, 25 Jan 2021 12:23:56 +0000 (14:23 +0200)]
arm: dts: ls1028a: Add Ethernet switch node and dependencies

The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs.  The switch node has the same structure as in Linux
and this patch enables it (and relevant ports) for the LS1028A RDB board.

ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is
not used in U-Boot and was disabled.  Ethernet port aliases were also
added to better manage the multitude of ports available now.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Michael Walle <michael@walle.cc>
3 years agodrivers: net: Add Felix DSA switch driver
Alex Marginean [Mon, 25 Jan 2021 12:23:55 +0000 (14:23 +0200)]
drivers: net: Add Felix DSA switch driver

This driver is used for the Ethernet switch integrated into LS1028A NXP.
Felix on LS1028A has 4 front panel ports and two internal ports, I/O
to/from the switch is done through an ENETC Ethernet interface.
The 4 front panel ports are available as Ethernet interfaces and can be
used with the typical network commands like tftp.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
3 years agonet: Introduce DSA class for Ethernet switches
Claudiu Manoil [Mon, 25 Jan 2021 12:23:53 +0000 (14:23 +0200)]
net: Introduce DSA class for Ethernet switches

DSA stands for Distributed Switch Architecture and it covers switches that
are connected to the CPU through an Ethernet link and generally use frame
tags to pass information about the source/destination ports to/from CPU.
Front panel ports are presented as regular ethernet devices in U-Boot and
they are expected to support the typical networking commands.
DSA switches may be cascaded, DSA class code does not currently support
this.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
3 years agonet: phy: introduce fixed_phy_create for DSA CPU ports
Vladimir Oltean [Mon, 25 Jan 2021 12:23:52 +0000 (14:23 +0200)]
net: phy: introduce fixed_phy_create for DSA CPU ports

The DSA (Distributed Switch Architecture) implementation has made a
design decision when it got introduced to the Linux kernel in 2008.
That was to hide away from the user the CPU-facing Ethernet MAC, since
it does not make sense to register it as a struct net_device (UCLASS_ETH
udevice for U-Boot), because that would never be beneficial for a user:
they would not be able to use it for traffic, since conceptually, a
packet delivered to the CPU port should loop back into the system.

Nonetheless, DSA has had numerous growing pains due to the lack of a
struct net_device for the CPU port, but so far it has overcome them.
It is unlikely at this stage of maturity that this aspect of it will
change.

We would like U-Boot to present the same information as Linux, to be at
parity in terms of number of interfaces, so that ethNaddr environment
variables could directly be associated between U-Boot and Linux.
Therefore, we would implicitly like U-Boot to hide the CPU port from the
user as well.

But the paradox is that DSA still needs a struct phy_device to inform
the driver of the parameters of the link that it should configure the
CPU port to. The problem is that the phy_device is typically returned
via a call to phy_connect, which needs an udevice to attach the PHY to,
and to search its ofnode for the 'fixed-link' property. But we don't
have an udevice to present for the CPU port.

Since 99% of DSA setups are MAC-to-MAC connections between the switch
and the host Ethernet controller, the struct phy_device is going to be a
fixed PHY. This simplifies things quite a bit. In U-Boot, a fixed PHY
does not need an MDIO bus, and does not need an attached dev either.
Basically, the phy_connect call doesn't do any connection, it just
creates the fixed PHY.

The proposal of this patch is to introduce a new fixed_phy_create
function which will take a single argument: the ofnode that holds this:

port@4 {
reg = <4>;
phy-mode = "internal";

fixed-link {
speed = <2500>;
full-duplex;
};
};

and probe a fixed PHY driver using the information from this ofnode.
DSA will probably be the only user of this function.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
3 years agonet: phy: fixed: support speeds of 2500 and 10000
Vladimir Oltean [Mon, 25 Jan 2021 12:23:51 +0000 (14:23 +0200)]
net: phy: fixed: support speeds of 2500 and 10000

Unlike the Linux fixed PHY driver, the one in U-Boot does not attempt to
emulate the clause 22 register set of a gigabit copper PHY driver
through the swphy framework. Therefore, the limitation of being unable
to support speeds higher than gigabit in fixed-link does not apply to
the U-Boot fixed PHY driver. This makes the fixed-link U-Boot
implementation more similar to the one from phylink, which can work with
any valid link speed.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
3 years agotest: dm: tee: extend with RPC test
Igor Opaniuk [Mon, 25 Jan 2021 12:28:43 +0000 (14:28 +0200)]
test: dm: tee: extend with RPC test

Extend existing DM tee tests adding test coverage for reverse RPC calls.
Currently this commit only adds tests for I2C requests from TEE driver
to TEE supplicant, for instance reading/writing data to emulated i2c
eeprom defines in standard sandbox test device tree
(arch/sandbox/dts/test.dtb):

=> i2c bus
Bus 0: i2c@0  (active 0)
   2c: eeprom@2c, offset len 1, flags 0
   ...

Running TEE tests:
=> ut dm tee
Test: dm_test_tee: tee.c
Test: dm_test_tee: tee.c (flat tree)
Failures: 0

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agodrivers: tee: sandbox: add rpc test ta emulation
Igor Opaniuk [Mon, 25 Jan 2021 12:28:42 +0000 (14:28 +0200)]
drivers: tee: sandbox: add rpc test ta emulation

This adds support for RPC test trusted application emulation, which
permits to test reverse RPC calls to TEE supplicant. Currently it covers
requests to the I2C bus from TEE.

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agotest: py: add pygit2 and pyelftools to requirements.txt
Igor Opaniuk [Mon, 25 Jan 2021 12:28:41 +0000 (14:28 +0200)]
test: py: add pygit2 and pyelftools to requirements.txt

Add pygit2 and pyelftools to the list of packages for virtualenv
needed to run all sets of pytests.This fixes warnings like:

binman.elf_test.TestElf.testDecodeElf (subunit.RemotedTestCase):
Python elftools not available

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agodrivers: tee: i2c trampoline driver
Jorge Ramirez-Ortiz [Mon, 25 Jan 2021 12:28:40 +0000 (14:28 +0200)]
drivers: tee: i2c trampoline driver

This commit gives the secure world access to the I2C bus so it can
communicate with I2C slaves (typically those would be secure elements
like the NXP SE050).

A similar service implementation has been merged in linux:
c05210ab ("drivers: optee: allow op-tee to access devices on the i2c
bus")

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agousb: kbd: destroy device after console is stopped
Andy Shevchenko [Thu, 11 Feb 2021 15:09:44 +0000 (17:09 +0200)]
usb: kbd: destroy device after console is stopped

In case of IOMUX enabled it assumes that console devices in the list
are available to get them stopped properly via ->stop() callback.
However, the USB keyboard driver violates this assumption and tries
to play tricks so the device get destroyed while being listed as
an active console.

Swap the order of device deregistration and IOMUX update along with
converting to use iomux_replace_device() jelper to avoid the use-after-free.

Fixes: 3cbcb2892809 ("usb: Fix usb_kbd_deregister when console-muxing is used")
Fixes: 8a8348703081 ("dm: usb: Add a remove() method for USB keyboards")
Reported-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Introduce iomux_replace_device()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:43 +0000 (17:09 +0200)]
IOMUX: Introduce iomux_replace_device()

Some console devices may appear or disappear at run time. In order to
support such a hotplug mechanism introduce a new iomux_replace_device()
helper to update the list of devices without altering environment.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Split out for_each_console_dev() helper macro
Andy Shevchenko [Thu, 11 Feb 2021 15:09:42 +0000 (17:09 +0200)]
IOMUX: Split out for_each_console_dev() helper macro

It is not only less lines of code, but also better readability
when new macro is being in use. Introduce for_each_console_dev()
helper macro and convert current users to it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Split out iomux_match_device() helper
Andy Shevchenko [Thu, 11 Feb 2021 15:09:41 +0000 (17:09 +0200)]
IOMUX: Split out iomux_match_device() helper

Deduplicate the code used in a few places by splitting out a common helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Switch to use stdio_file_to_flags()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:40 +0000 (17:09 +0200)]
IOMUX: Switch to use stdio_file_to_flags()

Deduplicate code by replacing with stdio_file_to_flags() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>