[PATCH 2/2] ARM: i.MX: xload: Add support for signed HDMI firmware

2018-08-23 Thread Andrey Smirnov
When booting images that have HDMI firmware embedded we need to skip the first v2 header we encounter and get all of the necessary data from the next one. Add code implementing that. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/xload-esdhc.c | 43 + 1 file

[PATCH 1/2] scripts: imx: Add support for signed HDMI firmware

2018-08-23 Thread Andrey Smirnov
Boot header on i.MX8MQ SoC allows embedding signed HDMI firmware images that are used by mask ROM code during the very early stages of boot. Since providing that firmware appear to be necessary to enable SoC's HDMI/DP functionality extend imx-image tool to support this feature. To do that add code

[PATCH] ARM: mmu64: Don't flush freshly invalidated region

2018-08-23 Thread Andrey Smirnov
Current code for dma_sync_single_for_device(), when called with dir set to DMA_FROM_DEVICE, will first invalidate given region of memory as a first step and then clean+invalidate it as a second. While the second step should be harmless it seems to be an unnecessary no-op that could probably be avoi

[PATCH 3/3] ARM: start: Place malloc pool within 32-bit address space

2018-08-23 Thread Andrey Smirnov
Some 64-bit SoC have IP cores whose DMA capability is limited to 32-bits only. To handles such cases introduced DMA_32_BIT_ONLY as well as add the code to make sure that malloc pool (which will be used for DMA buffers) is accessible using 32-bit address. Signed-off-by: Andrey Smirnov --- arch/ar

[PATCH 1/3] mci: imx-esdhc: Bail out if DMA address is larger than 32-bits

2018-08-23 Thread Andrey Smirnov
On 64-bit SoCs it becomes possible to end up with a DMA buffer allocated in the region of memory inaccessible to ESDHC controller. Change the code to bail out if that happens to avoid silent failures. Signed-off-by: Andrey Smirnov --- drivers/mci/imx-esdhc.c | 3 +++ 1 file changed, 3 insertions

[PATCH 0/3] i.MX8 malloc pool position and 32-bit only DMA

2018-08-23 Thread Andrey Smirnov
Everyone: This series is a result of debugging FEC and uSDHC failures on i.MX8MQ. Patches 1 and 2 are pretty straightforward and shouldn't be controversial. Patch 3, OTOH, may or may not be a good way to solve this problem, but it's a good way to start a discussion on the subject which is my main

[PATCH 2/3] net: fec: Bail out if DMA address is larger than 32-bits

2018-08-23 Thread Andrey Smirnov
On 64-bit SoCs it becomes possible to end up with a DMA buffer allocated in the region of memory inaccessible to FEC controller. Change the code to bail out if that happens to avoid silent failures that'd result otherwise. Signed-off-by: Andrey Smirnov --- drivers/net/fec_imx.c | 10 +-

[PATCH 5/5] scsi: ilog2: create truly constant version for sparse

2018-08-23 Thread Andrey Smirnov
From: Martin Wilck Sparse emits errors about ilog2() in array indices because of the use of __ilog2_32() and __ilog2_64(), rightly so (https://www.spinics.net/lists/linux-sparse/msg03471.html). Create a const_ilog2() variant that works with sparse for this scenario. (Note: checkpatch.pl complai

[PATCH 2/5] give up on gcc ilog2() constant optimizations

2018-08-23 Thread Andrey Smirnov
From: Linus Torvalds gcc-7 has an "optimization" pass that completely screws up, and generates the code expansion for the (impossible) case of calling ilog2() with a zero constant, even when the code gcc compiles does not actually have a zero constant. And we try to generate a compile-time error

[PATCH 0/5] include/linux/log2.h warning fix

2018-08-23 Thread Andrey Smirnov
Everyone: This series is result of fixing compiler warnings similar to the one below: In file included from drivers/clk/clk-divider.c:22: include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Wattributes] int ilog2_NaN(void); that I

[PATCH 4/5] linux/log2.h: fix kernel-doc notation

2018-08-23 Thread Andrey Smirnov
From: Randy Dunlap Fix kernel-doc: - Add kernel-doc notation to some functions. - Fix kernel-doc notation in function parameters. Signed-off-by: Randy Dunlap Signed-off-by: Jonathan Corbet [andrew.smir...@gmail.com: Applied kernel patch to Barebox as-is] Signed-off-by: Andrey Smirnov --- in

[PATCH 1/5] log2: make order_base_2() behave correctly on const input value zero

2018-08-23 Thread Andrey Smirnov
From: Ard Biesheuvel The function order_base_2() is defined (according to the comment block) as returning zero on input zero, but subsequently passes the input into roundup_pow_of_two(), which is explicitly undefined for input zero. This has gone unnoticed until now, but optimization passes in G

[PATCH 3/5] log2: Use fls_long() in __roundup_pow_of_two()

2018-08-23 Thread Andrey Smirnov
Convert __roundup_pow_of_two() to use fls_long() instead of fls() so the code would be identical to that found in Linux. This fix also allowed next patch(taken from Linux kernel verbatim) to apply cleanly. Signed-off-by: Andrey Smirnov --- include/linux/log2.h | 2 +- 1 file changed, 1 insertion

[PATCH v2 10/24] ARM: i.MX: bbu: Detect which platforms need v2 i.MX header

2018-08-23 Thread Andrey Smirnov
Detect which platforms need header v2 based on current CPU type and replace all of the code explicitly specifying that. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 32 +--- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/a

[PATCH v2 11/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler()

2018-08-23 Thread Andrey Smirnov
Alias imx5*_bbu_internal_mmc_register_handler() to imx_bbu_internal_mmc_register_handler() Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/

[PATCH v2 24/24] bbu: command: Make sure specified update handler exists

2018-08-23 Thread Andrey Smirnov
Add code to verify that update handler specified with either -t or of -d exists before commencing the update procedure. Signed-off-by: Andrey Smirnov --- commands/barebox-update.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/commands/barebox-update.c b/com

[PATCH v2 20/24] ARM: i.MX: bbu: Use pwrite_full() instead of pwrite()

2018-08-23 Thread Andrey Smirnov
Use pwrite_full() instead of pwrite() to make sure that all of the data was written to target device. While at it adjust return value of imx_bbu_write_device() to be zero in case of success. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 10 +++--- 1 file changed, 7

[PATCH v2 22/24] block: Do not ignore error in blk->ops->write()

2018-08-23 Thread Andrey Smirnov
Getting a error from blk->ops->write() is not a very unlikely event (happens quite often during new board bringup), so we need to catch and propagate them to upper layers so they can be at least reported properly. Change the code of all of the callers to bail out as soon as blk->ops->write() fails.

[PATCH v2 18/24] ARM: nxp-imx8mq-evk: Add eMMC BBU configuration

2018-08-23 Thread Andrey Smirnov
Add BBU configuration to allow programming Barebox to eMMC. Normally factory U-Boot is shipped in mmc0.boot0, so us using user partition for Barebox should allow those two to coexist. Signed-off-by: Andrey Smirnov --- arch/arm/boards/nxp-imx8mq-evk/board.c | 3 +++ 1 file changed, 3 insertions(+

[PATCH v2 16/24] ARM: i.MX: zii-vf610-dev-rev-b/c: Add support for BBU on SPI-NOR

2018-08-23 Thread Andrey Smirnov
Signed-off-by: Andrey Smirnov --- arch/arm/boards/zii-vf610-dev/board.c | 19 +++ arch/arm/dts/vf610-zii-dev-rev-b.dts | 11 +++ 2 files changed, 30 insertions(+) diff --git a/arch/arm/boards/zii-vf610-dev/board.c b/arch/arm/boards/zii-vf610-dev/board.c index d88b26164.

[PATCH v2 19/24] libfile: Introduce pwrite_full()

2018-08-23 Thread Andrey Smirnov
Analogous to what we have with write()/write_full(), introduce a lightweight wrapper around pwrite() that guarantees the either all data is going to be written or a negative error code would be returned. Signed-off-by: Andrey Smirnov --- include/libfile.h | 1 + lib/libfile.c | 24 +

[PATCH v2 21/24] bbu: Remove logical negation in barebox_update_handler_exists()

2018-08-23 Thread Andrey Smirnov
Returning !bbu_find_handler() from barebox_update_handler_exists() would return the opposite result from what the name of that funciton implies. Drop the "!" to make it behave as expected. Signed-off-by: Andrey Smirnov --- common/bbu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v2 09/24] ARM: i.MX: bbu: Constify all 'devicefile' arguments

2018-08-23 Thread Andrey Smirnov
Constify all 'devicefile' arguments since they are treated as so by all of the users in BBU code. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 40 +--- arch/arm/mach-imx/include/mach/bbu.h | 40 ++-- 2 files changed, 44

[PATCH v2 15/24] ARM: i.MX: bbu: Add support for SPI/I2C on VFxxx

2018-08-23 Thread Andrey Smirnov
Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 10 ++ arch/arm/mach-imx/include/mach/bbu.h | 11 +++ 2 files changed, 21 insertions(+) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index c1b3d9ce8..ecc885d29 10

[PATCH v2 05/24] ARM: i.MX: bbu: Move inner-image type check

2018-08-23 Thread Andrey Smirnov
Since imx_bbu_check_prereq() already uses file_detect_type() and we've extended it to understand i.MX boot image file type, we can simplify a bunch of repetitive code as follows: 1. Convert all checks from IVT_BARKER to filetype_imx_image_v2 check 2. Move all of the checking to be

[PATCH v2 17/24] ARM: i.MX: bbu: Add support for MMC on i.MX8MQ

2018-08-23 Thread Andrey Smirnov
Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 8 arch/arm/mach-imx/include/mach/bbu.h | 9 + 2 files changed, 17 insertions(+) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index ecc885d29..59fe6218e 100644 -

[PATCH v2 14/24] ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQ

2018-08-23 Thread Andrey Smirnov
Flash header is located at 33KiB mark on i.MX8MQ, so we need to take that into account when initializing imx_handler->flash_header_offset. Convert FLASH_HEADER_OFFSET_MMC into a function call that will check if Barebox is running on i.MX8MQ CPU and adjust the offset accordingly. Signed-off-by: An

[PATCH v2 12/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler()

2018-08-23 Thread Andrey Smirnov
Alias imx5*_bbu_internal_spi_i2c_register_handler() to a common function. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/i

[PATCH v2 13/24] ARM: i.MX: bbu: Move protect code into a separate routine

2018-08-23 Thread Andrey Smirnov
Both code sections responsible for enabling/disabling underlying device write protection are almost identical to each other. To avoid code duplication move them into a separate routine and adjust the rest of the code accordignly. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-intern

[PATCH v2 23/24] bbu: Report update failures explicitly

2018-08-23 Thread Andrey Smirnov
Change the code of barebox_update() to explicitly log that update failed instead of failing silently (unless update was interrupted) and relying on user checking the return code. Signed-off-by: Andrey Smirnov --- common/bbu.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) di

[PATCH v2 04/24] filetype: Add code to detect i.MX image v2

2018-08-23 Thread Andrey Smirnov
Modify file_detect_type() and add code needed to be able to detect i.MX boot images with v2 header. Signed-off-by: Andrey Smirnov --- common/filetype.c | 4 include/filetype.h | 1 + 2 files changed, 5 insertions(+) diff --git a/common/filetype.c b/common/filetype.c index 8f2be2773..f8b6b

[PATCH v2 07/24] ARM: i.MX: bbu: Consolidate various update helpers

2018-08-23 Thread Andrey Smirnov
All three, imx_bbu_internal_v1_update(), imx_bbu_external_update() and imx_bbu_internal_v2_update() are doing exactly the same thing. Instead of having three almost identical functions, convert imx_bbu_internal_v2_update() (the most versatile of the three) to be a generic function and use it everyw

[PATCH v2 06/24] ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NAND

2018-08-23 Thread Andrey Smirnov
Replace IMX_INTERNAL_FLAG_NAND with a function pointer that can be customized by individual registration functions. The change by iteself doesn't have that much value, however it makes the simplification in the commit that follows more straightforward. Signed-off-by: Andrey Smirnov --- arch/arm/

[PATCH v2 01/24] ARM: i.MX: bbu: Remove unused define

2018-08-23 Thread Andrey Smirnov
Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index 55e344cff..67ae2961c 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach

[PATCH v2 00/24] i.MX BBU improvements and bugfixes

2018-08-23 Thread Andrey Smirnov
Everyone: This series is the result simplification, bugfixing and adding features to some of the code in BBU subsytem: - Patches 1 - 13 are a number of code simplifications intended to minimize amount of duplicated code as well as generic improvements (IMHO) - Patches 14 - 18 are i.M

[PATCH v2 08/24] ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler()

2018-08-23 Thread Andrey Smirnov
Second parameter of __init_handler() will initialize handler.devicefile for us, so there's no need to to it explicitly after. Signed-off-by: Andrey Smirnov --- arch/arm/mach-imx/imx-bbu-internal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-int

[PATCH v2 02/24] filetype: Add arch/ to include path

2018-08-23 Thread Andrey Smirnov
Add arch/ to include path for filetype.o so that it would be possible to pull in various machine specific constants in. Signed-off-by: Andrey Smirnov --- common/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/common/Makefile b/common/Makefile index b6284c255..13920cc5a 100644 --- a/

[PATCH v2 03/24] filetype: Add code to detect i.MX image v1

2018-08-23 Thread Andrey Smirnov
Modify file_detect_type() and add code needed to be able to detect i.MX boot images with v1 header. Signed-off-by: Andrey Smirnov --- common/filetype.c | 7 +++ include/filetype.h | 1 + 2 files changed, 8 insertions(+) diff --git a/common/filetype.c b/common/filetype.c index c5f2384a6..8f

Re: [PATCH] ARM: phytec-phycard-imx27: Add debug UART support

2018-08-23 Thread Andrey Smirnov
On Thu, Aug 23, 2018 at 2:59 AM Florian Bäuerle wrote: > > Signed-off-by: Florian Bäuerle > --- > arch/arm/boards/phytec-phycard-imx27/lowlevel.c | 15 +++ > arch/arm/mach-imx/include/mach/debug_ll.h | 13 + > include/serial/imx-uart.h | 5 +++

Re: [PATCH 02/22] filetype: Add code to detect i.MX image v1

2018-08-23 Thread Andrey Smirnov
On Thu, Aug 23, 2018 at 2:33 AM Roland Hieber wrote: > > On Tue, Aug 21, 2018 at 01:23:28PM -0700, Andrey Smirnov wrote: > > On Tue, Aug 21, 2018 at 3:07 AM Roland Hieber > > wrote: > > > > > > Hello Andrey, > > > > > > On Mon, Aug 20, 2018 at 11:25:43PM -0700, Andrey Smirnov wrote: > > > > Modi

Re: [PATCH 1/4] ratp: implement i2c read/write support

2018-08-23 Thread Aleksander Morgado
>> +struct ratp_bb_i2c_read_request { >> + struct ratp_bb header; >> + uint16_t buffer_offset; >> + uint8_t bus; >> + uint8_t addr; > > I wonder how we see the RATP support. If it's for adhoc debugging then > bus/addr is fine. The caller should have no expectations that the bus >

Re: [PATCH] ARM: phytec-phycard-imx27: Add debug UART support

2018-08-23 Thread Baeuerle, Florian
Some background on that patch: I've tried to get barebox master compiled with OSELAS 2018 running on a phycard-imx27. I had a few problems with that: It turned out, that I can boot the resulting image as a seconds stage (from an older version of barebox), after commenting out pca100_usb_init(). I

[PATCH] ARM: phytec-phycard-imx27: Add debug UART support

2018-08-23 Thread Florian Bäuerle
Signed-off-by: Florian Bäuerle --- arch/arm/boards/phytec-phycard-imx27/lowlevel.c | 15 +++ arch/arm/mach-imx/include/mach/debug_ll.h | 13 + include/serial/imx-uart.h | 5 + 3 files changed, 33 insertions(+) diff --git a/arch/arm/boards/

Re: [PATCH 02/22] filetype: Add code to detect i.MX image v1

2018-08-23 Thread Roland Hieber
On Tue, Aug 21, 2018 at 01:23:28PM -0700, Andrey Smirnov wrote: > On Tue, Aug 21, 2018 at 3:07 AM Roland Hieber wrote: > > > > Hello Andrey, > > > > On Mon, Aug 20, 2018 at 11:25:43PM -0700, Andrey Smirnov wrote: > > > Modify file_detect_type() and add code needed to be able to detect > > > i.MX b