aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/Kconfig1
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c4
-rw-r--r--board/toradex/common/tdx-cfg-block.c4
-rw-r--r--cmd/Kconfig5
-rw-r--r--cmd/Makefile2
-rw-r--r--cmd/bcb.c4
-rw-r--r--cmd/blk_common.c2
-rw-r--r--cmd/ide.c2
-rw-r--r--cmd/mmc.c8
-rw-r--r--cmd/mvebu/bubt.c2
-rw-r--r--cmd/nvme.c4
-rw-r--r--cmd/pvblock.c2
-rw-r--r--cmd/sata.c4
-rw-r--r--cmd/scsi.c2
-rw-r--r--cmd/usb.c2
-rw-r--r--cmd/virtio.c2
-rw-r--r--common/spl/Kconfig2
-rw-r--r--common/spl/spl_sata.c2
-rw-r--r--common/spl/spl_usb.c2
-rw-r--r--common/usb_storage.c8
-rw-r--r--configs/M5253DEMO_defconfig1
-rw-r--r--configs/axm_defconfig1
-rw-r--r--configs/bcm968380gerg_ram_defconfig1
-rw-r--r--configs/gardena-smart-gateway-mt7688_defconfig1
-rw-r--r--configs/nsim_hs38_defconfig2
-rw-r--r--configs/qemu-ppce500_defconfig1
-rw-r--r--disk/Kconfig8
-rw-r--r--disk/Makefile4
-rw-r--r--disk/disk-uclass.c3
-rw-r--r--disk/part.c151
-rw-r--r--disk/part_amiga.c4
-rw-r--r--disk/part_dos.c4
-rw-r--r--disk/part_efi.c3
-rw-r--r--disk/part_iso.c3
-rw-r--r--disk/part_mac.c3
-rw-r--r--doc/develop/driver-model/migration.rst2
-rw-r--r--doc/develop/uefi/uefi.rst2
-rw-r--r--drivers/Makefile3
-rw-r--r--drivers/ata/Kconfig4
-rw-r--r--drivers/ata/dwc_ahsata.c2
-rw-r--r--drivers/ata/fsl_sata.c2
-rw-r--r--drivers/ata/sata.c2
-rw-r--r--drivers/ata/sata_mv.c2
-rw-r--r--drivers/ata/sata_sil.c2
-rw-r--r--drivers/block/Kconfig20
-rw-r--r--drivers/block/Makefile2
-rw-r--r--drivers/block/blk-uclass.c134
-rw-r--r--drivers/block/blk_legacy.c22
-rw-r--r--drivers/block/efi_blk.c2
-rw-r--r--drivers/block/ide.c14
-rw-r--r--drivers/block/sandbox.c12
-rw-r--r--drivers/dfu/dfu_mmc.c6
-rw-r--r--drivers/mmc/Kconfig1
-rw-r--r--drivers/mmc/mmc-uclass.c10
-rw-r--r--drivers/mmc/mmc_legacy.c6
-rw-r--r--drivers/mmc/mmc_write.c4
-rw-r--r--drivers/nvme/Kconfig2
-rw-r--r--drivers/nvme/nvme.c2
-rw-r--r--drivers/scsi/Kconfig2
-rw-r--r--drivers/scsi/scsi.c10
-rw-r--r--drivers/tee/optee/rpmb.c4
-rw-r--r--drivers/virtio/Kconfig1
-rw-r--r--drivers/virtio/virtio_blk.c4
-rw-r--r--drivers/xen/Kconfig1
-rw-r--r--drivers/xen/pvblock.c6
-rw-r--r--env/mmc.c4
-rw-r--r--fs/fat/fat.c2
-rw-r--r--include/blk.h63
-rw-r--r--include/efi_loader.h2
-rw-r--r--include/mmc.h2
-rw-r--r--lib/efi_driver/efi_block_device.c4
-rw-r--r--lib/efi_loader/Kconfig1
-rw-r--r--lib/efi_loader/efi_disk.c4
-rw-r--r--lib/efi_loader/efi_var_file.c2
-rw-r--r--test/dm/blk.c24
76 files changed, 291 insertions, 358 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index c4dc47dccb..994fd3b7f8 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -146,7 +146,6 @@ config SANDBOX
select DM_SPI
select DM_SPI_FLASH
select GZIP_COMPRESSED
- select HAVE_BLOCK_DEVICE
select LZO
select OF_BOARD_SETUP
select PCI_ENDPOINT
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3649222470..03169eba8d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1026,7 +1026,6 @@ config ARCH_NPCM
config ARCH_APPLE
bool "Apple SoCs"
select ARM64
- select BLK
select CLK
select CMD_USB
select DM
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index c391b6c7ab..a720d0ba71 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1823,7 +1823,7 @@ static int part_delete(struct stm32prog_data *data,
* need to switch to associated hwpart 1 or 2
*/
if (part->part_id < 0)
- if (blk_select_hwpart_devnum(IF_TYPE_MMC,
+ if (blk_select_hwpart_devnum(UCLASS_MMC,
part->dev->dev_id,
-part->part_id))
return -1;
@@ -1832,7 +1832,7 @@ static int part_delete(struct stm32prog_data *data,
/* return to user partition */
if (part->part_id < 0)
- blk_select_hwpart_devnum(IF_TYPE_MMC,
+ blk_select_hwpart_devnum(UCLASS_MMC,
part->dev->dev_id, 0);
if (blks != blks_size) {
ret = -1;
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 22c67c6e38..11f4d5e14a 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -211,7 +211,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
return -EINVAL;
}
if (part != mmc_get_blk_desc(mmc)->hwpart) {
- if (blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part)) {
+ if (blk_select_hwpart_devnum(UCLASS_MMC, dev, part)) {
puts("MMC partition switch failed\n");
ret = -ENODEV;
goto out;
@@ -239,7 +239,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
out:
/* Switch back to regular eMMC user partition */
- blk_select_hwpart_devnum(IF_TYPE_MMC, 0, 0);
+ blk_select_hwpart_devnum(UCLASS_MMC, 0, 0);
return ret;
}
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 08821b0bd4..6db76e9da8 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1092,7 +1092,6 @@ config CMD_PWM
config CMD_GPT
bool "GPT (GUID Partition Table) command"
select EFI_PARTITION
- select HAVE_BLOCK_DEVICE
select PARTITION_UUIDS
imply RANDOM_UUID
help
@@ -1211,7 +1210,6 @@ config CMD_LSBLK
config CMD_MBR
bool "MBR (Master Boot Record) command"
select DOS_PARTITION
- select HAVE_BLOCK_DEVICE
help
Enable the 'mbr' command to ready and write MBR (Master Boot Record)
style partition tables.
@@ -1343,7 +1341,6 @@ config CMD_OSD
config CMD_PART
bool "part"
depends on PARTITIONS
- select HAVE_BLOCK_DEVICE
select PARTITION_UUIDS
help
Read and display information about the partition table on
@@ -1474,7 +1471,6 @@ config CMD_UNIVERSE
config CMD_USB
bool "usb"
depends on USB_HOST
- select HAVE_BLOCK_DEVICE
help
USB support.
@@ -1514,7 +1510,6 @@ config CMD_PVBLOCK
config CMD_VIRTIO
bool "virtio"
depends on VIRTIO
- depends on HAVE_BLOCK_DEVICE
default y if VIRTIO
help
VirtIO block device support
diff --git a/cmd/Makefile b/cmd/Makefile
index 0ef4e2e466..cf6ce1bd6f 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -18,7 +18,7 @@ obj-$(CONFIG_CMD_AES) += aes.o
obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o
obj-$(CONFIG_CMD_ADC) += adc.o
obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o
+obj-$(CONFIG_BLK) += blk_common.o
obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o
obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o
obj-$(CONFIG_CMD_BOOTMETH) += bootmeth.o
diff --git a/cmd/bcb.c b/cmd/bcb.c
index 1bbd1fae99..8b87aa062f 100644
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -122,7 +122,7 @@ static int __bcb_load(int devnum, const char *partp)
char *endp;
int part, ret;
- desc = blk_get_devnum_by_type(IF_TYPE_MMC, devnum);
+ desc = blk_get_devnum_by_type(UCLASS_MMC, devnum);
if (!desc) {
ret = -ENODEV;
goto err_read_fail;
@@ -287,7 +287,7 @@ static int __bcb_store(void)
u64 cnt;
int ret;
- desc = blk_get_devnum_by_type(IF_TYPE_MMC, bcb_dev);
+ desc = blk_get_devnum_by_type(UCLASS_MMC, bcb_dev);
if (!desc) {
ret = -ENODEV;
goto err;
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 4e442f2918..369c5ae4bb 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -12,7 +12,7 @@
#include <blk.h>
#include <command.h>
-int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
int *cur_devnump)
{
const char *if_name = blk_get_if_type_name(if_type);
diff --git a/cmd/ide.c b/cmd/ide.c
index b78c38e159..6739f0b12d 100644
--- a/cmd/ide.c
+++ b/cmd/ide.c
@@ -37,7 +37,7 @@ int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
}
- return blk_common_cmd(argc, argv, IF_TYPE_IDE, &curr_device);
+ return blk_common_cmd(argc, argv, UCLASS_IDE, &curr_device);
}
int do_diskboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 7bd4cd9e01..0f1f4e0a71 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -331,13 +331,13 @@ static int do_mmcrpmb(struct cmd_tbl *cmdtp, int flag,
#else
original_part = mmc_get_blk_desc(mmc)->hwpart;
#endif
- if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, MMC_PART_RPMB) !=
+ if (blk_select_hwpart_devnum(UCLASS_MMC, curr_device, MMC_PART_RPMB) !=
0)
return CMD_RET_FAILURE;
ret = cp->cmd(cmdtp, flag, argc, argv);
/* Return to original partition */
- if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, original_part) !=
+ if (blk_select_hwpart_devnum(UCLASS_MMC, curr_device, original_part) !=
0)
return CMD_RET_FAILURE;
return ret;
@@ -530,7 +530,7 @@ static int do_mmc_part(struct cmd_tbl *cmdtp, int flag,
if (!mmc)
return CMD_RET_FAILURE;
- mmc_dev = blk_get_devnum_by_type(IF_TYPE_MMC, curr_device);
+ mmc_dev = blk_get_devnum_by_type(UCLASS_MMC, curr_device);
if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) {
part_print(mmc_dev);
return CMD_RET_SUCCESS;
@@ -580,7 +580,7 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag,
if (!mmc)
return CMD_RET_FAILURE;
- ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
+ ret = blk_select_hwpart_devnum(UCLASS_MMC, dev, part);
printf("switch to partitions #%d, %s\n",
part, (!ret) ? "OK" : "ERROR");
if (ret)
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index 2136af6416..825d4beb89 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -412,7 +412,7 @@ static size_t usb_read_file(const char *file_name)
}
/* Try to recognize storage devices immediately */
- blk_first_device(IF_TYPE_USB, &dev);
+ blk_first_device(UCLASS_USB, &dev);
if (!dev) {
printf("Error: USB storage device not found\n");
return 0;
diff --git a/cmd/nvme.c b/cmd/nvme.c
index e715c570a3..09d5f438fb 100644
--- a/cmd/nvme.c
+++ b/cmd/nvme.c
@@ -28,7 +28,7 @@ static int do_nvme(struct cmd_tbl *cmdtp, int flag, int argc,
if (strncmp(argv[1], "deta", 4) == 0) {
struct udevice *udev;
- ret = blk_get_device(IF_TYPE_NVME, nvme_curr_dev,
+ ret = blk_get_device(UCLASS_NVME, nvme_curr_dev,
&udev);
if (ret < 0)
return CMD_RET_FAILURE;
@@ -39,7 +39,7 @@ static int do_nvme(struct cmd_tbl *cmdtp, int flag, int argc,
}
}
- return blk_common_cmd(argc, argv, IF_TYPE_NVME, &nvme_curr_dev);
+ return blk_common_cmd(argc, argv, UCLASS_NVME, &nvme_curr_dev);
}
U_BOOT_CMD(
diff --git a/cmd/pvblock.c b/cmd/pvblock.c
index 56ce8b18d5..1b604c3737 100644
--- a/cmd/pvblock.c
+++ b/cmd/pvblock.c
@@ -14,7 +14,7 @@ static int pvblock_curr_device;
int do_pvblock(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
- return blk_common_cmd(argc, argv, IF_TYPE_PVBLOCK,
+ return blk_common_cmd(argc, argv, UCLASS_PVBLOCK,
&pvblock_curr_device);
}
diff --git a/cmd/sata.c b/cmd/sata.c
index 76da1906b7..9c9fe111d1 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -27,7 +27,7 @@ int sata_remove(int devnum)
struct udevice *dev;
int rc;
- blk_unbind_all(IF_TYPE_SATA);
+ blk_unbind_all(UCLASS_AHCI);
rc = uclass_find_device(UCLASS_AHCI, devnum, &dev);
if (!rc && !dev)
@@ -111,7 +111,7 @@ static int do_sata(struct cmd_tbl *cmdtp, int flag, int argc,
sata_curr_device = 0;
}
- return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device);
+ return blk_common_cmd(argc, argv, UCLASS_AHCI, &sata_curr_device);
}
U_BOOT_CMD(
diff --git a/cmd/scsi.c b/cmd/scsi.c
index 5f710d2895..4549995ba7 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -50,7 +50,7 @@ static int do_scsi(struct cmd_tbl *cmdtp, int flag, int argc,
}
}
- return blk_common_cmd(argc, argv, IF_TYPE_SCSI, &scsi_curr_dev);
+ return blk_common_cmd(argc, argv, UCLASS_SCSI, &scsi_curr_dev);
}
U_BOOT_CMD(
diff --git a/cmd/usb.c b/cmd/usb.c
index 3d87376525..2ba056982c 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -719,7 +719,7 @@ static int do_usb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if (strncmp(argv[1], "stor", 4) == 0)
return usb_stor_info();
- return blk_common_cmd(argc, argv, IF_TYPE_USB, &usb_stor_curr_dev);
+ return blk_common_cmd(argc, argv, UCLASS_USB, &usb_stor_curr_dev);
#else
return CMD_RET_USAGE;
#endif /* CONFIG_USB_STORAGE */
diff --git a/cmd/virtio.c b/cmd/virtio.c
index ea3ed2e631..ec87d4f02c 100644
--- a/cmd/virtio.c
+++ b/cmd/virtio.c
@@ -40,7 +40,7 @@ static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}
- return blk_common_cmd(argc, argv, IF_TYPE_VIRTIO, &virtio_curr_dev);
+ return blk_common_cmd(argc, argv, UCLASS_VIRTIO, &virtio_curr_dev);
}
U_BOOT_CMD(
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 70d97815f0..e1b2a421cd 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,7 +792,6 @@ config SPL_DM_MAILBOX
config SPL_MMC
bool "Support MMC"
depends on MMC
- select HAVE_BLOCK_DEVICE
help
Enable support for MMC (Multimedia Card) within SPL. This enables
the MMC protocol implementation and allows any enabled drivers to
@@ -1318,7 +1317,6 @@ config SPL_THERMAL
config SPL_USB_HOST
bool "Support USB host drivers"
- select HAVE_BLOCK_DEVICE
help
Enable access to USB (Universal Serial Bus) host devices so that
SPL can load U-Boot from a connected USB peripheral, such as a USB
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 1351d78612..ea9f1756c0 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -71,7 +71,7 @@ static int spl_sata_load_image(struct spl_image_info *spl_image,
/* try to recognize storage devices immediately */
scsi_scan(false);
- stor_dev = blk_get_devnum_by_type(IF_TYPE_SCSI, 0);
+ stor_dev = blk_get_devnum_by_type(UCLASS_SCSI, 0);
if (!stor_dev)
return -ENODEV;
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c
index ccf01c8276..63c00f872b 100644
--- a/common/spl/spl_usb.c
+++ b/common/spl/spl_usb.c
@@ -41,7 +41,7 @@ int spl_usb_load(struct spl_image_info *spl_image,
/* try to recognize storage devices immediately */
usb_stor_curr_dev = usb_stor_scan(1);
- stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, usb_stor_curr_dev);
+ stor_dev = blk_get_devnum_by_type(UCLASS_USB, usb_stor_curr_dev);
if (!stor_dev)
return -ENODEV;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index eaa31374ef..7d420160cd 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -144,7 +144,7 @@ int usb_stor_info(void)
#if CONFIG_IS_ENABLED(BLK)
struct udevice *dev;
- for (blk_first_device(IF_TYPE_USB, &dev);
+ for (blk_first_device(UCLASS_USB, &dev);
dev;
blk_next_device(&dev)) {
struct blk_desc *desc = dev_get_uclass_plat(dev);
@@ -219,7 +219,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
snprintf(str, sizeof(str), "lun%d", lun);
ret = blk_create_devicef(udev->dev, "usb_storage_blk", str,
- IF_TYPE_USB, usb_max_devs, 512, 0,
+ UCLASS_USB, usb_max_devs, 512, 0,
&dev);
if (ret) {
debug("Cannot bind driver\n");
@@ -279,7 +279,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
blkdev = &usb_dev_desc[usb_max_devs];
memset(blkdev, '\0', sizeof(struct blk_desc));
- blkdev->if_type = IF_TYPE_USB;
+ blkdev->if_type = UCLASS_USB;
blkdev->devnum = usb_max_devs;
blkdev->part_type = PART_TYPE_UNKNOWN;
blkdev->target = 0xff;
@@ -1578,7 +1578,7 @@ U_BOOT_DRIVER(usb_storage_blk) = {
#else
U_BOOT_LEGACY_BLK(usb) = {
.if_typename = "usb",
- .if_type = IF_TYPE_USB,
+ .if_type = UCLASS_USB,
.max_devs = USB_MAX_STOR_DEV,
.desc = usb_dev_desc,
};
diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
index 79382eb0fe..a73aca082c 100644
--- a/configs/M5253DEMO_defconfig
+++ b/configs/M5253DEMO_defconfig
@@ -25,6 +25,7 @@ CONFIG_CMD_EXT2=y
CONFIG_CMD_FAT=y
CONFIG_MAC_PARTITION=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_BLOCK_CACHE is not set
CONFIG_SYS_IDE_MAXBUS=1
CONFIG_SYS_ATA_STRIDE=4
CONFIG_SYS_ATA_DATA_OFFSET=0xA0
diff --git a/configs/axm_defconfig b/configs/axm_defconfig
index dc262c95a3..b1e0090f35 100644
--- a/configs/axm_defconfig
+++ b/configs/axm_defconfig
@@ -80,7 +80,6 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_SPL_DM=y
CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
CONFIG_CLK=y
CONFIG_CLK_AT91=y
CONFIG_AT91_GPIO=y
diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
index a0924689e4..284fa2fdef 100644
--- a/configs/bcm968380gerg_ram_defconfig
+++ b/configs/bcm968380gerg_ram_defconfig
@@ -42,7 +42,6 @@ CONFIG_CMD_NAND=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
# CONFIG_NET is not set
# CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
CONFIG_BCM6345_GPIO=y
CONFIG_LED=y
CONFIG_LED_BCM6328=y
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
index b9ee281be9..992e850999 100644
--- a/configs/gardena-smart-gateway-mt7688_defconfig
+++ b/configs/gardena-smart-gateway-mt7688_defconfig
@@ -78,7 +78,6 @@ CONFIG_VERSION_VARIABLE=y
CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_SPL_DM=y
# CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_LED=y
CONFIG_LED_BLINK=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 8e5e8ea305..740de7a409 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_USE_BOOTFILE=y
CONFIG_BOOTFILE="uImage"
CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_DM_ETH=y
CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_SYS_NS16550=y
diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
index 172ac18351..79cfa829e6 100644
--- a/configs/qemu-ppce500_defconfig
+++ b/configs/qemu-ppce500_defconfig
@@ -40,7 +40,6 @@ CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_DM=y
CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
CONFIG_LBA48=y
CONFIG_CHIP_SELECTS_PER_CTRL=0
CONFIG_MPC8XXX_GPIO=y
diff --git a/disk/Kconfig b/disk/Kconfig
index 81d8867ed7..c9b9dbaf1a 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -24,7 +24,7 @@ config SPL_PARTITIONS
select SPL_STRTO
help
Enable this for base partition support in SPL. The required
- partition table types shold be enabled separately. This add a
+ partition table types shold be enabled separately. This adds a
small amount of size to SPL, typically 500 bytes.
config TPL_PARTITIONS
@@ -32,9 +32,9 @@ config TPL_PARTITIONS
select TPL_SPRINTF
select TPL_STRTO
help
- Enable this for base partition support in SPL. The required
- partition table types shold be enabled separately. This add a
- small amount of size to SPL, typically 500 bytes.
+ Enable this for base partition support in TPL. The required
+ partition table types shold be enabled separately. This adds a
+ small amount of size to TPL, typically 500 bytes.
config MAC_PARTITION
bool "Enable Apple's MacOS partition table"
diff --git a/disk/Makefile b/disk/Makefile
index ec148832b3..45588cf66e 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -9,8 +9,12 @@ obj-$(CONFIG_$(SPL_TPL_)PARTITIONS) += part.o
ifdef CONFIG_$(SPL_TPL_)BLK
obj-$(CONFIG_$(SPL_TPL_)PARTITIONS) += disk-uclass.o
endif
+
+# Must have BLK or SPL_LEGACY_BLOCK to support partitions
+ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_SPL_LEGACY_BLOCK),)
obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION) += part_mac.o
obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION) += part_dos.o
obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION) += part_iso.o
obj-$(CONFIG_$(SPL_TPL_)AMIGA_PARTITION) += part_amiga.o
obj-$(CONFIG_$(SPL_TPL_)EFI_PARTITION) += part_efi.o
+endif
diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
index f3fb942a6b..9351a5cfa6 100644
--- a/disk/disk-uclass.c
+++ b/disk/disk-uclass.c
@@ -27,8 +27,7 @@ int part_create_block_devices(struct udevice *blk_dev)
struct udevice *dev;
int ret;
- if (!CONFIG_IS_ENABLED(PARTITIONS) ||
- !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
+ if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
return 0;
if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
diff --git a/disk/part.c b/disk/part.c
index 79955c7fb0..5705c229d5 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -54,12 +54,13 @@ static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
return NULL;
}
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
{
struct blk_desc *dev_desc;
int ret;
+ if (!blk_enabled())
+ return NULL;
dev_desc = blk_get_devnum_by_typename(ifname, dev);
if (!dev_desc) {
debug("%s: No device for iface '%s', dev %d\n", __func__,
@@ -78,21 +79,11 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
struct blk_desc *blk_get_dev(const char *ifname, int dev)
{
- return get_dev_hwpart(ifname, dev, 0);
-}
-#else
-struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
-{
- return NULL;
-}
+ if (!blk_enabled())
+ return NULL;
-struct blk_desc *blk_get_dev(const char *ifname, int dev)
-{
- return NULL;
+ return get_dev_hwpart(ifname, dev, 0);
}
-#endif
-
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
/* ------------------------------------------------------------------------- */
/*
@@ -120,7 +111,7 @@ static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by,
return bc_quot * mul_by + ((bc_rem * mul_by) >> right_shift);
}
-void dev_print (struct blk_desc *dev_desc)
+void dev_print(struct blk_desc *dev_desc)
{
lba512_t lba512; /* number of blocks if 512bytes block size */
@@ -130,39 +121,37 @@ void dev_print (struct blk_desc *dev_desc)
}
switch (dev_desc->if_type) {
- case IF_TYPE_SCSI:
+ case UCLASS_SCSI:
printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
dev_desc->target,dev_desc->lun,
dev_desc->vendor,
dev_desc->product,
dev_desc->revision);
break;
- case IF_TYPE_ATAPI:
- case IF_TYPE_IDE:
- case IF_TYPE_SATA:
+ case UCLASS_IDE:
+ case UCLASS_AHCI:
printf ("Model: %s Firm: %s Ser#: %s\n",
dev_desc->vendor,
dev_desc->revision,
dev_desc->product);
break;
- case IF_TYPE_SD:
- case IF_TYPE_MMC:
- case IF_TYPE_USB:
- case IF_TYPE_NVME:
- case IF_TYPE_PVBLOCK:
- case IF_TYPE_HOST:
+ case UCLASS_MMC:
+ case UCLASS_USB:
+ case UCLASS_NVME:
+ case UCLASS_PVBLOCK:
+ case UCLASS_ROOT:
printf ("Vendor: %s Rev: %s Prod: %s\n",
dev_desc->vendor,
dev_desc->revision,
dev_desc->product);
break;
- case IF_TYPE_VIRTIO:
+ case UCLASS_VIRTIO:
printf("%s VirtIO Block Device\n", dev_desc->vendor);
break;
- case IF_TYPE_DOC:
- puts("device type DOC\n");
- return;
- case IF_TYPE_UNKNOWN:
+ case UCLASS_EFI_MEDIA:
+ printf("EFI media Block Device %d\n", dev_desc->devnum);
+ break;
+ case UCLASS_INVALID:
puts("device type unknown\n");
return;
default:
@@ -228,9 +217,6 @@ void dev_print (struct blk_desc *dev_desc)
puts (" Capacity: not available\n");
}
}
-#endif
-
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
void part_init(struct blk_desc *dev_desc)
{
@@ -263,40 +249,34 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
CONFIG_IS_ENABLED(EFI_PARTITION)
puts ("\nPartition Map for ");
switch (dev_desc->if_type) {
- case IF_TYPE_IDE:
+ case UCLASS_IDE:
puts ("IDE");
break;
- case IF_TYPE_SATA:
+ case UCLASS_AHCI:
puts ("SATA");
break;
- case IF_TYPE_SCSI:
+ case UCLASS_SCSI:
puts ("SCSI");
break;
- case IF_TYPE_ATAPI:
- puts ("ATAPI");
- break;
- case IF_TYPE_USB:
+ case UCLASS_USB:
puts ("USB");
break;
- case IF_TYPE_DOC:
- puts ("DOC");
- break;
- case IF_TYPE_MMC:
+ case UCLASS_MMC:
puts ("MMC");
break;
- case IF_TYPE_HOST:
+ case UCLASS_ROOT:
puts ("HOST");
break;
- case IF_TYPE_NVME:
+ case UCLASS_NVME:
puts ("NVMe");
break;
- case IF_TYPE_PVBLOCK:
+ case UCLASS_PVBLOCK:
puts("PV BLOCK");
break;
- case IF_TYPE_VIRTIO:
+ case UCLASS_VIRTIO:
puts("VirtIO");
break;
- case IF_TYPE_EFI_MEDIA:
+ case UCLASS_EFI_MEDIA:
puts("EFI");
break;
default:
@@ -325,38 +305,36 @@ void part_print(struct blk_desc *dev_desc)
drv->print(dev_desc);
}
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
-
int part_get_info(struct blk_desc *dev_desc, int part,
struct disk_partition *info)
{
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
struct part_driver *drv;
+ if (blk_enabled()) {
#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- /* The common case is no UUID support */
- info->uuid[0] = 0;
+ /* The common case is no UUID support */
+ info->uuid[0] = 0;
#endif
#ifdef CONFIG_PARTITION_TYPE_GUID
- info->type_guid[0] = 0;
+ info->type_guid[0] = 0;
#endif
- drv = part_driver_lookup_type(dev_desc);
- if (!drv) {
- debug("## Unknown partition table type %x\n",
- dev_desc->part_type);
- return -EPROTONOSUPPORT;
- }
- if (!drv->get_info) {
- PRINTF("## Driver %s does not have the get_info() method\n",
- drv->name);
- return -ENOSYS;
- }
- if (drv->get_info(dev_desc, part, info) == 0) {
- PRINTF("## Valid %s partition found ##\n", drv->name);
- return 0;
+ drv = part_driver_lookup_type(dev_desc);
+ if (!drv) {
+ debug("## Unknown partition table type %x\n",
+ dev_desc->part_type);
+ return -EPROTONOSUPPORT;
+ }
+ if (!drv->get_info) {
+ PRINTF("## Driver %s does not have the get_info() method\n",
+ drv->name);
+ return -ENOSYS;
+ }
+ if (drv->get_info(dev_desc, part, info) == 0) {
+ PRINTF("## Valid %s partition found ##\n", drv->name);
+ return 0;
+ }
}
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
return -ENOENT;
}
@@ -424,15 +402,15 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
goto cleanup;
}
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
- /*
- * Updates the partition table for the specified hw partition.
- * Always should be done, otherwise hw partition 0 will return stale
- * data after displaying a non-zero hw partition.
- */
- if ((*dev_desc)->if_type == IF_TYPE_MMC)
- part_init(*dev_desc);
-#endif
+ if (blk_enabled()) {
+ /*
+ * Updates the partition table for the specified hw partition.
+ * Always should be done, otherwise hw partition 0 will return
+ * stale data after displaying a non-zero hw partition.
+ */
+ if ((*dev_desc)->if_type == UCLASS_MMC)
+ part_init(*dev_desc);
+ }
cleanup:
free(dup_str);
@@ -785,22 +763,17 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
char *devtype;
switch (dev_desc->if_type) {
- case IF_TYPE_IDE:
- case IF_TYPE_SATA:
- case IF_TYPE_ATAPI:
+ case UCLASS_IDE:
+ case UCLASS_AHCI:
devtype = "hd";
break;
- case IF_TYPE_SCSI:
+ case UCLASS_SCSI:
devtype = "sd";
break;
- case IF_TYPE_USB:
+ case UCLASS_USB:
devtype = "usbd";
break;
- case IF_TYPE_DOC:
- devtype = "docd";
- break;
- case IF_TYPE_MMC:
- case IF_TYPE_SD:
+ case UCLASS_MMC:
devtype = "mmcsd";
break;
default:
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index ac7ada5478..45d3a70486 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -11,8 +11,6 @@
#include "part_amiga.h"
#include <part.h>
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
#undef AMIGA_DEBUG
#ifdef AMIGA_DEBUG
@@ -387,5 +385,3 @@ U_BOOT_PART_TYPE(amiga) = {
.print = part_print_amiga,
.test = part_test_amiga,
};
-
-#endif
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 94fae7166d..a94702c5f3 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -23,8 +23,6 @@
#include "part_dos.h"
#include <part.h>
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
#define DOS_PART_DEFAULT_SECTOR 512
/* should this be configurable? It looks like it's not very common at all
@@ -518,5 +516,3 @@ U_BOOT_PART_TYPE(dos) = {
.print = part_print_ptr(part_print_dos),
.test = part_test_dos,
};
-
-#endif
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 5090efd119..ad94504ed9 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -28,8 +28,6 @@
#include <linux/ctype.h>
#include <u-boot/crc.h>
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
/* GUID for basic data partitons */
#if CONFIG_IS_ENABLED(EFI_PARTITION)
static const efi_guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID;
@@ -1204,4 +1202,3 @@ U_BOOT_PART_TYPE(a_efi) = {
.print = part_print_ptr(part_print_efi),
.test = part_test_efi,
};
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 1061f341d3..4cd619bf46 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -12,8 +12,6 @@
#include <asm/unaligned.h>
#include "part_iso.h"
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
/* #define ISO_PART_DEBUG */
#ifdef ISO_PART_DEBUG
@@ -241,4 +239,3 @@ U_BOOT_PART_TYPE(iso) = {
.print = part_print_iso,
.test = part_test_iso,
};
-#endif
diff --git a/disk/part_mac.c b/disk/part_mac.c
index e01ae74566..ae8263f755 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -20,8 +20,6 @@
#include "part_mac.h"
#include <part.h>
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
/* stdlib.h causes some compatibility problems; should fixe these! -- wd */
#ifndef __ldiv_t_defined
typedef struct {
@@ -247,4 +245,3 @@ U_BOOT_PART_TYPE(mac) = {
.print = part_print_mac,
.test = part_test_mac,
};
-#endif
diff --git a/doc/develop/driver-model/migration.rst b/doc/develop/driver-model/migration.rst
index 5a60436925..742fea5515 100644
--- a/doc/develop/driver-model/migration.rst
+++ b/doc/develop/driver-model/migration.rst
@@ -57,7 +57,7 @@ In concert with maintainers migrating their block device usage to the
appropriate DM driver, CONFIG_BLK needs to be set as well. The final deadline
here coincides with the final deadline for migration of the various block
subsystems. At this point we will be able to audit and correct the logic in
-Kconfig around using CONFIG_PARTITIONS and CONFIG_HAVE_BLOCK_DEVICE and make
+Kconfig around using CONFIG_PARTITIONS and CONFIG_SPL_LEGACY_BLOCK and make
use of CONFIG_BLK / CONFIG_SPL_BLK as needed.
CONFIG_DM_SPI / CONFIG_DM_SPI_FLASH
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
index 941e427093..cd84706953 100644
--- a/doc/develop/uefi/uefi.rst
+++ b/doc/develop/uefi/uefi.rst
@@ -748,7 +748,7 @@ UEFI block IO driver
The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL.
When connected it creates a new U-Boot block IO device with interface type
-IF_TYPE_EFI_LOADER, adds child controllers mapping the partitions, and installs
+UCLASS_EFI_LOADER, adds child controllers mapping the partitions, and installs
the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the
software iPXE to boot from iSCSI network drives [4].
diff --git a/drivers/Makefile b/drivers/Makefile
index eba9940231..9d9f69a3c9 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -59,7 +59,8 @@ obj-$(CONFIG_SPL_WATCHDOG) += watchdog/
obj-$(CONFIG_SPL_USB_HOST) += usb/host/
obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
obj-$(CONFIG_SPL_SATA) += ata/ scsi/
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
+obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
+obj-$(CONFIG_SPL_BLK) += block/
obj-$(CONFIG_SPL_THERMAL) += thermal/
endif
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 7715c40365..a063b221cd 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -9,8 +9,6 @@ config AHCI
config SATA
bool "Support SATA controllers"
- depends on BLK
- select HAVE_BLOCK_DEVICE
help
This enables support for SATA (Serial Advanced Technology
Attachment), a serial bus standard for connecting to hard drives and
@@ -48,7 +46,7 @@ config SPL_AHCI_PCI
bool "Support for PCI-based AHCI controller for SPL"
depends on SPL
depends on SPL_PCI
- depends on SPL_SATA_SUPPORT && DM_SCSI
+ depends on SPL_SATA && DM_SCSI
config DWC_AHCI
bool "Enable Synopsys DWC AHCI driver support"
diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 1a2c3c2fe7..167b5a395f 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -880,7 +880,7 @@ int dwc_ahsata_scan(struct udevice *dev)
device_find_first_child(dev, &blk);
if (!blk) {
ret = blk_create_devicef(dev, "dwc_ahsata_blk", "blk",
- IF_TYPE_SATA, -1, 512, 0, &blk);
+ UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) {
debug("Can't create device\n");
return ret;
diff --git a/drivers/ata/fsl_sata.c b/drivers/ata/fsl_sata.c
index 6db4247368..972101b29c 100644
--- a/drivers/ata/fsl_sata.c
+++ b/drivers/ata/fsl_sata.c
@@ -888,7 +888,7 @@ static int fsl_ata_probe(struct udevice *dev)
for (i = 0; i < nr_ports; i++) {
snprintf(sata_name, sizeof(sata_name), "fsl_sata%d", i);
ret = blk_create_devicef(dev, "sata_fsl_blk", sata_name,
- IF_TYPE_SATA, -1, 512, 0, &blk);
+ UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) {
debug("Can't create device\n");
return ret;
diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
index 0e6c8cdd42..604c721cfd 100644
--- a/drivers/ata/sata.c
+++ b/drivers/ata/sata.c
@@ -79,7 +79,7 @@ int __sata_initialize(void)
for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc));
- sata_dev_desc[i].if_type = IF_TYPE_SATA;
+ sata_dev_desc[i].if_type = UCLASS_AHCI;
sata_dev_desc[i].devnum = i;
sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
sata_dev_desc[i].type = DEV_TYPE_HARDDISK;
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index a187796dfc..18c7a66db1 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -1076,7 +1076,7 @@ static int sata_mv_probe(struct udevice *dev)
for (i = 0; i < nr_ports; i++) {
ret = blk_create_devicef(dev, "sata_mv_blk", "blk",
- IF_TYPE_SATA, -1, 512, 0, &blk);
+ UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) {
debug("Can't create device\n");
continue;
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 7065154572..b5e150d568 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -730,7 +730,7 @@ static int sil_pci_probe(struct udevice *dev)
for (i = sata_info.portbase; i < sata_info.maxport; i++) {
snprintf(sata_name, sizeof(sata_name), "sil_sata%d", i);
ret = blk_create_devicef(dev, "sata_sil_blk", sata_name,
- IF_TYPE_SATA, -1, 512, 0, &blk);
+ UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) {
debug("Can't create device\n");
return ret;
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index b5b482086a..707e2bcd23 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,7 +1,8 @@
config BLK
- bool "Support block devices"
+ bool # "Support block devices"
depends on DM
- default y if DM_MMC || DM_USB
+ default y if MMC || USB || SCSI || NVME || IDE || AHCI || SATA
+ default y if EFI_MEDIA || VIRTIO_BLK || PVBLOCK
help
Enable support for block devices, such as SCSI, MMC and USB
flash sticks. These provide a block-level interface which permits
@@ -10,10 +11,16 @@ config BLK
be partitioned into several areas, called 'partitions' in U-Boot.
A filesystem can be placed in each partition.
-config HAVE_BLOCK_DEVICE
- bool "Enable Legacy Block Device"
+config SPL_LEGACY_BLOCK
+ bool # "Enable Legacy Block Device"
+ depends on SPL && !DM_SPL
+ default y if SPL_MMC || SPL_USB_STORAGE || SCSI || NVME || IDE
+ default y if SPL_AHCI_PCI
help
- Some devices require block support whether or not DM is enabled
+ Some devices require block support whether or not DM is enabled. This
+ is only supported in SPL. With this, the blk uclass is not used, but
+ instead a legacy implementation of block devices is used, with all
+ devices consisting of 'struct blk_desc' records.
config SPL_BLK
bool "Support block devices in SPL"
@@ -108,7 +115,6 @@ endif # EFI_MEDIA
config IDE
bool "Support IDE controllers"
- select HAVE_BLOCK_DEVICE
help
Enables support for IDE (Integrated Drive Electronics) hard drives.
This allows access to raw blocks and filesystems on an IDE drive
@@ -221,7 +227,6 @@ endif # IDE
config LBA48
bool "Enable LBA support for disks larger than 137GB"
- depends on HAVE_BLOCK_DEVICE
help
Set this to enable support for disks larger than 137GB.
Also look at CONFIG_SYS_64BIT_LBA. Without both of these, LBA48
@@ -230,7 +235,6 @@ config LBA48
config SYS_64BIT_LBA
bool "Enable 64bit number of blocks on a block device"
- depends on HAVE_BLOCK_DEVICE
help
Make the block subsystem use 64bit sector addresses, rather than the
default of 32bit.
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index b221a7c6ee..f48d3e1214 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -6,7 +6,7 @@
obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
ifndef CONFIG_$(SPL_)BLK
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_legacy.o
+obj-$(CONFIG_SPL_LEGACY_BLOCK) += blk_legacy.o
endif
ifndef CONFIG_SPL_BUILD
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 21c5209bb6..a9a85aa37f 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -17,64 +17,73 @@
#include <dm/uclass-internal.h>
#include <linux/err.h>
-static const char *if_typename_str[IF_TYPE_COUNT] = {
- [IF_TYPE_IDE] = "ide",
- [IF_TYPE_SCSI] = "scsi",
- [IF_TYPE_ATAPI] = "atapi",
- [IF_TYPE_USB] = "usb",
- [IF_TYPE_DOC] = "doc",
- [IF_TYPE_MMC] = "mmc",
- [IF_TYPE_SD] = "sd",
- [IF_TYPE_SATA] = "sata",
- [IF_TYPE_HOST] = "host",
- [IF_TYPE_NVME] = "nvme",
- [IF_TYPE_EFI_MEDIA] = "efi",
- [IF_TYPE_EFI_LOADER] = "efiloader",
- [IF_TYPE_VIRTIO] = "virtio",
- [IF_TYPE_PVBLOCK] = "pvblock",
-};
-
-static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
- [IF_TYPE_IDE] = UCLASS_IDE,
- [IF_TYPE_SCSI] = UCLASS_SCSI,
- [IF_TYPE_ATAPI] = UCLASS_INVALID,
- [IF_TYPE_USB] = UCLASS_MASS_STORAGE,
- [IF_TYPE_DOC] = UCLASS_INVALID,
- [IF_TYPE_MMC] = UCLASS_MMC,
- [IF_TYPE_SD] = UCLASS_INVALID,
- [IF_TYPE_SATA] = UCLASS_AHCI,
- [IF_TYPE_HOST] = UCLASS_ROOT,
- [IF_TYPE_NVME] = UCLASS_NVME,
- [IF_TYPE_EFI_MEDIA] = UCLASS_EFI_MEDIA,
- [IF_TYPE_EFI_LOADER] = UCLASS_EFI_LOADER,
- [IF_TYPE_VIRTIO] = UCLASS_VIRTIO,
- [IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK,
+static struct {
+ enum uclass_id id;
+ const char *name;
+} if_typename_str[] = {
+ { UCLASS_IDE, "ide" },
+ { UCLASS_SCSI, "scsi" },
+ { UCLASS_USB, "usb" },
+ { UCLASS_MMC, "mmc" },
+ { UCLASS_AHCI, "sata" },
+ { UCLASS_ROOT, "host" },
+ { UCLASS_NVME, "nvme" },
+ { UCLASS_EFI_MEDIA, "efi" },
+ { UCLASS_EFI_LOADER, "efiloader" },
+ { UCLASS_VIRTIO, "virtio" },
+ { UCLASS_PVBLOCK, "pvblock" },
};
-static enum if_type if_typename_to_iftype(const char *if_typename)
+static enum uclass_id if_typename_to_iftype(const char *if_typename)
{
int i;
- for (i = 0; i < IF_TYPE_COUNT; i++) {
- if (if_typename_str[i] &&
- !strcmp(if_typename, if_typename_str[i]))
- return i;
+ for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
+ if (!strcmp(if_typename, if_typename_str[i].name))
+ return if_typename_str[i].id;
}
- return IF_TYPE_UNKNOWN;
+ return UCLASS_INVALID;
}
-static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
+static enum uclass_id if_type_to_uclass_id(enum uclass_id if_type)
{
- return if_type_uclass_id[if_type];
+ /*
+ * This strange adjustment is used because we use UCLASS_MASS_STORAGE
+ * for USB storage devices, so need to return this as the uclass to
+ * use for USB. In fact USB_UCLASS is for USB controllers, not
+ * peripherals.
+ *
+ * The name of the UCLASS_MASS_STORAGE uclass driver is
+ * "usb_mass_storage", but we want to use "usb" in things like the
+ * 'part list' command and when showing interfaces.
+ *
+ * So for now we have this one-way conversion.
+ *
+ * The fix for this is possibly to:
+ * - rename UCLASS_MASS_STORAGE name to "usb"
+ * - rename UCLASS_USB name to "usb_ctlr"
+ * - use UCLASS_MASS_STORAGE instead of UCLASS_USB in if_typename_str
+ */
+ if (if_type == UCLASS_USB)
+ return UCLASS_MASS_STORAGE;
+
+ return if_type;
}
-const char *blk_get_if_type_name(enum if_type if_type)
+const char *blk_get_if_type_name(enum uclass_id if_type)
{
- return if_typename_str[if_type];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
+ if (if_typename_str[i].id == if_type)
+ return if_typename_str[i].name;
+ }
+
+ return "(none)";
}
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
{
struct blk_desc *desc;
struct udevice *dev;
@@ -96,21 +105,21 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
{
enum uclass_id uclass_id;
- enum if_type if_type;
+ enum uclass_id type;
struct udevice *dev;
struct uclass *uc;
int ret;
- if_type = if_typename_to_iftype(if_typename);
- if (if_type == IF_TYPE_UNKNOWN) {
+ type = if_typename_to_iftype(if_typename);
+ if (type == UCLASS_INVALID) {
debug("%s: Unknown interface type '%s'\n", __func__,
if_typename);
return NULL;
}
- uclass_id = if_type_to_uclass_id(if_type);
+ uclass_id = if_type_to_uclass_id(type);
if (uclass_id == UCLASS_INVALID) {
debug("%s: Unknown uclass for interface type'\n",
- if_typename_str[if_type]);
+ blk_get_if_type_name(type));
return NULL;
}
@@ -121,7 +130,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
struct blk_desc *desc = dev_get_uclass_plat(dev);
debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
- if_type, devnum, dev->name, desc->if_type, desc->devnum);
+ type, devnum, dev->name, desc->if_type, desc->devnum);
if (desc->devnum != devnum)
continue;
@@ -176,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
* with a higher device number, -ENOENT if there is no such device but there
* is one with a higher number, or other -ve on other error.
*/
-static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
+static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
{
bool found_more = false;
struct udevice *dev;
@@ -209,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
return found_more ? -ENOENT : -ENODEV;
}
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
{
struct udevice *dev;
int ret;
@@ -221,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
return blk_select_hwpart(dev, hwpart);
}
-int blk_list_part(enum if_type if_type)
+int blk_list_part(enum uclass_id if_type)
{
struct blk_desc *desc;
int devnum, ok;
@@ -246,7 +255,7 @@ int blk_list_part(enum if_type if_type)
return 0;
}
-int blk_print_part_devnum(enum if_type if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id if_type, int devnum)
{
struct blk_desc *desc;
int ret;
@@ -261,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
return 0;
}
-void blk_list_devices(enum if_type if_type)
+void blk_list_devices(enum uclass_id if_type)
{
struct blk_desc *desc;
int ret;
@@ -280,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
}
}
-int blk_print_device_num(enum if_type if_type, int devnum)
+int blk_print_device_num(enum uclass_id if_type, int devnum)
{
struct blk_desc *desc;
int ret;
@@ -294,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
return 0;
}
-int blk_show_device(enum if_type if_type, int devnum)
+int blk_show_device(enum uclass_id if_type, int devnum)
{
struct blk_desc *desc;
int ret;
@@ -315,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
return 0;
}
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
lbaint_t blkcnt, void *buffer)
{
struct blk_desc *desc;
@@ -332,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
return n;
}
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
{
struct blk_desc *desc;
@@ -516,7 +525,7 @@ const char *blk_get_devtype(struct udevice *dev)
return uclass_get_name(device_get_uclass_id(parent));
};
-int blk_find_max_devnum(enum if_type if_type)
+int blk_find_max_devnum(enum uclass_id if_type)
{
struct udevice *dev;
int max_devnum = -ENODEV;
@@ -536,7 +545,7 @@ int blk_find_max_devnum(enum if_type if_type)
return max_devnum;
}
-int blk_next_free_devnum(enum if_type if_type)
+int blk_next_free_devnum(enum uclass_id if_type)
{
int ret;
@@ -622,7 +631,7 @@ int blk_count_devices(enum blk_flag_t flag)
return count;
}
-static int blk_claim_devnum(enum if_type if_type, int devnum)
+static int blk_claim_devnum(enum uclass_id if_type, int devnum)
{
struct udevice *dev;
struct uclass *uc;
@@ -743,8 +752,7 @@ int blk_unbind_all(int if_type)
static int blk_post_probe(struct udevice *dev)
{
- if (CONFIG_IS_ENABLED(PARTITIONS) &&
- IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) {
+ if (CONFIG_IS_ENABLED(PARTITIONS) && blk_enabled()) {
struct blk_desc *desc = dev_get_uclass_plat(dev);
part_init(desc);
diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
index df9a359754..8c6f9cb208 100644
--- a/drivers/block/blk_legacy.c
+++ b/drivers/block/blk_legacy.c
@@ -39,7 +39,7 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
return NULL;
}
-const char *blk_get_if_type_name(enum if_type if_type)
+const char *blk_get_if_type_name(enum uclass_id if_type)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
@@ -70,8 +70,7 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
return drv->get_dev(devnum, descp);
}
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-int blk_list_part(enum if_type if_type)
+int blk_list_part(enum uclass_id if_type)
{
struct blk_driver *drv;
struct blk_desc *desc;
@@ -98,7 +97,7 @@ int blk_list_part(enum if_type if_type)
return 0;
}
-int blk_print_part_devnum(enum if_type if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id if_type, int devnum)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
struct blk_desc *desc;
@@ -116,7 +115,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
return 0;
}
-void blk_list_devices(enum if_type if_type)
+void blk_list_devices(enum uclass_id if_type)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
struct blk_desc *desc;
@@ -134,7 +133,7 @@ void blk_list_devices(enum if_type if_type)
}
}
-int blk_print_device_num(enum if_type if_type, int devnum)
+int blk_print_device_num(enum uclass_id if_type, int devnum)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
struct blk_desc *desc;
@@ -151,7 +150,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
return 0;
}
-int blk_show_device(enum if_type if_type, int devnum)
+int blk_show_device(enum uclass_id if_type, int devnum)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
struct blk_desc *desc;
@@ -174,9 +173,8 @@ int blk_show_device(enum if_type if_type, int devnum)
return 0;
}
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
struct blk_desc *desc;
@@ -216,7 +214,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
return desc;
}
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
lbaint_t blkcnt, void *buffer)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
@@ -236,7 +234,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
return n;
}
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
@@ -251,7 +249,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
return desc->block_write(desc, start, blkcnt, buffer);
}
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
{
struct blk_driver *drv = blk_driver_lookup_type(if_type);
struct blk_desc *desc;
diff --git a/drivers/block/efi_blk.c b/drivers/block/efi_blk.c
index 9d25ecbf37..917a19f602 100644
--- a/drivers/block/efi_blk.c
+++ b/drivers/block/efi_blk.c
@@ -94,7 +94,7 @@ static int efi_media_bind(struct udevice *dev)
struct udevice *blk;
int ret;
- ret = blk_create_devicef(dev, "efi_block", "blk", IF_TYPE_EFI_MEDIA,
+ ret = blk_create_devicef(dev, "efi_block", "blk", UCLASS_EFI_MEDIA,
dev_seq(dev), plat->blkio->media->block_size,
plat->blkio->media->last_block, &blk);
if (ret) {
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 3270a9f032..73da29ad55 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -525,8 +525,8 @@ static void ide_ident(struct blk_desc *dev_desc)
{
unsigned char c;
hd_driveid_t iop;
-
#ifdef CONFIG_ATAPI
+ bool is_atapi = false;
int retries = 0;
#endif
int device;
@@ -537,7 +537,7 @@ static void ide_ident(struct blk_desc *dev_desc)
/* Select device
*/
ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
- dev_desc->if_type = IF_TYPE_IDE;
+ dev_desc->if_type = UCLASS_IDE;
#ifdef CONFIG_ATAPI
retries = 0;
@@ -550,7 +550,7 @@ static void ide_ident(struct blk_desc *dev_desc)
(ide_inb(device, ATA_CYL_LOW) == 0x14) &&
(ide_inb(device, ATA_CYL_HIGH) == 0xEB)) {
/* ATAPI Signature found */
- dev_desc->if_type = IF_TYPE_ATAPI;
+ is_atapi = true;
/*
* Start Ident Command
*/
@@ -623,7 +623,7 @@ static void ide_ident(struct blk_desc *dev_desc)
dev_desc->removable = 0;
#ifdef CONFIG_ATAPI
- if (dev_desc->if_type == IF_TYPE_ATAPI) {
+ if (is_atapi) {
atapi_inquiry(dev_desc);
return;
}
@@ -752,7 +752,7 @@ void ide_init(void)
for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
- ide_dev_desc[i].if_type = IF_TYPE_IDE;
+ ide_dev_desc[i].if_type = UCLASS_IDE;
ide_dev_desc[i].devnum = i;
ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
ide_dev_desc[i].blksz = 0;
@@ -1110,7 +1110,7 @@ static int ide_probe(struct udevice *udev)
if (!blksz)
continue;
ret = blk_create_devicef(udev, "ide_blk", name,
- IF_TYPE_IDE, i,
+ UCLASS_IDE, i,
blksz, size, &blk_dev);
if (ret)
return ret;
@@ -1144,7 +1144,7 @@ UCLASS_DRIVER(ide) = {
#else
U_BOOT_LEGACY_BLK(ide) = {
.if_typename = "ide",
- .if_type = IF_TYPE_IDE,
+ .if_type = UCLASS_IDE,
.max_devs = CONFIG_SYS_IDE_MAXDEVICE,
.desc = ide_dev_desc,
};
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 1388498a1d..2de12e0a93 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -98,7 +98,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
int ret, fd;
/* Remove and unbind the old device, if any */
- ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+ ret = blk_get_device(UCLASS_ROOT, devnum, &dev);
if (ret == 0) {
ret = device_remove(dev, DM_REMOVE_NORMAL);
if (ret)
@@ -135,7 +135,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
}
}
ret = blk_create_device(gd->dm_root, "sandbox_host_blk", str,
- IF_TYPE_HOST, devnum, 512,
+ UCLASS_ROOT, devnum, 512,
os_lseek(fd, 0, OS_SEEK_END) / 512, &dev);
if (ret)
goto err_file;
@@ -150,7 +150,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
goto err_file;
}
- desc = blk_get_devnum_by_type(IF_TYPE_HOST, devnum);
+ desc = blk_get_devnum_by_type(UCLASS_ROOT, devnum);
desc->removable = removable;
snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot");
snprintf(desc->product, BLK_PRD_SIZE, "hostfile");
@@ -192,7 +192,7 @@ int host_dev_bind(int dev, char *filename, bool removable)
}
struct blk_desc *blk_dev = &host_dev->blk_dev;
- blk_dev->if_type = IF_TYPE_HOST;
+ blk_dev->if_type = UCLASS_ROOT;
blk_dev->priv = host_dev;
blk_dev->blksz = 512;
blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
@@ -216,7 +216,7 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
struct udevice *dev;
int ret;
- ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+ ret = blk_get_device(UCLASS_ROOT, devnum, &dev);
if (ret)
return ret;
*blk_devp = dev_get_uclass_plat(dev);
@@ -263,7 +263,7 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
#else
U_BOOT_LEGACY_BLK(sandbox_host) = {
.if_typename = "host",
- .if_type = IF_TYPE_HOST,
+ .if_type = UCLASS_ROOT,
.max_devs = SANDBOX_HOST_MAX_DEVICES,
.get_dev = host_get_dev_err,
};
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index a91da972d4..f5832083ba 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -52,7 +52,7 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
if (dfu->data.mmc.hw_partition >= 0) {
part_num_bkp = mmc_get_blk_desc(mmc)->hwpart;
- ret = blk_select_hwpart_devnum(IF_TYPE_MMC,
+ ret = blk_select_hwpart_devnum(UCLASS_MMC,
dfu->data.mmc.dev_num,
dfu->data.mmc.hw_partition);
if (ret)
@@ -77,14 +77,14 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
if (n != blk_count) {
pr_err("MMC operation failed");
if (dfu->data.mmc.hw_partition >= 0)
- blk_select_hwpart_devnum(IF_TYPE_MMC,
+ blk_select_hwpart_devnum(UCLASS_MMC,
dfu->data.mmc.dev_num,
part_num_bkp);
return -EIO;
}
if (dfu->data.mmc.hw_partition >= 0) {
- ret = blk_select_hwpart_devnum(IF_TYPE_MMC,
+ ret = blk_select_hwpart_devnum(UCLASS_MMC,
dfu->data.mmc.dev_num,
part_num_bkp);
if (ret)
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 0dcec8adce..f799f70e43 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -3,7 +3,6 @@ menu "MMC Host controller Support"
config MMC
bool "MMC/SD/SDIO card support"
default ARM || PPC || SANDBOX
- select HAVE_BLOCK_DEVICE
select DM_MMC if DM
help
This selects MultiMediaCard, Secure Digital and Secure
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 688bdc06d4..b1bd4ae1bc 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -290,7 +290,7 @@ struct mmc *find_mmc_device(int dev_num)
struct udevice *dev, *mmc_dev;
int ret;
- ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev);
+ ret = blk_find_device(UCLASS_MMC, dev_num, &dev);
if (ret) {
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
@@ -308,12 +308,12 @@ struct mmc *find_mmc_device(int dev_num)
int get_mmc_num(void)
{
- return max((blk_find_max_devnum(IF_TYPE_MMC) + 1), 0);
+ return max((blk_find_max_devnum(UCLASS_MMC) + 1), 0);
}
int mmc_get_next_devnum(void)
{
- return blk_find_max_devnum(IF_TYPE_MMC);
+ return blk_find_max_devnum(UCLASS_MMC);
}
int mmc_get_blk(struct udevice *dev, struct udevice **blkp)
@@ -411,8 +411,8 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
/* Use the fixed index with aliases node's index */
debug("%s: alias devnum=%d\n", __func__, dev_seq(dev));
- ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
- dev_seq(dev), 512, 0, &bdev);
+ ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC,
+ dev_seq(dev), 512, 0, &bdev);
if (ret) {
debug("Cannot create block device\n");
return ret;
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index a05da6c2e8..4e0891e5df 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -132,7 +132,7 @@ static struct mmc mmc_static = {
.dsr_imp = 0,
.dsr = 0xffffffff,
.block_dev = {
- .if_type = IF_TYPE_MMC,
+ .if_type = UCLASS_MMC,
.removable = 1,
.devnum = 0,
.block_read = mmc_bread,
@@ -194,7 +194,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
mmc->dsr = 0xffffffff;
/* Setup the universal parts of the block interface just once */
bdesc = mmc_get_blk_desc(mmc);
- bdesc->if_type = IF_TYPE_MMC;
+ bdesc->if_type = UCLASS_MMC;
bdesc->removable = 1;
bdesc->devnum = mmc_get_next_devnum();
bdesc->block_read = mmc_bread;
@@ -254,7 +254,7 @@ static int mmc_get_dev(int dev, struct blk_desc **descp)
U_BOOT_LEGACY_BLK(mmc) = {
.if_typename = "mmc",
- .if_type = IF_TYPE_MMC,
+ .if_type = UCLASS_MMC,
.max_devs = -1,
.get_dev = mmc_get_dev,
.select_hwpart = mmc_select_hwpartp,
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index eab94c7b60..5b7aeeb012 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -85,7 +85,7 @@ ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt)
if (!mmc)
return -1;
- err = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_num,
+ err = blk_select_hwpart_devnum(UCLASS_MMC, dev_num,
block_dev->hwpart);
if (err < 0)
return -1;
@@ -203,7 +203,7 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
if (!mmc)
return 0;
- err = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_num, block_dev->hwpart);
+ err = blk_select_hwpart_devnum(UCLASS_MMC, dev_num, block_dev->hwpart);
if (err < 0)
return 0;
diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
index 0cb465160b..73edb35516 100644
--- a/drivers/nvme/Kconfig
+++ b/drivers/nvme/Kconfig
@@ -4,8 +4,6 @@
config NVME
bool "NVM Express device support"
- depends on BLK
- select HAVE_BLOCK_DEVICE
help
This option enables support for NVM Express devices.
It supports basic functions of NVMe (read/write).
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 31cf700633..3510f797e0 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -880,7 +880,7 @@ int nvme_init(struct udevice *udev)
sprintf(name, "blk#%d", i);
/* The real blksz and size will be set by nvme_blk_probe() */
- ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME,
+ ret = blk_create_devicef(udev, "nvme-blk", name, UCLASS_NVME,
-1, 512, 0, &ns_udev);
if (ret)
goto free_id;
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c400e2de16..ad484ce8e8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1,6 +1,5 @@
config SCSI
bool "Support SCSI controllers"
- select HAVE_BLOCK_DEVICE
help
This enables support for SCSI (Small Computer System Interface),
a parallel interface widely used with storage peripherals such as
@@ -10,7 +9,6 @@ config SCSI
config DM_SCSI
bool "Support SCSI controllers with driver model"
- depends on BLK
help
This option enables the SCSI (Small Computer System Interface) uclass
which supports SCSI and SATA HDDs. For every device configuration
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 78d729d809..99be5aef87 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -456,7 +456,7 @@ static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
{
dev_desc->lba = 0;
dev_desc->blksz = 0;
- dev_desc->if_type = IF_TYPE_SCSI;
+ dev_desc->if_type = UCLASS_SCSI;
dev_desc->devnum = devnum;
dev_desc->part_type = PART_TYPE_UNKNOWN;
@@ -574,8 +574,8 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
* block devices created
*/
snprintf(str, sizeof(str), "id%dlun%d", id, lun);
- ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1,
- bd.blksz, bd.lba, &bdev);
+ ret = blk_create_devicef(dev, "scsi_blk", str, UCLASS_SCSI, -1,
+ bd.blksz, bd.lba, &bdev);
if (ret) {
debug("Can't create device\n");
return ret;
@@ -638,7 +638,7 @@ int scsi_scan(bool verbose)
if (verbose)
printf("scanning bus for devices...\n");
- blk_unbind_all(IF_TYPE_SCSI);
+ blk_unbind_all(UCLASS_SCSI);
ret = uclass_get(UCLASS_SCSI, &uc);
if (ret)
@@ -707,7 +707,7 @@ U_BOOT_DRIVER(scsi_blk) = {
#else
U_BOOT_LEGACY_BLK(scsi) = {
.if_typename = "scsi",
- .if_type = IF_TYPE_SCSI,
+ .if_type = UCLASS_SCSI,
.max_devs = SCSI_MAX_DEVICE,
.desc = scsi_dev_desc,
};
diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
index cf5e0a08e6..5bc13757ea 100644
--- a/drivers/tee/optee/rpmb.c
+++ b/drivers/tee/optee/rpmb.c
@@ -48,7 +48,7 @@ static void release_mmc(struct optee_private *priv)
if (!priv->rpmb_mmc)
return;
- rc = blk_select_hwpart_devnum(IF_TYPE_MMC, priv->rpmb_dev_id,
+ rc = blk_select_hwpart_devnum(UCLASS_MMC, priv->rpmb_dev_id,
priv->rpmb_original_part);
if (rc)
debug("%s: blk_select_hwpart_devnum() failed: %d\n",
@@ -88,7 +88,7 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id)
priv->rpmb_original_part = mmc_get_blk_desc(mmc)->hwpart;
- rc = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_id, MMC_PART_RPMB);
+ rc = blk_select_hwpart_devnum(UCLASS_MMC, dev_id, MMC_PART_RPMB);
if (rc) {
debug("Device id %d: cannot select RPMB partition: %d\n",
dev_id, rc);
diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 586263ec88..852f6735b6 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -64,7 +64,6 @@ config VIRTIO_NET
config VIRTIO_BLK
bool "virtio block driver"
depends on VIRTIO
- depends on BLK
help
This is the virtual block driver for virtio. It can be used with
QEMU based targets.
diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
index 3ff74f4a97..9710b79117 100644
--- a/drivers/virtio/virtio_blk.c
+++ b/drivers/virtio/virtio_blk.c
@@ -75,14 +75,14 @@ static int virtio_blk_bind(struct udevice *dev)
struct blk_desc *desc = dev_get_uclass_plat(dev);
int devnum;
- desc->if_type = IF_TYPE_VIRTIO;
+ desc->if_type = UCLASS_VIRTIO;
/*
* Initialize the devnum to -ENODEV. This is to make sure that
* blk_next_free_devnum() works as expected, since the default
* value 0 is a valid devnum.
*/
desc->devnum = -ENODEV;
- devnum = blk_next_free_devnum(IF_TYPE_VIRTIO);
+ devnum = blk_next_free_devnum(UCLASS_VIRTIO);
if (devnum < 0)
return devnum;
desc->devnum = devnum;
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 6ad2a93668..0ee74d036c 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -2,7 +2,6 @@ config PVBLOCK
bool "Xen para-virtualized block device"
depends on DM
select BLK
- select HAVE_BLOCK_DEVICE
help
This driver implements the front-end of the Xen virtual
block device driver. It communicates with a back-end driver
diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c
index c25c3ea4ff..1090e528d0 100644
--- a/drivers/xen/pvblock.c
+++ b/drivers/xen/pvblock.c
@@ -665,14 +665,14 @@ static int pvblock_blk_bind(struct udevice *udev)
struct blk_desc *desc = dev_get_uclass_plat(udev);
int devnum;
- desc->if_type = IF_TYPE_PVBLOCK;
+ desc->if_type = UCLASS_PVBLOCK;
/*
* Initialize the devnum to -ENODEV. This is to make sure that
* blk_next_free_devnum() works as expected, since the default
* value 0 is a valid devnum.
*/
desc->devnum = -ENODEV;
- devnum = blk_next_free_devnum(IF_TYPE_PVBLOCK);
+ devnum = blk_next_free_devnum(UCLASS_PVBLOCK);
if (devnum < 0)
return devnum;
desc->devnum = devnum;
@@ -804,7 +804,7 @@ static void print_pvblock_devices(void)
const char *class_name;
class_name = uclass_get_name(UCLASS_PVBLOCK);
- for (blk_first_device(IF_TYPE_PVBLOCK, &udev); udev;
+ for (blk_first_device(UCLASS_PVBLOCK, &udev); udev;
blk_next_device(&udev), first = false) {
struct blk_desc *desc = dev_get_uclass_plat(udev);
diff --git a/env/mmc.c b/env/mmc.c
index 0c498d9a46..c28f4c6c6d 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -143,7 +143,7 @@ static int mmc_set_env_part(struct mmc *mmc, uint part)
int dev = mmc_get_env_dev();
int ret = 0;
- ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
+ ret = blk_select_hwpart_devnum(UCLASS_MMC, dev, part);
if (ret)
puts("MMC partition switch failed\n");
@@ -179,7 +179,7 @@ static void fini_mmc_for_env(struct mmc *mmc)
#ifdef CONFIG_SYS_MMC_ENV_PART
int dev = mmc_get_env_dev();
- blk_select_hwpart_devnum(IF_TYPE_MMC, dev, env_mmc_orig_hwpart);
+ blk_select_hwpart_devnum(UCLASS_MMC, dev, env_mmc_orig_hwpart);
#endif
}
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index df9ea2c028..c64e253abd 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1144,7 +1144,7 @@ int file_fat_detectfs(void)
return 1;
}
- if (IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) {
+ if (blk_enabled()) {
printf("Interface: %s\n", blk_get_if_type_name(cur_dev->if_type));
printf(" Device %d: ", cur_dev->devnum);
dev_print(cur_dev);
diff --git a/include/blk.h b/include/blk.h
index 9503369db8..279f9ea4a9 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -7,6 +7,7 @@
#ifndef BLK_H
#define BLK_H
+#include <dm/uclass-id.h>
#include <efi.h>
#ifdef CONFIG_SYS_64BIT_LBA
@@ -21,26 +22,10 @@ typedef ulong lbaint_t;
struct udevice;
-/* Interface types: */
-enum if_type {
- IF_TYPE_UNKNOWN = 0,
- IF_TYPE_IDE,
- IF_TYPE_SCSI,
- IF_TYPE_ATAPI,
- IF_TYPE_USB,
- IF_TYPE_DOC,
- IF_TYPE_MMC,
- IF_TYPE_SD,
- IF_TYPE_SATA,
- IF_TYPE_HOST,
- IF_TYPE_NVME,
- IF_TYPE_EFI_LOADER,
- IF_TYPE_PVBLOCK,
- IF_TYPE_VIRTIO,
- IF_TYPE_EFI_MEDIA,
-
- IF_TYPE_COUNT, /* Number of interface types */
-};
+static inline bool blk_enabled(void)
+{
+ return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
+}
#define BLK_VEN_SIZE 40
#define BLK_PRD_SIZE 20
@@ -69,7 +54,7 @@ struct blk_desc {
* TODO: With driver model we should be able to use the parent
* device's uclass instead.
*/
- enum if_type if_type; /* type of the interface */
+ enum uclass_id if_type; /* type of the interface */
int devnum; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
@@ -294,7 +279,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
* This function does not activate the device. The device will be returned
* whether or not it is activated.
*
- * @if_type: Interface type (enum if_type_t)
+ * @if_type: Interface type (enum uclass_id_t)
* @devnum: Device number (specific to each interface type)
* @devp: the device, if found
* Return: 0 if found, -ENODEV if no device found, or other -ve error value
@@ -304,7 +289,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp);
/**
* blk_get_device() - Find and probe a block device ready for use
*
- * @if_type: Interface type (enum if_type_t)
+ * @if_type: Interface type (enum uclass_id_t)
* @devnum: Device number (specific to each interface type)
* @devp: the device, if found
* Return: 0 if found, -ENODEV if no device found, or other -ve error value
@@ -342,7 +327,7 @@ int blk_next_device(struct udevice **devp);
* @parent: Parent of the new device
* @drv_name: Driver name to use for the block device
* @name: Name for the device
- * @if_type: Interface type (enum if_type_t)
+ * @if_type: Interface type (enum uclass_id_t)
* @devnum: Device number, specific to the interface type, or -1 to
* allocate the next available number
* @blksz: Block size of the device in bytes (typically 512)
@@ -359,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
* @parent: Parent of the new device
* @drv_name: Driver name to use for the block device
* @name: Name for the device (parent name is prepended)
- * @if_type: Interface type (enum if_type_t)
+ * @if_type: Interface type (enum uclass_id_t)
* @devnum: Device number, specific to the interface type, or -1 to
* allocate the next available number
* @blksz: Block size of the device in bytes (typically 512)
@@ -402,7 +387,7 @@ int blk_unbind_all(int if_type);
* Return: maximum device number found, or -ENODEV if none, or other -ve on
* error
*/
-int blk_find_max_devnum(enum if_type if_type);
+int blk_find_max_devnum(enum uclass_id if_type);
/**
* blk_next_free_devnum() - get the next device number for an interface type
@@ -413,7 +398,7 @@ int blk_find_max_devnum(enum if_type if_type);
* @if_type: Interface type to scan
* Return: next device number safe to use, or -ve on error
*/
-int blk_next_free_devnum(enum if_type if_type);
+int blk_next_free_devnum(enum uclass_id if_type);
/**
* blk_select_hwpart() - select a hardware partition
@@ -508,7 +493,7 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
*/
struct blk_driver {
const char *if_typename;
- enum if_type if_type;
+ enum uclass_id if_type;
int max_devs;
struct blk_desc *desc;
/**
@@ -569,7 +554,7 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
* @devnum: Device number
* Return: point to block device descriptor, or NULL if not found
*/
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
/**
* blk_get_devnum_by_type() - Get a block device by type name, and number
@@ -606,7 +591,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
* @if_type: Block device type
* Return: 0 if OK, -ENODEV if there is none of that type
*/
-int blk_list_part(enum if_type if_type);
+int blk_list_part(enum uclass_id if_type);
/**
* blk_list_devices() - list the block devices of a given type
@@ -616,7 +601,7 @@ int blk_list_part(enum if_type if_type);
*
* @if_type: Block device type
*/
-void blk_list_devices(enum if_type if_type);
+void blk_list_devices(enum uclass_id if_type);
/**
* blk_show_device() - show information about a given block device
@@ -627,7 +612,7 @@ void blk_list_devices(enum if_type if_type);
* @devnum: Device number
* Return: 0 if OK, -ENODEV for invalid device number
*/
-int blk_show_device(enum if_type if_type, int devnum);
+int blk_show_device(enum uclass_id if_type, int devnum);
/**
* blk_print_device_num() - show information about a given block device
@@ -640,7 +625,7 @@ int blk_show_device(enum if_type if_type, int devnum);
* Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
* device is not connected
*/
-int blk_print_device_num(enum if_type if_type, int devnum);
+int blk_print_device_num(enum uclass_id if_type, int devnum);
/**
* blk_print_part_devnum() - print the partition information for a device
@@ -650,7 +635,7 @@ int blk_print_device_num(enum if_type if_type, int devnum);
* Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
* the interface type is not supported, other -ve on other error
*/
-int blk_print_part_devnum(enum if_type if_type, int devnum);
+int blk_print_part_devnum(enum uclass_id if_type, int devnum);
/**
* blk_read_devnum() - read blocks from a device
@@ -661,7 +646,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum);
* @buffer: Address to write data to
* Return: number of blocks read, or -ve error number on error
*/
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
lbaint_t blkcnt, void *buffer);
/**
@@ -673,7 +658,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
* @buffer: Address to read data from
* Return: number of blocks written, or -ve error number on error
*/
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
lbaint_t blkcnt, const void *buffer);
/**
@@ -687,7 +672,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
* @hwpart: Partition number to select
* Return: 0 if OK, -ve on error
*/
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
/**
* blk_get_if_type_name() - Get the name of an interface type
@@ -695,7 +680,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
* @if_type: Interface type to check
* Return: name of interface, or NULL if none
*/
-const char *blk_get_if_type_name(enum if_type if_type);
+const char *blk_get_if_type_name(enum uclass_id if_type);
/**
* blk_common_cmd() - handle common commands with block devices
@@ -706,7 +691,7 @@ const char *blk_get_if_type_name(enum if_type if_type);
* @cur_devnump: Current device number for this interface type
* Return: 0 if OK, CMD_RET_ERROR on error
*/
-int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
int *cur_devnump);
enum blk_flag_t {
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 6b63ae8dde..fb35087ddb 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -161,7 +161,7 @@ extern bool efi_st_keep_devices;
/* EFI system partition */
extern struct efi_system_partition {
- enum if_type if_type;
+ enum uclass_id if_type;
int devnum;
u8 part;
} efi_system_partition;
diff --git a/include/mmc.h b/include/mmc.h
index f519d86972..027e8bcc73 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -767,7 +767,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv);
/**
* mmc_bind() - Set up a new MMC device ready for probing
*
- * A child block device is bound with the IF_TYPE_MMC interface type. This
+ * A child block device is bound with the UCLASS_MMC interface type. This
* allows the device to be used with CONFIG_BLK
*
* @dev: MMC device to set up
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index d57d281f85..3177ab67b8 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -128,7 +128,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
if (!obj)
return -ENOENT;
- devnum = blk_find_max_devnum(IF_TYPE_EFI_LOADER);
+ devnum = blk_find_max_devnum(UCLASS_EFI_LOADER);
if (devnum == -ENODEV)
devnum = 0;
else if (devnum < 0)
@@ -140,7 +140,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
sprintf(name, "efiblk#%d", devnum);
/* Create driver model udevice for the EFI block io device */
- ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI_LOADER,
+ ret = blk_create_device(parent, "efi_blk", name, UCLASS_EFI_LOADER,
devnum, io->media->block_size,
(lbaint_t)io->media->last_block, &bdev);
if (ret)
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 5cfff8c56b..476a22d7ea 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -20,7 +20,6 @@ config EFI_LOADER
select EVENT_DYNAMIC
select LIB_UUID
imply PARTITION_UUIDS
- select HAVE_BLOCK_DEVICE
select REGEX
imply FAT
imply FAT_WRITE
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index a34ca46a11..819dcb4f13 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -640,7 +640,7 @@ static int efi_disk_probe(void *ctx, struct event *event)
* has already created an efi_disk at this moment.
*/
desc = dev_get_uclass_plat(dev);
- if (desc->if_type != IF_TYPE_EFI_LOADER) {
+ if (desc->if_type != UCLASS_EFI_LOADER) {
ret = efi_disk_create_raw(dev);
if (ret)
return -1;
@@ -675,7 +675,7 @@ static int efi_disk_delete_raw(struct udevice *dev)
return -1;
desc = dev_get_uclass_plat(dev);
- if (desc->if_type != IF_TYPE_EFI_LOADER) {
+ if (desc->if_type != UCLASS_EFI_LOADER) {
diskobj = container_of(handle, struct efi_disk_obj, header);
efi_free_pool(diskobj->dp);
}
diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 76a2ff9e41..994e66392f 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -38,7 +38,7 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
char part_str[PART_STR_LEN];
int r;
- if (!efi_system_partition.if_type) {
+ if (efi_system_partition.if_type == UCLASS_INVALID) {
log_err("No EFI system partition\n");
return EFI_DEVICE_ERROR;
}
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 85c3a3bd45..35bd5318f0 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -25,19 +25,19 @@ static int dm_test_blk_base(struct unit_test_state *uts)
/* Create two, one the parent of the other */
ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
- IF_TYPE_HOST, 1, 512, 2, &blk1));
+ UCLASS_ROOT, 1, 512, 2, &blk1));
ut_assertok(blk_create_device(blk1, "sandbox_host_blk", "test",
- IF_TYPE_HOST, 3, 512, 2, &blk3));
+ UCLASS_ROOT, 3, 512, 2, &blk3));
/* Check we can find them */
- ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev));
- ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
+ ut_asserteq(-ENODEV, blk_get_device(UCLASS_ROOT, 0, &dev));
+ ut_assertok(blk_get_device(UCLASS_ROOT, 1, &dev));
ut_asserteq_ptr(blk1, dev);
- ut_assertok(blk_get_device(IF_TYPE_HOST, 3, &dev));
+ ut_assertok(blk_get_device(UCLASS_ROOT, 3, &dev));
ut_asserteq_ptr(blk3, dev);
/* Check we can iterate */
- ut_assertok(blk_first_device(IF_TYPE_HOST, &dev));
+ ut_assertok(blk_first_device(UCLASS_ROOT, &dev));
ut_asserteq_ptr(blk1, dev);
ut_assertok(blk_next_device(&dev));
ut_asserteq_ptr(blk3, dev);
@@ -79,7 +79,7 @@ static int dm_test_blk_usb(struct unit_test_state *uts)
ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc));
/* The parent should be a block device */
- ut_assertok(blk_get_device(IF_TYPE_USB, 0, &dev));
+ ut_assertok(blk_get_device(UCLASS_USB, 0, &dev));
ut_asserteq_ptr(usb_dev, dev_get_parent(dev));
/* Check we have one block device for each mass storage device */
@@ -101,14 +101,14 @@ static int dm_test_blk_find(struct unit_test_state *uts)
struct udevice *blk, *dev;
ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
- IF_TYPE_HOST, 1, 512, 2, &blk));
- ut_asserteq(-ENODEV, blk_find_device(IF_TYPE_HOST, 0, &dev));
- ut_assertok(blk_find_device(IF_TYPE_HOST, 1, &dev));
+ UCLASS_ROOT, 1, 512, 2, &blk));
+ ut_asserteq(-ENODEV, blk_find_device(UCLASS_ROOT, 0, &dev));
+ ut_assertok(blk_find_device(UCLASS_ROOT, 1, &dev));
ut_asserteq_ptr(blk, dev);
ut_asserteq(false, device_active(dev));
/* Now activate it */
- ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
+ ut_assertok(blk_get_device(UCLASS_ROOT, 1, &dev));
ut_asserteq_ptr(blk, dev);
ut_asserteq(true, device_active(dev));
@@ -134,7 +134,7 @@ static int dm_test_blk_devnum(struct unit_test_state *uts)
/* Check that the bblock device is attached */
ut_assertok(uclass_get_device_by_seq(UCLASS_MMC, i, &mmc_dev));
- ut_assertok(blk_find_device(IF_TYPE_MMC, i, &dev));
+ ut_assertok(blk_find_device(UCLASS_MMC, i, &dev));
parent = dev_get_parent(dev);
ut_asserteq_ptr(parent, mmc_dev);
ut_asserteq(trailing_strtol(mmc_dev->name), i);