]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
feat(st-sdmmc2): define FIFO size
authorYann Gautier <yann.gautier@foss.st.com>
Wed, 5 May 2021 11:47:56 +0000 (13:47 +0200)
committerYann Gautier <yann.gautier@st.com>
Tue, 16 Aug 2022 13:58:22 +0000 (15:58 +0200)
Instead of using hard-coded values in stm32_sdmmc2_read() function,
use a defined SDMMC_FIFO_SIZE, which is 64 on STM32MP1.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I1ace0a28fbddae474379f0187371b9c360ceb7b3

drivers/st/mmc/stm32_sdmmc2.c

index c9bad711ce93e4b5200b9d205e2e14c4492e8f23..6bdd782aeab3fa9c3b9f166e21d041fc4001bcac 100644 (file)
 #define DT_SDMMC2_COMPAT               "st,stm32-sdmmc2"
 #endif
 
+#define SDMMC_FIFO_SIZE                        64U
+
 static void stm32_sdmmc2_init(void);
 static int stm32_sdmmc2_send_cmd_req(struct mmc_cmd *cmd);
 static int stm32_sdmmc2_send_cmd(struct mmc_cmd *cmd);
@@ -644,7 +646,7 @@ static int stm32_sdmmc2_read(int lba, uintptr_t buf, size_t size)
                        return -ETIMEDOUT;
                }
 
-               if (size < (8U * sizeof(uint32_t))) {
+               if (size < (SDMMC_FIFO_SIZE / 2U)) {
                        if ((mmio_read_32(base + SDMMC_DCNTR) > 0U) &&
                            ((status & SDMMC_STAR_RXFIFOE) == 0U)) {
                                *buffer = mmio_read_32(fifo_reg);
@@ -654,7 +656,8 @@ static int stm32_sdmmc2_read(int lba, uintptr_t buf, size_t size)
                        uint32_t count;
 
                        /* Read data from SDMMC Rx FIFO */
-                       for (count = 0; count < 8U; count++) {
+                       for (count = 0; count < (SDMMC_FIFO_SIZE / 2U);
+                            count += sizeof(uint32_t)) {
                                *buffer = mmio_read_32(fifo_reg);
                                buffer++;
                        }