dm: blk: Add functions to select a hardware partition

The block device uclass does not currently support selecting a particular
hardware partition but this is needed for MMC. Add it so that the blk API
can support MMC properly.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2016-05-01 13:52:30 -06:00
parent 69f45cd53b
commit cd0fb55b64
2 changed files with 59 additions and 0 deletions

View File

@@ -165,6 +165,18 @@ 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)
{
struct udevice *dev;
int ret;
ret = blk_get_device(if_type, devnum, &dev);
if (ret)
return ret;
return blk_select_hwpart(dev, hwpart);
}
int blk_list_part(enum if_type if_type)
{
struct blk_desc *desc;
@@ -291,6 +303,23 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
return blk_dwrite(desc, start, blkcnt, buffer);
}
int blk_select_hwpart(struct udevice *dev, int hwpart)
{
const struct blk_ops *ops = blk_get_ops(dev);
if (!ops)
return -ENOSYS;
if (!ops->select_hwpart)
return 0;
return ops->select_hwpart(dev, hwpart);
}
int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
{
return blk_select_hwpart(desc->bdev, hwpart);
}
int blk_first_device(int if_type, struct udevice **devp)
{
struct blk_desc *desc;