diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c index aa93af6..f93ddfa 100644 --- a/drivers/mci/imx-esdhc-pbl.c +++ b/drivers/mci/imx-esdhc-pbl.c @@ -28,11 +28,13 @@ #include "imx-esdhc.h" #define SECTOR_SIZE 512 +#define SECTOR_WML (SECTOR_SIZE / sizeof(u32)) struct esdhc { void __iomem *regs; bool is_mx6; bool is_be; + bool wrap_wml; }; static uint32_t esdhc_read32(struct esdhc *esdhc, int reg) @@ -107,7 +109,7 @@ } } - for (i = 0; i < SECTOR_SIZE / sizeof(uint32_t); i++) { + for (i = 0; i < SECTOR_WML; i++) { databuf = esdhc_read32(esdhc, SDHCI_BUFFER); *((u32 *)buffer) = databuf; buffer += 4; @@ -203,7 +205,7 @@ { struct mci_cmd cmd; struct mci_data data; - u32 val; + u32 val, wml; int ret; esdhc_write32(esdhc, SDHCI_INT_ENABLE, @@ -212,7 +214,18 @@ IRQSTATEN_DTOE | IRQSTATEN_DCE | IRQSTATEN_DEBE | IRQSTATEN_DINT); - esdhc_write32(esdhc, IMX_SDHCI_WML, 0x0); + wml = FIELD_PREP(WML_WR_BRST_LEN, 16) | + FIELD_PREP(WML_WR_WML_MASK, SECTOR_WML) | + FIELD_PREP(WML_RD_BRST_LEN, 16) | + FIELD_PREP(WML_RD_WML_MASK, SECTOR_WML); + /* + * Some SoCs intrpret 0 as MAX value so for those cases the + * above value translates to zero + */ + if (esdhc->wrap_wml) + wml = 0; + + esdhc_write32(esdhc, IMX_SDHCI_WML, wml); val = esdhc_read32(esdhc, SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET); val |= SYSCTL_HCKEN | SYSCTL_IPGEN; @@ -388,6 +401,7 @@ esdhc.is_be = 0; esdhc.is_mx6 = 1; + esdhc.wrap_wml = false; return esdhc_start_image(&esdhc, 0x10000000, 0x10000000, 0); } @@ -421,6 +435,7 @@ esdhc.is_be = 0; esdhc.is_mx6 = 1; + esdhc.wrap_wml = false; return esdhc_start_image(&esdhc, MX8MQ_DDR_CSD1_BASE_ADDR, MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K); @@ -447,6 +462,7 @@ esdhc.is_be = 0; esdhc.is_mx6 = 1; + esdhc.wrap_wml = false; /* * We expect to be running at MX8MQ_ATF_BL33_BASE_ADDR where the atf @@ -503,6 +519,7 @@ struct esdhc esdhc = { .regs = IOMEM(0x01560000), .is_be = true, + .wrap_wml = true, }; unsigned long sdram = 0x80000000; void (*barebox)(unsigned long, unsigned long, unsigned long) = diff --git a/drivers/mci/imx-esdhc.h b/drivers/mci/imx-esdhc.h index 9b79346..2d54719 100644 --- a/drivers/mci/imx-esdhc.h +++ b/drivers/mci/imx-esdhc.h @@ -24,6 +24,7 @@ #include #include +#include #define SYSCTL_INITA 0x08000000 #define SYSCTL_TIMEOUT_MASK 0x000f0000 @@ -43,7 +44,9 @@ #define WML_WRITE 0x00010000 #define WML_RD_WML_MASK 0xff +#define WML_WR_BRST_LEN GENMASK(28, 24) #define WML_WR_WML_MASK 0xff0000 +#define WML_RD_BRST_LEN GENMASK(12, 8) #define BLKATTR_CNT(x) ((x & 0xffff) << 16) #define BLKATTR_SIZE(x) (x & 0x1fff)