]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - include/sdhci.h
mmc: sdhci: Fix potential ADMA descriptor table overflow
[thirdparty/u-boot.git] / include / sdhci.h
index a1b74e3bd79905e165a2c55421a516c9a7ebce34..2dd13b4c714a5c1d85c89aa0351a1303db0efcbb 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/bitops.h>
 #include <linux/types.h>
+#include <linux/kernel.h>
 #include <asm/io.h>
 #include <mmc.h>
 #include <asm/gpio.h>
@@ -291,6 +292,11 @@ struct sdhci_ops {
         * Return: 0 if successful, -ve on error
         */
        int     (*set_enhanced_strobe)(struct sdhci_host *host);
+
+#ifdef CONFIG_MMC_SDHCI_ADMA_HELPERS
+       void    (*adma_write_desc)(struct sdhci_host *host, void **desc,
+                                  dma_addr_t addr, int len, bool end);
+#endif
 };
 
 #define ADMA_MAX_LEN   65532
@@ -299,8 +305,8 @@ struct sdhci_ops {
 #else
 #define ADMA_DESC_LEN  8
 #endif
-#define ADMA_TABLE_NO_ENTRIES (CONFIG_SYS_MMC_MAX_BLK_COUNT * \
-                              MMC_MAX_BLOCK_LEN) / ADMA_MAX_LEN
+#define ADMA_TABLE_NO_ENTRIES DIV_ROUND_UP(CONFIG_SYS_MMC_MAX_BLK_COUNT * \
+                             MMC_MAX_BLOCK_LEN, ADMA_MAX_LEN)
 
 #define ADMA_TABLE_SZ (ADMA_TABLE_NO_ENTRIES * ADMA_DESC_LEN)
 
@@ -526,8 +532,11 @@ extern const struct dm_mmc_ops sdhci_ops;
 #else
 #endif
 
+void sdhci_adma_write_desc(struct sdhci_host *host, void **next_desc,
+                          dma_addr_t addr, int len, bool end);
 struct sdhci_adma_desc *sdhci_adma_init(void);
-void sdhci_prepare_adma_table(struct sdhci_adma_desc *table,
-                             struct mmc_data *data, dma_addr_t addr);
+void sdhci_prepare_adma_table(struct sdhci_host *host,
+                             struct sdhci_adma_desc *table,
+                             struct mmc_data *data, dma_addr_t start_addr);
 
 #endif /* __SDHCI_HW_H */