summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
Diffstat (limited to 'disk')
-rw-r--r--disk/Kconfig8
-rw-r--r--disk/Makefile4
-rw-r--r--disk/disk-uclass.c11
-rw-r--r--disk/part.c163
-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
9 files changed, 81 insertions, 122 deletions
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..551f8b1dca 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)
@@ -192,12 +191,12 @@ unsigned long dev_read(struct udevice *dev, lbaint_t start,
start_in_disk += part->gpt_part_info.start;
}
- if (blkcache_read(block_dev->if_type, block_dev->devnum,
+ if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
start_in_disk, blkcnt, block_dev->blksz, buffer))
return blkcnt;
blks_read = ops->read(dev, start, blkcnt, buffer);
if (blks_read == blkcnt)
- blkcache_fill(block_dev->if_type, block_dev->devnum,
+ blkcache_fill(block_dev->uclass_id, block_dev->devnum,
start_in_disk, blkcnt, block_dev->blksz, buffer);
return blks_read;
@@ -217,7 +216,7 @@ unsigned long dev_write(struct udevice *dev, lbaint_t start,
if (!ops->write)
return -ENOSYS;
- blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+ blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
return ops->write(dev, start, blkcnt, buffer);
}
@@ -236,7 +235,7 @@ unsigned long dev_erase(struct udevice *dev, lbaint_t start,
if (!ops->erase)
return -ENOSYS;
- blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+ blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
return ops->erase(dev, start, blkcnt);
}
diff --git a/disk/part.c b/disk/part.c
index de1b917e84..f982b30f97 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -54,13 +54,14 @@ 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;
- dev_desc = blk_get_devnum_by_typename(ifname, dev);
+ if (!blk_enabled())
+ return NULL;
+ dev_desc = blk_get_devnum_by_uclass_idname(ifname, dev);
if (!dev_desc) {
debug("%s: No device for iface '%s', dev %d\n", __func__,
ifname, dev);
@@ -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 */
@@ -129,44 +120,42 @@ void dev_print (struct blk_desc *dev_desc)
return;
}
- switch (dev_desc->if_type) {
- case IF_TYPE_SCSI:
+ switch (dev_desc->uclass_id) {
+ 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:
- printf("Unhandled device type: %i\n", dev_desc->if_type);
+ printf("Unhandled device type: %i\n", dev_desc->uclass_id);
return;
}
puts (" Type: ");
@@ -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)
{
@@ -239,7 +225,7 @@ void part_init(struct blk_desc *dev_desc)
const int n_ents = ll_entry_count(struct part_driver, part_driver);
struct part_driver *entry;
- blkcache_invalidate(dev_desc->if_type, dev_desc->devnum);
+ blkcache_invalidate(dev_desc->uclass_id, dev_desc->devnum);
dev_desc->part_type = PART_TYPE_UNKNOWN;
for (entry = drv; entry != drv + n_ents; entry++) {
@@ -262,41 +248,35 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
CONFIG_IS_ENABLED(EFI_PARTITION)
puts ("\nPartition Map for ");
- switch (dev_desc->if_type) {
- case IF_TYPE_IDE:
+ switch (dev_desc->uclass_id) {
+ 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)->uclass_id == UCLASS_MMC)
+ part_init(*dev_desc);
+ }
cleanup:
free(dup_str);
@@ -784,23 +762,18 @@ 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:
+ switch (dev_desc->uclass_id) {
+ 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