summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/imx-bbu-internal.c
Commit message (Collapse)AuthorAgeFilesLines
* ARM: i.MX: add i.MX8MN (Nano) SoC support boilerplateAhmad Fatoum2021-10-051-4/+4
| | | | | | | | | The Nano is basically a downsized mini. Add the necessary bits, so driver and board support can be added. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211001100949.6891-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partitionAhmad Fatoum2021-10-051-1/+16
| | | | | | | | | | | | | | According to the reference manual of the i.MX8MP, the bootrom expects the bootloader to sit directly at the start of the eMMC boot partition. The 32K offset is only valid for eMMC user partitions and SD. Tell barebox_update about this, so it can strip away the first 32K when writing to an eMMC boot partition. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210830115156.21907-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arm: imx: Replace license and copyright boilerplate by SPDX identifiersUwe Kleine-König2021-05-251-11/+3
| | | | | | | | | | Converts the files that licensecheck can determine to be licensed under GPL-2.0-only or GPL-2.0-or-later and also convert their copyright statements to SPDX. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.barebox.org/20210522143431.824057-1-u.kleine-koenig@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX8M: bbu: rename imx8mq_bbu_* functions to imx8m_bbu_*Ahmad Fatoum2020-12-071-3/+3
| | | | | | | | | | | imx_bbu_internal_mmcboot_register_handler already supports the i.MX8MQ, i.MX8MP and i.MX8MM, but the latter two do not have helpers with their SoC as prefix. As it seems like that it will be possible to extend imx_bbu_internal_mmcboot_register_handler for upcoming SoCs in the i.MX8M family as well, rename the function to start with imx8m_. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Fix IVT offset for i.MX8MPSascha Hauer2020-07-141-6/+11
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX8M: Add i.MX8MM supportSascha Hauer2020-02-191-2/+2
| | | | | | This adds support for the i.MX8MM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: early exit when partition too smallAhmad Fatoum2019-08-301-0/+10
| | | | | | | | | | | | | | | | | | | | So far, writing a barebox image exceeding the partition size aborts with EPERM as truncate isn't implemented: ERROR: writing to /dev/flash-boot.barebox failed with Operation not permitted update failed ERROR: fastboot: update barebox: Operation not permitted This is unfortunate because by the time the truncation fails, erasing the partition had already occurred. Avoid this by checking prior to the pwrite_all whether the file to be written is big enough. This is valid here because barebox update wouldn't be called on a regular file. While at it, present callers with a more helpful ENOSPC error. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Fix variable type in imx_bbu_internal_v2_write_nand_dbbt()Andrey Smirnov2019-03-111-1/+1
| | | | | | | | MEMGETBADBLOCK returns loff_t, so that's the type we should use to store its result. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Fix lseek error check in imx_bbu_internal_v2_write_nand_dbbt()Andrey Smirnov2019-03-111-3/+5
| | | | | | | | | Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX8MQ: bbu: Add MMC boot handlerAndrey Smirnov2019-02-111-0/+5
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX7: bbu: Add I2C and SPI handlerAndrey Smirnov2018-10-081-0/+6
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX7: bbu: Add MMC boot handlerAndrey Smirnov2018-10-081-0/+5
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: VFxxx: bbu: Add a handler for MMC boot partitionsAndrey Smirnov2018-09-191-0/+5
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Detect MMC before reading current boot partitionAndrey Smirnov2018-09-191-0/+6
| | | | | | | | | In order to be able to read "mmcN.boot" we need to detect that device first. Not doing so would result in failure if "barebox_update" is executed before "detect mmc0". Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Convert devicefile to device nameAndrey Smirnov2018-09-191-2/+3
| | | | | | | | Data->devicefile can contain absolute path to target device, so we need to convert it to a device name before we can safely use it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Check retrun value of getenv()Andrey Smirnov2018-09-191-0/+5
| | | | | | | | Add code to make sure that getenv() returned correct result and bail out if it failed. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX51: bbu: Add a handler for MMC boot partitionsAndrey Smirnov2018-09-191-0/+5
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Add support for v1 header to MMC boot handlerAndrey Smirnov2018-09-191-15/+17
| | | | | | | | | | Convert imx_bbu_internal_v2_mmcboot_update() to use imx_bbu_update() for actual update in order to be able to support v1 as well as v2 headers. While at it rename the function to imx_bbu_internal_mmcboot_update() to reflect that change. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Use pwrite_full() instead of pwrite()Andrey Smirnov2018-08-311-3/+7
| | | | | | | | | 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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Add support for MMC on i.MX8MQAndrey Smirnov2018-08-311-0/+8
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Add support for SPI/I2C on VFxxxAndrey Smirnov2018-08-311-0/+10
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQAndrey Smirnov2018-08-311-6/+18
| | | | | | | | | | | | 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: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Move protect code into a separate routineAndrey Smirnov2018-08-311-20/+42
| | | | | | | | | | 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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler()Andrey Smirnov2018-08-311-11/+10
| | | | | | | Alias imx5*_bbu_internal_spi_i2c_register_handler() to a common function. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler()Andrey Smirnov2018-08-311-6/+2
| | | | | | | | Alias imx5*_bbu_internal_mmc_register_handler() to imx_bbu_internal_mmc_register_handler() Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Detect which platforms need v2 i.MX headerAndrey Smirnov2018-08-311-13/+19
| | | | | | | | 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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Constify all 'devicefile' argumentsAndrey Smirnov2018-08-311-16/+24
| | | | | | | | Constify all 'devicefile' arguments since they are treated as so by all of the users in BBU code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler()Andrey Smirnov2018-08-311-2/+1
| | | | | | | | | 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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Consolidate various update helpersAndrey Smirnov2018-08-311-58/+12
| | | | | | | | | | | 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 everywhere. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NANDAndrey Smirnov2018-08-311-10/+14
| | | | | | | | | | 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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Move inner-image type checkAndrey Smirnov2018-08-311-25/+43
| | | | | | | | | | | | | | 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 a part of imx_bbu_check_prereq() Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Remove unused defineAndrey Smirnov2018-08-311-2/+0
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: support partitions starting at i.MX headerSascha Hauer2018-07-021-2/+5
| | | | | | | | The i.MX header is at an offset in the boot device, usually 0x400 bytes. This patch adds a flag to support the case that the partition the image is written to starts at that offset rather than 0x0. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: reimplement IMX_INTERNAL_FLAG_KEEP_DOSPART flagSascha Hauer2018-07-021-45/+20
| | | | | | | | | | | | | | | | | | | This patch reimplements the IMX_INTERNAL_FLAG_KEEP_DOSPART flag and makes it more generic. Until now we only kept a dos partition table over the update. Beginning with i.MX8 we may also want to preserve a GPT, so we have to extend the preserved area. It might also be the case that not (only) a partition table is stored in the initial area of a device, but also other unrelated data, so it's better to just keep the initial area that is unused by the i.MX ROM. It's also good to export the flag to allow boards to specify the initial area shall be preserved. When a board wants to set the flag for a mtd like device then it has to check for suitable erase sizes beforehand. We do not check this (yet). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: remove handler specific flags variableSascha Hauer2018-07-021-18/+17
| | | | | | | Now that we can store flags in the generic handler flags we no longer need our own variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Add support for MMC on VFxxxAndrey Smirnov2018-06-131-0/+7
| | | | | | | | Add support for MMC on VFxxx by providing an alias to imx6_bbu_internal_mmc_register_handler(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Use pr_* functions for outputAndrey Smirnov2018-06-131-15/+15
| | | | | | | | | Use pr_* function family for all of the logging in the file both for consistency with the rest of the code and to make all of the output be properly tagged with loglevel information. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Share MMC code between i.MX51 and 53Andrey Smirnov2018-06-131-15/+17
| | | | | | | | | Both functions do exactly the same thing with only difference being type of hanler they pass one. Convert the code to use a generic function accpeting handler as additional parameter. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Replace magic number with a constantAndrey Smirnov2018-06-131-1/+1
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu: Alias identical functionsAndrey Smirnov2018-06-131-25/+6
| | | | | | | | Some BBU functions for i.MX53 and i.MX6 are identical, so declare the latter as an alias for former to avoid code duplication. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: imx-bbu-internal: add i.MX51 SPI/I2C flash handlerLucas Stach2018-05-141-0/+14
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: imx-bbu-internal: make pointers to image constSascha Hauer2018-01-301-3/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: imx-bbu-internal: Do not modify imageSascha Hauer2018-01-301-4/+15
| | | | | | | | | Instead of copying the existing partition table into the image to be flashed, modify the temporary buffer and write from this one. This makes it unnecessary to modify the input image which can be made const then in a later step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mii'Sascha Hauer2018-01-051-2/+1
|\
| * i.MX: imu-bbu-internal: Make use of devpath_to_name()Andrey Smirnov2017-12-061-2/+1
| | | | | | | | | | | | | | Convert the code to use shared function from fs.h Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: i.MX: bbu-internal: fix typosUlrich Ölmann2017-11-281-6/+6
| | | | | | | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: i.MX: bbu-internal: fix commentUlrich Ölmann2017-11-281-1/+1
|/ | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu-internal: new handler to make use of mmc boot partitionsUwe Kleine-König2017-10-241-0/+76
| | | | | | | | | This handler updates the non-active MMC boot partition and after a successful update makes the updated partition the active one. This way the machine should continue to be bootable when the update fails. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu-internal: make filename for device to write to adaptableUwe Kleine-König2017-10-241-17/+20
| | | | | | | | | | | | This is a preparatory for the next patch that autodetects the device to write to. To not have to modify the callback data for each call, some static functions get an additional parameter to allow that. This doesn't affect boards making use of the file's function and doesn't change behaviour. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>