Merge tag 'efi-2021-01-rc3-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[platform/kernel/u-boot.git] / include / mmc.h
index 85fc349..1d377e0 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef _MMC_H_
 #define _MMC_H_
 
+#include <linux/bitops.h>
 #include <linux/list.h>
 #include <linux/sizes.h>
 #include <linux/compiler.h>
@@ -359,6 +360,19 @@ enum mmc_voltage {
 #define MMC_NUM_BOOT_PARTITION 2
 #define MMC_PART_RPMB           3       /* RPMB partition number */
 
+/* timing specification used */
+#define MMC_TIMING_LEGACY      0
+#define MMC_TIMING_MMC_HS      1
+#define MMC_TIMING_SD_HS       2
+#define MMC_TIMING_UHS_SDR12   3
+#define MMC_TIMING_UHS_SDR25   4
+#define MMC_TIMING_UHS_SDR50   5
+#define MMC_TIMING_UHS_SDR104  6
+#define MMC_TIMING_UHS_DDR50   7
+#define MMC_TIMING_MMC_DDR52   8
+#define MMC_TIMING_MMC_HS200   9
+#define MMC_TIMING_MMC_HS400   10
+
 /* Driver model support */
 
 /**
@@ -377,7 +391,7 @@ struct mmc_uclass_priv {
  * @dev:       Device
  * @return associated mmc struct pointer if available, else NULL
  */
-struct mmc *mmc_get_mmc_dev(struct udevice *dev);
+struct mmc *mmc_get_mmc_dev(const struct udevice *dev);
 
 /* End of driver model support */
 
@@ -421,6 +435,14 @@ struct dm_mmc_ops {
         */
        int (*deferred_probe)(struct udevice *dev);
        /**
+        * reinit() - Re-initialization to clear old configuration for
+        * mmc rescan.
+        *
+        * @dev:        Device to reinit
+        * @return 0 if Ok, -ve if error
+        */
+       int (*reinit)(struct udevice *dev);
+       /**
         * send_cmd() - Send a command to the MMC device
         *
         * @dev:        Device to receive the command
@@ -491,6 +513,27 @@ struct dm_mmc_ops {
         * @return 0 if not present, 1 if present, -ve on error
         */
        int (*host_power_cycle)(struct udevice *dev);
+
+       /**
+        * get_b_max - get maximum length of single transfer
+        *             Called before reading blocks from the card,
+        *             useful for system which have e.g. DMA limits
+        *             on various memory ranges.
+        *
+        * @dev:        Device to check
+        * @dst:        Destination buffer in memory
+        * @blkcnt:     Total number of blocks in this transfer
+        * @return maximum number of blocks for this transfer
+        */
+       int (*get_b_max)(struct udevice *dev, void *dst, lbaint_t blkcnt);
+
+       /**
+        * hs400_prepare_ddr - prepare to switch to DDR mode
+        *
+        * @dev:        Device to check
+        * @return 0 if success, -ve on error
+        */
+       int (*hs400_prepare_ddr)(struct udevice *dev);
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -504,6 +547,8 @@ int dm_mmc_execute_tuning(struct udevice *dev, uint opcode);
 int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout_us);
 int dm_mmc_host_power_cycle(struct udevice *dev);
 int dm_mmc_deferred_probe(struct udevice *dev);
+int dm_mmc_reinit(struct udevice *dev);
+int dm_mmc_get_b_max(struct udevice *dev, void *dst, lbaint_t blkcnt);
 
 /* Transition functions for compatibility */
 int mmc_set_ios(struct mmc *mmc);
@@ -514,7 +559,9 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us);
 int mmc_set_enhanced_strobe(struct mmc *mmc);
 int mmc_host_power_cycle(struct mmc *mmc);
 int mmc_deferred_probe(struct mmc *mmc);
-
+int mmc_reinit(struct mmc *mmc);
+int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt);
+int mmc_hs400_prepare_ddr(struct mmc *mmc);
 #else
 struct mmc_ops {
        int (*send_cmd)(struct mmc *mmc,
@@ -524,7 +571,13 @@ struct mmc_ops {
        int (*getcd)(struct mmc *mmc);
        int (*getwp)(struct mmc *mmc);
        int (*host_power_cycle)(struct mmc *mmc);
+       int (*get_b_max)(struct mmc *mmc, void *dst, lbaint_t blkcnt);
 };
+
+static inline int mmc_hs400_prepare_ddr(struct mmc *mmc)
+{
+       return 0;
+}
 #endif
 
 struct mmc_config {
@@ -680,6 +733,7 @@ struct mmc {
                                  * accessing the boot partitions
                                  */
        u32 quirks;
+       u8 hs400_tuning;
 };
 
 struct mmc_hwpart_conf {
@@ -871,6 +925,8 @@ void mmc_set_preinit(struct mmc *mmc, int preinit);
 #define mmc_host_is_spi(mmc)   0
 #endif
 
+#define mmc_dev(x)     ((x)->dev)
+
 void board_mmc_power_init(void);
 int board_mmc_init(struct bd_info *bis);
 int cpu_mmc_init(struct bd_info *bis);
@@ -907,6 +963,15 @@ struct blk_desc *mmc_get_blk_desc(struct mmc *mmc);
  */
 int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd);
 
+/**
+ * mmc_boot_wp() - power on write protect boot partitions
+ *
+ * The boot partitions are write protected until the next power cycle.
+ *
+ * Return:     0 for success
+ */
+int mmc_boot_wp(struct mmc *mmc);
+
 static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
 {
        return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;