From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Pawe=c5=82_Jarosz?= Date: Fri, 18 Aug 2017 11:36:23 +0200 Subject: [U-Boot] [PATCH v4 14/19] mmc: dw_mmc: support transfer mode autodetection In-Reply-To: <127b375c-a03b-70fb-46d8-458990adc4d0@samsung.com> References: <127b375c-a03b-70fb-46d8-458990adc4d0@samsung.com> Message-ID: <8f0d2d0d-8f61-ccd2-0874-63857dce614f@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de Hi, W dniu 18.08.2017 o 09:02, Jaehoon Chung pisze: > On 08/17/2017 10:15 PM, =?UTF-8?q?Pawe=C5=82=20Jarosz?= wrote: >> dw_mmc supports two transfer modes in u-boot: idma and fifo. >> This patch adds autodetection of transfer mode and eliminates setting this in host config struct >> >> Signed-off-by: Paweł Jarosz >> --- >> Changes since v1: >> - none >> >> Changes since v2: >> - none >> >> Changes since v3: >> - none >> >> drivers/mmc/dw_mmc.c | 8 ++++++++ >> include/dwmmc.h | 4 ++++ >> 2 files changed, 12 insertions(+) >> >> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c >> index 700f764..2cc4d67 100644 >> --- a/drivers/mmc/dw_mmc.c >> +++ b/drivers/mmc/dw_mmc.c >> @@ -428,6 +428,7 @@ static int dwmci_set_ios(struct mmc *mmc) >> static int dwmci_init(struct mmc *mmc) >> { >> struct dwmci_host *host = mmc->priv; >> + uint32_t use_dma; > Does it need to use unit32_t for use_dma? SDMMC_GET_TRANS_MODE returns 2 bit value so i guess it can be uint8_t. >> >> if (host->board_init) >> host->board_init(host); >> @@ -439,6 +440,13 @@ static int dwmci_init(struct mmc *mmc) >> return -EIO; >> } >> >> + use_dma = SDMMC_GET_TRANS_MODE(dwmci_readl(host, DWMCI_HCON)); >> + if (use_dma == DMA_INTERFACE_IDMA) { >> + host->fifo_mode = 0; >> + } else { >> + host->fifo_mode = 1; >> + } > Don't need to use the brackets. i will do that in the next version. Thanks for your comments. Regards, Paweł > Best Regards, > Jaehoon Chung > >> + >> /* Enumerate at 400KHz */ >> dwmci_setup_bus(host, mmc->cfg->f_min); >> >> diff --git a/include/dwmmc.h b/include/dwmmc.h >> index 4dda009..269536d 100644 >> --- a/include/dwmmc.h >> +++ b/include/dwmmc.h >> @@ -115,6 +115,10 @@ >> #define RX_WMARK_SHIFT 16 >> #define RX_WMARK_MASK (0xfff << RX_WMARK_SHIFT) >> >> +/* HCON Register */ >> +#define DMA_INTERFACE_IDMA (0x0) >> +#define SDMMC_GET_TRANS_MODE(x) (((x)>>16) & 0x3) >> + >> #define DWMCI_IDMAC_OWN (1 << 31) >> #define DWMCI_IDMAC_CH (1 << 4) >> #define DWMCI_IDMAC_FS (1 << 3) >>