summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/imx-bbu-internal.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* ARM: i.MX: remove unused imx-flash-header.hSascha Hauer2016-04-011-1/+0
| | | | | | | All i.MX images are nowadays built with the imx-image tool, so we do not need the header files and Kconfig options anymore. Remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: bbu-internal: detect device before writing to itSascha Hauer2016-03-021-0/+3
| | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Stefan Christ <s.christ@phytec.de>
* sizes.h: move include/sizes.h to include/linux/sizes.hMasahiro Yamada2015-01-081-1/+1
| | | | | | | | | | | | | | This file originates in Linux. Linux has it under include/linux/ directory since commit dccd2304cc90. Let's move it to the same place as well in barebox. This commit was generated by the following commands: find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:' git mv include/sizes.h include/linux/ Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX5: internal NAND update: simplify codeSascha Hauer2014-07-241-24/+9
| | | | | | | | Allocate space for the resulting image (FCB+DBBT+Firmware) in imx_bbu_internal_v2_write_nand_dbbt() instead of its caller to make the code simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX5: internal NAND update: Use variables for some constantsSascha Hauer2014-07-241-6/+10
| | | | | | | Instead oof using the same constants multiple times use a variable to make the meaning of the constants clear. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX5: internal NAND update: Fix firmware start page for internal nand bootSascha Hauer2014-07-241-0/+3
| | | | | | | | | | | Documentation clearly states that the FCB at offset 0x68 has to contain the start page of the firmware. In our case this was set to 0x0. I don't know how this could ever work, but it did, at least until: 15ee301 ARM: i.MX: bbu-internal: optionally use DCD data from image Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX5: internal NAND update: Use variable for pre_image_sizeSascha Hauer2014-07-241-6/+9
| | | | | | | | | We have the hardcoded value 0x8000 for the space needed for FCB and DBBT in several places. Use a variable instead and initialize it correctly with 12 * meminfo.writesize (which is in fact 0x6000 for 2k pagesize). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX bbu: Add update handler for external NOR bootSascha Hauer2014-06-131-1/+45
| | | | | | | | External NOR boot only requires copying the image to NOR Flash. This also adds (un)protecting the flash which is required for NOR Flash. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>