dm: Add a new header for block devices
authorSimon Glass <sjg@chromium.org>
Mon, 29 Feb 2016 22:25:39 +0000 (15:25 -0700)
committerSimon Glass <sjg@chromium.org>
Mon, 14 Mar 2016 21:34:50 +0000 (15:34 -0600)
At present block devices are tied up with partitions. But not all block
devices have partitions within them. They are in fact separate concepts.

Create a separate blk.h header file for block devices.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
include/blk.h [new file with mode: 0644]
include/ide.h
include/part.h

diff --git a/include/blk.h b/include/blk.h
new file mode 100644 (file)
index 0000000..1e8334c
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef BLK_H
+#define BLK_H
+
+#ifdef CONFIG_SYS_64BIT_LBA
+typedef uint64_t lbaint_t;
+#define LBAFlength "ll"
+#else
+typedef ulong lbaint_t;
+#define LBAFlength "l"
+#endif
+#define LBAF "%" LBAFlength "x"
+#define LBAFU "%" LBAFlength "u"
+
+/* Interface types: */
+#define IF_TYPE_UNKNOWN                0
+#define IF_TYPE_IDE            1
+#define IF_TYPE_SCSI           2
+#define IF_TYPE_ATAPI          3
+#define IF_TYPE_USB            4
+#define IF_TYPE_DOC            5
+#define IF_TYPE_MMC            6
+#define IF_TYPE_SD             7
+#define IF_TYPE_SATA           8
+#define IF_TYPE_HOST           9
+#define IF_TYPE_MAX            10      /* Max number of IF_TYPE_* supported */
+
+struct blk_desc {
+       int             if_type;        /* type of the interface */
+       int             dev;            /* device number */
+       unsigned char   part_type;      /* partition type */
+       unsigned char   target;         /* target SCSI ID */
+       unsigned char   lun;            /* target LUN */
+       unsigned char   hwpart;         /* HW partition, e.g. for eMMC */
+       unsigned char   type;           /* device type */
+       unsigned char   removable;      /* removable device */
+#ifdef CONFIG_LBA48
+       /* device can use 48bit addr (ATA/ATAPI v7) */
+       unsigned char   lba48;
+#endif
+       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 */
+       unsigned long   (*block_read)(struct blk_desc *block_dev,
+                                     lbaint_t start,
+                                     lbaint_t blkcnt,
+                                     void *buffer);
+       unsigned long   (*block_write)(struct blk_desc *block_dev,
+                                      lbaint_t start,
+                                      lbaint_t blkcnt,
+                                      const void *buffer);
+       unsigned long   (*block_erase)(struct blk_desc *block_dev,
+                                      lbaint_t start,
+                                      lbaint_t blkcnt);
+       void            *priv;          /* driver private struct pointer */
+};
+
+#define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
+#define PAD_TO_BLOCKSIZE(size, blk_desc) \
+       (PAD_SIZE(size, blk_desc->blksz))
+
+#endif
index 24073938507179fb75224f5281a1a8d97721af9e..a4e65cf2a9420dbc7523c6d2ae9b91ce6c87209e 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef        _IDE_H
 #define _IDE_H
 
+#include <blk.h>
+
 #define IDE_BUS(dev)   (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS))
 
 #define        ATA_CURR_BASE(dev)      (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
@@ -26,16 +28,6 @@ extern ulong ide_bus_offset[];
 void ide_led(uchar led, uchar status);
 #endif /* CONFIG_IDE_LED */
 
-#ifdef CONFIG_SYS_64BIT_LBA
-typedef uint64_t lbaint_t;
-#define LBAFlength "ll"
-#else
-typedef ulong lbaint_t;
-#define LBAFlength "l"
-#endif
-#define LBAF "%" LBAFlength "x"
-#define LBAFU "%" LBAFlength "u"
-
 /*
  * Function Prototypes
  */
index 140c9b6a45fc3c4549d23a1d753d60ba053db31e..25999984df19dd58468df4f2fbdbc9798fc36bf7 100644 (file)
@@ -7,61 +7,14 @@
 #ifndef _PART_H
 #define _PART_H
 
+#include <blk.h>
 #include <ide.h>
 
-struct blk_desc {
-       int             if_type;        /* type of the interface */
-       int             dev;            /* device number */
-       unsigned char   part_type;      /* partition type */
-       unsigned char   target;         /* target SCSI ID */
-       unsigned char   lun;            /* target LUN */
-       unsigned char   hwpart;         /* HW partition, e.g. for eMMC */
-       unsigned char   type;           /* device type */
-       unsigned char   removable;      /* removable device */
-#ifdef CONFIG_LBA48
-       unsigned char   lba48;          /* device can use 48bit addr (ATA/ATAPI v7) */
-#endif
-       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 */
-       unsigned long   (*block_read)(struct blk_desc *block_dev,
-                                     lbaint_t start,
-                                     lbaint_t blkcnt,
-                                     void *buffer);
-       unsigned long   (*block_write)(struct blk_desc *block_dev,
-                                      lbaint_t start,
-                                      lbaint_t blkcnt,
-                                      const void *buffer);
-       unsigned long   (*block_erase)(struct blk_desc *block_dev,
-                                      lbaint_t start,
-                                      lbaint_t blkcnt);
-       void            *priv;          /* driver private struct pointer */
-};
-
-#define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
-#define PAD_TO_BLOCKSIZE(size, blk_desc) \
-       (PAD_SIZE(size, blk_desc->blksz))
 #define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
                 ((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
                 ((x & 0xffff0000) ? 16 : 0))
 #define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))
 
-/* Interface types: */
-#define IF_TYPE_UNKNOWN                0
-#define IF_TYPE_IDE            1
-#define IF_TYPE_SCSI           2
-#define IF_TYPE_ATAPI          3
-#define IF_TYPE_USB            4
-#define IF_TYPE_DOC            5
-#define IF_TYPE_MMC            6
-#define IF_TYPE_SD             7
-#define IF_TYPE_SATA           8
-#define IF_TYPE_HOST           9
-#define IF_TYPE_MAX            10      /* Max number of IF_TYPE_* supported */
-
 /* Part types */
 #define PART_TYPE_UNKNOWN      0x00
 #define PART_TYPE_MAC          0x01