* 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;
/* 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;
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;
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;
}
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;
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;
}
}
- 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[])
#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;
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;
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)
}
/* 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;
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;
}
}
- 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(
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);
}
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)
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(
}
}
- 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(
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 */
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(
/* 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;
/* 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;
#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);
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");
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;
#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,
};
}
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_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_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_UNKNOWN:
+ case UCLASS_INVALID:
puts("device type unknown\n");
return;
default:
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_USB:
+ case UCLASS_USB:
puts ("USB");
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:
* 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)
+ if ((*dev_desc)->if_type == UCLASS_MMC)
part_init(*dev_desc);
}
char *devtype;
switch (dev_desc->if_type) {
- case IF_TYPE_IDE:
- case IF_TYPE_SATA:
+ 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_MMC:
+ case UCLASS_MMC:
devtype = "mmcsd";
break;
default:
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].
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;
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;
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;
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;
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;
enum uclass_id id;
const char *name;
} if_typename_str[] = {
- { IF_TYPE_IDE, "ide" },
- { IF_TYPE_SCSI, "scsi" },
- { IF_TYPE_USB, "usb" },
- { IF_TYPE_MMC, "mmc" },
- { IF_TYPE_SCSI, "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_USB] = UCLASS_MASS_STORAGE,
- [IF_TYPE_MMC] = UCLASS_MMC,
- [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,
+ { 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)
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)
{
- 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)
int i;
for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
- if ((int)if_typename_str[i].id == if_type)
+ if (if_typename_str[i].id == if_type)
return if_typename_str[i].name;
}
int ret;
type = if_typename_to_iftype(if_typename);
- if (type == IF_TYPE_UNKNOWN) {
+ if (type == UCLASS_INVALID) {
debug("%s: Unknown interface type '%s'\n", __func__,
if_typename);
return NULL;
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) {
/* 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;
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;
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;
#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,
};
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)
}
}
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;
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");
}
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;
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);
#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,
};
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)
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)
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)
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)
/* 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;
.dsr_imp = 0,
.dsr = 0xffffffff,
.block_dev = {
- .if_type = IF_TYPE_MMC,
+ .if_type = UCLASS_MMC,
.removable = 1,
.devnum = 0,
.block_read = mmc_bread,
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;
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,
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;
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;
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;
{
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;
* 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;
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)
#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,
};
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",
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);
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;
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;
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);
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");
#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
}
#ifndef BLK_H
#define BLK_H
+#include <dm/uclass-id.h>
#include <efi.h>
#ifdef CONFIG_SYS_64BIT_LBA
}
/* Interface types: */
-enum if_type {
- IF_TYPE_UNKNOWN = 0,
- IF_TYPE_IDE,
- IF_TYPE_SCSI,
- IF_TYPE_USB,
- IF_TYPE_MMC,
- 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 */
-};
+#define if_type uclass_id
#define BLK_VEN_SIZE 40
#define BLK_PRD_SIZE 20
/**
* 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
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)
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)
* 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;
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);
}
/* 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);
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 */
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));
/* 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);