aboutsummaryrefslogtreecommitdiff
path: root/drivers/block
AgeCommit message (Collapse)AuthorFilesLines
2023-04-27ide: Drop weak functionsSimon Glass1-7/+7
These are not used from outside this file anymore. Make them static and remove them from the header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27ide: Move a few functions further up the fileSimon Glass1-34/+34
Move these functions so they appear before they are used. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27ide: Drop ide_device_present()Simon Glass1-9/+0
This function is not used anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27ide: Move ide_init() into probingSimon Glass1-7/+6
At present the code does ide_init() as a separate operation, then calls device_probe() to copy over the information. We can call ide_init() from probe just as easily. The only difference is that using 'ide init' twice will do nothing. However it already fails to copy over the new data in that case, so the effect is the same. For now, unbind the block devices and remove the IDE device, which causes the bus to be probed again. Later patches will fix this up fully, so that all blk_desc data is copied across. Since ide_reset() is only called from ide_init(), there is no need to init the ide_dev_desc[] array. This is already done at the end of ide_init() so drop this code. The call to uclass_first_device() is now within the probe() function of the same device, so does nothing. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27ide: Use mdelay() for long delaysSimon Glass1-14/+11
Rather than using very large numbers with udelay(), use mdelay(), which is easier to follow. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27ide: Move ATA_CURR_BASE to C fileSimon Glass1-0/+3
This is not used outside one C file. Move it out of the header to reduce its visbility. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-05blk: blkmap: Add linear device mapping supportTobias Waldekranz1-0/+71
Allow a slice of an existing block device to be mapped to a blkmap. This means that filesystems that are not stored at exact partition boundaries can be accessed by remapping a slice of the existing device to a blkmap device. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-05blk: blkmap: Add memory mapping supportTobias Waldekranz1-0/+105
Allow a slice of RAM to be mapped to a blkmap. This means that RAM can now be accessed as if it was a block device, meaning that existing filesystem drivers can now be used to access ramdisks. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-05blk: blkmap: Add basic infrastructureTobias Waldekranz4-0/+363
blkmaps are loosely modeled on Linux's device mapper subsystem. The basic idea is that you can create virtual block devices whose blocks can be backed by a plethora of sources that are user configurable. This change just adds the basic infrastructure for creating and removing blkmap devices. Subsequent changes will extend this to add support for actual mappings. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a new pre-scan priority for bootdevsSimon Glass1-2/+2
We need extensions to be set up before we start trying to boot any of the bootdevs. Add a new priority before all the others for tht sort of thing. Also add a 'none' option, so that the first one is not 0. While we are here, comment enum bootdev_prio_t fully and expand the test for the 'bootdev hunt' command. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add an IDE bootdevSimon Glass1-0/+44
Add a bootdev for IDE so that these devices can be used with standard boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23ide: Drop non-DM code for BLKSimon Glass1-41/+1
We require CONFIG_BLK to be enabled now, so this code is unused. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: blk: Add probe in blk_first_device/blk_next_deviceMichal Suchanek1-24/+22
The description claims that the device is probed but it isn't. Add the device_probe() call. Also consolidate the iteration into one function. Fixes: 8a5cbc065d ("dm: blk: Use uclass_find_first/next_device() in blk_first/next_device()") Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2022-11-07dm: sandbox: Switch over to using the new host uclassSimon Glass2-118/+18
Update the sandbox implementation to use UCLASS_HOST and adjust all the pieces to continue to work: - Update the 'host' command to use the new API - Replace various uses of UCLASS_ROOT with UCLASS_HOST - Disable test_eficonfig since it doesn't work (this should have a unit test to allow this to be debugged) - Update the blk test to use the new API - Drop the old header file Unfortunately it does not seem to be possible to split this change up further. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: sandbox: Create a block driverSimon Glass2-1/+143
Create a block driver for the new HOST uclass. This handles attaching and detaching host files. For now the uclass is not used but this will be plumbed in with future patches. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: sandbox: Create a new HOST uclassSimon Glass2-1/+177
Sandbox supports block devices which can access files on the host machine. At present there is no uclass for this. The devices are attached to the root devic. The block-device type is therefore set to UCLASS_ROOT which is confusing. Block devices should be attached to a 'media' device instead, something which handles access to the actual media and provides the block driver for the block device. Create a new uclass to handle this. It supports two operations, to attach and detach a file on the host machine. For now this is not fully plumbed in. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: blk: Tidy up obtaining a block device from its parentSimon Glass1-11/+15
This function now finds its block-device child by looking for a child device of the correct uclass (UCLASS_BLK). It cannot produce a device of any other type, so drop the superfluous check. Provide a version which does not probe the device, since that is often needed when setting up the device's platdata. Also fix up the function's comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: test: Clear the block cache after running a testSimon Glass1-13/+10
Some tests access data in block devices and so cause the cache to fill up. This results in memory being allocated. Some tests check the malloc usage at the beginning and then again at the end, to ensure there is no memory leak caused by the test. The block cache makes this difficult, since the any test may cause entries to be allocated or even freed, if the cache becomes full. It is simpler to clear the block cache after each test. This ensures that it will not introduce noise in tests which check malloc usage. Add the logic to clear the cache, using the existing blkcache_invalidate() function. Drop the duplicate code at the same time. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: sandbox: Drop non-BLK code from host implementationSimon Glass1-102/+0
This is not used anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31dm: blk: mmc: Tidy up some Makefile rules for SPLSimon Glass2-2/+1
Use the correct SPL_TPL_ variable so that these features can be enabled in TPL and VPL as needed. Disable it by default in TPL to avoid any code-size increase. No boards are actually using it since the Makefile rules don't allow including drivers/block/ with TPL_DM enabled. It can be manually enabled as needed. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2022-10-31dm: blk: Add udevice functionsSimon Glass1-17/+34
At present we have functions called blk_dread(), etc., which take a struct blk_desc * to refer to the block device. Add some functions which use udevice instead, since this is more in keeping with how driver model is supposed to work. Update one of the tests to use this. Note that it would be nice to update the functions in disk-uclass.c to use these new functions. However they are not quite the same. For example, disk_blk_read() adds the partition offset to 'start' when calling the cache read/fill functions, but does not with part_blk_read(), which does the addition itself. So as designed the code is duplicated. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-17dm: blk: Do not use uclass_next_device_errMichal Suchanek1-10/+6
blk_first_device_err/blk_next_device_err uses uclass_first_device_err/uclass_next_device_err for device iteration. Although the function names superficially match the return value from uclass_first_device_err/uclass_next_device_err is never used meaningfully, and uclass_first_device/uclass_next_device works equally well for this purpose. In the following patch the semantic of uclass_first_device_err/uclass_next_device_err will be changed to be based on uclass_first_device_check/uclass_next_device_check breaking this sole user that uses uclass_next_device_err for iteration. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-25blk: Rename if_type to uclass_idSimon Glass4-110/+109
Use the word 'uclass' instead of 'if_type' to complete the conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-18cyclic: Use schedule() instead of WATCHDOG_RESET()Stefan Roese1-4/+4
Globally replace all occurances of WATCHDOG_RESET() with schedule(), which handles the HW_WATCHDOG functionality and the cyclic infrastructure. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Tom Rini <trini@konsulko.com> [am335x_evm, mx6cuboxi, rpi_3,dra7xx_evm, pine64_plus, am65x_evm, j721e_evm]
2022-09-16blk: Drop if_typeWIP/2022-09-16-rationalize-the-block-interfaceSimon Glass2-27/+27
Use the uclass ID instead. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-09-16blk: Switch over to using uclass IDsSimon Glass4-40/+46
We currently have an if_type (interface type) and a uclass id. These are closely related and we don't need to have both. Drop the if_type values and use the uclass ones instead. Maintain the existing, subtle, one-way conversion between UCLASS_USB and UCLASS_MASS_STORAGE for now, and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Rewrite if_type to name functionsSimon Glass1-18/+27
These are currently using a simple array lookup in one direction, and relying on if_type being sequential. With the move to uclass IDs this needs to change. Update the code to prepare for the new way. This patch is intended to introduce no functional change. The returning of "(none)" from blk_get_if_type_name() is handling a case that should not happen in either case. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Rename var in blk_get_devnum_by_typename()Simon Glass1-6/+6
At present we use a variable with the same name as the enum. Change this since we plan to #define the enum to uclass_id. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_SDSimon Glass1-2/+0
This is not really needed since it does the same things as MMC. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_ATAPISimon Glass1-2/+0
This is not really needed since it does the same things as IDE. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16ide: Use a flag for an ATAPI deviceSimon Glass1-3/+3
Rather than setting a different interface type, use a flag to indicate that a device is ATAPI. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_DOCSimon Glass1-2/+0
This doesn't seem to be used for anything and it isn't clear what it is. It dates from the first U-Boot commit. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Hide the BLK and SPL_LEGACY_BLOCK optionsSimon Glass1-2/+2
We don't want boards to be able to change these. They can be handled as dependencies of options that need them, such as SPL_MMC. There is no point in enabling the block interface without any storage devices to create a block device. Hide both options from the 'menuconfig' display and deny their use in defconfig files. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Select SPL_LEGACY_BLOCK automaticallySimon Glass1-4/+7
Selecting this option can be handled in the Kconfig option itself, as it is with BLK. Update this an drop the various 'select' clauses. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Rename HAVE_BLOCK_DEVICESimon Glass2-5/+5
This option is fact really related to SPL. For U-Boot proper we always use driver model for block devices, so CONFIG_BLK is enabled if block devices are in use. It is only for SPL that we have two cases: - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c - SPL_BLK is not enabled, in which case (if we need block devices) we must use blk_legacy.c Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is different enough from BLK and SPL_BLK that there should be no confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop unnecessary #ifdef in in blk_legacySimon Glass1-2/+0
We can rely on the compiler to eliminate any dead code. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Use a function for whether block devices are availableSimon Glass1-2/+1
At present we use HAVE_BLOCK_DEVICE to indicate when block devices are available. This is a very strange option, since it partially duplicates the BLK option used by driver model. It also covers both U-Boot proper and SPL, even though one might have block devices and another not. As a first step towards correcting this, create a new inline function called blk_enabled() which indicates if block devices are available. This cannot be used in Makefiles, or #if clauses, but can be used in C code. A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to decide if block devices are needed, since we must consider the legacy block interface, enabled by HAVE_BLOCK_DEVICE Update a few places where it can be used and drop some unnecessary #if checks around some functions in disk/part.c - rely on the compiler's dead-code elimination instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Enable CONFIG_BLK for all mediaSimon Glass1-1/+2
Enable this option on all boards which support block devices. Drop the related depencies on BLK since these are not needed anymore. Disable BLOCK_CACHE on M5253DEMO as this causes a build error. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28block: ide: Remove ide_preinit functionTom Rini1-9/+0
The only platform currently that defines an ide_preinit function has an empty one that immediately returns. Remove this hook. Signed-off-by: Tom Rini <trini@konsulko.com>
2022-06-28Convert CONFIG_LBA48 et al to KconfigTom Rini1-0/+16
This converts the following to Kconfig: CONFIG_LBA48 CONFIG_SYS_64BIT_LBA Signed-off-by: Tom Rini <trini@konsulko.com>
2022-05-02vpl: Add Kconfig options for VPLSimon Glass1-0/+12
Add VPL versions of commonly used Kconfig options. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-25Merge branch '2022-04-25-initial-implementation-of-stdboot'Tom Rini1-0/+7
To quote the author: The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting. It introduces the following concepts: - bootdev - a device which can hold a distro - bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot) - bootflow - a description of how to boot (owned by the distro) This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot. With this we can boot on a Raspberry Pi 3 with just one command: bootflow scan -lb which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this. With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only. ... The design is described in these two documents: https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing
2022-04-25dm: blk: Add a function to return the device typeSimon Glass1-0/+7
Use the uclass name to get the device type for a block device. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-23dm: blk: add a device-probe hook for scanning disk partitionsAKASHI Takahiro1-0/+4
Now that all the block device drivers have enable a probe hook, we will call part_create_block_devices() to enumerate all the partitions and create associated udevices when a block device is detected. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-04-09block: ide: call device_probe() after scanningAKASHI Takahiro1-0/+4
Every time an ide bus/port is scanned and a new device is detected, we want to call device_probe() as it will give us a chance to run additional post-processings for some purposes. In particular, support for creating partitions on a device will be added. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-04-06dm: blk: Expand iteration and add testsWIP/2022-04-06-various-verified-boot-bugfixesSimon Glass1-0/+24
Add some functions which support iteration before probing. Also add tests for the functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-03-25disk: Add an option for partitions in SPLSimon Glass1-1/+1
In some cases we do not want to enable partition support in SPL. Add an option to allow this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-03-18sandbox: Open host file for read-only access if neededSimon Glass1-3/+8
Some files cannot be written but read-only access is still useful for tests. Add a fallback to read-only access when needed. This is useful in CI when opening a large data file provided by docker, where read/write access would result in copying the file, thus needing a lot of extra disk space. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09Convert CONFIG_SYS_IDE_MAXBUS et al to KconfigSimon Glass1-0/+104
This converts the following to Kconfig: CONFIG_SYS_IDE_MAXBUS CONFIG_SYS_IDE_MAXDEVICE CONFIG_SYS_ATA_BASE_ADDR CONFIG_SYS_ATA_STRIDE CONFIG_SYS_ATA_DATA_OFFSET CONFIG_SYS_ATA_REG_OFFSET CONFIG_SYS_ATA_ALT_OFFSET CONFIG_SYS_ATA_IDE0_OFFSET CONFIG_SYS_ATA_IDE1_OFFSET CONFIG_ATAPI CONFIG_IDE_RESET Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-09ide: Drop CONFIG_IDE_AHBSimon Glass1-22/+0
This is not used in U-Boot anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>