summaryrefslogtreecommitdiff
path: root/common/env_mmc.c
Commit message (Collapse)AuthorAgeLines
* dm: env: mmc: Convert env_mmc to support CONFIG_BLKSimon Glass2016-05-27-4/+4
| | | | | | | Update the MMC environment code so that it works with driver-model enabled for block devices. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: mmc: Use the new select_hwpart() APISimon Glass2016-05-17-3/+3
| | | | | | Avoid calling directly into the MMC code - use the new API call instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* env_mmc: support overriding mmc dev from board codeClemens Gruber2016-01-25-7/+12
| | | | | | | | | | | | | | | | | | | | | | | This enables boards to choose where to/from the environment should be saved/loaded. They can then for example support using the same device (dynamically) from which the bootloader was launched to load and save env data and do not have to define CONFIG_SYS_MMC_ENV_DEV statically. In my use case, the environment needs to be on the same device I booted from. It can be the eMMC or an optional SD card. I therefore would override mmc_get_env_dev in the board code, read the CPU registers to determine where we booted from and return the corresponding device index. Cc: Tom Rini <trini@konsulko.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Tim Harvey <tharvey@gateworks.com> Cc: Simon Glass <sjg@chromium.org> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* mmc: store hwpart in the block deviceStephen Warren2016-01-13-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow us to have multiple block device structs each referring to the same eMMC device, yet different HW partitions. For now, there is still a single block device per eMMC device. As before, this block device always accesses whichever HW partition was most recently selected. Clients wishing to make use of multiple block devices referring to different HW partitions can simply take a copy of this block device once it points at the correct HW partition, and use each one as they wish. This feature will be used by the next patch. In the future, perhaps get_device() could be enhanced to return a dynamically allocated block device struct, to avoid the client needing to copy it in order to maintain multiple block devices. However, this would require all users to be updated to free those block device structs at some point, which is rather a large change. Most callers of mmc_switch_part() wish to permanently switch the default MMC block device's HW partition. Enhance mmc_switch_part() so that it does this. This removes the need for callers to do this. However, common/env_mmc.c needs to save and restore the current HW partition. Make it do this more explicitly. Replace use of mmc_switch_part() with mmc_select_hwpart() in order to remove duplicate code that skips the call if that HW partition is already selected. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* block: pass block dev not num to read/write/erase()Stephen Warren2016-01-13-7/+3
| | | | | | | | | | | This will allow the implementation to make use of data in the block_dev structure beyond the base device number. This will be useful so that eMMC block devices can encompass the HW partition ID rather than treating this out-of-band. Equally, the existence of the priv field is crying out for this patch to exist. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass2015-09-11-0/+1
| | | | | | | Now that we have a new header file for cache-aligned allocation, we should move the stack-based allocation macro there also. Signed-off-by: Simon Glass <sjg@chromium.org>
* env_mmc: Properly prefix mmc errors with '!'Hans de Goede2015-08-28-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The set_default_env() function from env_common.c expects either a fully formatted error msg, e.g.: "## Resetting to default environment\n" or an error msg prefixed with an !, in which case it will format it. Fix the init_mmc_for_env() error messages to be prefixed with a ! this changes the bootup-log on sunxi when no mmc card is found from: MMC: SUNXI SD/MMC: 0 No MMC card foundIn: serial Out: serial To: MMC: SUNXI SD/MMC: 0 *** Warning - No MMC card found, using default environment In: serial Out: serial Which clearly is how things should look. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* env_mmc: add error message to pass to set_default_envTim Harvey2015-05-27-16/+24
| | | | | | | | Add an error message that gets passed to set_default_env() like env_nand implements. This message is displayed to the user as the reason for falling back to the default environment. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
* env_mmc: correct fini partition to match init partitionPeter Bigot2014-10-03-1/+1
| | | | | | | | | | | The code to set the MMC partition uses an weak function to obtain the correct partition number. Use that instead of the compile-time default when deciding whether it needs to switch back. Fixes: 6e7b7df4df43574 ("env_mmc: support env partition setup in runtime") Signed-off-by: Peter A. Bigot <pab@pabigot.com> Acked-by: Dmitry Lifshitz <lifshitz@compulab.co.il> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
* env_mmc: support env partition setup in runtimeDmitry Lifshitz2014-08-01-12/+23
| | | | | | | | | | | | Add callback with __weak annotation to allow setup of environment partition number in runtime from a board file. Propagate mmc_switch_part() return value into init_mmc_for_env() instead of -1 in case of failure. Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
* Merge branch 'u-boot/master'Albert ARIBAUD2014-05-09-10/+2
|\ | | | | | | | | | | | | Conflicts: drivers/net/Makefile (trivial merge)
| * env: Add env_export() wrapperMarek Vasut2014-03-21-10/+2
| | | | | | | | | | | | | | | | Implement env_export() wrapper, so that all implementers of saveenv() don't have to call hexport_r(), crc32() etc. sequence . This trims down a bit of code duplication. Signed-off-by: Marek Vasut <marex@denx.de>
* | env_mmc.c: Remove NULL check on tmp_env1/2Tom Rini2014-04-17-6/+0
| | | | | | | | | | | | | | With 452a272 we moved to allocating these variables on the stack. So they will never now be NULL so remove these checks. Signed-off-by: Tom Rini <trini@ti.com>
* | env_mmc.c: Allow environment to be used within SPLTom Rini2014-04-17-8/+37
|/ | | | | | | | Inside of SPL we only concern ourself with one MMC device, so instead of being able to use CONFIG_SYS_MMC_ENV_DEV we need to use 0 in SPL. Switch the code to use a 'dev' variable to facilitate this. Signed-off-by: Tom Rini <trini@ti.com>
* Coding Style cleanup: remove trailing white spaceWolfgang Denk2013-10-14-1/+1
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* env_mmc: fix buffer allocation for armv7Markus Niebel2013-10-14-5/+4
| | | | | | | | | | | | | | | | | | | | commit d196bd880347373237d73e0d115b4d51c68cf2ad adds redundand environment to mmc. The usage of malloc in env_relocate_spec triggers cache errors on armv7. Tested on a not mainlined i.MX53 board: Board: TQMa53 I2C: ready DRAM: 512 MiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 ERROR: v7_dcache_inval_range - start address is not aligned - 0x8f57c2d8 ERROR: v7_dcache_inval_range - stop address is not aligned - 0x8f57e2d8 ERROR: v7_dcache_inval_range - start address is not aligned - 0x8f57e2e0 ERROR: v7_dcache_inval_range - stop address is not aligned - 0x8f5802e0 Using default environment Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-24-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* env_mmc: allow negative CONFIG_ENV_OFFSETStephen Warren2013-06-13-2/+10
| | | | | | | | | | | | | | | | A negative value of CONFIG_ENV_OFFSET is treated as a backwards offset from the end of the eMMC device/partition, rather than a forwards offset from the start. This is useful when a single board may be stuffed with different eMMC devices, each of which has a different capacity, and you always want the environment to be stored at the very end of the device (or eMMC boot partition for example). One example of this case is NVIDIA's Ventana reference board. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* env_mmc: add support for redundant environmentMichael Heimpold2013-05-01-9/+123
| | | | | | | | This patch add support for storing the environment redundant on mmc devices. Substantially it re-uses the logic from the NAND implementation, that means using an incremental counter for marking newer data. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
* Revert "env: fix potential stack overflow in environment functions"Tom Rini2013-04-05-7/+6
| | | | | | | | | | Wolfgang requested this be reverted and Rob agreed after further discussion. This was a symptom of a larger problem we need to deal with. This reverts commit 60d7d5a63189c9f77a190c9965861dc15482c2d0. Signed-off-by: Tom Rini <trini@ti.com>
* env: fix potential stack overflow in environment functionsRob Herring2013-04-02-6/+7
| | | | | | | | | Most of the various environment functions create CONFIG_ENV_SIZE buffers on the stack. At least on ARM and PPC which have 4KB stacks, this can overflow the stack if we have large environment sizes. So move all the buffers off the stack to static buffers. Signed-off-by: Rob Herring <rob.herring@calxeda.com>
* common: env_mmc: Use __weak annotation to simplify codeFabio Estevam2013-02-04-3/+1
| | | | | | | Using the __weak annotation can make the code cleaner. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Marek Vasut <marex@denx.de>
* env: Hide '.' variables in env print by defaultJoe Hershberger2012-12-13-1/+1
| | | | | | | | | | When printing all variables with env print, don't print variables that begin with '.'. If env print is called with a '-a' switch, then include variables that begin with '.' (just like the ls command). Variables printed explicitly will be printed even without the -a. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env_mmc: allow environment to be in an eMMC partitionStephen Warren2012-09-05-8/+56
| | | | | | | | | | | | | eMMC devices may have hardware-level partitions: 2 boot partitions, up to 4 general partitions, plus the user area. This change introduces optional config variable CONFIG_SYS_MMC_ENV_PART to indicate which partition the environment should be stored in: 0=user, 1=boot0, 2=boot1, 4..7=general0..3. This allows the environment to be kept out of the user area, which simplifies the management of OS-/user-level (MBR/GPT) partitions within the user area. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* env_mmc: align buffers using ALLOC_CACHE_ALIGN_BUFFERStephen Warren2012-07-07-5/+5
| | | | | | | | | This allows MMC drivers to perform cache flusing on the bufffers without issue. Signed-off-by: Stephen Warren <swarren@nvidia.com> Cc: Andy Fleming <afleming@gmail.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
* env: factor out the env_get_char_spec() functionIgor Grinberg2012-01-05-5/+0
| | | | | | | | | env_get_char_spec() function is duplicated across multiple environment files. Remove the duplication by providing a default implementation. Add "weak" declaration, so the default implementation can be overridden. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
* env: clean env_mmc.c checkpatch and code styleIgor Grinberg2011-11-22-49/+23
| | | | | | | | Cleanup the env_mmc.c checkpatch warnings, errors and coding style. Simplify env_relocate_spec() function implementation. Also mark internal functions as static. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
* env: move extern environment[] to environment.hIgor Grinberg2011-11-22-2/+1
| | | | | | | Extract all extern declarations for environment out of c files into the environment.h header. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
* env: move extern default_environment[] to environment.hIgor Grinberg2011-11-22-3/+0
| | | | | | | | | Extract all extern declarations for default_environment[] out of c files into the environment.h header. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Cc: Stefan Roese <sr@denx.de> Acked-by: Stefan Roese <sr@denx.de>
* env: allow to export only selected variablesWolfgang Denk2011-11-08-1/+1
| | | | | | | | | | | | | | New syntax: env export [-t | -b | -c] [-s size] addr [var ...] With this change it is possible to provide a list of variables names that shall be exported. Whenno arguments are given, the whole environment gets exported. NOTE: The new handling of the "size" argument means a change to the user API. Signed-off-by: Wolfgang Denk <wd@denx.de>
* env_mmc: Allow board code to override the environment addressMingkai Hu2011-04-04-4/+27
| | | | | | | | | | | | On some boards the environment may not be located at a fixed address in the MMC/SDHC card. This allows those boards to implement their own means to report what address the environment is located at. Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com> Signed-off-by: Zhao Chenhui <b35336@freescale.com> Acked-by: Andy Fleming <afleming@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* hashtable: drop all non-reentrant versionsMike Frysinger2010-12-17-1/+1
| | | | | | | | | | | The non-reentrant versions of the hashtable functions operate on a single shared hashtable. So if two different people try using these funcs for two different purposes, they'll cause problems for the other. Avoid this by converting all existing hashtable consumers over to the reentrant versions and then punting the non-reentrant ones. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* env_mmc: fix compile warningLei Wen2010-11-14-0/+1
| | | | | | | | | | hexport would complain implicit declaration, if we don't add the include file. env_mmc.c: In function 'saveenv': env_mmc.c:109: warning: implicit declaration of function 'hexport' Signed-off-by: Lei Wen <leiwen@marvell.com>
* Merge branch 'master' of git://git.denx.de/u-boot-armWolfgang Denk2010-10-17-7/+10
|\
| * env_mmc: Fix crashing bug encountered after enabling ARM relocationSteve Sakoman2010-10-13-7/+10
| | | | | | | | | | | | | | | | | | | | | | The crash was occuring in env_relocate because it was being called prior to mmc_initialize. This patch moves the MMC initialization earlier in the init process. This patch also cleans up the env_relocate_spec code in env_mmc.c Signed-off-by: Steve Sakoman <steve.sakoman@linaro.org> Acked-by: Stefano Babic <sbabic@denx.de>
* | env_mmc: fix cannot save env issueLei Wen2010-10-13-1/+12
|/ | | | | | | | | | | | | | The env change its implementation after this log, while env mmc didn't change it immediately, which cause issue. Follow to the new style to fix it. commit ea882baf9c17cd142c99e3ff640d3ab01daa5cec Author: Wolfgang Denk <wd@denx.de> Date: Sun Jun 20 23:33:59 2010 +0200 New implementation for internal handling of environment variables. Signed-off-by: Lei Wen <leiwen@marvell.com>
* env_mmc: Fix broken build due to set_default_env() changeSteve Sakoman2010-10-06-2/+1
| | | | | | | | Previously the function was set_default_env(void), it is now set_default_env(const char *s). This patch adds the required parameter. This fixes a broken build on OMAP4430 SDP. Signed-off-by: Steve Sakoman <steve.sakoman@linaro.org>
* Save environment data to mmc.Terry Lv2010-09-19-0/+153
This patch is to save environment data to mmc card. It uses interfaces defined in generic mmc. Signed-off-by: Terry Lv <r65388@freescale.com> Acked-by: Stefano Babic <sbabic@denx.de>