Skip to content

Commit 889c9e0

Browse files
AxelLinstorulf
authored andcommitted
mmc: wmt-sdmmc: Fix settting BM_EIGHTBIT_MODE bit in wmt_mci_set_ios()
For MMC_BUS_WIDTH_8 case, current code missed setting BM_EIGHTBIT_MODE bit. Also has a small refactor to make the code looks better in readability. So the bit settings witch below logic: SDMMC_BUSMODE register: Set EIGHTBIT_MODE bit for 8 bit mode, Set FOURBIT_MODE bit for 4 bit mode. Clear both EIGHTBIT_MODE and FOURBIT_MODE bits for 1 bit mode. SDMMC_EXTCTRL register: Set EXT_EIGHTBIT bit for 8 bit mode, Clear EXT_EIGHTBIT bit for 1/4 bit mode. Add define for EXT_EIGHTBIT to avoid using magic number. BM_ONEBIT_MASK is no longer used, thus remove it. This patch is untested due to lack of platform with 8-bit hardware. However since the code is there, it's good to make the code match the document. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 5e86366 commit 889c9e0

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

drivers/mmc/host/wmt-sdmmc.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
#define BM_SPI_CS 0x20
7373
#define BM_SD_POWER 0x40
7474
#define BM_SOFT_RESET 0x80
75-
#define BM_ONEBIT_MASK 0xFD
7675

7776
/* SDMMC_BLKLEN bit fields */
7877
#define BLKL_CRCERR_ABORT 0x0800
@@ -120,6 +119,8 @@
120119
#define STS2_DATARSP_BUSY 0x20
121120
#define STS2_DIS_FORCECLK 0x80
122121

122+
/* SDMMC_EXTCTRL bit fields */
123+
#define EXT_EIGHTBIT 0x04
123124

124125
/* MMC/SD DMA Controller Registers */
125126
#define SDDMA_GCR 0x100
@@ -672,7 +673,7 @@ static void wmt_mci_request(struct mmc_host *mmc, struct mmc_request *req)
672673
static void wmt_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
673674
{
674675
struct wmt_mci_priv *priv;
675-
u32 reg_tmp;
676+
u32 busmode, extctrl;
676677

677678
priv = mmc_priv(mmc);
678679

@@ -687,28 +688,26 @@ static void wmt_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
687688
if (ios->clock != 0)
688689
clk_set_rate(priv->clk_sdmmc, ios->clock);
689690

691+
busmode = readb(priv->sdmmc_base + SDMMC_BUSMODE);
692+
extctrl = readb(priv->sdmmc_base + SDMMC_EXTCTRL);
693+
694+
busmode &= ~(BM_EIGHTBIT_MODE | BM_FOURBIT_MODE);
695+
extctrl &= ~EXT_EIGHTBIT;
696+
690697
switch (ios->bus_width) {
691698
case MMC_BUS_WIDTH_8:
692-
reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL);
693-
writeb(reg_tmp | 0x04, priv->sdmmc_base + SDMMC_EXTCTRL);
699+
busmode |= BM_EIGHTBIT_MODE;
700+
extctrl |= EXT_EIGHTBIT;
694701
break;
695702
case MMC_BUS_WIDTH_4:
696-
reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
697-
writeb(reg_tmp | BM_FOURBIT_MODE, priv->sdmmc_base +
698-
SDMMC_BUSMODE);
699-
700-
reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL);
701-
writeb(reg_tmp & 0xFB, priv->sdmmc_base + SDMMC_EXTCTRL);
703+
busmode |= BM_FOURBIT_MODE;
702704
break;
703705
case MMC_BUS_WIDTH_1:
704-
reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
705-
writeb(reg_tmp & BM_ONEBIT_MASK, priv->sdmmc_base +
706-
SDMMC_BUSMODE);
707-
708-
reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL);
709-
writeb(reg_tmp & 0xFB, priv->sdmmc_base + SDMMC_EXTCTRL);
710706
break;
711707
}
708+
709+
writeb(busmode, priv->sdmmc_base + SDMMC_BUSMODE);
710+
writeb(extctrl, priv->sdmmc_base + SDMMC_EXTCTRL);
712711
}
713712

714713
static int wmt_mci_get_ro(struct mmc_host *mmc)

0 commit comments

Comments
 (0)