platform/kernel/u-boot.git
2 years agosunxi: Only initialize legacy I2C when enabled
Samuel Holland [Fri, 8 Oct 2021 05:17:17 +0000 (00:17 -0500)]
sunxi: Only initialize legacy I2C when enabled

CONFIG_SPL_I2C is the wrong symbol to use here. It is the top-level
Kconfig symbol (not specific to either legacy or DM I2C), whereas the
i2c_init() function is specific to legacy I2C. This change fixes a
build failure when enabling SPL_I2C but not SPL_SYS_I2C_LEGACY.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-by: Andre Przywara <andre.przywara@arm.com>
2 years agopower: pmic: Add a driver for X-Powers AXP PMICs
Samuel Holland [Fri, 8 Oct 2021 05:17:16 +0000 (00:17 -0500)]
power: pmic: Add a driver for X-Powers AXP PMICs

These PMICs provide some combination of battery charger, fuel gauge,
GPIOs, regulators, and VBUS routing. These functions are represented
as child nodes in the device tree. Add the minimal driver needed to
probe these child devices and provide the DM_PMIC ops.

Enable the driver by default for SoCs that normally pair with a PMIC.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopower: pmic: Consistently depend on SPL_DM_PMIC
Samuel Holland [Fri, 8 Oct 2021 05:17:15 +0000 (00:17 -0500)]
power: pmic: Consistently depend on SPL_DM_PMIC

Now that there is a separate symbol to enable DM_PMIC in SPL, update the
the SPL-specific driver symbols to depend on this new option.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopower: pmic: Consistently depend on DM_PMIC
Samuel Holland [Fri, 8 Oct 2021 05:17:14 +0000 (00:17 -0500)]
power: pmic: Consistently depend on DM_PMIC

Kconfig symbols for two PMIC drivers (PMIC_AS3722 and DM_PMIC_MC34708)
were missing a dependency on DM_PMIC. To fix this inconsistency, and to
keep it from happening again, wrap the driver section with "if DM_PMIC"
instead of using a "depends on DM_PMIC" clause for each driver.

Reviewed-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Add support for FriendlyARM NanoPi R1S H5
Chukun Pan [Sun, 10 Oct 2021 13:36:57 +0000 (21:36 +0800)]
sunxi: Add support for FriendlyARM NanoPi R1S H5

This adds support for the NanoPi R1S H5 board.

Allwinner H5 SoC
512MB DDR3 RAM
10/100/1000M Ethernet x 2
RTL8189ETV WiFi 802.11b/g/n
USB 2.0 host port (A)
MicroSD Slot
Reset button
Serial Debug Port
WAN - LAN - SYS LED

The dts file is taken from Linux 5.14 tag.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoclk: sunxi: Add drivers for A31 and H6 PRCM CCUs
Samuel Holland [Sun, 12 Sep 2021 14:47:25 +0000 (09:47 -0500)]
clk: sunxi: Add drivers for A31 and H6 PRCM CCUs

Add a driver so the clocks/resets for these peripherals (especially I2C,
RSB, and UART) can be enabled using the normal uclass methods.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoclk: sunxi: Add support for I2C gates/resets
Samuel Holland [Sun, 12 Sep 2021 14:47:24 +0000 (09:47 -0500)]
clk: sunxi: Add support for I2C gates/resets

Currently, the I2C clocks are configured in the sunxi board code. Add
the I2C clocks to the DM clock driver so they can be enabled from the
DM I2C driver using the normal uclass methods.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: gpio: Remove bank-specific size macros
Samuel Holland [Sat, 11 Sep 2021 21:50:49 +0000 (16:50 -0500)]
sunxi: gpio: Remove bank-specific size macros

Since the beginning, all banks have had space for 32 pins, even when
not all pins were implemented. Let's use a single constant for the GPIO
bank size here, like the GPIO driver is already doing.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: gpio: Remove name_to_gpio macro
Samuel Holland [Sat, 11 Sep 2021 21:50:48 +0000 (16:50 -0500)]
sunxi: gpio: Remove name_to_gpio macro

This clarifies which callers must be updated to complete the DM_GPIO
conversion.

The only remaining caller of name_to_gpio in generic code is inside the
!DM_GPIO block in cmd/gpio.c. DM_GPIO is always selected on sunxi, so
that code cannot be reached. And after this commit, there are only two
remaining implementations of name_to_gpio.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Clean up inclusions of asm/arch/gpio.h
Samuel Holland [Sat, 11 Sep 2021 21:50:47 +0000 (16:50 -0500)]
sunxi: Clean up inclusions of asm/arch/gpio.h

As part of migrating to DM_GPIO and DM_PINCTRL, eventually we will
remove the asm/arch/gpio.h header. In preparation, clean up the various
files that include it.

Some files did not contain any GPIO code at all, so this header was
completely unused.

A few files contained only legacy platform-specific GPIO code for
setting up pin muxes. They were left unchanged, as that code will be
completely removed by the DM_PINCTRL migration.

The remaining files contain some combination of DM_GPIO and legacy GPIO
code. For those, switch to including asm/gpio.h (if it wasn't included
already). Right now, this header provides both sets of functions,
because ARCH_SUNXI selects GPIO_EXTRA_HEADER. This will still be the
right header to include once the DM_GPIO migration is complete and
GPIO_EXTRA_HEADER is no longer needed.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinephone_defconfig: add support for early-boot status LED
Arnaud Ferraris [Wed, 8 Sep 2021 19:14:20 +0000 (21:14 +0200)]
pinephone_defconfig: add support for early-boot status LED

This commit enables the green status LED (PD18/GPIO 114) on boot in the
SPL, in order to provide visual feedback that the PinePhone is booting.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Tested-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoboard: sunxi: enable status LED early
Arnaud Ferraris [Wed, 8 Sep 2021 19:14:19 +0000 (21:14 +0200)]
board: sunxi: enable status LED early

For some systems, such as the PinePhone, there is no way for the end
user to make sure the system is indeed booting before the boot script is
executed, which takes several seconds. Therefore, it can be useful to
provide early visual feedback as soon as possible.

In order achieve this goal, this patch initializes the status LED (if
configured) in the SPL.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agogpio: sunxi: Remove the sunxi_name_to_gpio_bank function
Samuel Holland [Sun, 12 Sep 2021 15:28:36 +0000 (10:28 -0500)]
gpio: sunxi: Remove the sunxi_name_to_gpio_bank function

The only caller of this function was the MMC pinmux code, which used it
to parse a string given from a Kconfig symbol. As the Kconfig symbol has
been converted to a Boolean, this function is no longer needed.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Simplify MMC pinmux selection
Samuel Holland [Sun, 12 Sep 2021 15:28:35 +0000 (10:28 -0500)]
sunxi: Simplify MMC pinmux selection

Only one board, Yones Toptech BD1078, actually uses a non-default MMC
pinmux. All other uses of these symbols select the default value or an
invalid value. To simplify things, remove support for the unused pinmux
options, and convert the remaining option to a Boolean.

This allows the pinmux to be chosen by the preprocessor, instead of
having the code parse a string at runtime (for a build-time option!).
Not only does this reduce code size, but it also allows this Kconfig
option to be used in a table-driven DM pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoclk: sunxi: Move header out of arch directory
Samuel Holland [Sun, 12 Sep 2021 16:48:43 +0000 (11:48 -0500)]
clk: sunxi: Move header out of arch directory

The CCU header is only used by the DM drivers, not any platform code.
Its current location adds an artificial dependency on CONFIG_ARM and
ARCH_SUNXI, which will be problematic when adding the CCU driver for
a RISC-V sunxi platform.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoconfigs: add PineTab defconfig
Arnaud Ferraris [Mon, 6 Sep 2021 21:06:13 +0000 (23:06 +0200)]
configs: add PineTab defconfig

The PineTab device-tree is already in u-boot, this commit adds the
corresponding defconfig, based on pinephone_defconfig.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoMerge tag 'video-20211009' of https://source.denx.de/u-boot/custodians/u-boot-video
Tom Rini [Sat, 9 Oct 2021 21:47:27 +0000 (17:47 -0400)]
Merge tag 'video-20211009' of https://source.denx.de/u-boot/custodians/u-boot-video

 - add 30bpp support (EFI, simplefb, vidconsole)
 - fix video console name in CONSOLE_MUX Kconfig help
 - move mxsfb driver config option to Kconfig
 - remove unused mx3fb driver

# gpg verification failed.

2 years agovideo: move MXS to Kconfig
Anatolij Gustschin [Mon, 4 Oct 2021 15:33:12 +0000 (17:33 +0200)]
video: move MXS to Kconfig

Move CONFIG_VIDEO_MXS from board headers to Kconfig
and drop it from obsolete cfb_console driver.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
2 years agovideo: remove not used mx3fb driver
Anatolij Gustschin [Mon, 4 Oct 2021 15:07:14 +0000 (17:07 +0200)]
video: remove not used mx3fb driver

i.MX31 support was removed, and the non dm-video driver
is obsolete and not used. Remove it.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
2 years agocommon: Kconfig: use 'vidconsole' name instead of old 'video'
Anatolij Gustschin [Mon, 4 Oct 2021 14:04:32 +0000 (16:04 +0200)]
common: Kconfig: use 'vidconsole' name instead of old 'video'

After DM_VIDEO conversion the 'vidconsole' is the correct name
for the frame buffer console. 'video' will not work, so update
the description of the config option.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
2 years agolz4: Use a private header for U-Boot
Simon Glass [Sat, 9 Oct 2021 15:28:21 +0000 (09:28 -0600)]
lz4: Use a private header for U-Boot

At present U-Boot has a header file called lz4.h for its own use. If the
host has its own lz4 header file installed (e.g. from the 'liblz4-dev'
package) then host builds will use that instead.

Move the U-Boot file into its own directory, as is done with various
other headers with the same problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoefi_loader: GOP: Fix 30bpp block transfer support
Mark Kettenis [Sat, 25 Sep 2021 20:47:39 +0000 (22:47 +0200)]
efi_loader: GOP: Fix 30bpp block transfer support

Convert pixel values when necessary like we do for 16bpp
framebuffers.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agovideo: simplefb: Add 30bpp support
Mark Kettenis [Sat, 25 Sep 2021 20:47:38 +0000 (22:47 +0200)]
video: simplefb: Add 30bpp support

Recognize the canonical format strings for framebuffers in
30bpp mode and 32/24bpp mode.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
2 years agoefi_loader: GOP: Add 30bpp support
Mark Kettenis [Sat, 25 Sep 2021 20:47:37 +0000 (22:47 +0200)]
efi_loader: GOP: Add 30bpp support

Provide correct framebuffer information for 30bpp modes.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
2 years agovideo: Add 30bpp support
Mark Kettenis [Sat, 25 Sep 2021 20:47:36 +0000 (22:47 +0200)]
video: Add 30bpp support

Add support for 30bpp mode where pixels are picked in 32-bit
integers but use 10 bits instead of 8 bits for each component.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
2 years agoMerge branch '2021-10-08-image-cleanups'
Tom Rini [Fri, 8 Oct 2021 20:02:55 +0000 (16:02 -0400)]
Merge branch '2021-10-08-image-cleanups'

- A large number of image file and tooling related cleanups

2 years agoimage: Split up boot_get_fdt()
Simon Glass [Sun, 26 Sep 2021 01:43:41 +0000 (19:43 -0600)]
image: Split up boot_get_fdt()

This function is far too long. Before trying to remove #ifdefs, split out
the code that deals with selecting the FDT into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Reduce variable scope in boot_get_fdt()
Simon Glass [Sun, 26 Sep 2021 01:43:40 +0000 (19:43 -0600)]
image: Reduce variable scope in boot_get_fdt()

Move the variables declarations to where they are needed, to reduce the
number of #ifdefs needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Remove some #ifdefs from image-fit and image-fit-sig
Simon Glass [Sun, 26 Sep 2021 01:43:39 +0000 (19:43 -0600)]
image: Remove some #ifdefs from image-fit and image-fit-sig

Drop the #ifdefs which are easy to remove without refactoring.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Remove #ifdefs from select_ramdisk()
Simon Glass [Sun, 26 Sep 2021 01:43:38 +0000 (19:43 -0600)]
image: Remove #ifdefs from select_ramdisk()

Use boolean variables to deal with the strange #ifdef logic of this
function, so we can remove the #ifdefs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Split up boot_get_ramdisk()
Simon Glass [Sun, 26 Sep 2021 01:43:37 +0000 (19:43 -0600)]
image: Split up boot_get_ramdisk()

This function is far too long. Before trying to remove #ifdefs, split out
the code that deals with selecting the ramdisk into a separate function.

Leave the code indented as it was for easier review. The next patch cleans
this up along with checkpatch violations.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Reduce variable scope in boot_get_ramdisk()
Simon Glass [Sun, 26 Sep 2021 01:43:36 +0000 (19:43 -0600)]
image: Reduce variable scope in boot_get_ramdisk()

Move the variables declarations to where they are needed, to reduce the
number of #ifdefs needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Drop most #ifdefs in image-board.c
Simon Glass [Sun, 26 Sep 2021 01:43:35 +0000 (19:43 -0600)]
image: Drop most #ifdefs in image-board.c

Remove ifdefs in this file, so far as possible without too much
refactoring.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Drop #ifdefs for fit_print_contents()
Simon Glass [Sun, 26 Sep 2021 01:43:34 +0000 (19:43 -0600)]
image: Drop #ifdefs for fit_print_contents()

Use a simple return to drop the unwanted code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Drop unnecessary #ifdefs from image.h
Simon Glass [Sun, 26 Sep 2021 01:43:33 +0000 (19:43 -0600)]
image: Drop unnecessary #ifdefs from image.h

This file has a lot of conditional code and much of it is unnecessary.
Clean this up to reduce the number of build combinations.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Tidy up fit_unsupported_reset()
Simon Glass [Sun, 26 Sep 2021 01:43:32 +0000 (19:43 -0600)]
image: Tidy up fit_unsupported_reset()

This function is only used in one place and does not need to use the
preprocessor. Move it to the C file and convert it to a normal function.

Drop fit_unsupported() since it is not used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoefi: Correct dependency on FIT_SIGNATURE
Simon Glass [Sun, 26 Sep 2021 01:43:29 +0000 (19:43 -0600)]
efi: Correct dependency on FIT_SIGNATURE

At present EFI_SECURE BOOT selects RSA but does not necessarily enable
FIT_SIGNATURE. Mostly this is fine, but a few boards do not enable it,
so U-Boot tries to do RSA verification when loading FIT images, but it
is not enabled.

This worked because the condition for checking the RSA signature is
wrong in the fit_image_verify_with_data() function. In order to fix it
we need to fix this dependency. Make sure that FIT_SIGNATURE is enabled
so that RSA can be used.

It might be better to avoid using 'select' in this situation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Drop IMAGE_ENABLE_IGNORE
Simon Glass [Sun, 26 Sep 2021 01:43:28 +0000 (19:43 -0600)]
image: Drop IMAGE_ENABLE_IGNORE

We can use the new host_build() function for this, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Drop IMAGE_OF_SYSTEM_SETUP
Simon Glass [Sun, 26 Sep 2021 01:43:27 +0000 (19:43 -0600)]
image: Drop IMAGE_OF_SYSTEM_SETUP

This is not needed with Kconfig, since we can use IS_ENABLED() easily
enough. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Drop IMAGE_OF_BOARD_SETUP
Simon Glass [Sun, 26 Sep 2021 01:43:26 +0000 (19:43 -0600)]
image: Drop IMAGE_OF_BOARD_SETUP

This is not needed with Kconfig, since we can use IS_ENABLED() easily
enough. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Drop IMAGE_BOOT_GET_CMDLINE
Simon Glass [Sun, 26 Sep 2021 01:43:25 +0000 (19:43 -0600)]
image: Drop IMAGE_BOOT_GET_CMDLINE

This is not needed with Kconfig, since we can use IS_ENABLED() easily
enough and the board code is now in a separate file. Update the only place
where this is used and drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Use the correct checks for CRC32
Simon Glass [Sun, 26 Sep 2021 01:43:24 +0000 (19:43 -0600)]
image: Use the correct checks for CRC32

Add a host Kconfig for CRC32. With this we can use CONFIG_IS_ENABLED(CRC32)
directly in the host build, so drop the unnecessary indirection.

Add a few more conditions to SPL_CRC32 to avoid build failures as well as
TPL_CRC32. Also update hash.c to make crc32 optional and to actually take
notice of SPL_CRC32.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Use Kconfig to enable FIT_RSASSA_PSS on host
Simon Glass [Sun, 26 Sep 2021 01:43:23 +0000 (19:43 -0600)]
image: Use Kconfig to enable FIT_RSASSA_PSS on host

Add a host Kconfig for FIT_RSASSA_PSS. With this we can use
CONFIG_IS_ENABLED(FIT_RSASSA_PSS) directly in the host build, so drop the
forcing of this in the image.h header.

Drop the #ifdef around padding_pss_verify() too since it is not needed.
Use the compiler to check the config where possible, instead of the
preprocessor.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Use Kconfig to enable CONFIG_FIT_VERBOSE on host
Simon Glass [Sun, 26 Sep 2021 01:43:22 +0000 (19:43 -0600)]
image: Use Kconfig to enable CONFIG_FIT_VERBOSE on host

Add a host Kconfig for FIT_VERBOSE. With this we can use
CONFIG_IS_ENABLED(FIT_VERBOSE) directly in the tools build, so drop the
forcing of this in the image.h header.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Drop IMAGE_ENABLE_OF_LIBFDT
Simon Glass [Sun, 26 Sep 2021 01:43:21 +0000 (19:43 -0600)]
image: Drop IMAGE_ENABLE_OF_LIBFDT

Add a host Kconfig for OF_LIBFDT. With this we can use
CONFIG_IS_ENABLED(OF_LIBFDT) directly in the tools build, so drop the
unnecessary indirection.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Drop IMAGE_ENABLE_FIT
Simon Glass [Sun, 26 Sep 2021 01:43:20 +0000 (19:43 -0600)]
image: Drop IMAGE_ENABLE_FIT

Make use of the host Kconfig for FIT. With this we can use
CONFIG_IS_ENABLED(FIT) directly in the host build, so drop the unnecessary
indirection.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agohash: Drop some #ifdefs in hash.c
Simon Glass [Sun, 26 Sep 2021 01:43:19 +0000 (19:43 -0600)]
hash: Drop some #ifdefs in hash.c

We can use the __maybe_unused attribute to avoid some of the #ifdefs in
this file. Update the functions accordingly.

Note: The actual hashing interface is still a mess, with four separate
combinations and lots of #ifdefs. This should really use a driver
approach, e.g. as is done with partition drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agohash: Use Kconfig to enable hashing in host tools and SPL
Simon Glass [Sun, 26 Sep 2021 01:43:18 +0000 (19:43 -0600)]
hash: Use Kconfig to enable hashing in host tools and SPL

At present when building host tools, we force CONFIG_SHAxxx to be enabled
regardless of the board Kconfig setting. This is done in the image.h
header file.

For SPL we currently just assume the algorithm is desired if U-Boot proper
enables it.

Clean this up by adding new Kconfig options to enable hashing on the host,
relying on CONFIG_IS_ENABLED() to deal with the different builds.

Add new SPL Kconfigs for hardware-accelerated hashing, to maintain the
current settings.

This allows us to drop the image.h code and the I_WANT_MD5 hack.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agospl: cypto: Bring back SPL_ versions of SHA
Simon Glass [Sun, 26 Sep 2021 01:43:17 +0000 (19:43 -0600)]
spl: cypto: Bring back SPL_ versions of SHA

Unfortunately these were removed by mistake. This means that adding hash
support to SPL brings in all software algorithms, with a substantial
increase in code size.

The origin of the problem was renaming them to SPL_FIT_xxx and then these
were removed altogether in a later commit.

Add them back. This aligns with CONFIG_MD5, for example, which has an SPL
variant.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: f5bc9c25f31 ("image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxx")
Fixes: eb5171ddec9 ("common: Remove unused CONFIG_FIT_SHAxxx selectors")
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Add Kconfig options for FIT in the tools build
Simon Glass [Sun, 26 Sep 2021 01:43:16 +0000 (19:43 -0600)]
image: Add Kconfig options for FIT in the tools build

In preparation for enabling CONFIG_IS_ENABLED() on the host build, add
some options to enable the various FIT options expected in these tools.
This will ensure that the code builds correctly when CONFIG_TOOLS_xxx
is distinct from CONFIG_xxx.

Drop some #ifdefs which are immediately unnecessary (many more are in
later patches).

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agokconfig: Add tools support to CONFIG_IS_ENABLED()
Simon Glass [Sun, 26 Sep 2021 01:43:15 +0000 (19:43 -0600)]
kconfig: Add tools support to CONFIG_IS_ENABLED()

At present we must separately test for the host build for many options,
since we force them to be enabled. For example, CONFIG_FIT is always
enabled in the host tools, even if CONFIG_FIT is not enabled by the
board itself.

It would be more convenient if we could use, for example,
CONFIG_IS_ENABLED(FIT) and get CONFIG_HOST_FIT, when building for the
host. Add support for this.

With this and the tools_build() function, we should be able to remove all
the #ifdefs currently needed in code that is build by tools and targets.

This will be even nicer when we move to using CONFIG(xxx) everywhere,
since all the #ifdef and IS_ENABLED/CONFIG_IS_ENABLED stuff will go away.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> # b4f73886
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agocompiler: Rename host_build() to tools_build()
Simon Glass [Sun, 26 Sep 2021 01:43:14 +0000 (19:43 -0600)]
compiler: Rename host_build() to tools_build()

With the new TOOLS_LIBCRYPTO and some other changes, it seems that we are
heading towards calling this a tools build rather than a host build,
although of course it does happen on the host.

I cannot think of anything built by the host which cannot be described as
a tool, so rename this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2 years agoimage: Remove ifdefs around image_setup_linux() el at
Simon Glass [Sat, 25 Sep 2021 13:03:20 +0000 (07:03 -0600)]
image: Remove ifdefs around image_setup_linux() el at

Drop some more ifdefs in image-board.c and also the FPGA part of bootm.c
which calls into it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Avoid #ifdefs for manual relocation
Simon Glass [Sat, 25 Sep 2021 13:03:19 +0000 (07:03 -0600)]
image: Avoid #ifdefs for manual relocation

Add a macro to handle manually relocating a pointer. Update the iamge code
to use this to avoid needing #ifdefs.

This also fixes a bug where the 'done' flag was not set.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Create a function to do manual relocation
Simon Glass [Sat, 25 Sep 2021 13:03:18 +0000 (07:03 -0600)]
image: Create a function to do manual relocation

Rather than adding an #ifdef and open-coding this calculation, add a
helper function to handle it. Use this in the image code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Split host code out into its own file
Simon Glass [Sat, 25 Sep 2021 13:03:17 +0000 (07:03 -0600)]
image: Split host code out into its own file

To avoid having #ifdefs in a few functions which are completely different
in the board and host code, create a new image-host.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Fix up checkpatch warnings in image-board.c
Simon Glass [Sat, 25 Sep 2021 13:03:16 +0000 (07:03 -0600)]
image: Fix up checkpatch warnings in image-board.c

Tidy up the warnings.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Split board code out into its own file
Simon Glass [Sat, 25 Sep 2021 13:03:15 +0000 (07:03 -0600)]
image: Split board code out into its own file

To avoid a large #ifdef in the image.c file, move the affected code into
a separate file.

Avoid any style fix-ups for easier review. Those are in the next patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Update image_decomp() to avoid ifdefs
Simon Glass [Sat, 25 Sep 2021 13:03:14 +0000 (07:03 -0600)]
image: Update image_decomp() to avoid ifdefs

Adjust this function so that preprocessor macros are not needed. With
this, the host build uses more of the same header files as the target
build.

Rather than definining CONFIG_SYS_MALLOC_LEN, add a CONSERVE_MEMORY
define, since that is the purpose of the value.

This appears to have no impact on code size from a spot check of a few
boards (snow, firefly-rk3288, boston32r2el, m53menlo).

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agogzip: Avoid use of u64
Simon Glass [Sat, 25 Sep 2021 13:03:13 +0000 (07:03 -0600)]
gzip: Avoid use of u64

The gzip API uses the u64 type in it, which is not available in the host
build. This makes it impossible to include the header file.

We could make this type available, but it seems unnecessary. Limiting the
compression size to that of the 'unsigned long' type seems good enough. On
32-bit machines the limit then becomes 4GB, which likely exceeds available
RAM anyway, therefore it should be sufficient. On 64-bit machines this is
effectively u64 anyway.

Update the header file and implementation to use 'ulong' instead of 'u64'.

Add a definition of u32 for the cases that seem to need exactly that
length. This should be safe enough.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Update zstd to avoid reporting error twice
Simon Glass [Sat, 25 Sep 2021 13:03:12 +0000 (07:03 -0600)]
image: Update zstd to avoid reporting error twice

The zstd implementation prints the error in image_decomp() which is
incorrect and does not match other algorithms. Drop this and let the
caller report the error.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoimage: Avoid switch default in image_decomp()
Simon Glass [Sat, 25 Sep 2021 13:03:11 +0000 (07:03 -0600)]
image: Avoid switch default in image_decomp()

At present this function is full of preprocessor macros. Adjust it to
check for an unsupported algorithm after the switch(). This will allow
us to drop the macros.

Fix up the return-value path and an extra blank line while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agobtrfs: Use U-Boot API for decompression
Simon Glass [Sat, 25 Sep 2021 13:03:10 +0000 (07:03 -0600)]
btrfs: Use U-Boot API for decompression

Use the common function to avoid code duplication.

Acked-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agozstd: Create a function for use from U-Boot
Simon Glass [Sat, 25 Sep 2021 13:03:09 +0000 (07:03 -0600)]
zstd: Create a function for use from U-Boot

The existing zstd API requires the same sequence of calls to perform its
task. Create a helper for U-Boot, to avoid code duplication, as is done
with other compression algorithms. Make use of of this from the image
code.

Note that the zstd code lacks a test in test/compression.c and this should
be added by the maintainer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agocompiler: Add a comment to host_build()
Simon Glass [Sat, 25 Sep 2021 13:03:08 +0000 (07:03 -0600)]
compiler: Add a comment to host_build()

This function should have a comment explaining what it does. Add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoAdd support for an owned buffer
Simon Glass [Sat, 25 Sep 2021 13:03:07 +0000 (07:03 -0600)]
Add support for an owned buffer

When passing a data buffer back from a function, it is not always clear
who owns the buffer, i.e. who is responsible for freeing the memory used.
An example of this is where multiple files are decompressed from the
firmware image, using a temporary buffer for reading (since the
compressed data has to live somewhere) and producing a temporary or
permanent buffer with the resuilts.

Where the firmware image can be memory-mapped, as on x86, the compressed
data does not need to be buffered, but the complexity of having a buffer
which is either allocated or not, makes the code hard to understand.

Introduce a new 'abuf' which supports simple buffer operations:

- encapsulating a buffer and its size
- either allocated with malloc() or not
- able to be reliably freed if necessary
- able to be converted to an allocated buffer if needed

This simple API makes it easier to deal with allocated and memory-mapped
buffers.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agolib: Add memdup()
Simon Glass [Sat, 25 Sep 2021 13:03:06 +0000 (07:03 -0600)]
lib: Add memdup()

Add a function to duplicate a memory region, a little like strdup().

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Fri, 8 Oct 2021 12:02:47 +0000 (08:02 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- a37xx: pci: Increase PCIe IO size from 64 KiB to 1 MiB (Pali)
- phy: marvell: a3700: Misc improvements (Pali)
- a38x serdes cleanup (Pali)
- A3720 PCIe enhancements (Pali & Marek)
- mvebu: mvebu_armada-8k: Puzzle M801 enhancements (Robert)
- mvebu: x530: Remove custom kwbimage.cfg (Chris)
- mvebu: Select SPL_SKIP_LOWLEVEL_INIT on ARMADA_32BIT (Stefan)

2 years agoARM: mvebu: x530: Remove custom kwbimage.cfg
Chris Packham [Thu, 7 Oct 2021 08:39:23 +0000 (21:39 +1300)]
ARM: mvebu: x530: Remove custom kwbimage.cfg

Commit ca1a4c863232 ("mvebu: select boot device at SoC level") made it
unnecessary for the A385 boards to have their own kwbimage.cfg but as
the x530 was in flight at the time it was added with it's own
kwbimage.cfg. Remove the custom kwbimage.cfg as the SoC level file is
suitable.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: mvebu_armada-8k: drop Puzzle M801 early init code
Robert Marko [Mon, 4 Oct 2021 13:12:54 +0000 (15:12 +0200)]
arm: mvebu: mvebu_armada-8k: drop Puzzle M801 early init code

Since the CP1 pinctrl is not properly set in the DTS, there is no
need for setting the pinctrl by writing hardcoded values to the MPP
registers.

So, drop the code relating to that.

Fixes: 87c220d0 ("arm: mvebu: mvebu_armada-8k: Add support for initializing iEi Puzzle-M801 networking")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: dts: m801: correct CP1 pinctrl
Robert Marko [Mon, 4 Oct 2021 13:12:53 +0000 (15:12 +0200)]
arm: mvebu: dts: m801: correct CP1 pinctrl

Current CP1 pinctrl that is set on the Puzzle M801 is incorrect.
CP1 pins are only used for the SMI bus and the MSS I2C, all other
pins are just GPIO-s.

Due to this being set completely wrong, the pinctrl was actually
ended up being hardcoded in the board_early_init_f() step so that
SMI would work.

That is obviously not the right thing to do, so convert the register
hex values that were being written to individual pin modes and set it
in the DTS.
Add the SMI pins to the CP1 MDIO node as otherwise CP1 pinctrl does
not get probed without an consumer.

Fixes: 2ae2b8a2 ("arm: mvebu: Initial iEi Puzzle-M801 support")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: Select SPL_SKIP_LOWLEVEL_INIT on ARMADA_32BIT
Stefan Roese [Sun, 3 Oct 2021 09:53:45 +0000 (11:53 +0200)]
arm: mvebu: Select SPL_SKIP_LOWLEVEL_INIT on ARMADA_32BIT

Select SPL_SKIP_LOWLEVEL_INIT on 32bit Armada platforms via Kconfig,
as this was removed from mach/config.h in a2ac2b96 ("Convert
CONFIG_SKIP_LOWLEVEL_INIT et al to Kconfig").

Signed-off-by: Stefan Roese <sr@denx.de>
Fixes: a2ac2b96 ("Convert CONFIG_SKIP_LOWLEVEL_INIT et al to Kconfig")
Cc: Tom Rini <trini@konsulko.com>
Cc: Marek Behún <kabel@kernel.org>
Cc: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
2 years agoarm: a37xx: pci: Update private structure documentation
Marek Behún [Sat, 25 Sep 2021 22:54:46 +0000 (00:54 +0200)]
arm: a37xx: pci: Update private structure documentation

There were several changes for this structure but the documentation was
not changed at the time. Fix this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Cosmetic change
Marek Behún [Sat, 25 Sep 2021 22:54:45 +0000 (00:54 +0200)]
arm: a37xx: pci: Cosmetic change

Update indentation in driver's private structure.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Handle propagation of CRSSVE bit from PCIe Root Port
Pali Rohár [Sat, 25 Sep 2021 22:54:44 +0000 (00:54 +0200)]
arm: a37xx: pci: Handle propagation of CRSSVE bit from PCIe Root Port

Now that PCI Bridge (PCIe Root Port) for Aardvark is emulated in U-Boot,
add support for handling and propagation of CRSSVE bit.

When CRSSVE bit is unset (default), driver has to reissue config
read/write request on CRS response.

CRSSVE bit is supported only when CRSVIS bit is provided in read-only
Root Capabilities register. So manually inject this CRSVIS bit into read
response for that register.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Do not automatically enable bus mastering on PCI Bridge
Pali Rohár [Sat, 25 Sep 2021 22:54:43 +0000 (00:54 +0200)]
arm: a37xx: pci: Do not automatically enable bus mastering on PCI Bridge

Now that PCI Bridge is working for the PCIe Root Port, U-Boot's PCI_PNP
code automatically enables memory access and bus mastering when needed.

We do not need to enable it when setting the HW up.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Add support for accessing PCI Bridge on root bus
Pali Rohár [Sat, 25 Sep 2021 22:54:42 +0000 (00:54 +0200)]
arm: a37xx: pci: Add support for accessing PCI Bridge on root bus

Aardvark does not have a real PCIe Root Port device on the root bus.
Instead it has PCIe registers of PCIe Root Port device mapped in
internal Aardvark memory space starting at offset 0xc0.

The PCIe Root Port itself is normally available as a PCI Bridge device
on the root bus with bus number zero. Aardvark instead has the
configuration registers of this PCI Bridge at offset 0x00 of Aardvark's
memory space, but the class code of this device is Mass Storage
Controller (0x010400), instead of PCI Bridge (0x600400), which causes
U-Boot to fail to recognize it as a P2P Bridge

Add a hook into the pcie_advk_read_config() / pcie_advk_write_config()
functions to redirect access for root bus from PIO transfer to this
internal Aardvark memory space. This will allow U-Boot to access
configuration space of this PCI Bridge which represents PCIe Root Port.

Redirect access to PCI Bridge registers in range 0x10 - 0x34 to driver's
internal buffer (cfgcache[]). This is because at those addresses
Aardvark has different registers, incompatible with config space of a
PCI Bridge.

Redirect access to PCI Bridge register PCI_ROM_ADDRESS1 (0x38) to
Aardvark internal address for that register (0x30).

When reading PCI Bridge register PCI_HEADER_TYPE, set it explicitly to
value Type 1 (PCI_HEADER_TYPE_BRIDGE) as PCI Bridge must be of Type 1.

When writing to PCI_PRIMARY_BUS or PCI_SECONDARY_BUS registers on this
PCI Bridge, correctly update driver's first_busno and sec_busno
variables, so that pcie_advk_addr_valid() function can check if address
of any device behind the root bus is valid and that PIO transfers are
started with correct config type (1 vs 0), which is required for
accessing devices behind some PCI bridge after the root bus.

U-Boot's PCI_PNP code sets primary and secondary bus numbers as relative
to the configured bus number of the root bus. This is done so that
U-Boot can support multiple PCIe host bridges or multiple root port
buses, when internal bus numbers are different.

Now that root bus is available, update code in pcie_advk_read_config()
and pcie_advk_write_config() functions to correctly calculate real
Aardvark bus number of the target device from U-Boot's bus number as:
  busno = PCI_BUS(bdf) - dev_seq(bus)

Stefan: Small fix of header masking as suggested by Pali.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Fix pcie_advk_link_up()
Pali Rohár [Sat, 25 Sep 2021 22:54:41 +0000 (00:54 +0200)]
arm: a37xx: pci: Fix pcie_advk_link_up()

Aardvark reports Disabled and Hot Reset LTSSM states as values >= 0x20.
Link is not up in these states, so fix pcie_advk_link_up() function.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Update comment about PCIE*_ENABLE_* defines
Pali Rohár [Fri, 24 Sep 2021 20:59:22 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Update comment about PCIE*_ENABLE_* defines

These are part of SOC_CONTROL_REG1 register, not PEX_CAPABILITIES_REG.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Remove unused PCIe macros and functions
Pali Rohár [Fri, 24 Sep 2021 20:59:21 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Remove unused PCIe macros and functions

Remove unused PCIe functions from SerDes code. They are unused and are
duplicated either from generic PCIe code or from pci_mvebu.c.

Remove also unused PCIe macros from SerDes code. They are just obfuscated
variants of standards macros in include/pci.h or in pci_mvebu.c.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Don't configure PCIe cards in SerDes init code
Pali Rohár [Fri, 24 Sep 2021 20:59:20 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Don't configure PCIe cards in SerDes init code

This code is trying to parse PCIe config space of PCIe card connected on
the other end of link and then is trying to force 5.0 GT/s speed via Target
Link Speed bits in PCIe Root Port Link Control 2 Register on the local part
of link if it sees that card supports 5.0 GT/s via Max Link Speed bits in
Link Capabilities Register.

The code is incorrect for more reasons:
- Accessing config space of an endpoint card cannot be done immediately.
  If the PCIe link is not up, reading vendor/device ID registers will
  return all ones.
- Parsing is incomplete, so it can cause issues even for working cards.

Moreover there is no need to force speed to 5.0 GT/s via Target Link Speed
bits on PCIe Root Port Link Control 2 Register. Hardware changes speed from
2.5 GT/s to 5.0 GT/s autonomously when it is supported.

Most importantly, this code does not change link speed at all, since
because after updating Target Link Speed bits on PCIe Root Port Link
Control 2 Register, it is required to retrain the link, and the code for
that is completely missing.

The code was probably needed for making buggy endpoint cards work. Such a
workaround, though, should be implemented via PCIe subsystem (via quirks,
for example), as buggy cards could also affect other PCIe controllers.

Note that this code is fully unrelated to a38x SerDes code and really
should not have been included in SerDes initialization. Usage of magic
constants without names and comments made this SerDes code hard to read and
understand.

Remove this PCIe application code from low level SerDes code. As this code
is configuring only 5.0 GT/s part, in the worst case, it could leave buggy
cards at the initial speed of 2.5 GT/s (if somehow before this change they
could have been "upgraded" to 5.0 GT/s speed even with missing link
retraining). Compliant cards which just need longer initialization should
work better after this change.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Don't overwrite PCI device ID
Pali Rohár [Fri, 24 Sep 2021 20:59:19 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Don't overwrite PCI device ID

PCI device ID is part of the PCIe controller SoC / revision. For Root
Complex mode (which is the default and the only mode supported currently
by U-Boot and Linux kernel), it is PCI device ID of PCIe Root Port device.

If there is some issue with this device ID, it should be set / updated by
PCIe controller driver (pci_mvebu.c), as this register resides in address
space of the controller. It shouldn't be done in SerDes initialization
code.

In the worst case (a specific board for example) it could be done via
U-Boot's weak function board_pex_config().

But it should not be overwritten globally for all A38x devices.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Don't set PCIe Common Clock Configuration
Pali Rohár [Fri, 24 Sep 2021 20:59:18 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Don't set PCIe Common Clock Configuration

Enabling Common Clock Configuration bit in PCIe Root Port Link Control
Register should not be done unconditionally. It is enabled by operating
system as part of ASPM. Also after enabling Common Clock Configuration it
is required to do more work, like retraining link. Some cards may be broken
due to this incomplete Common Clock Configuration and some cards are broken
and do not support ASPM at all.

Remove this incomplete code for Common Clock Configuration. It really
should not be done in SerDes code as it is not related to SerDes, but to
PCIe subsystem.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Don't overwrite read-only SAR PCIe registers
Pali Rohár [Fri, 24 Sep 2021 20:59:17 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Don't overwrite read-only SAR PCIe registers

Device/Port Type bits of PCIe Root Port PCI Express Capabilities Register
are read-only SAR registers and are initialized according to current mode
configured by PCIe controller. Changing PCIe controller mode (from Root
Complex mode to Endpoint mode or the other way) is possible via PCI
Express Control Register (offset 0x41A00), bit 1 (ConfRoot Complex). This
has to be done in PCIe controller driver (in our case pci_mvebu.c). Note
that default mode is Root Complex.

Maximum Link Speed bits of PCIe Root Port Link Capabilities Register are
platform specific and overwriting them does not make sense. They are set by
PCIe controller according to current SerDes configuration. For A38x it is
5.0 GT/s if SerDes supports appropriate speed.

Maximum Link Width bits of PCIe Root Port Link Capabilities Register are
read-only SAR registers, but unfortunately if this is not set correctly
here, then access PCI config space of the endpoint card behind this Root
Port does not work.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Add comments for hws_pex_config() code
Pali Rohár [Fri, 24 Sep 2021 20:59:16 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Add comments for hws_pex_config() code

Add comments to understand what this magic code is doing.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Remove duplicate macro SOC_CTRL_REG
Pali Rohár [Fri, 24 Sep 2021 20:59:15 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Remove duplicate macro SOC_CTRL_REG

SoC Control 1 Register (offset 0x18204) is already defined by macro
SOC_CONTROL_REG1.

Use macro SOC_CONTROL_REG1 instead of macro SOC_CTRL_REG in ctrl_pex.c
code and remove the other definition.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: a38x: serdes: Add comments and use macros in PCIe code
Pali Rohár [Fri, 24 Sep 2021 20:59:14 +0000 (22:59 +0200)]
arm: mvebu: a38x: serdes: Add comments and use macros in PCIe code

Replace magic register offsets by macros to make code more readable.
Add comments about what this code is doing.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agophy: marvell: a3700: Return correct error code when power up fails
Pali Rohár [Fri, 24 Sep 2021 14:11:57 +0000 (16:11 +0200)]
phy: marvell: a3700: Return correct error code when power up fails

Subroutines in comphy_usb2_power_up() and comphy_sgmii_power_up() functions
may fail. In this case, do not continue execution of current function and
instead jump to the end. Return value in 'ret' variable is already set.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agophy: marvell: a3700: Fix configuring polarity invert bits
Pali Rohár [Fri, 24 Sep 2021 14:11:56 +0000 (16:11 +0200)]
phy: marvell: a3700: Fix configuring polarity invert bits

phy_txd_inv or phy_rxd_inv needs to be set only in case when
appropriate polarity is inverted. Otherwise these bits should be
cleared.

Same change was included in TF-A project:
https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/9406

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agophy: marvell: a3700: Set TXDCLK_2X_SEL bit during PCIe initialization
Pali Rohár [Fri, 24 Sep 2021 14:11:55 +0000 (16:11 +0200)]
phy: marvell: a3700: Set TXDCLK_2X_SEL bit during PCIe initialization

Marvell Armada 3700 Functional Specifications, section 52.2 PCIe Link
Initialization says that TXDCLK_2X_SEL bit needs to be enabled for PCIe
Root Complex mode.

Same change was included in TF-A project:
https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/9408

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Increase PCIe IO size from 64 KiB to 1 MiB
Pali Rohár [Thu, 23 Sep 2021 09:07:18 +0000 (11:07 +0200)]
arm: a37xx: pci: Increase PCIe IO size from 64 KiB to 1 MiB

Commit 079b35a26111 ("arm: a37xx: pci: Increase PCIe MEM size from 16 MiB
to 127 MiB") increased size of PCIe MEM to 127 MiB, which is the maximal
possible size for allocated 128 MiB PCIe window. PCIe IO size in that
commit was unchanged.

Armada 3720 PCIe controller supports 32-bit IO space mapping so it is
possible to assign more than 64 KiB if address space for IO.

Currently controller has assigned 127 MiB + 64 KiB memory and therefore
there is 960 KiB of unused memory. So assign it to IO space by increasing
IO window from 64 KiB to 1 MiB.

Signed-off-by: Pali Rohár <pali@kernel.org>
Fixes: 079b35a26111 ("arm: a37xx: pci: Increase PCIe MEM size from 16 MiB to 127 MiB")
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoMerge tag 'u-boot-amlogic-20211007' of https://source.denx.de/u-boot/custodians/u...
Tom Rini [Thu, 7 Oct 2021 13:02:22 +0000 (09:02 -0400)]
Merge tag 'u-boot-amlogic-20211007' of https://source.denx.de/u-boot/custodians/u-boot-amlogic

- Add new SoC ID for S905Y2 found in Radxa Zero
- pcie_dw_meson: fix usb fail when pci link fails to go up
- Sync Amlogic DT from Linux 5.14
- dwc3-meson-gxl: add AXG compatible
- dts: keep back HW order for MMC devices since change in Upstream Linux
- Cleanup local AXG DT USB nodes now everything is upstream
- distro_bootcmd: run pci enum for scsi_boot just like it is done for nvme_boot
- New Boards:
  - Odroid-HC4: a variant of Odroid-C4 with 2 SATA ports (via PCIe-SATA bridge)
  - Beelink GS-King X: A variant of the other Beelink board with 2 SATA ports (via USB3-SATA bridge)
  - Banana Pi M5: another credit card SBC
  - JetHub D1/H1: home automation controllers
  - Radxa Zero: another RPi Zero sized SBC

2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Thu, 7 Oct 2021 13:00:45 +0000 (09:00 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-riscv

- Reset improvements, enable coherence manager on ae350, k210 clk
  improvements, other fixes

2 years agodoc: boards: amlogic: update for Radxa Zero
Christian Hewitt [Wed, 15 Sep 2021 01:46:59 +0000 (01:46 +0000)]
doc: boards: amlogic: update for Radxa Zero

Add documentation bits for the Radxa Zero

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
[narmstrong: updated u200 MAINTAINERS]
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2 years agoboards: amlogic: add Radxa Zero defconfig
Christian Hewitt [Wed, 15 Sep 2021 01:46:58 +0000 (01:46 +0000)]
boards: amlogic: add Radxa Zero defconfig

Add a defconfig for the Radxa Zero SBC, using an Amlogic S905Y2 chip.

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
[narmstrong: updated u200 MAINTAINERS & add missing CONFIG_SYS_LOAD_ADDR from defconfig]
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2 years agoARM: dts: add support for Radxa Zero
Christian Hewitt [Wed, 15 Sep 2021 01:46:57 +0000 (01:46 +0000)]
ARM: dts: add support for Radxa Zero

Import the initial dts queued for Linux 5.16.y

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2 years agoARM: dts: sort Amlogic Makefile section
Christian Hewitt [Wed, 15 Sep 2021 01:46:56 +0000 (01:46 +0000)]
ARM: dts: sort Amlogic Makefile section

Alpha sort the Amlogic dtb list (same as the kernel).

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2 years agoARM: amlogic: add JetHub D1/H1 docs
Vyacheslav Bocharov [Mon, 20 Sep 2021 08:40:16 +0000 (11:40 +0300)]
ARM: amlogic: add JetHub D1/H1 docs

Fix doc/board/amlogic/index.rst:
- Add S905W to S905X column.
- Add JetHub devices to the corresponding columns.
- Fix tabs to spaces for table alignment

Add doc/board/amlogic files:
- jethub-j100.rst
- jethub-j80.rst

Signed-off-by: Vyacheslav Bocharov <adeep@lexina.in>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2 years agoARM: amlogic: add JetHub D1/H1 device support
Vyacheslav Bocharov [Mon, 20 Sep 2021 08:40:15 +0000 (11:40 +0300)]
ARM: amlogic: add JetHub D1/H1 device support

Add support for new home automation devices.

JetHome Jethub D1 (http://jethome.ru/jethub-d1) is a home automation controller with the following features:
- DIN Rail Mounting case
- Amlogic A113X (ARM Cortex-A53) quad-core up to 1.5GHz
- no video out
- 512Mb/1GB DDR3
- 8/16GB eMMC flash
- 1 x USB 2.0
- 1 x 10/100Mbps ethernet
- WiFi / Bluetooth AMPAK AP6255 (Broadcom BCM43455) IEEE 802.11a/b/g/n/ac, Bluetooth 4.2.
- TI CC2538 + CC2592 Zigbee Wireless Module with up to 20dBm output power and Zigbee 3.0 support.
- 2 x gpio LEDS
- GPIO user Button
- 1 x 1-Wire
- 2 x RS-485
- 4 x dry contact digital GPIO inputs
- 3 x relay GPIO outputs
- DC source with a voltage of 9 to 56 V / Passive POE

JetHome Jethub H1 (http://jethome.ru/jethub-h1) is a home automation controller with the following features:
- Square plastic case
- Amlogic S905W (ARM Cortex-A53) quad-core up to 1.5GHz
- no video out
- 1GB DDR3
- 8/16GB eMMC flash
- 2 x USB 2.0
- 1 x 10/100Mbps ethernet
- WiFi / Bluetooth RTL8822CS IEEE 802.11a/b/g/n/ac, Bluetooth 5.0.
- TI CC2538 + CC2592 Zigbee Wireless Module with up to 20dBm output power and Zigbee 3.0 support.
- MicroSD 2.x/3.x/4.x DS/HS cards.
- 1 x gpio LED
- ADC user Button
- DC source 5V microUSB with serial console

Patches from:
- JetHub H1
  https://lore.kernel.org/r/20210915085715.1134940-4-adeep@lexina.in
  https://git.kernel.org/amlogic/c/abfaae24ecf3e7f00508b60fa05e2b6789b8f607
- JetHub D1
  https://lore.kernel.org/r/20210915085715.1134940-5-adeep@lexina.in
  https://git.kernel.org/amlogic/c/8e279fb2903990cc6296ec56b3b80b2f854b6c79

Signed-off-by: Vyacheslav Bocharov <adeep@lexina.in>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
[narmstrong: removed unused variable value]
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2 years agoARM: amlogic: add JetHub common config header
Vyacheslav Bocharov [Mon, 20 Sep 2021 08:40:14 +0000 (11:40 +0300)]
ARM: amlogic: add JetHub common config header

JetHub devices uses its own boot sequence with "rescue" button

Signed-off-by: Vyacheslav Bocharov <adeep@lexina.in>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>