]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - include/blk.h
usb: dwc2: convert to livetree
[people/ms/u-boot.git] / include / blk.h
index ef29a07ee260a516e808cc9f172ebfa39c1fb221..1965812a9d5a39f0148ce133a895a69b4058d07b 100644 (file)
@@ -31,10 +31,15 @@ enum if_type {
        IF_TYPE_SATA,
        IF_TYPE_HOST,
        IF_TYPE_SYSTEMACE,
+       IF_TYPE_NVME,
 
        IF_TYPE_COUNT,                  /* Number of interface types */
 };
 
+#define BLK_VEN_SIZE           40
+#define BLK_PRD_SIZE           20
+#define BLK_REV_SIZE           8
+
 /*
  * With driver model (CONFIG_BLK) this is uclass platform data, accessible
  * with dev_get_uclass_platdata(dev)
@@ -59,10 +64,10 @@ struct blk_desc {
        lbaint_t        lba;            /* number of blocks */
        unsigned long   blksz;          /* block size */
        int             log2blksz;      /* for convenience: log2(blksz) */
-       char            vendor[40+1];   /* IDE model, SCSI Vendor */
-       char            product[20+1];  /* IDE Serial no, SCSI product */
-       char            revision[8+1];  /* firmware revision */
-#ifdef CONFIG_BLK
+       char            vendor[BLK_VEN_SIZE + 1]; /* device vendor string */
+       char            product[BLK_PRD_SIZE + 1]; /* device product number */
+       char            revision[BLK_REV_SIZE + 1]; /* firmware revision */
+#if CONFIG_IS_ENABLED(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
@@ -174,7 +179,7 @@ static inline void blkcache_invalidate(int iftype, int dev) {}
 
 #endif
 
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
 struct udevice;
 
 /* Operations on block devices */
@@ -310,12 +315,12 @@ int blk_next_device(struct udevice **devp);
  * @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
+ * @lba:       Total number of blocks of the device
  * @devp:      the new device (which has not been probed)
  */
 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);
+                     lbaint_t lba, struct udevice **devp);
 
 /**
  * blk_create_devicef() - Create a new named block device
@@ -327,12 +332,12 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
  * @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
+ * @lba:       Total number of blocks of the device
  * @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);
+                      lbaint_t lba, struct udevice **devp);
 
 /**
  * blk_prepare_device() - Prepare a block device for use
@@ -623,4 +628,24 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
  */
 int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
 
+/**
+ * blk_get_if_type_name() - Get the name of an interface type
+ *
+ * @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);
+
+/**
+ * blk_common_cmd() - handle common commands with block devices
+ *
+ * @args: Number of arguments to the command (argv[0] is the command itself)
+ * @argv: Command arguments
+ * @if_type: Interface 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 *cur_devnump);
+
 #endif