]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - include/blk.h
arc/cache: really do invalidate_dcache_all() even if IOC exists
[people/ms/u-boot.git] / include / blk.h
index 2caac9c96b68be6f95d1e5d42457afccf9560265..66a1c55cc8b69c256e9caf214642bbc60c439406 100644 (file)
@@ -63,6 +63,11 @@ struct blk_desc {
        char            product[20+1];  /* IDE Serial no, SCSI product */
        char            revision[8+1];  /* firmware revision */
 #ifdef CONFIG_BLK
+       /*
+        * For now we have a few functions which take struct blk_desc as a
+        * parameter. This field allows them to look up the associated
+        * device. Once these functions are removed we can drop this field.
+        */
        struct udevice *bdev;
 #else
        unsigned long   (*block_read)(struct blk_desc *block_dev,
@@ -211,6 +216,25 @@ struct blk_ops {
         */
        unsigned long (*erase)(struct udevice *dev, lbaint_t start,
                               lbaint_t blkcnt);
+
+       /**
+        * select_hwpart() - select a particular hardware partition
+        *
+        * Some devices (e.g. MMC) can support partitioning at the hardware
+        * level. This is quite separate from the normal idea of
+        * software-based partitions. MMC hardware partitions must be
+        * explicitly selected. Once selected only the region of the device
+        * covered by that partition is accessible.
+        *
+        * The MMC standard provides for two boot partitions (numbered 1 and 2),
+        * rpmb (3), and up to 4 addition general-purpose partitions (4-7).
+        *
+        * @desc:       Block device to update
+        * @hwpart:     Hardware partition number to select. 0 means the raw
+        *              device, 1 is the first partition, 2 is the second, etc.
+        * @return 0 if OK, -ve on error
+        */
+       int (*select_hwpart)(struct udevice *dev, int hwpart);
 };
 
 #define blk_get_ops(dev)       ((struct blk_ops *)(dev)->driver->ops)
@@ -270,7 +294,8 @@ int blk_next_device(struct udevice **devp);
  * @drv_name:  Driver name to use for the block device
  * @name:      Name for the device
  * @if_type:   Interface type (enum if_type_t)
- * @devnum:    Device number, specific to the interface type
+ * @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)
  * @size:      Total size of the device in bytes
  * @devp:      the new device (which has not been probed)
@@ -279,6 +304,23 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
                      const char *name, int if_type, int devnum, int blksz,
                      lbaint_t size, struct udevice **devp);
 
+/**
+ * blk_create_devicef() - Create a new named block device
+ *
+ * @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)
+ * @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)
+ * @size:      Total size of the device in bytes
+ * @devp:      the new device (which has not been probed)
+ */
+int blk_create_devicef(struct udevice *parent, const char *drv_name,
+                      const char *name, int if_type, int devnum, int blksz,
+                      lbaint_t size, struct udevice **devp);
+
 /**
  * blk_prepare_device() - Prepare a block device for use
  *
@@ -299,6 +341,29 @@ int blk_prepare_device(struct udevice *dev);
  */
 int blk_unbind_all(int if_type);
 
+/**
+ * blk_find_max_devnum() - find the maximum device number for an interface type
+ *
+ * Finds the last allocated device number for an interface type @if_type. The
+ * next number is safe to use for a newly allocated device.
+ *
+ * @if_type:   Interface type to scan
+ * @return maximum device number found, or -ENODEV if none, or other -ve on
+ * error
+ */
+int blk_find_max_devnum(enum if_type if_type);
+
+/**
+ * blk_select_hwpart() - select a hardware partition
+ *
+ * Select a hardware partition if the device supports it (typically MMC does)
+ *
+ * @dev:       Device to update
+ * @hwpart:    Partition number to select
+ * @return 0 if OK, -ve on error
+ */
+int blk_select_hwpart(struct udevice *dev, int hwpart);
+
 #else
 #include <errno.h>
 /*