platform/kernel/u-boot.git
3 years agoMerge tag 'xilinx-for-v2021.04-rc3' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Tue, 23 Feb 2021 15:45:55 +0000 (10:45 -0500)]
Merge tag 'xilinx-for-v2021.04-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze

Xilinx changes for v2021.04-rc3

qspi:
- Support for dual/quad mode
- Fix speed handling

clk:
- Add clock enable function for zynq/zynqmp/versal

gem:
- Enable clock for Versal
- Fix error path
- Fix mdio deregistration path

fpga:
- Fix buffer alignment for ZynqMP

xilinx:
- Fix reset reason clearing in ZynqMP
- Show silicon version in SPL for Zynq/ZynqMP
- Fix DTB selection for ZynqMP
- Rename zc1275 to zcu1275 to match DT name

3 years agospi: zynqmp_gqspi: fix set_speed bug on multiple runs
Brandon Maier [Wed, 20 Jan 2021 20:28:30 +0000 (14:28 -0600)]
spi: zynqmp_gqspi: fix set_speed bug on multiple runs

If zynqmp_qspi_set_speed() is called multiple times with the same speed,
then on the second call it will skip recalculating the baud_rate_val as
it assumes the speed is already configured correctly. But it will still
write the baud_rate_val to the configuration register and call
zynqmp_gqspi_set_tapdelay(). Because it skipped recalculating the
baud_rate_val, it will use the initial value of 0 . This causes the
driver to run at maximum speed which for many spi flashes is too fast and
causes data corruption.

Instead only write out a new baud_rate_val if we have calculated the
correct baud_rate_val.

This opens up another issue with the "if (speed == 0)", we don't save
off the new plat->speed_hz value when setting the baud rate on the
speed=0 path. Instead mimic what the Linux zynqmp gqspi driver does, and
have speed==0 just use the same calculation as a normal speed. That will
cause the baud_rate_val to use the slowest speed possible, which is the
safest option.

Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com>
CC: jagan@amarulasolutions.com
CC: michal.simek@xilinx.com
CC: Ashok Reddy Soma <ashokred@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agoarm64: zynqmp: Rename zc1275/zcu1275 to be aligned with DT name
Michal Simek [Wed, 17 Feb 2021 07:55:34 +0000 (08:55 +0100)]
arm64: zynqmp: Rename zc1275/zcu1275 to be aligned with DT name

Folder names corresponds to DT name. These boards have been renamed from
zc1275 to zcu1275 by commit shown below and this should be the part of that
commit.

Fixes: 420d44678119 ("arm64: zynqmp: Rename zc1275 to zcu1275")
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agonet: gem: Fix error path in zynq_gem_probe
Michal Simek [Thu, 11 Feb 2021 18:03:30 +0000 (19:03 +0100)]
net: gem: Fix error path in zynq_gem_probe

Clean up error path in connection where priv->rxbuffers and priv->tx_bd are
allocated.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agonet: gem: Enable ethernet rx clock for versal
T Karthik Reddy [Wed, 3 Feb 2021 10:10:48 +0000 (03:10 -0700)]
net: gem: Enable ethernet rx clock for versal

Enable rx clock along with tx clock for versal platform. Use compatible
data to enable/disable clocks in the driver.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
3 years agoi2c: i2c_cdns: Enable i2c clock
T Karthik Reddy [Wed, 3 Feb 2021 10:10:46 +0000 (03:10 -0700)]
i2c: i2c_cdns: Enable i2c clock

Enable i2c controller clock from driver probe function
by calling clk_enable().

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoclk: versal: Add support to enable clocks
T Karthik Reddy [Wed, 3 Feb 2021 10:10:47 +0000 (03:10 -0700)]
clk: versal: Add support to enable clocks

Add clock enable functionality in versal clock driver to enable
clocks from peripheral drivers using clk_ops.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agoclk: zynqmp: Add support to enable clocks
T Karthik Reddy [Wed, 3 Feb 2021 10:10:45 +0000 (03:10 -0700)]
clk: zynqmp: Add support to enable clocks

Add clock enable functionality in zynqmp clock driver to enable
clocks from peripheral drivers using clk_ops.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agoclk: zynq: Add dummy clock enable function
Michal Simek [Tue, 9 Feb 2021 14:28:15 +0000 (15:28 +0100)]
clk: zynq: Add dummy clock enable function

A lot of Xilinx drivers are checking -ENOSYS which means that clock driver
doesn't have enable function. Remove this checking from drivers and create
dummy enable function as was done for clk_fixed_rate driver by
commit 6bf6d81c1112 ("clk: fixed_rate: add dummy enable() function").

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agoarm64: zynqmp: Do not clear reset reason
Michal Simek [Tue, 9 Feb 2021 07:50:22 +0000 (08:50 +0100)]
arm64: zynqmp: Do not clear reset reason

There is no need to clear reset reason register because it is protected by
PMUFW already which is reported when verbose log is enabled as:
pm_core.c@733 APU> No write permission to 0xFF5E0220

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agofpga: zynqpl: fix buffer alignment
Michael Walle [Wed, 10 Feb 2021 21:42:29 +0000 (22:42 +0100)]
fpga: zynqpl: fix buffer alignment

Due to pointer arithmetic, "sizeof(u32) * ARCH_DMA_MINALIGN" is
subtracted. It seems that the original intention was to just subtract
ARCH_DMA_MINALIGN. Fix it.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
3 years agoMerge tag 'u-boot-amlogic-20210222' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Mon, 22 Feb 2021 17:37:02 +0000 (12:37 -0500)]
Merge tag 'u-boot-amlogic-20210222' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic

- adds adc-keys button driver
- fix meson-saradc driver to get reference voltage
- add adc-keys test for sandbox
- enable adc-keys for VIM3 & VIM3L boards
- fix button.h build

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

- Fix ethernet on J721e
- Sync am335x DT nodes from Linux 5.9-rc7
- Minor Clock fixes

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 agobutton: add udevice forward declaration
Neil Armstrong [Fri, 19 Feb 2021 07:31:47 +0000 (08:31 +0100)]
button: add udevice forward declaration

After 401d1c4f5d2d ("common: Drop asm/global_data.h from common header")
build fails with :

drivers/button/button-uclass.c:13:5: error: conflicting types for 'button_get_by_label'
int button_get_by_label(const char *label, struct udevice **devp)
    ^~~~~~~~~~~~~~~~~~~

Adding struct udevice forward declaration in button.h solves the build error.

Fixes: 401d1c4f5d2d ("common: Drop asm/global_data.h from common header")
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoarch: sandbox: fix typo in clk.h
Dario Binacchi [Sun, 14 Feb 2021 14:17:43 +0000 (15:17 +0100)]
arch: sandbox: fix typo in clk.h

Fix the 'devivce' typo in arch/sandbox/include/asm/clk.h.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoclk: remove a redundant header
Dario Binacchi [Sun, 14 Feb 2021 14:17:42 +0000 (15:17 +0100)]
clk: remove a redundant header

The linux/err.h header file was included twice.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoarm: dts: sync am33xx-clocks with Linux 5.9-rc7
Dario Binacchi [Sat, 13 Feb 2021 11:09:19 +0000 (12:09 +0100)]
arm: dts: sync am33xx-clocks with Linux 5.9-rc7

The commit 6337d53fdf45 ("arm: dts: sync am33xx with Linux 5.9-rc7")
synchronized the am33xx-clocks.dtsi file with Linux 5.9-rc7 with the
exception of two nodes. I think I was wrong and it is better to keep
the two files similar and possibly make changes to the *-u-boot.dtsi
files.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
3 years agoclk: ti: improve debug messages for clkctrl driver
Dario Binacchi [Sat, 13 Feb 2021 11:02:30 +0000 (12:02 +0100)]
clk: ti: improve debug messages for clkctrl driver

The previous version printed the same debug message for both the enable
and disable routines without highlighting whether you were enabling or
disabling the module. It is now clear whether you are enabling or
disabling the module.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
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 agotest: add a simple test for the adc-keys button driver
Marek Szyprowski [Thu, 18 Feb 2021 10:33:18 +0000 (11:33 +0100)]
test: add a simple test for the adc-keys button driver

Add adc-keys device to the sandbox/test.dts and connect it to the channel
#3 of the sandbox_adc driver. The default values sampled by sandbox_adc
driver determines that button3 and button4 are released and button5 is
pressed.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agoconfigs: khadas-vim3(l): enable Function button support
Marek Szyprowski [Thu, 18 Feb 2021 10:33:17 +0000 (11:33 +0100)]
configs: khadas-vim3(l): enable Function button support

Add options required to check the 'Function' button state.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agoadc: meson-saradc: add support for getting reference voltage value
Marek Szyprowski [Thu, 18 Feb 2021 10:33:16 +0000 (11:33 +0100)]
adc: meson-saradc: add support for getting reference voltage value

Add support for getting the 'vref-supply' regulator and register it as
ADC's reference voltage regulator, so clients can translate sampled ADC
values to the voltage.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agobutton: add a simple Analog to Digital Converter device based button driver
Marek Szyprowski [Thu, 18 Feb 2021 10:33:15 +0000 (11:33 +0100)]
button: add a simple Analog to Digital Converter device based button driver

Add a simple Analog to Digital Converter device based button driver. This
driver binds to the 'adc-keys' device tree node.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agodt-bindings: input: adc-keys bindings documentation
Marek Szyprowski [Thu, 18 Feb 2021 10:33:14 +0000 (11:33 +0100)]
dt-bindings: input: adc-keys bindings documentation

Dump adc-keys bindings documentation from Linux kernel source tree from
commit 698dc0cf9447 ("dt-bindings: input: adc-keys: clarify
description").

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.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>