platform/kernel/u-boot.git
2 years agoconfigs: Resync with savedefconfig
Tom Rini [Thu, 5 May 2022 18:47:31 +0000 (14:47 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMerge branch '2022-05-05-platform-updates'
Tom Rini [Thu, 5 May 2022 18:42:02 +0000 (14:42 -0400)]
Merge branch '2022-05-05-platform-updates'

- Nuvoton NPCM750 board support and some related drivers
- MediaTek pinctrl updates
- Bugfixes for sandbox, ls10xxx, and 64bit TI platforms

2 years agogpio: npcm: Add support for Nuvoton NPCM SoCs
Stanley Chu [Fri, 25 Feb 2022 02:14:50 +0000 (10:14 +0800)]
gpio: npcm: Add support for Nuvoton NPCM SoCs

Add Nuvoton BMC NPCM7xx/NPCM8xx gpio driver

Signed-off-by: Stanley Chu <yschu@nuvoton.com>
2 years agoinclude: configs: am**x/j721e/j721s2_evm.h: Move the stack pointer init address in...
Aswath Govindraju [Tue, 19 Apr 2022 15:26:02 +0000 (20:56 +0530)]
include: configs: am**x/j721e/j721s2_evm.h: Move the stack pointer init address in arm64

Currently, in case of arm64 bootloader and U-Boot the stack pointer is
initialized at an offset of NON_SECURE_MSRAM_SIZE from arm64 SPL's text
base address. After jumping to arm64, execution is done out of DDR.
Therefore, having an offset corresponding to the size of MSRAM does not
have any significance.

Instead, initialize the stack pointer after an offset of 4MB from the SPL
text base address. This helps in allocating larger memory for stack.

  ┌────────────────────┐0x80080000
  │                    │
  │   arm64 SPL        │
  ├────────────────────┤
  │        ▲           │
  │        │           │
  │      STACK         │
  ├────────────────────┤0x80480000
  │ Memory for Load    │
  │ Buffer Allocation  │
  ├────────────────────┤0x80800000
  │                    │
  │    U-Boot Image    │
  │                    │
  └────────────────────┘

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
2 years agopinctrl: mediatek: add support for different types of IO pins
Sam Shih [Thu, 21 Apr 2022 06:23:53 +0000 (14:23 +0800)]
pinctrl: mediatek: add support for different types of IO pins

There are many pins in an SoC, and register usage may vary by pins.
This patch introduces a concept of "io type" and "io type group"
to mediatek pinctrl drivers. This can provide different pinconf
handlers implementation (eg: "bias-pull-up/down", "driving" and
"input-enable") for IO pins that belong to different types.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
2 years agopinctrl: mediatek: introduce multiple memory bases support
Sam Shih [Thu, 21 Apr 2022 06:23:52 +0000 (14:23 +0800)]
pinctrl: mediatek: introduce multiple memory bases support

Pinctrl design of some mediatek SoC need to access registers that
distribute in multiple memory base address. this patch introduce new
mechanism in mediatek pinctrl driver to support the chips which have
the new design.

This patch add a member 'base_calc' in pinctrl private data, and changed
original 'base' private data to an array of *iomem.

When 'base_calc' attribute is set, it will requests multiplue regs base
from the DT, if 'base_calc' attribute is not set, it only use legacy way
to request single reg resource from the DT.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
2 years agopinctrl: mediatek: rewrite mtk_pinconf_set and related functions
Sam Shih [Thu, 21 Apr 2022 06:23:51 +0000 (14:23 +0800)]
pinctrl: mediatek: rewrite mtk_pinconf_set and related functions

There are many pins in a SoCs, and different pin may belong
to different "io_type", For example: some pins of MT7622 belongs
to "io_type A", the other belongs to "io_type B", and pinctrl "V0"
means handle pinconf via "io_type A" or "io_type B", so SoCs that
contain "io_type A" and "io_type B" pins, use "V0" in pinctrl driver.

This patch separates the implementation of register operations
(e.g: "bias-pull-up/down", "driving" and "input-enable") into
different functions, and lets the original V0/V1
ops to call the new functions.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
2 years agosandbox: Avoid binman error when run without device tree
Simon Glass [Wed, 27 Apr 2022 19:47:57 +0000 (13:47 -0600)]
sandbox: Avoid binman error when run without device tree

With sandbox, U-Boot can be run without a device tree (i.e. no -d or -T
parameter). In this case an empty device tree is created for convenience.
With a recent change this causes an error due to the missing '/binman'
node.

Add this node to avoid the problem, as well as a test that U-Boot can
be run without a device tree.

Fixes: 059df5624b ("arch: Kconfig: imply BINMAN for SANDBOX")
Fixes: https://source.denx.de/u-boot/u-boot/-/issues/11
Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agotest/py: Add a way to start sandbox without a device tree
Simon Glass [Wed, 27 Apr 2022 19:47:56 +0000 (13:47 -0600)]
test/py: Add a way to start sandbox without a device tree

This is useful sometimes when running a specific test. Add support for it
in the existing restart_uboot_with_flags() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoboard: synquacer: developerbox: Remove Masami from MAINTAINERS
Masami Hiramatsu [Thu, 28 Apr 2022 09:13:04 +0000 (18:13 +0900)]
board: synquacer: developerbox: Remove Masami from MAINTAINERS

Remove Masami Hiramatsu from MAINTAINERS since he will leave
Linaro and his email will be not available anymore.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
2 years agols10xxx: Use a sane SPL_SYS_MALLOC_F_LEN default
Sean Anderson [Thu, 28 Apr 2022 16:39:49 +0000 (12:39 -0400)]
ls10xxx: Use a sane SPL_SYS_MALLOC_F_LEN default

SPL_SYS_MALLOC_F_LEN defaults to SYS_MALLOC_F_LEN. 0x10000 is 64 KiB, or
around half of the total OCRAM size. Revert to the default of 0x2000. This
fixes SPL boot.

Fixes: 545eceb520 ("imx8/ls10xx: Use a sane SYS_MALLOC_F_LEN default")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Fabio Estevam <festevam@denx.de>
2 years agotimer: npcm: Add NPCM timer support
Jim Liu [Tue, 19 Apr 2022 05:32:22 +0000 (13:32 +0800)]
timer: npcm: Add NPCM timer support

Add Nuvoton BMC NPCM7xx/NPCM8xx timer driver.

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
2 years agoserial: npcm: Add support for Nuvoton NPCM SoCs
Jim Liu [Tue, 19 Apr 2022 05:32:21 +0000 (13:32 +0800)]
serial: npcm: Add support for Nuvoton NPCM SoCs

Add Nuvoton BMC NPCM7xx/NPCM8xx uart driver

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
2 years agoclk: nuvoton: Add support for NPCM750
Jim Liu [Tue, 19 Apr 2022 05:32:20 +0000 (13:32 +0800)]
clk: nuvoton: Add support for NPCM750

Add clock controller driver for NPCM750

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
2 years agoarm: nuvoton: Add support for Nuvoton NPCM750 BMC
Jim Liu [Tue, 19 Apr 2022 05:32:19 +0000 (13:32 +0800)]
arm: nuvoton: Add support for Nuvoton NPCM750 BMC

Add basic support for the Nuvoton NPCM750 EVB (Poleg).

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
2 years agoMerge tag 'efi-2022-07-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Wed, 4 May 2022 16:08:40 +0000 (12:08 -0400)]
Merge tag 'efi-2022-07-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-07-rc2-2

* Test
  Unit test for 'bootmenu' command

* UEFI
  Preparatory patches for implementing a UEFI boot options based menu

2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Wed, 4 May 2022 13:05:03 +0000 (09:05 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- mips: octeon: Add ethernet support (Aaron & Stefan)
- Misc mvneta changes, cleanups, fixes (Marek)

2 years agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi
Tom Rini [Wed, 4 May 2022 13:04:43 +0000 (09:04 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi

- NPCM7xx FIU SPI driver (Jim Liu)
- AT45DB641E dataflash (Luca Ellero)

2 years agonet: mvneta: Drop unneeded macro
Marek Behún [Wed, 27 Apr 2022 10:42:02 +0000 (12:42 +0200)]
net: mvneta: Drop unneeded macro

Macro MVNETA_GMAC_FORCE_LINK_UP can be dropped from value assignment in
fixed link case, since it's value is written into the register later in
the function for link-down-to-link-up case. The value is written as
MVNETA_GMAC_FORCE_LINK_DOWN | MVNETA_GMAC_FORCE_LINK_PASS, and so the
macro definition can also be dropped.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
Marek Behún [Wed, 27 Apr 2022 10:42:01 +0000 (12:42 +0200)]
net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in

Guard the code handling the fixed PHY case by
CONFIG_IS_ENABLED(PHY_FIXED).

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Drop fixed_link member from private struct
Marek Behún [Wed, 27 Apr 2022 10:42:00 +0000 (12:42 +0200)]
net: mvneta: Drop fixed_link member from private struct

Since this member is checked only at two places drop it and inline it's
usage.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Write PHY address just before enabling HW polling
Marek Behún [Wed, 27 Apr 2022 10:41:59 +0000 (12:41 +0200)]
net: mvneta: Write PHY address just before enabling HW polling

Write PHY address just before enabling HW polling of the PHY.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Convert to use PHY_FIXED for fixed-link
Marek Behún [Wed, 27 Apr 2022 10:41:58 +0000 (12:41 +0200)]
net: mvneta: Convert to use PHY_FIXED for fixed-link

Stop parsing fixed-link in the MAC driver. Instead support only PHY mode
and let the fixed PHY driver handle the fixed-link case.

Enable CONFIG_PHY_FIXED for mvneta boards that need it: Turris Omnia and
ESPRESSObin.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
Marek Behún [Wed, 27 Apr 2022 10:41:57 +0000 (12:41 +0200)]
net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS

The CONFIG_* macros are reserved for Kconfig. This was probably done
when this driver was being imported from Linux. Rename the macro.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Don't check for CONFIG_PHYLIB
Marek Behún [Wed, 27 Apr 2022 10:41:56 +0000 (12:41 +0200)]
net: mvneta: Don't check for CONFIG_PHYLIB

Drop checking for CONFIG_PHYLIB in mvneta, this is already done in
Kconfig.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Drop unnecessary space
Marek Behún [Wed, 27 Apr 2022 10:41:55 +0000 (12:41 +0200)]
net: mvneta: Drop unnecessary space

Drop unnecessary space in mvneta_adjust_link().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Use bool instead of int for boolean variable
Marek Behún [Wed, 27 Apr 2022 10:41:54 +0000 (12:41 +0200)]
net: mvneta: Use bool instead of int for boolean variable

Use the bool type instead of int for status_change variable.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Drop one indentation level in mvneta_adjust_link()
Marek Behún [Wed, 27 Apr 2022 10:41:53 +0000 (12:41 +0200)]
net: mvneta: Drop one indentation level in mvneta_adjust_link()

Drop one indentation level in the mvneta_adjust_link() function.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Fix unused variable warning if DM_GPIO is disabled
Marek Behún [Wed, 27 Apr 2022 10:41:52 +0000 (12:41 +0200)]
net: mvneta: Fix unused variable warning if DM_GPIO is disabled

The `ret` variable in mvneta_probe() is unused if DM_GPIO is disabled.

Since the variable is used only once after assigning value, we can
inline the usage and drop the variable.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Don't register MDIO bus
Marek Behún [Wed, 27 Apr 2022 10:41:51 +0000 (12:41 +0200)]
net: mvneta: Don't register MDIO bus

This MDIO bus is now handled by a proper mvmdio DM driver. Remove it
from mvneta.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: turris_mox: Use DM registered MDIO
Marek Behún [Wed, 27 Apr 2022 10:41:50 +0000 (12:41 +0200)]
arm: mvebu: turris_mox: Use DM registered MDIO

In order to be able to get rid of the non-DM MDIO bus registered in
mvneta driver, start using the DM registered one in Turris MOX board
code.

This also allows us to drop the hack introduced in MOX' -u-boot.dtsi
file.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mdio-uclass: add dm_phy_find_by_ofnode() helper
Marek Behún [Wed, 27 Apr 2022 10:41:49 +0000 (12:41 +0200)]
net: mdio-uclass: add dm_phy_find_by_ofnode() helper

Add helper to resolve PHY node from it's ofnode via DM MDIO subsystem.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: Espressobin: Use DM registered MDIO to configure switch
Marek Behún [Wed, 27 Apr 2022 10:41:48 +0000 (12:41 +0200)]
arm: mvebu: Espressobin: Use DM registered MDIO to configure switch

In order to be able to get rid of the non-DM MDIO bus registered in
mvneta driver, we need to stop using board_network_enable() and instead
use the DM registered MDIO device to configure switch in
last_stage_init().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Remember fixed link instead of PHY address in priv data
Marek Behún [Wed, 27 Apr 2022 10:41:47 +0000 (12:41 +0200)]
net: mvneta: Remember fixed link instead of PHY address in priv data

We don't need to remember PHY address anymore, because since using DM
MDIO for connecting PHY, the address is parsed by mdio-uclass from
the ofnode.

But the driver uses a special value of the address to signal fixed link
usage.

Drop phyaddr add fixed_link in driver private structure. This simplifies
code a little.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Use DM MDIO API for connecting PHY
Marek Behún [Wed, 27 Apr 2022 10:41:46 +0000 (12:41 +0200)]
net: mvneta: Use DM MDIO API for connecting PHY

Use the modern DM MDIO API for connecting PHY in the mvneta driver.

This requires enabling MVMDIO driver in several config files.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Fix 10Mbps speed
Marek Behún [Wed, 27 Apr 2022 10:41:45 +0000 (12:41 +0200)]
net: mvneta: Fix 10Mbps speed

In mvneta_adjust_link() we need to set MII_SPEED bit only if PHY reports
the speed at 100Mbps.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agonet: mvneta: Get rid of platdata
Marek Behún [Wed, 27 Apr 2022 10:41:44 +0000 (12:41 +0200)]
net: mvneta: Get rid of platdata

Drop .of_to_plat() from the mvneta driver and parse the two properties
in .probe().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: nic23: Enable ethernet support
Stefan Roese [Thu, 7 Apr 2022 07:11:54 +0000 (09:11 +0200)]
mips: octeon: nic23: Enable ethernet support

This patch enables the Kconfig symbols needed for full ethernet support
on the NIC23. Additionally board specific setup is done, mostly GPIOs
related to SFP / GPIO configuration. With this, ethernet can be used on
this board. Here an example of a tftp load:

=> tftp ffffffff81000000 big
Using ethernet-mac-nexus@11800e2000000 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.247
Filename 'big'.
Load address: 0xffffffff81000000
Loading: ##################################################  10 MiB
         9.7 MiB/s
done
Bytes transferred = 10485760 (a00000 hex)

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: ebb7304: Enable ethernet support
Stefan Roese [Thu, 7 Apr 2022 07:11:53 +0000 (09:11 +0200)]
mips: octeon: ebb7304: Enable ethernet support

This patch enables the Kconfig symbols needed for full ethernet support
on the EBB7304. Also the PHY autonegotiation timeout is increased, as
the default 5 seconds are sometime a bit short. With this, ethernet can
be used on this board. Here an example of a tftp load:

=> tftp ffffffff81000000 big
ethernet-mac-nexus@11800e0000000 Waiting for PHY auto negotiation to complete....... done
Using ethernet-mac-nexus@11800e0000000 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.243
Filename 'big'.
Load address: 0xffffffff81000000
Loading: ##################################################  10 MiB
         13.2 MiB/s
done
Bytes transferred = 10485760 (a00000 hex)

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agonet: Add ethernet support for MIPS Octeon
Stefan Roese [Thu, 7 Apr 2022 07:11:52 +0000 (09:11 +0200)]
net: Add ethernet support for MIPS Octeon

This patchs adds the ethernet & MDIO driver for the MIPS Octeon II / III
SoC platform. Please note that these drivers are based on the 2013
U-Boot version from Marvell and make use of the platform supported
helper functions for the ethernet functionality, including stuff like
SFP handling.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
2 years agomips: octeon: mrvl, octeon-nic23.dts: Add ethernet DT support
Stefan Roese [Thu, 7 Apr 2022 07:11:51 +0000 (09:11 +0200)]
mips: octeon: mrvl, octeon-nic23.dts: Add ethernet DT support

Add the Octeon ethernet (BGX) and SFP DT nodes to the NIC23 dts file to
enable ethernet support on this board.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: mrvl, octeon-ebb7304.dts: Add ethernet DT support
Stefan Roese [Thu, 7 Apr 2022 07:11:50 +0000 (09:11 +0200)]
mips: octeon: mrvl, octeon-ebb7304.dts: Add ethernet DT support

Add the Octeon ethernet (BGX), SMI and PHY DT nodes to the EBB7304 dts
file to enable ethernet support on this board.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: mrvl, cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes
Stefan Roese [Thu, 7 Apr 2022 07:11:49 +0000 (09:11 +0200)]
mips: octeon: mrvl, cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes

Add the Octeon ethernet (BGX) and SMI DT node to the dtsi file.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: octeon_common.h: Move init SP because of increased image size
Stefan Roese [Thu, 7 Apr 2022 07:11:48 +0000 (09:11 +0200)]
mips: octeon: octeon_common.h: Move init SP because of increased image size

This patch moves CONFIG_SYS_INIT_SP_OFFSET to a higher address so that
it does not interfere with larger U-Boot images. This was noticed, while
adding network support to the EBB7304 board.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: cpu.c: Implement configure_lmtdma_window()
Stefan Roese [Thu, 7 Apr 2022 07:11:47 +0000 (09:11 +0200)]
mips: octeon: cpu.c: Implement configure_lmtdma_window()

Import configure_lmtdma_window from Marvell 2013 U-Boot as it's needed
for network functionality.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: cpu.c: Move bootmem init to arch_early_init_r()
Stefan Roese [Thu, 7 Apr 2022 07:11:46 +0000 (09:11 +0200)]
mips: octeon: cpu.c: Move bootmem init to arch_early_init_r()

Call octeon_bootmem_init() earlier in the boot process, so that this
bootmemory infrastructure is already initialized when e.g. the
networking support gets probed.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Makefile: Enable building of the newly added C files
Stefan Roese [Thu, 7 Apr 2022 07:11:45 +0000 (09:11 +0200)]
mips: octeon: Makefile: Enable building of the newly added C files

This patch adds the newly added C files to the Makefile to enable
compilation. This is done in a separate step, to not introduce build
breakage while adding the single files with potentially missing
externals.

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Misc changes to existing C files for upcoming eth support
Stefan Roese [Thu, 7 Apr 2022 07:11:44 +0000 (09:11 +0200)]
mips: octeon: Misc changes to existing C files for upcoming eth support

This patch includes misc changes to already present Octeon MIPS C files
files, which are necessary for the upcoming ethernet support.

The changes are mostly:
- DM GPIO & I2C infrastructure
- Coding style cleanup while reworking of the code

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-range.c
Aaron Williams [Thu, 6 May 2021 07:40:43 +0000 (09:40 +0200)]
mips: octeon: Add cvmx-range.c

Import cvmx-range.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-qlm-tables.c
Aaron Williams [Thu, 7 Apr 2022 07:11:42 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-qlm-tables.c

Import cvmx-qlm-tables.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pko-internal-ports-range.c
Aaron Williams [Thu, 7 Apr 2022 07:11:41 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pko-internal-ports-range.c

Import cvmx-pko-internal-ports-range.c from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pko3-resources.c
Aaron Williams [Thu, 7 Apr 2022 07:11:40 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pko3-resources.c

Import cvmx-pko3-resources.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pko3-compat.c
Aaron Williams [Thu, 7 Apr 2022 07:11:39 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pko3-compat.c

Import cvmx-pko3-compat.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pko3-queue.c
Aaron Williams [Thu, 6 May 2021 10:26:07 +0000 (12:26 +0200)]
mips: octeon: Add cvmx-pko3-queue.c

Import cvmx-pko3-queue.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pko3.c
Aaron Williams [Thu, 7 Apr 2022 07:11:37 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pko3.c

Import cvmx-pko3.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pko.c
Aaron Williams [Thu, 7 Apr 2022 07:11:36 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pko.c

Import cvmx-pko.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pki-resources.c
Aaron Williams [Thu, 7 Apr 2022 07:11:35 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pki-resources.c

Import cvmx-pki-resources.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pki.c
Aaron Williams [Thu, 6 May 2021 06:03:04 +0000 (08:03 +0200)]
mips: octeon: Add cvmx-pki.c

Import cvmx-pki.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-ipd.c
Aaron Williams [Mon, 10 May 2021 13:15:39 +0000 (15:15 +0200)]
mips: octeon: Add cvmx-ipd.c

Import cvmx-ipd.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-ilk.c
Aaron Williams [Thu, 7 Apr 2022 07:11:32 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-ilk.c

Import cvmx-ilk.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-global-resource.c
Aaron Williams [Thu, 6 May 2021 07:17:53 +0000 (09:17 +0200)]
mips: octeon: Add cvmx-global-resource.c

Import cvmx-global-resource.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-fpa-resource.c
Aaron Williams [Mon, 10 May 2021 13:19:12 +0000 (15:19 +0200)]
mips: octeon: Add cvmx-fpa-resource.c

Import cvmx-fpa-resource.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-fpa.c
Aaron Williams [Thu, 7 Apr 2022 07:11:29 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-fpa.c

Import cvmx-fpa.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-fau-compat.c
Aaron Williams [Thu, 7 Apr 2022 07:11:28 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-fau-compat.c

Import cvmx-fau-compat.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-cmd-queue.c
Aaron Williams [Mon, 10 May 2021 11:45:15 +0000 (13:45 +0200)]
mips: octeon: Add cvmx-cmd-queue.c

Import cvmx-cmd-queue.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-agl.c
Aaron Williams [Thu, 7 Apr 2022 07:11:26 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-agl.c

Import cvmx-agl.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-xaui.c
Aaron Williams [Thu, 7 Apr 2022 07:11:25 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-xaui.c

Import cvmx-helper-xaui.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-sfp.c
Aaron Williams [Thu, 6 May 2021 09:32:54 +0000 (11:32 +0200)]
mips: octeon: Add cvmx-helper-sfp.c

Import cvmx-helper-sfp.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-sgmii.c
Aaron Williams [Thu, 7 Apr 2022 07:11:23 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-sgmii.c

Import cvmx-helper-sgmii.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-rgmii.c
Aaron Williams [Thu, 7 Apr 2022 07:11:22 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-rgmii.c

Import cvmx-helper-rgmii.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-pko3.c
Aaron Williams [Thu, 7 Apr 2022 07:11:21 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-pko3.c

Import cvmx-helper-pko3.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-pko.c
Aaron Williams [Thu, 7 Apr 2022 07:11:20 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-pko.c

Import cvmx-helper-pko.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-pki.c
Aaron Williams [Thu, 7 Apr 2022 07:11:19 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-pki.c

Import cvmx-helper-pki.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-npi.c
Aaron Williams [Thu, 7 Apr 2022 07:11:18 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-npi.c

Import cvmx-helper-npi.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-loop.c
Aaron Williams [Thu, 7 Apr 2022 07:11:17 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-loop.c

Import cvmx-helper-loop.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-ipd.c
Aaron Williams [Thu, 7 Apr 2022 07:11:16 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-ipd.c

Import cvmx-helper-ipd.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-ilk.c
Aaron Williams [Thu, 7 Apr 2022 07:11:15 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-ilk.c

Import cvmx-helper-ilk.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-fpa.c
Aaron Williams [Thu, 7 Apr 2022 07:11:14 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-fpa.c

Import cvmx-helper-fpa.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-board.c
Aaron Williams [Thu, 7 Apr 2022 07:11:13 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-board.c

Import cvmx-helper-board.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-bgx.c
Aaron Williams [Thu, 7 Apr 2022 07:11:12 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-bgx.c

Import cvmx-helper-bgx.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-helper-agl.c
Aaron Williams [Thu, 7 Apr 2022 07:11:11 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-helper-agl.c

Import cvmx-helper-agl.c from 2013 U-Boot. It will be used by the later
added drivers to support networking on the MIPS Octeon II / III
platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Misc changes to existing headers for upcoming eth support
Stefan Roese [Thu, 7 Apr 2022 07:11:10 +0000 (09:11 +0200)]
mips: octeon: Misc changes to existing headers for upcoming eth support

This patch includes misc changes to already present Octeon MIPS header
files, which are necessary for the upcoming ethernet support.

The changes are mostly:
- DM GPIO & I2C infrastructure
- Coding style cleanup while reworking the headers

Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-xcv-defs.h header file
Aaron Williams [Thu, 7 Apr 2022 07:11:09 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-xcv-defs.h header file

Import cvmx-xcv-defs.h header file from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-pcsxx-defs.h header file
Aaron Williams [Thu, 7 Apr 2022 07:11:08 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-pcsxx-defs.h header file

Import cvmx-pcsxxx-defs.h header file from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-npei-defs.h header file
Aaron Williams [Thu, 7 Apr 2022 07:11:07 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-npei-defs.h header file

Import cvmx-npei-defs.h header file from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-lbk-defs.h header file
Aaron Williams [Thu, 7 Apr 2022 07:11:06 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-lbk-defs.h header file

Import cvmx-lbk-defs.h header file from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-iob-defs.h header file
Aaron Williams [Thu, 7 Apr 2022 07:11:05 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-iob-defs.h header file

Import cvmx-iob-defs.h header file from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add cvmx-ilk-defs.h header file
Aaron Williams [Thu, 7 Apr 2022 07:11:04 +0000 (09:11 +0200)]
mips: octeon: Add cvmx-ilk-defs.h header file

Import cvmx-igl-defs.h header file from 2013 U-Boot. It will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agomips: octeon: Add misc cvmx-* header files
Aaron Williams [Thu, 7 Apr 2022 07:11:03 +0000 (09:11 +0200)]
mips: octeon: Add misc cvmx-* header files

Import misc cvmx-helper header files from 2013 U-Boot. They will be used
by the later added drivers to support networking on the MIPS Octeon II /
III platforms.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agoMerge branch '2022-05-03-virtio-pci-add-and-fix-consistency-checks'
Tom Rini [Tue, 3 May 2022 22:33:46 +0000 (18:33 -0400)]
Merge branch '2022-05-03-virtio-pci-add-and-fix-consistency-checks'

To quote the author:
The virtio PCI drivers forgo a number of consistency checks,
particularly around pointer validation and bounds checking. This series
focuses on the modern driver to add those checks.

The start of the series adds and fixes some basic bounds checks. Later
patches ensure PCI addresses fall within the expected regions rather
than any arbitrary address. This is acheived by introducing range
parameters to a few of the dm_pci_* functions that allow the ranges to
be checked.

The series also adds a few new configs to allow parts of virtio and PCI
to be disabled where the features may be unused and the current
implementations don't have the needed consistencty checks.

2 years agopci: Add config for Enhanced Allocation
Andrew Scull [Thu, 21 Apr 2022 16:11:16 +0000 (16:11 +0000)]
pci: Add config for Enhanced Allocation

Add a config to control whether Enhanced Allocation is supported by the
driver.

Signed-off-by: Andrew Scull <ascull@google.com>
2 years agovirtio: pci: Make use of dm_pci_map_bar()
Andrew Scull [Thu, 21 Apr 2022 16:11:15 +0000 (16:11 +0000)]
virtio: pci: Make use of dm_pci_map_bar()

The virtio PCI capabilities describe regions of memory that should be
mapped. Map those with dm_pci_map_bar() which will ensure they are valid
PCI regions.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agovirtio: pci: Check virtio configs are mapped
Andrew Scull [Thu, 21 Apr 2022 16:11:14 +0000 (16:11 +0000)]
virtio: pci: Check virtio configs are mapped

Prepare for calls to `virtio_pci_map_capability()` failing by returning
NULL on error. If this happens, later accesses to the pointers would be
unsafe so cause the probe to fail if such an error occurs.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agopci: Add mask parameter to dm_pci_map_bar()
Andrew Scull [Thu, 21 Apr 2022 16:11:13 +0000 (16:11 +0000)]
pci: Add mask parameter to dm_pci_map_bar()

Add a mask parameter to control the lookup of the PCI region from which
the mapping can be made.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agopci: Update dm_pci_bus_to_virt() parameters
Andrew Scull [Thu, 21 Apr 2022 16:11:12 +0000 (16:11 +0000)]
pci: Update dm_pci_bus_to_virt() parameters

Add mask parameter and reorder length parameter to match the other PCI
address conversion functions. Using PCI_REGION_TYPE as the mask gives
the old behaviour.

It's converted from a macro to an inline function as the length
parameter is now used twice, but should only be calculated once.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agopci: Match region flags using a mask
Andrew Scull [Thu, 21 Apr 2022 16:11:11 +0000 (16:11 +0000)]
pci: Match region flags using a mask

When converting addresses, apply a mask to the region flags during
lookup. This allows the caller to specify which flags are important and
which are not, for example to exclude system memory regions.

The behaviour of the function is changed such that they don't
preferentially search for a non-system memory region. However, system
memory regions are added after other regions in decode_regions() leading
to a similar outcome.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agopci: Map bars with offset and length
Andrew Scull [Thu, 21 Apr 2022 16:11:10 +0000 (16:11 +0000)]
pci: Map bars with offset and length

Evolve dm_pci_map_bar() to include an offset and length parameter. These
allow a portion of the memory to be mapped and range checks to be
applied.

Passing both the offset and length as zero results in the previous
behaviour and this is used to migrate the previous callers.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agotest: pci: Test PCI address conversion functions
Andrew Scull [Thu, 21 Apr 2022 16:11:09 +0000 (16:11 +0000)]
test: pci: Test PCI address conversion functions

Add tests for the functions dm_pci_bus_to_phys() and
dm_pci_phys_to_bus() which convert between PCI bus addresses and
physical addresses based on the ranges declared for the PCI controller.

The ranges of bus#1 are used for the tests, adding a translation to one
of the ranges to cover more cases.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agopci: Range check address conversions
Andrew Scull [Thu, 21 Apr 2022 16:11:08 +0000 (16:11 +0000)]
pci: Range check address conversions

When converting between PCI bus and physical addresses, include a length
parameter that can be used to check that the entire range fits within
one of the PCI regions. This prevents an address being returned that
might be only partially valid for the range it is going to be used for.

Where the range check is not wanted, passing a length of 0 will have the
same behaviour as before this change.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agopci: Check region ranges are addressable
Andrew Scull [Thu, 21 Apr 2022 16:11:07 +0000 (16:11 +0000)]
pci: Check region ranges are addressable

When parsing the `ranges` DT node, check that both extremes of the
regions are addressable without overflow. This assumption can then be
safely made when processing the regions.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>