platform/kernel/u-boot.git
17 months agoglobal: Move remaining CONFIG_SYS_NAND_* to CFG_SYS_NAND_*
Tom Rini [Sat, 12 Nov 2022 22:36:51 +0000 (17:36 -0500)]
global: Move remaining CONFIG_SYS_NAND_* to CFG_SYS_NAND_*

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

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_SIZE to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:50 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_SIZE to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_SIZE

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_PAGE_2K et al to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:49 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_PAGE_2K et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_PAGE_2K
   CONFIG_SYS_NAND_PAGE_4K

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_NO_SUBPAGE_WRITE to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:48 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_NO_SUBPAGE_WRITE to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_NO_SUBPAGE_WRITE

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_MAX_OOBFREE et al to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:47 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_MAX_OOBFREE et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_MAX_OOBFREE
   CONFIG_SYS_NAND_MAX_ECCPOS

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agomtd: nand: raw: atmel_nand: Use ATMEL_BASE_ECC directly
Tom Rini [Sat, 12 Nov 2022 22:36:46 +0000 (17:36 -0500)]
mtd: nand: raw: atmel_nand: Use ATMEL_BASE_ECC directly

This is the only driver, and only one platform makes use of, setting
CONFIG_SYS_NAND_ECC_BASE. Reference ATMEL_BASE_ECC directly in this
case.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_HW_ECC to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:45 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_HW_ECC to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_HW_ECC

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_HW_ECC_OOBFIRST to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:44 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_HW_ECC_OOBFIRST to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_HW_ECC_OOBFIRST

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoRemove unused symbols
Tom Rini [Sat, 12 Nov 2022 22:36:43 +0000 (17:36 -0500)]
Remove unused symbols

This commit removes the following unused symbols:
   CONFIG_SYS_NAND_DDR_LAW
   CONFIG_SYS_NAND_ECCSTEPS
   CONFIG_SYS_NAND_ECCTOTAL
   CONFIG_SYS_NAND_ENABLE_PIN_SPL
   CONFIG_SYS_NAND_MX7_GPMI_62_ECC_BYTES
   CONFIG_SYS_NAND_U_BOOT_RELOC_SP

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoConvert CONFIG_SYS_NAND_DBW_8 et al to Kconfig
Tom Rini [Sat, 12 Nov 2022 22:36:42 +0000 (17:36 -0500)]
Convert CONFIG_SYS_NAND_DBW_8 et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_DBW_8
   CONFIG_SYS_NAND_DBW_16

Note that all instances of the code check for CONFIG_SYS_NAND_DBW_16
being defined, and then "else" to CONFIG_SYS_NAND_DBW_8 whereas all of
the configs set CONFIG_SYS_NAND_DBW_8. So we introduce
CONFIG_SYS_NAND_DBW_16 as an option.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoPrepare v2023.01-rc3
Tom Rini [Mon, 5 Dec 2022 20:21:53 +0000 (15:21 -0500)]
Prepare v2023.01-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>
17 months agoMerge branch '2022-12-05-add-IPv6-support'
Tom Rini [Mon, 5 Dec 2022 18:28:22 +0000 (13:28 -0500)]
Merge branch '2022-12-05-add-IPv6-support'

To quote the author:
This patch set adds basic IPv6 support to U-boot.
It is based on Chris's Packham patches
(https://lists.denx.de/pipermail/u-boot/2017-January/279366.html)
Chris's patches were taken as base. There were efforts to launch it on
HiFive SiFive Unmatched board but the board didn't work well. The code was
refactored, fixed some bugs as CRC for little-endian, some parts were implemented in
our own way, something was taken from Linux. Finally we did manual tests and the
board worked well.

Testing was done on HiFive SiFive Unmatched board (RISC-V)

17 months agoconfigs: Add IPV6 config to sandbox_flattree_defconfig
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:17 +0000 (12:18 +0300)]
configs: Add IPV6 config to sandbox_flattree_defconfig

Allow to use IPV6 tests in sandbox

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
17 months agoconfigs: Add IPV6 config to sandbox64_defconfig
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:16 +0000 (12:18 +0300)]
configs: Add IPV6 config to sandbox64_defconfig

Allow to use IPV6 tests in sandbox

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
17 months agoconfigs: Add IPV6 config to sandbox_defconfig
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:14 +0000 (12:18 +0300)]
configs: Add IPV6 config to sandbox_defconfig

Allow to use IPV6 tests in sandbox

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
17 months agotest: dm: eth: Add ip6_make_lladdr test
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:13 +0000 (12:18 +0300)]
test: dm: eth: Add ip6_make_lladdr test

Add a test that checks generated Link Local Address. Use in sandbox

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agotest: dm: eth: Add ip6_make_snma test
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:12 +0000 (12:18 +0300)]
test: dm: eth: Add ip6_make_snma test

Add a test that checks generated Solicited Node Multicast Address from our
ipv6 address. Use in sandbox

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agotest: dm: eth: Add ip6_addr_in_subnet test
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:11 +0000 (12:18 +0300)]
test: dm: eth: Add ip6_addr_in_subnet test

Add a test if two address are in the same subnet. Use in sandbox

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agotest: dm: eth: Add csum_ipv6_magic test
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:10 +0000 (12:18 +0300)]
test: dm: eth: Add csum_ipv6_magic test

Test checksum computation. csum_ipv6_magic() uses in upper layer
protocols as TCP/UDP/ICMPv6/etc to calculate payload checksum.

Series-changes: 3
- Fixed style problems

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agotest: dm: eth: Add string_to_ip6 test
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:09 +0000 (12:18 +0300)]
test: dm: eth: Add string_to_ip6 test

Add a test to check convertation from char* to struct in6_addr.
Use in sandbox

Series-changes: 3
- Fixed tests to use length param in string_to_ip6()

Series-changes: 5
- Add test under #ifdef

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ping6: Add ping6 command
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:08 +0000 (12:18 +0300)]
net: ping6: Add ping6 command

Implement ping6 command to ping hosts using IPv6. It works the same way as
an ordinary ping command. There is no ICMP request so it is not possible
to ping our host. This patch adds options in Kconfig and Makefile to
build ping6 command.

Series-changes: 3
- Added structures and functions descriptions
- Added to ping6_receive() return value instead of void

Series-changes: 4
- Fixed structures and functions description style

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: tftp: Add IPv6 support for tftpboot
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:07 +0000 (12:18 +0300)]
net: tftp: Add IPv6 support for tftpboot

The command tftpboot uses IPv4 by default. Add the possibility to use IPv6
instead. If an address in the command is an IPv6 address it will use IPv6
to boot or if there is a suffix -ipv6 in the end of the command it also
force using IPv6. All other tftpboot features and parameters are left
the same.

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Incorporate IPv6 support into u-boot net subsystem
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:06 +0000 (12:18 +0300)]
net: ipv6: Incorporate IPv6 support into u-boot net subsystem

Add net_ip6_handler (an IPv6 packet handler) into net_loop. Add
neighbor discovery mechanism into network init process. That is the
main step to run IPv6 in u-boot. Now u-boot is capable to use NDP and
handle IPv6 packets.

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add implementation of main IPv6 functions
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:05 +0000 (12:18 +0300)]
net: ipv6: Add implementation of main IPv6 functions

Functions that were exposed in "net: ipv6: Add IPv6 basic primitives"
had only empty implementations and were exposed as API for futher
patches. This patch add implementation of these functions. Main
functions are: net_ip6_handler() - IPv6 packet handler for incoming
packets; net_send_udp_packet6() - make up and send an UDP packet;
csum_ipv6_magic() - compute checksum of IPv6 "psuedo-header" per RFC2460
section 8.1; ip6_addr_in_subnet() - check if an address is in our
subnet. Other functions are auxiliary.

Series-changes: 3
- Added comments
- Fixed style problems
- Fixed return codes instead of -1

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add ip6addr, gatewayip6, serverip6 variables callbacks
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:04 +0000 (12:18 +0300)]
net: ipv6: Add ip6addr, gatewayip6, serverip6 variables callbacks

Implement actions on ip6addr, gatewayip6, serverip6 varaibles.
on_ip6addr - convert IPv6 string addr to struct ip6_addr
on_gatewayip6 - convert IPv6 string addr to struct ip6_addr
on_serverip6 - convert IPv6 string addr to struct ip6_addr

Series-changes: 3
- Removed memory allocation
- Substituted -1 for error code

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Enable IPv6 typeconversion specifier
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:03 +0000 (12:18 +0300)]
net: ipv6: Enable IPv6 typeconversion specifier

Add the possibility to recognize IPv6 address in print function.
To output IPv6 address use %pI6 specifier.

Series-changes: 3
- Substituted #if (...) for if (...) to get better readability

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add string_to_ip6 converter
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:02 +0000 (12:18 +0300)]
net: ipv6: Add string_to_ip6 converter

This functions is used as a converter from IPv6 address string notation
to struct ip6_addr that is used everywhere in IPv6 implementation. For
example it is used to parse and convert IPv6 address from tftpboot
command. Conversion algorithm uses two passes, first to verify syntax and
locate colons and second pass to read the address. In case of valid IPv6
address it returns 0.

Examples of valid strings:
2001:db8::0:1234:1
2001:0db8:0000:0000:0000:0000:1234:0001
::1
::ffff:192.168.1.1

Examples of invalid strings
2001:db8::0::0          (:: can only appear once)
2001:db8:192.168.1.1::1 (v4 part can only appear at the end)
192.168.1.1             (we don't implicity map v4)

Series-changes: 3
- Added function description
- Added length parameter to string_to_ip6()

Series-changes: 4
- Fixed function description style

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add Neighbor Discovery Protocol (NDP)
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:01 +0000 (12:18 +0300)]
net: ipv6: Add Neighbor Discovery Protocol (NDP)

Implement basic of NDP. It doesn't include such things as Router
Solicitation, Router Advertisement and Redirect. It just has Neighbor
Solicitation and Neighbor Advertisement. Only these two features are used
in u-boot IPv6. Implementation of some NDP functions uses API that was
exposed in "net: ipv6: Add IPv6 basic primitives".

Also this patch inlcudes update in Makefile to build NDP.

Series-changes: 3
- Added structures and functions descriptions
- Fixed style problems

Series-changes: 4
- Fixed structures and functions description style

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add callbacks declarations to get access to IPv6 variables
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:18:00 +0000 (12:18 +0300)]
net: ipv6: Add callbacks declarations to get access to IPv6 variables

Set up callbacks for main IPv6 variables ip6add, serverip6, gatewayip6
and set options to them in flag file. These variables are often set up by
users.

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add IPv6 build options
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:17:59 +0000 (12:17 +0300)]
net: ipv6: Add IPv6 build options

Add options to Makefile and Kconfig file to build IPv6

Series-changes: 3
- Added help for IPv6 support

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agonet: ipv6: Add IPv6 basic primitives
Viacheslav Mitrofanov [Fri, 2 Dec 2022 09:17:58 +0000 (12:17 +0300)]
net: ipv6: Add IPv6 basic primitives

This patch is a collection of basic primitives that are prerequisite for
further IPv6 implementation.

There are structures definition such as IPv6 header, UDP header
(for TFTP), ICMPv6 header. There are auxiliary defines such as protocol
codes, padding, struct size and etc. Also here are functions prototypes
and its empty implementation that will be used as API for further patches.
Here are variables declaration such as IPv6 address of our host,
gateway, ipv6 server.

Series-changes: 3
- Added functions and structures descriptions
- Removed enums ND_OPT_*. It will be moved into further patches
- Substituted -1 for error codes

Series-changes: 4
- Changed functions and structures description style

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoMerge tag 'xilinx-for-v2023.01-rc3-v2' of https://source.denx.de/u-boot/custodians...
Tom Rini [Mon, 5 Dec 2022 13:33:19 +0000 (08:33 -0500)]
Merge tag 'xilinx-for-v2023.01-rc3-v2' of https://source.denx.de/u-boot/custodians/u-boot-microblaze

Xilinx changes for v2023.01-rc3-v2

xilinx:
- Fix MAC address selection for System Controller from FRU
- Cleanup Kconfig (ZYNQ_MAC_IN_EEPROM symbol)

versal:
- Create u-boot.elf for mini spi configurations

versal-net:
- Enable MT35XU flash

zynq:
- Add missing timer to DT for mini configurations

zynqmp:
- Do not include psu_init to U-Boot by default
- Do not enable IPI by default to mini U-Boot
- Update Luca's fragment
- Fix SPL_FS_LOAD_PAYLOAD_NAME usage

spi:
- gqspi: Fix tapdelay values
- gqspi: Fix 64bit address support
- cadence: Remove condition for calling enable linear mode
- nor-core: Invert logic to reflect sst26 flash unlocked

net:
- Add PCS/PMA phy support

17 months agoMerge tag 'i2cfixes-for-v2023.01-rc3' of https://source.denx.de/u-boot/custodians...
Tom Rini [Mon, 5 Dec 2022 13:33:01 +0000 (08:33 -0500)]
Merge tag 'i2cfixes-for-v2023.01-rc3' of https://source.denx.de/u-boot/custodians/u-boot-i2c

i2c Fixes for v2023.01-rc3

- nuovoton driver:
  rename npcm_i2c -> npcm-i2c from Jim Liu

17 months agomtd: spi-nor-core: Invert logic to reflect sst26 flash unlocked
Algapally Santosh Sagar [Tue, 22 Nov 2022 05:18:33 +0000 (22:18 -0700)]
mtd: spi-nor-core: Invert logic to reflect sst26 flash unlocked

flash_is_locked is changed to flash_is_unlocked with commit 513c6071ce73
("mtd: spi: Convert is_locked callback to is_unlocked"). sst26_is_locked()
is also changed to sst26_is_unlocked() but the logic remained same.
Invert the logic for the flash lock/unlock to work properly.

Signed-off-by: Algapally Santosh Sagar <santoshsagar.algapally@amd.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Link: https://lore.kernel.org/r/20221122051833.13306-1-ashok.reddy.soma@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agoxilinx: zynqmp: Fix SPL_FS_LOAD_PAYLOAD_NAME usage
Michal Simek [Fri, 2 Dec 2022 13:06:15 +0000 (14:06 +0100)]
xilinx: zynqmp: Fix SPL_FS_LOAD_PAYLOAD_NAME usage

SPL_FS_LOAD_PAYLOAD_NAME depends on SPL to be enabled.
If SPL is not enabled code still expects SPL_FS_LOAD_PAYLOAD_NAME to be
present. That's why setup proper dependency in the code.
And by doing so also change the logic around dfu_alt_info string
composition to be simpler.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/3989c390a4acae13a1b05c040e14fb3d68bced02.1669986373.git.michal.simek@amd.com
17 months agoarm64: versal-net: Enable defconfig for Micron octal flashes
Ashok Reddy Soma [Tue, 29 Nov 2022 10:18:31 +0000 (11:18 +0100)]
arm64: versal-net: Enable defconfig for Micron octal flashes

Micron mt35 series octal flashes are under config option
CONFIG_SPI_FLASH_MT35XU. Enable it in default defconfig for octal
flashes to be detected.

Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/dfaf73a72c7b408f1b8530f411c405d3dcf9f854.1669717110.git.michal.simek@amd.com
17 months agospi: cadence-qspi: Remove condition for calling enable linear mode
Ashok Reddy Soma [Tue, 29 Nov 2022 11:41:34 +0000 (04:41 -0700)]
spi: cadence-qspi: Remove condition for calling enable linear mode

cadence_qspi_apb_enable_linear_mode() has a weak function defined, so no
need to gaurd this under if (CONFIG_IS_ENABLED(ARCH_VERSAL)).

In cadence_qspi_apb_write_execute(), enable linear mode is called twice by
mistake, remove extra one.

Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Link: https://lore.kernel.org/r/20221129114134.18909-1-ashok.reddy.soma@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agoARM: zynq: Add missing twd timer for mini configurations
Michal Simek [Tue, 29 Nov 2022 12:23:20 +0000 (13:23 +0100)]
ARM: zynq: Add missing twd timer for mini configurations

The commit b7e0750d8872 ("zynq: Convert arm twd timer to DM driver")
switched timer to DM but missing to add nodes to all mini configurations.
Based on it missing timer end up in non functional system where any delay
doesn't work.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/2020fc7e3d4760e890265485b3c7e18eb1caf8be.1669724598.git.michal.simek@amd.com
17 months agoarm64: zynqmp: Do not enable IPI by default
Michal Simek [Tue, 29 Nov 2022 15:09:42 +0000 (16:09 +0100)]
arm64: zynqmp: Do not enable IPI by default

ZynqMP mini configurations are not using IPI driver and enabling this is
adding additional ~1200 Bytes (depends on configuration).
This ends up in situation that there is no enough space in OCM for
relocation that's why disable this driver for all mini configurations.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/c71bab3927cb71ae517d9c21f59f3d5cf0caf712.1669734580.git.michal.simek@amd.com
17 months agoarm64: zynqmp: Do not include psu_init to U-Boot by default
Michal Simek [Fri, 2 Dec 2022 08:18:06 +0000 (09:18 +0100)]
arm64: zynqmp: Do not include psu_init to U-Boot by default

The commit ed35de617013 ("Convert CONFIG_ZYNQMP_PSU_INIT_ENABLED to
Kconfig") converted CONFIG_ZYNQMP_PSU_INIT_ENABLED symbol and enabled it by
default which is not correct configuration.
Intention of this config was to have it enabled by default for SPL and
provide an option to users to also do low level initialization directly
from U-Boot.
That's why it is necessary to define second symbol with SPL marking in it
and properly use symbols depends on usage in Makefile.
Also disable ZYNQMP_PSU_INIT_ENABLED from boards which enables it by
default. CONFIG_SPL_ZYNQMP_PSU_INIT_ENABLED is enabled by default when SPL
is enabled.

Reported-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Reviewed-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/d5fcbd66b05bf0d7ef594e66464ee23b48c5e4cc.1669969083.git.michal.simek@amd.com
17 months agoboard/xilinx/zynqmp/MAINTAINERS: change e-mail address for Luca Ceresoli
Luca Ceresoli [Sat, 3 Dec 2022 21:49:39 +0000 (22:49 +0100)]
board/xilinx/zynqmp/MAINTAINERS: change e-mail address for Luca Ceresoli

My Bootlin address is the preferred one now.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Link: https://lore.kernel.org/r/20221203214939.56608-1-luca@lucaceresoli.net
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agoxilinx: Remove unused ZYNQ_MAC_IN_EEPROM/ZYNQ_GEM_I2C_MAC_OFFSET entries
Michal Simek [Wed, 23 Nov 2022 08:27:08 +0000 (09:27 +0100)]
xilinx: Remove unused ZYNQ_MAC_IN_EEPROM/ZYNQ_GEM_I2C_MAC_OFFSET entries

The commit ba74bcf3e07b ("xilinx: common: Remove
zynq_board_read_rom_ethaddr()") removed zynq_board_read_rom_ethaddr()
because xlnx,eeprom link via DT chosen node is no longer used. But forget
to remove Kconfig entries which are used by this code only.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/f97451ed33409838efea4071553b6da795cfc578.1669192026.git.michal.simek@amd.com
17 months agoxilinx: Add option to select SC id instead of DUT id for SC support
Michal Simek [Wed, 23 Nov 2022 11:48:44 +0000 (12:48 +0100)]
xilinx: Add option to select SC id instead of DUT id for SC support

Reading MAC address from on board EEPROM requires different type for System
Controller (SC).

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/90bb7cc5463568a690b979f18c8d42556986b46d.1669204122.git.michal.simek@amd.com
17 months agospi: zynqmp_qspi: Add support for 64-bit read/write
Venkatesh Yadav Abbarapu [Fri, 25 Nov 2022 10:44:13 +0000 (16:14 +0530)]
spi: zynqmp_qspi: Add support for 64-bit read/write

When we pass the 64-bit address to read/write, only lower 32-bit
address is getting updated. Program the upper 32-bit address in the
DMA destination memory address MSBs register, which can handle upto
44-bit destination address.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Link: https://lore.kernel.org/r/20221125104413.26140-1-venkatesh.abbarapu@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agoarm64: versal: Enable REMAKE_ELF for mini_ospi/mini_qspi
Venkatesh Yadav Abbarapu [Fri, 25 Nov 2022 08:46:39 +0000 (14:16 +0530)]
arm64: versal: Enable REMAKE_ELF for mini_ospi/mini_qspi

Enable the config REMAKE_ELF in xilinx_versal_mini_ospi_defconfig
and xilinx_versal_mini_qspi_defconfig which generates u-boot.elf.
This commit a8c281d4b737("Convert CONFIG_REMAKE_ELF to Kconfig")
misses to enable this config in these defconfigs.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Link: https://lore.kernel.org/r/20221125084639.23835-1-venkatesh.abbarapu@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agospi: zynqmp_gqspi: Update tapdelay value
T Karthik Reddy [Wed, 23 Nov 2022 09:04:51 +0000 (02:04 -0700)]
spi: zynqmp_gqspi: Update tapdelay value

The driver was using an incorrect value for GQSPI_LPBK_DLY_ADJ_DLY_1
tapdelay for Versal for frequencies above 100MHz. Change it from 2 to 1
based on the recommended value in IP spec.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Link: https://lore.kernel.org/r/20221123090451.11409-1-ashok.reddy.soma@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agoarm64: zynqmp: dynamically mark r5 cores as used
Lukas Funke [Fri, 28 Oct 2022 12:15:47 +0000 (14:15 +0200)]
arm64: zynqmp: dynamically mark r5 cores as used

When Linux boot takes over control of the pmu
(by signaling PM_INIT_FINALIZE via ipi), pmu will switch off 'unused'
rpu cores. The Xilinx zynqmp fsbl prevents switching off those cores by
marking rpu cores as 'used' when loading code partitions to those cores.
The current u-boot SPL is missing this behaviour, which results in
halting rpu cores during Linux boot.

This commit mimics the xilinx zynqmp fsbl behavior by marking r5 cores as
used when they are released during boot.

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
Signed-off-by: Lukas Funke <lukas.funke-oss@weidmueller.com>
Link: https://lore.kernel.org/r/20221028121547.26464-2-lukas.funke-oss@weidmueller.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agonet: xilinx_axi: check PCS/PMA PHY status in setup_phy
Andy Chiu [Tue, 1 Nov 2022 03:58:00 +0000 (11:58 +0800)]
net: xilinx_axi: check PCS/PMA PHY status in setup_phy

Both PCS/PMA PHY and the external PHY need to have a valid link status
in order to have Ethernet traffic. Check and wait this status at
setup_phy() so that we could diagnose if there is a PHY issue.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Link: https://lore.kernel.org/r/20221101035800.912644-3-andy.chiu@sifive.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agonet: xilinx_axi: add PCS/PMA PHY
Andy Chiu [Tue, 1 Nov 2022 03:57:59 +0000 (11:57 +0800)]
net: xilinx_axi: add PCS/PMA PHY

If we bridge an external PHY to Xilinx's PCS/PMA PHY and would like to
get and set the real status of the PHY facing the external world. Then
we should phy_connect() to the external PHY instead of the PCS/PMA one.
Thus, we add a pcs-handle DT entry, which have been merged in Linux, and
leave the configuration of it to the driver itself.

Unlike Linux, where the PCS/PMA PHY is managed by phylink, managing the
PCS/PMA PHY is only internal to the driver in U-Boot. The PCS/PMA PHY
pressents only when the phy-mode is configured as SGMII or 1000Base-X,
so it is always 1 Gbps and full-duplex and we may skip passing link
information out.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Link: https://lore.kernel.org/r/20221101035800.912644-2-andy.chiu@sifive.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
17 months agoi2c: nuvoton: renamed the NPCM i2c driver
Jim Liu [Mon, 21 Nov 2022 08:59:32 +0000 (16:59 +0800)]
i2c: nuvoton: renamed the NPCM i2c driver

The Makefile name is npcm_i2c but the driver is npcm-i2c.

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
17 months agoMerge tag 'efi-2023-01-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sun, 4 Dec 2022 15:01:48 +0000 (10:01 -0500)]
Merge tag 'efi-2023-01-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2023-01-rc3

Documentation:

* describe DM firmware needed for j721e_evm
* describe management of UEFI security data base with eficonfig

UEFI:

* code clean-up for eficonfig command
* fix handling of DHCP aknowledge
* correct EFI memory type used for U-Boot code
* unit test for FatToStr() truncation
* add an EFI binary to print boot hart ID

Other:

* improve parameter checks in console functions
* fix variable initialization in blk_get_device_part_str

17 months agodoc: eficonfig: add description for UEFI Secure Boot Configuration
Masahisa Kojima [Fri, 2 Dec 2022 04:59:37 +0000 (13:59 +0900)]
doc: eficonfig: add description for UEFI Secure Boot Configuration

This commits adds the description for the UEFI Secure Boot
Configuration through the eficonfig menu.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Redacted the complete document.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
17 months agoeficonfig: use efi_get_next_variable_name_int()
Masahisa Kojima [Fri, 2 Dec 2022 04:59:36 +0000 (13:59 +0900)]
eficonfig: use efi_get_next_variable_name_int()

eficonfig command reads all possible UEFI load options
from 0x0000 to 0xFFFF to construct the menu. This takes too much
time in some environment.
This commit uses efi_get_next_variable_name_int() to read all
existing UEFI load options to significantlly reduce the count of
efi_get_var() call.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
17 months agoefi_loader: utility function to check the variable name is "Boot####"
Masahisa Kojima [Fri, 2 Dec 2022 04:59:35 +0000 (13:59 +0900)]
efi_loader: utility function to check the variable name is "Boot####"

Some commands need to enumerate the existing UEFI load
option variable("Boot####"). This commit transfers some code
from cmd/efidebug.c to lib/efi_loder/, then exposes
efi_varname_is_load_option() function to check whether
the UEFI variable name is "Boot####".

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
17 months agoeficonfig: use u16_strsize() to get u16 string buffer size
Masahisa Kojima [Fri, 2 Dec 2022 04:59:34 +0000 (13:59 +0900)]
eficonfig: use u16_strsize() to get u16 string buffer size

Use u16_strsize() to simplify the u16 string buffer
size calculation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
17 months agoeficonfig: fix going one directory up issue
Masahisa Kojima [Fri, 2 Dec 2022 04:59:33 +0000 (13:59 +0900)]
eficonfig: fix going one directory up issue

The directory name in eficonfig menu entry contains the
'\' separator. strcmp() argument ".." is wrong and one directory
up handling does not work correctly. strcmp() argument must
include '\' separator.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
17 months agodoc: board: typo GIUD Microchip MPFS Icicle Kit doc
Heinrich Schuchardt [Wed, 30 Nov 2022 16:58:56 +0000 (17:58 +0100)]
doc: board: typo GIUD Microchip MPFS Icicle Kit doc

%s/GIUD/GUID/

Fixes: 9e550e18305f ("doc: board: Add Microchip MPFS Icicle Kit doc")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
17 months agoefi_loader: don't use EFI_LOADER_DATA internally
Heinrich Schuchardt [Tue, 29 Nov 2022 15:00:41 +0000 (16:00 +0100)]
efi_loader: don't use EFI_LOADER_DATA internally

EFI_LOADER_DATA/CODE is reserved for EFI applications.
Memory allocated by U-Boot for internal usage should be
EFI_BOOT_SERVICES_DATA or _CODE or EFI_RUNTIME_SERVICES_DATA or _CODE.

Reported-by: François-Frédéric Ozog <ff@ozog.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: François-Frédéric Ozog <ff@ozog.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
17 months agoefi_loader: fix handling of DHCP acknowledge
Heinrich Schuchardt [Sat, 26 Nov 2022 15:44:38 +0000 (16:44 +0100)]
efi_loader: fix handling of DHCP acknowledge

The dhcp command may be executed after the first UEFI command.
We should still update the EFI_PXE_BASE_CODE_PROTOCOL.

Don't leak content of prior acknowledge packages.

Handle failing allocation when calling malloc().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
17 months agoefi_selftest: test FatToStr() truncation
Heinrich Schuchardt [Tue, 22 Nov 2022 11:25:10 +0000 (12:25 +0100)]
efi_selftest: test FatToStr() truncation

Let the FatToStr test check that the FatSize parameter is considered.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
17 months agoefi_loader: add an EFI binary to print boot hart ID
Heinrich Schuchardt [Thu, 1 Dec 2022 18:07:57 +0000 (19:07 +0100)]
efi_loader: add an EFI binary to print boot hart ID

Provide an EFI binary that prints the boot hart ID as found in the
device-tree as /chosen/boot-hartid property and as provided by the
RISCV_EFI_BOOT_PROTOCOL.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
17 months agodoc: board: j721e_evm: Fix code-block type and indents
Andrew Davis [Wed, 9 Nov 2022 17:30:01 +0000 (11:30 -0600)]
doc: board: j721e_evm: Fix code-block type and indents

* BASH code should be labeled as such.
 * Code blocks should be indented by 4 spaces.

Fix these here.

Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Andrew Davis <afd@ti.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
17 months agodoc: board: j721e_evm: Add DM firmware steps
Andrew Davis [Wed, 9 Nov 2022 17:30:00 +0000 (11:30 -0600)]
doc: board: j721e_evm: Add DM firmware steps

J721e needs DM firmware when using updated SYSFW. Add steps to fetch,
build, and deploy the same.

Signed-off-by: Andrew Davis <afd@ti.com>
17 months agonet: CONFIG_NET_DEVICES in dhcp_handler()
Heinrich Schuchardt [Sat, 26 Nov 2022 15:32:25 +0000 (16:32 +0100)]
net: CONFIG_NET_DEVICES in dhcp_handler()

The symbol CONFIG_NET_DEVICES does not exist.
The correct name is CONFIG_NETDEVICES.

Fixes: 77b5c4a5b1dc ("efi_loader: Let networking support depend on NETDEVICES")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
17 months agodisk: fix blk_get_device_part_str()
Heinrich Schuchardt [Sun, 20 Nov 2022 10:23:24 +0000 (11:23 +0100)]
disk: fix blk_get_device_part_str()

blk_get_device_part_str() should always initialize all info fields
including sys_ind. As a side effect the code is simplified.

Replace '(0 ==' by '(!' to conform with Linux coding style.

Fixes: 4d907025d6a5 ("sandbox: restore ability to access host fs through standard commands")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
17 months agoconsole: file should always be non-negative
Heinrich Schuchardt [Sat, 22 Oct 2022 09:32:34 +0000 (11:32 +0200)]
console: file should always be non-negative

We use the parameter file in console functions to choose from an array
after checking against MAX_FILES but we never check if the value of file
is negative.

Running ./u-boot -T -l and issuing the poweroff command has resulted in
crashes because os_exit() results in std::ostream::flush() calling U-Boot's
fflush with file being a pointer which when converted to int may be
represented by a negative number.

This shows that checking against MAX_FILES is not enough. We have to ensure
that the file argument is always positive.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoMerge branch '2022-12-02-assorted-updates'
Tom Rini [Fri, 2 Dec 2022 15:00:55 +0000 (10:00 -0500)]
Merge branch '2022-12-02-assorted-updates'

- Add Peter Robinson as a co-custodian for Pi, update the maintainer
  record for common/usb_storage.c, re-add bmp_logo to tools-only and fix
  SPI booting on the SanCloud BBE

17 months agoMAINTAINERS: Adopt SanCloud boards
Paul Barker [Mon, 14 Nov 2022 12:42:43 +0000 (12:42 +0000)]
MAINTAINERS: Adopt SanCloud boards

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
Cc: Marc Murphy <marc.murphy@sancloud.com>
17 months agoam335x-sancloud-bbe: Add -u-boot.dtsi files
Paul Barker [Mon, 14 Nov 2022 12:42:42 +0000 (12:42 +0000)]
am335x-sancloud-bbe: Add -u-boot.dtsi files

The SanCloud BBE requires the same dtb nodes to be present in the SPL as
the AM335x EVM.

The SanCloud BBE Lite also requires the SPI flash node and all
dependencies to be present in the SPL to support SPI boot.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agoam335x-sancloud-bbe-lite: SPI flash is JEDEC compatible
Paul Barker [Mon, 14 Nov 2022 12:42:41 +0000 (12:42 +0000)]
am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agoam335x-evm: Support STMicro/Micron SPI flash
Paul Barker [Mon, 14 Nov 2022 12:42:40 +0000 (12:42 +0000)]
am335x-evm: Support STMicro/Micron SPI flash

This change enables access to the SPI flash on the SanCloud BBE Lite
board.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agoam335x-evm: Fix spiboot configuration
Paul Barker [Mon, 14 Nov 2022 12:42:39 +0000 (12:42 +0000)]
am335x-evm: Fix spiboot configuration

The advanced address translation provided by CONFIG_SPL_OF_TRANSLATE is
needed to determine the base address of the uart0 peripheral on am335x
platforms when CONFIG_SPL_OF_CONTROL is enabled.

If CONFIG_SPL_OF_CONTROL is enabled in the base (non-spiboot)
am335x_evm_defconfig, then CONFIG_SPL_OF_TRANSLATE will also need to be
enabled there. Unfortunately this cannot be done pre-emptively due to
the kconfig dependencies.

The TI clk-ctrl & TI sysc drivers are also required to bring up the SPI
bus on am335x platforms.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agoam335x-evm: Enable required dtb nodes in SPL
Paul Barker [Mon, 14 Nov 2022 12:42:38 +0000 (12:42 +0000)]
am335x-evm: Enable required dtb nodes in SPL

For successful boot when CONFIG_SPL_OF_CONTROL=y, we need to ensure that
the board EEPROM on i2c0, the uart0 serial port and the relevant boot
device (mmc1 or mmc2) can be accessed in the SPL. We also need to
preserve the parent nodes for each required dtb node.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agobus: Optionally include TI sysc driver in SPL/TPL
Paul Barker [Mon, 14 Nov 2022 12:42:37 +0000 (12:42 +0000)]
bus: Optionally include TI sysc driver in SPL/TPL

The TI sysc bus driver is required to allow access to the SPI bus on
am335x platforms. To support SPI boot this driver needs to be enabled in
the SPL/TPL as appropriate.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agobus: TI sysc driver requires DM
Paul Barker [Mon, 14 Nov 2022 12:42:36 +0000 (12:42 +0000)]
bus: TI sysc driver requires DM

This driver does not build if CONFIG_DM is disabled as it uses the
function `dev_get_priv`.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agodm: core: Fix iteration over driver_info records
Paul Barker [Mon, 14 Nov 2022 12:42:35 +0000 (12:42 +0000)]
dm: core: Fix iteration over driver_info records

We should only perform additional iteration steps when needed to
initialize the parent of a device. Other binding errors (such as a
missing driver) should not lead to additional iteration steps.

Unnecessary iteration steps can cause issues when memory is tightly
constrained (such as in the TPL/SPL) since device_bind_by_name()
unconditionally allocates memory for a struct udevice. On the SanCloud
BBE this led to boot failure caused by memory exhaustion in the SPL
when booting from SPI flash.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
17 months agoMAINTAINERS: Move usb_storage from DFU to USB
Marek Vasut [Fri, 4 Nov 2022 11:28:07 +0000 (12:28 +0100)]
MAINTAINERS: Move usb_storage from DFU to USB

The usb_storage.c is the host-side USB mass storage device support,
it is not the DFU/UMS gadget-side implementation. Fix the entry.

Signed-off-by: Marek Vasut <marex@denx.de>
17 months agoconfig: tools only: add VIDEO to build bmp_logo
Peter Robinson [Thu, 24 Nov 2022 14:05:59 +0000 (14:05 +0000)]
config: tools only: add VIDEO to build bmp_logo

Pre 2023.01 the bmp_logo was built as part of the tools-only_defconfig
build, something changed and the VIDEO dep needed to build it
is no longer pulled in so fix that by explicitly defining it.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
17 months agoMAINTAINERS: add RaspberryPi co-maintainer
Matthias Brugger [Wed, 30 Nov 2022 11:57:49 +0000 (12:57 +0100)]
MAINTAINERS: add RaspberryPi co-maintainer

Peter accpeted to step up as a co-maintainer for the RPis.
Reflect that in the corresponding MAINTAINERS files.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
17 months agoMerge branch '2022-11-28-networking-updates-and-improvements'
Tom Rini [Mon, 28 Nov 2022 18:12:40 +0000 (13:12 -0500)]
Merge branch '2022-11-28-networking-updates-and-improvements'

- LiteX Ethernet support, dwc_eth_qos fixes, re-work fixing
  CVE-2022-{30790,30552}, macb race fix, Intel XWAY PHY support
  and add wget command and TCP support.

17 months agophy: add driver for Intel XWAY PHY
Tim Harvey [Thu, 17 Nov 2022 21:27:09 +0000 (13:27 -0800)]
phy: add driver for Intel XWAY PHY

Add a driver for the Intel XWAY GbE PHY:
 - configure RGMII using dt phy-mode and standard delay properties
 - use genphy_config

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
17 months agonet: macb: Fix race caused by flushing unwanted descriptors
Yaron Micher [Thu, 10 Nov 2022 17:31:34 +0000 (19:31 +0200)]
net: macb: Fix race caused by flushing unwanted descriptors

The rx descriptor list is in cached memory, and there may be multiple
descriptors per cache-line. After reclaim_rx_buffers marks a descriptor
as unused it does a cache flush, which causes the entire cache-line to
be written to memory, which may override other descriptors in the same
cache-line that the controller may have written to.

The fix skips freeing descriptors that are not the last in a cache-line,
and if the freed descriptor is the last one in a cache-line, it marks
all the descriptors in the cache-line as unused.
This is similarly to what is done in drivers/net/fec_mxc.c

In my case this bug caused tftpboot to fail some times when other
packets are sent to u-boot in addition to the ongoing tftp (e.g. ping).
The driver would stop receiving new packets because it is waiting
on a descriptor that is marked unused, when in reality the descriptor
contains a new unprocessed packet but while freeing the previous buffer
descriptor & flushing the cache, the driver accidentally marked the
descriptor as unused.

Signed-off-by: Yaron Micher <yaronm@hailo.ai>
17 months agotest: cmd: add test for wget command.
Ying-Chun Liu (PaulLiu) [Tue, 8 Nov 2022 06:17:31 +0000 (14:17 +0800)]
test: cmd: add test for wget command.

Simulate a TCP HTTP server's response for testing wget command.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agodoc: cmd: wget: add documentation
Ying-Chun Liu (PaulLiu) [Tue, 8 Nov 2022 06:17:30 +0000 (14:17 +0800)]
doc: cmd: wget: add documentation

Add documentation for the wget command.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agonet: Add wget application
Ying-Chun Liu (PaulLiu) [Tue, 8 Nov 2022 06:17:29 +0000 (14:17 +0800)]
net: Add wget application

This commit adds a simple wget command that can download files
from http server.

The command syntax is
wget ${loadaddr} <path of the file from server>

Signed-off-by: Duncan Hare <DuncanCHare@yahoo.com>
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agonet: Add TCP protocol
Ying-Chun Liu (PaulLiu) [Tue, 8 Nov 2022 06:17:28 +0000 (14:17 +0800)]
net: Add TCP protocol

Currently file transfers are done using tftp or NFS both
over udp. This requires a request to be sent from client
(u-boot) to the boot server.

The current standard is TCP with selective acknowledgment.

Signed-off-by: Duncan Hare <DH@Synoia.com>
Signed-off-by: Duncan Hare <DuncanCHare@yahoo.com>
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agodrivers: net: aquantia: fix typos
Tim Harvey [Thu, 3 Nov 2022 21:44:22 +0000 (14:44 -0700)]
drivers: net: aquantia: fix typos

Fix a couple of typos:
- s/Acquantia/Aquantia/
- s/firmare/firmware/

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agonet: deal with fragment-overlapping-two-holes case
Rasmus Villemoes [Mon, 17 Oct 2022 07:52:51 +0000 (09:52 +0200)]
net: deal with fragment-overlapping-two-holes case

With a suitable sequence of malicious packets, it's currently possible
to get a hole descriptor to contain arbitrary attacker-controlled
contents, and then with one more packet to use that as an arbitrary
write vector.

While one could possibly change the algorithm so we instead loop over
all holes, and in each hole puts as much of the current fragment as
belongs there (taking care to carefully update the hole list as
appropriate), it's not worth the complexity: In real, non-malicious
scenarios, one never gets overlapping fragments, and certainly not
fragments that would be supersets of one another.

So instead opt for this simple protection: Simply don't allow the
eventual memcpy() to write beyond the last_byte of the current hole.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
17 months agonet: tftp: sanitize tftp block size, especially for TX
Rasmus Villemoes [Fri, 14 Oct 2022 17:43:42 +0000 (19:43 +0200)]
net: tftp: sanitize tftp block size, especially for TX

U-Boot does not support IP fragmentation on TX (and unless
CONFIG_IP_DEFRAG is set, neither on RX). So the blocks we send must
fit in a single ethernet packet.

Currently, if tftpblocksize is set to something like 5000 and I
tftpput a large enough file, U-Boot crashes because we overflow
net_tx_packet (which only has room for 1500 bytes plus change).

Similarly, if tftpblocksize is set to something larger than what we
can actually receive (e.g. 50000, with NET_MAXDEFRAG being 16384), any
tftp get just hangs because we never receive any packets.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agonet: tftp: use IS_ENABLED(CONFIG_NET_TFTP_VARS) instead of #if
Rasmus Villemoes [Fri, 14 Oct 2022 17:43:41 +0000 (19:43 +0200)]
net: tftp: use IS_ENABLED(CONFIG_NET_TFTP_VARS) instead of #if

Nothing inside this block depends on NET_TFTP_VARS to be set to parse
correctly. Switch to C if() in preparation for adding code before
this (to avoid a declaration-after-statement warning).

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
[trini: Update to cover CONFIG_TFTP_PORT case as well]
Signed-off-by: Tom Rini <trini@konsulko.com>
17 months agonet: fix ip_len in reassembled IP datagram
Rasmus Villemoes [Fri, 14 Oct 2022 17:43:40 +0000 (19:43 +0200)]
net: fix ip_len in reassembled IP datagram

For some reason, the ip_len field in a reassembled IP datagram is set
to just the size of the payload, but it should be set to the value it
would have had if the datagram had never been fragmented in the first
place, i.e. size of payload plus size of IP header.

That latter value is currently returned correctly via the "len"
variable. And before entering net_defragment(), len does have the
value ntohs(ip->ip_len), so if we're not dealing with a
fragment (so net_defragment leaves *len alone), that relationship of
course also holds after the net_defragment() call.

The only use I can find of ip->ip_len after the net_defragment call is
the ntohs(ip->udp_len) > ntohs(ip->ip_len) sanity check - none of the
functions that are passed the "ip" pointer themselves inspect ->ip_len
but instead use the passed len.

But that sanity check is a bit odd, since the RHS really should be
"ntohs(ip->ip_len) - 20", i.e. the IP payload size.

Now that we've fixed things so that len == ntohs(ip->ip_len) in all
cases, change that sanity check to use len-20 as the RHS.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
17 months agonet: (actually/better) deal with CVE-2022-{30790,30552}
Rasmus Villemoes [Fri, 14 Oct 2022 17:43:39 +0000 (19:43 +0200)]
net: (actually/better) deal with CVE-2022-{30790,30552}

I hit a strange problem with v2022.10: Sometimes my tftp transfer
would seemingly just hang. It only happened for some files. Moreover,
changing tftpblocksize from 65464 to 65460 or 65000 made it work again
for all the files I tried. So I started suspecting it had something to
do with the file sizes and in particular the way the tftp blocks get
fragmented and reassembled.

v2022.01 showed no problems with any of the files or any value of
tftpblocksize.

Looking at what had changed in net.c or tftp.c since January showed
only one remotely interesting thing, b85d130ea0ca.

So I fired up wireshark on my host to see if somehow one of the
packets would be too small. But no, with both v2022.01 and v2022.10,
the exact same sequence of packets were sent, all but the last of size
1500, and the last being 1280 bytes.

But then it struck me that 1280 is 5*256, so one of the two bytes
on-the-wire is 0 and the other is 5, and when then looking at the code
again the lack of endianness conversion becomes obvious. [ntohs is
both applied to ip->ip_off just above, as well as to ip->ip_len just a
little further down when the "len" is actually computed].

IOWs the current code would falsely reject any packet which happens to
be a multiple of 256 bytes in size, breaking tftp transfers somewhat
randomly, and if it did get one of those "malicious" packets with
ip_len set to, say, 27, it would be seen by this check as being 6912
and hence not rejected.

====

Now, just adding the missing ntohs() would make my initial problem go
away, in that I can now download the file where the last fragment ends
up being 1280 bytes. But there's another bug in the code and/or
analysis: The right-hand side is too strict, in that it is ok for the
last fragment not to have a multiple of 8 bytes as payload - it really
must be ok, because nothing in the IP spec says that IP datagrams must
have a multiple of 8 bytes as payload. And comments in the code also
mention this.

To fix that, replace the comparison with <= IP_HDR_SIZE and add
another check that len is actually a multiple of 8 when the "more
fragments" bit is set - which it necessarily is for the case where
offset8 ends up being 0, since we're only called when

  (ip_off & (IP_OFFS | IP_FLAGS_MFRAG)).

====

So, does this fix CVE-2022-30790 for real? It certainly correctly
rejects the POC code which relies on sending a packet of size 27 with
the MFRAG flag set. Can the attack be carried out with a size 27
packet that doesn't set MFRAG (hence must set a non-zero fragment
offset)? I dunno. If we get a packet without MFRAG, we update
h->last_byte in the hole we've found to be start+len, hence we'd enter
one of

if ((h >= thisfrag) && (h->last_byte <= start + len)) {

or

} else if (h->last_byte <= start + len) {

and thus won't reach any of the

/* overlaps with initial part of the hole: move this hole */
newh = thisfrag + (len / 8);

/* fragment sits in the middle: split the hole */
newh = thisfrag + (len / 8);

IOW these division are now guaranteed to be exact, and thus I think
the scenario in CVE-2022-30790 cannot happen anymore.

====

However, there's a big elephant in the room, which has always been
spelled out in the comments, and which makes me believe that one can
still cause mayhem even with packets whose payloads are all 8-byte
aligned:

    This code doesn't deal with a fragment that overlaps with two
    different holes (thus being a superset of a previously-received
    fragment).

Suppose each character below represents 8 bytes, with D being already
received data, H being a hole descriptor (struct hole), h being
non-populated chunks, and P representing where the payload of a just
received packet should go:

  DDDHhhhhDDDDHhhhDDDD
        PPPPPPPPP

I'm pretty sure in this case we'd end up with h being the first hole,
enter the simple

} else if (h->last_byte <= start + len) {
/* overlaps with final part of the hole: shorten this hole */
h->last_byte = start;

case, and thus in the memcpy happily overwrite the second H with our
chosen payload. This is probably worth fixing...

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
17 months agonet: compare received length to sizeof(ip_hdr), not sizeof(ip_udp_hdr)
Rasmus Villemoes [Fri, 14 Oct 2022 17:43:38 +0000 (19:43 +0200)]
net: compare received length to sizeof(ip_hdr), not sizeof(ip_udp_hdr)

While the code mostly/only handles UDP packets, it's possible for the
last fragment of a fragmented UDP packet to be smaller than 28 bytes;
it can be as small as 21 bytes (an IP header plus one byte of
payload). So until we've performed the defragmentation step and thus
know whether we're now holding a full packet, we should only check for
the existence of the fields in the ip header, i.e. that there are at
least 20 bytes present.

In practice, we always seem to be handed a "len" of minimum 60 from the
device layer, i.e. minimal ethernet frame length minus FCS, so this is
mostly theoretical.

After we've fetched the header's claimed length and used that to
update the len variable, check that the header itself claims to be the
minimal possible length.

This is probably how CVE-2022-30552 should have been dealt with in the
first place, because net_defragment() is not the only place that wants
to know the size of the IP datagram payload: If we receive a
non-fragmented ICMP packet, we pass "len" to receive_icmp() which in
turn may pass it to ping_receive() which does

  compute_ip_checksum(icmph, len - IP_HDR_SIZE)

and due to the signature of compute_ip_checksum(), that would then
lead to accessing ~4G of address space, very likely leading to a
crash.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
17 months agonet: improve check for no IP options
Rasmus Villemoes [Fri, 14 Oct 2022 17:43:37 +0000 (19:43 +0200)]
net: improve check for no IP options

There's no reason we should accept an IP packet with a malformed IHL
field. So ensure that it is exactly 5, not just <= 5.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agonet: dwc_eth_qos: Add support for bulk RX descriptor cleaning
Marek Vasut [Sun, 9 Oct 2022 15:51:46 +0000 (17:51 +0200)]
net: dwc_eth_qos: Add support for bulk RX descriptor cleaning

Add new desc_per_cacheline property which lets a platform run RX descriptor
cleanup after every power-of-2 - 1 received packets instead of every packet.
This is useful on platforms where (axi_bus_width EQOS_AXI_WIDTH_n * DMA DSL
inter-descriptor word skip count + DMA descriptor size) is less than cache
line size, which necessitates packing multiple DMA descriptors into single
cache line.

In case of TX descriptors, this is not a problem, since the driver always
does synchronous TX, i.e. the TX descriptor is always written, flushed and
polled for completion in eqos_send().

In case of RX descriptors, it is necessary to update their status in bulk,
i.e. after the entire cache line worth of RX descriptors has been used up
to receive data.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agonet: dwc_eth_qos: Split TX and RX DMA rings
Marek Vasut [Sun, 9 Oct 2022 15:51:45 +0000 (17:51 +0200)]
net: dwc_eth_qos: Split TX and RX DMA rings

Separate TX and RX DMA rings to make their handling slightly clearer.
This is a preparatory patch for bulk RX descriptor flushing.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agoliteeth: LiteX Ethernet device
Joel Stanley [Mon, 26 Sep 2022 06:05:58 +0000 (15:35 +0930)]
liteeth: LiteX Ethernet device

LiteX is a soft system-on-chip that targets FPGAs. LiteETH is a basic
network device that is commonly used in LiteX designs.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
17 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Mon, 28 Nov 2022 14:35:02 +0000 (09:35 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

- DWC3 fixes / improvements

17 months agousb: dwc3: Drop support for "snps, ref-clock-period-ns" DT property
Marek Vasut [Sun, 27 Nov 2022 14:31:56 +0000 (15:31 +0100)]
usb: dwc3: Drop support for "snps, ref-clock-period-ns" DT property

Drop support for quickly deprecated DT property "snps,ref-clock-period-ns"
to prevent its proliferation.

Reviewed-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Marek Vasut <marex@denx.de>
17 months agousb: dwc3: Program GFLADJ
Sean Anderson [Sun, 27 Nov 2022 14:31:55 +0000 (15:31 +0100)]
usb: dwc3: Program GFLADJ

GUCTL.REFCLKPER can only account for clock frequencies with integer
periods. To address this, program REFCLK_FLADJ with the relative error
caused by period truncation. The formula given in the register reference
has been rearranged to allow calculation based on rate (instead of
period), and to allow for fixed-point arithmetic.

Additionally, calculate a value for 240MHZDECR. This configures a
simulated 240Mhz clock using a counter with one fractional bit (PLS1).

This register is programmed only for versions >= 2.50a, since this is
the check also used by commit db2be4e9e30c ("usb: dwc3: Add frame length
adjustment quirk").

[ marek: Ported from Linux kernel commit
         596c87856e08d ("usb: dwc3: Program GFLADJ") ]

Reviewed-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Marek Vasut <marex@denx.de> # Port from Linux