From patchwork Wed Nov 7 15:03:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 150406 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5277796ljp; Wed, 7 Nov 2018 07:06:38 -0800 (PST) X-Google-Smtp-Source: AJdET5esNug7tJ8UjjNTVFEjiRl9iWbfPX9GZGTKGoFXm93UVJhYCvuXWPtmS+hMo4vk1oK02YnO X-Received: by 2002:a17:906:9a9:: with SMTP id q9-v6mr377621eje.7.1541603198386; Wed, 07 Nov 2018 07:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541603198; cv=none; d=google.com; s=arc-20160816; b=rVjokwLVwdvW5vRMqoidrgXQ11qtkujm3ekQmblEmMtVd19CVLqeHClRp8mhtD4baS MxcagmO6AsvV5EbRDURQiWEx7eMqTEOsvP9+923bzBROvHrS2kP4IGS2VqxxPOeuXZfg BdfMvQ2PdsBL5meaCpZX39ZgyPni9KgJDkfsM8MR1rgAzLiO4BzkB88OyH9Fq0RjF8Lt uaWmbd1lR68a2mx7RUJBQT+I1mCcu+7+pShnu2Cer/BDd+HhqBV6c29IsUeRAbmHKBAL eTbmY2ZWdqqZRP2HZvBJu/fkBPiX08Su/ePDPv2wQbpFL9ErgAFPOmkutl0UMNw92t1d 4SSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:cms-type:in-reply-to :message-id:date:to:from:dkim-signature:dkim-filter; bh=VdrYSqDy+KADEAmwwuh6a5833DR4Y2fefEnR4wvWR2M=; b=Mx1deD25pQEVAM5T8XgkebJmrg0XOipmb8jUGNeE79YynOPndy4O9aHCMbHR+/G+73 OzqsjJt6XnKpxa4WNB60/cxWCfnLHeLaG+aHyMt66WTtyD8xX6IJ99IgKBaY4pLGaRSf iTQQv7kituFCc66NOTl08SqJDuibUAqeWrvCKEg211XxQBzGnGSdoHFtEvsA5vUWwydu II9K1JFdbbli3zwrEUX0X62d+4Ki5rUoRyrFMVuo5NYs8nYQ8KWzwMJ0SXRRDVqe34/e rW0cziRCRNIDZ2YOxRLom5LdifvlUj1XpO1lNTLxOvj/YKyLKiMHLZWofvgYD1RtAGRh 8Jdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=ezGxaMrT; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id k24si637449edx.435.2018.11.07.07.06.37; Wed, 07 Nov 2018 07:06:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=ezGxaMrT; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: by lists.denx.de (Postfix, from userid 105) id C164EC224CC; Wed, 7 Nov 2018 15:04:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C631BC224CC; Wed, 7 Nov 2018 15:04:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 37EBFC224FB; Wed, 7 Nov 2018 15:03:18 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lists.denx.de (Postfix) with ESMTPS id C1DB8C224DA for ; Wed, 7 Nov 2018 15:03:14 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181107150314euoutp014d766df0797b1ef869c30018f752c899~k38F1_pLK2202622026euoutp01A; Wed, 7 Nov 2018 15:03:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181107150314euoutp014d766df0797b1ef869c30018f752c899~k38F1_pLK2202622026euoutp01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541602994; bh=cwmMRfBa3lRMbHQnCsuv++nDsPcl/CxdffUcPd+XMO4=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=ezGxaMrT+859NoHfVm7NU8wTsBCxEy99tZb5MljgwMYIOF7drl3I723h2SmGIY65m mb6Hv8FGsXo+L39ouRZRvTOs4EZvAGH9bwFyLnhqKFXTZlMimwmZ0vF0+i3x2oUcaa hCNyiPpRAt90zTgb+2+p3W/2cahBbyFMBQ+9+Rxo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181107150314eucas1p2a7b04189112cd24f6e094b27d4998ef1~k38FaOGQd2090820908eucas1p2z; Wed, 7 Nov 2018 15:03:13 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 39.E5.04294.1BEF2EB5; Wed, 7 Nov 2018 15:03:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181107150313eucas1p1a29ae2865d3dbe16dd784e228d3e5124~k38EyCqNb1569715697eucas1p16; Wed, 7 Nov 2018 15:03:13 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-93-5be2feb101c6 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5C.51.04284.1BEF2EB5; Wed, 7 Nov 2018 15:03:13 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PHT00D5AWH9FF60@eusync1.samsung.com>; Wed, 07 Nov 2018 15:03:13 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Date: Wed, 07 Nov 2018 16:03:08 +0100 Message-id: <20181107150308.23267-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181107150105.23165-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRmVeSWpSXmKPExsWy7djPc7ob/z2KNpjwzMBi44z1rBY3frWx Wjx/d5nJYu2Ru+wWHUdaGC3e7u1kd2DzmDfrBIvH2Ts7GD36tqxiDGCO4rJJSc3JLEst0rdL 4Mr4sXcSY8E7s4ppR7YxNzA263QxcnJICJhIHJzRz97FyMUhJLCCUaLt93lWCOczo8TtJVcY YarW/d3LBmILCSxjlOi+IgtR1MAkcWBFA1gRm4ChRNfbLrAiEQEJiV/9V8HizALXGCVmbVcE sYUFrCUW/r7MDmKzCKhKfJ9yggXE5hWwlXh5eD0zxDJ5idUbDoDZnAJ2Et09k1lAlkkIfGSV WL79PjtEkYtE4+MuqOuEJV4d3wIVl5Ho7DjIBNHQzCjRPmMWO4TTwyixdc4ONogqa4nDxy+y QpzHJzFp23SgdRxAcV6JjjYhiBIPiRX3H0LDYiKjxMrPO5kmMEouYGRYxSieWlqcm55abJSX Wq5XnJhbXJqXrpecn7uJERhnp/8d/7KDcdefpEOMAhyMSjy8F7Y+jBZiTSwrrsw9xCjBwawk wtu7+lG0EG9KYmVValF+fFFpTmrxIUZpDhYlcd5qhgfRQgLpiSWp2ampBalFMFkmDk6pBsae RKtwht+r5SacSmnOn/8o3Nl2x+XPj99ee/BvhZ/AHPmIc2nFPT9m3JO3dLSpt7FNf5fScICz +Ce/CnuvofmF+1M57qs3n355hvvS5i29K7dX7VOfdK1t7+fuBrbyDbtXylxsf7utY96WQtNZ 0x4yiG/atbvup8DdH9sUD+2dM/Os4ZFDtYc4lFiKMxINtZiLihMBCBLBm68CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t/xy7ob/z2KNri7gd9i44z1rBY3frWx Wjx/d5nJYu2Ru+wWHUdaGC3e7u1kd2DzmDfrBIvH2Ts7GD36tqxiDGCO4rJJSc3JLEst0rdL 4Mr4sXcSY8E7s4ppR7YxNzA263QxcnJICJhIrPu7l62LkYtDSGAJo8T6W/MZIZwmJonDP+Yx g1SxCRhKdL3tYgOxRQQkJH71XwUrYha4wShx5/xPdpCEsIC1xMLfl8FsFgFVie9TTrCA2LwC thIvD69nhlgnL7F6wwEwm1PATqK7ZzJYjRBQzcOr5xknMPIsYGRYxSiSWlqcm55bbKhXnJhb XJqXrpecn7uJERgi24793LyD8dLG4EOMAhyMSjy8GjseRguxJpYVV+YeYpTgYFYS4e1d/Sha iDclsbIqtSg/vqg0J7X4EKM0B4uSOO95g8ooIYH0xJLU7NTUgtQimCwTB6dUA2PlWt/NzWau UXxcZsae+bq3311KXLDjlkzIZ9HuL/f8Y00dzMMtpCc/FOved+Xa/oXbDHUv1VqfnO8bWPUs Yf5Z9oOPvzR7PW6p357KalhnL5O3SD2T/8B73eVPKxIuCh3MOiAWzBs4Z98i4dTatBd5JYuO GPRwvEpd8OljRsVcgaXTp01P2qbEUpyRaKjFXFScCAADAfeXDQIAAA== X-CMS-MailID: 20181107150313eucas1p1a29ae2865d3dbe16dd784e228d3e5124 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181107150313eucas1p1a29ae2865d3dbe16dd784e228d3e5124 References: <20181107150105.23165-1-m.szyprowski@samsung.com> Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski Subject: [U-Boot] [PATCH 5/9] mmc: dw_mmc: add support for 64bit DMA X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Lukasz Majewski DW-MMC module in Samsung Exynos5433 requires 64bit DMA descriptors. This patch adds code for handling them. Signed-off-by: Lukasz Majewski [extracted from old sources and adapted to mainline u-boot, minor fixes] Signed-off-by: Marek Szyprowski --- drivers/mmc/dw_mmc.c | 53 ++++++++++++++++++++++++++++++------- drivers/mmc/exynos_dw_mmc.c | 6 +++++ include/dwmmc.h | 25 +++++++++++++++++ 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 3c702b3ed8..f50eb29ac9 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -30,8 +30,8 @@ static int dwmci_wait_reset(struct dwmci_host *host, u32 value) return 0; } -static void dwmci_set_idma_desc(struct dwmci_idmac *idmac, - u32 desc0, u32 desc1, u32 desc2) +static void dwmci_set_idma_desc_32bit(void *idmac, + u32 desc0, u32 desc1, u32 desc2) { struct dwmci_idmac *desc = idmac; @@ -41,11 +41,27 @@ static void dwmci_set_idma_desc(struct dwmci_idmac *idmac, desc->next_addr = (ulong)desc + sizeof(struct dwmci_idmac); } +static void dwmci_set_idma_desc_64bit(void *idmac, + u32 desc0, u32 desc1, u32 desc2) +{ + struct dwmci_idmac_64addr *desc = idmac; + + desc->flags = desc0; + desc->_res1 = 0; + desc->cnt = desc1; + desc->_res2 = 0; + desc->addrl = desc2; + desc->addrh = 0; + desc->next_addrl = (ulong)desc + sizeof(struct dwmci_idmac_64addr); + desc->next_addrh = 0; +} + static void dwmci_prepare_data(struct dwmci_host *host, struct mmc_data *data, - struct dwmci_idmac *cur_idmac, + struct dwmci_idmac_64addr *cur_idmac64, void *bounce_buffer) { + struct dwmci_idmac *cur_idmac = (struct dwmci_idmac *)cur_idmac64; unsigned long ctrl; unsigned int i = 0, flags, cnt, blk_cnt; ulong data_start, data_end; @@ -56,7 +72,12 @@ static void dwmci_prepare_data(struct dwmci_host *host, dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET); data_start = (ulong)cur_idmac; - dwmci_writel(host, DWMCI_DBADDR, (ulong)cur_idmac); + + if (host->dma_64bit_address) { + dwmci_writel(host, DWMCI_DBADDRU, 0); + dwmci_writel(host, DWMCI_DBADDRL, (ulong)cur_idmac64); + } else + dwmci_writel(host, DWMCI_DBADDR, (ulong)cur_idmac); do { flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH ; @@ -67,17 +88,27 @@ static void dwmci_prepare_data(struct dwmci_host *host, } else cnt = data->blocksize * 8; - dwmci_set_idma_desc(cur_idmac, flags, cnt, - (ulong)bounce_buffer + (i * PAGE_SIZE)); + if (host->dma_64bit_address) + dwmci_set_idma_desc_64bit(cur_idmac64, flags, cnt, + (ulong)bounce_buffer + + (i * PAGE_SIZE)); + else + dwmci_set_idma_desc_32bit(cur_idmac, flags, cnt, + (ulong)bounce_buffer + + (i * PAGE_SIZE)); if (blk_cnt <= 8) break; blk_cnt -= 8; cur_idmac++; + cur_idmac64++; i++; } while(1); - data_end = (ulong)cur_idmac; + if (host->dma_64bit_address) + data_end = (ulong)cur_idmac64; + else + data_end = (ulong)cur_idmac; flush_dcache_range(data_start, data_end + ARCH_DMA_MINALIGN); ctrl = dwmci_readl(host, DWMCI_CTRL); @@ -222,7 +253,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, { #endif struct dwmci_host *host = mmc->priv; - ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, + ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac_64addr, cur_idmac64, data ? DIV_ROUND_UP(data->blocks, 8) : 0); int ret = 0, flags = 0, i; unsigned int timeout = 500; @@ -256,7 +287,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, data->blocksize * data->blocks, GEN_BB_READ); } - dwmci_prepare_data(host, data, cur_idmac, + dwmci_prepare_data(host, data, cur_idmac64, bbstate.bounce_buffer); } } @@ -474,7 +505,9 @@ static int dwmci_init(struct mmc *mmc) dwmci_writel(host, DWMCI_TMOUT, 0xFFFFFFFF); - dwmci_writel(host, DWMCI_IDINTEN, 0); + dwmci_writel(host, host->dma_64bit_address ? + DWMCI_IDINTEN64 : DWMCI_IDINTEN, 0); + dwmci_writel(host, DWMCI_BMOD, 1); if (!host->fifoth_val) { diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 435ccac594..3e9d47538c 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -98,6 +98,7 @@ static void exynos_dwmci_board_init(struct dwmci_host *host) static int exynos_dwmci_core_init(struct dwmci_host *host) { + unsigned int addr_config; unsigned int div; unsigned long freq, sclk; @@ -122,6 +123,11 @@ static int exynos_dwmci_core_init(struct dwmci_host *host) host->clksel = exynos_dwmci_clksel; host->get_mmc_clk = exynos_dwmci_get_clk; + addr_config = DWMCI_GET_ADDR_CONFIG(dwmci_readl(host, DWMCI_HCON)); + if (addr_config == 1) + /* host supports IDMAC in 64-bit address mode */ + host->dma_64bit_address = 1; + #ifndef CONFIG_DM_MMC /* Add the mmc channel to be registered with mmc core */ if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) { diff --git a/include/dwmmc.h b/include/dwmmc.h index 0f9d51b557..14db03d7d4 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -48,6 +48,17 @@ #define DWMCI_DSCADDR 0x094 #define DWMCI_BUFADDR 0x098 #define DWMCI_DATA 0x200 +/* + * Registers to support idmac 64-bit address mode + */ +#define DWMCI_DBADDRL 0x088 +#define DWMCI_DBADDRU 0x08c +#define DWMCI_IDSTS64 0x090 +#define DWMCI_IDINTEN64 0x094 +#define DWMCI_DSCADDRL 0x098 +#define DWMCI_DSCADDRU 0x09c +#define DWMCI_BUFADDRL 0x0A0 +#define DWMCI_BUFADDRU 0x0A4 /* Interrupt Mask register */ #define DWMCI_INTMSK_ALL 0xffffffff @@ -132,6 +143,7 @@ /* quirks */ #define DWMCI_QUIRK_DISABLE_SMU (1 << 0) +#define DWMCI_GET_ADDR_CONFIG(x) (((x)>>27) & 0x1) /** * struct dwmci_host - Information about a designware MMC host * @@ -145,6 +157,7 @@ * @dev_id: Arbitrary device ID for use by controller * @buswidth: Bus width in bits (8 or 4) * @fifoth_val: Value for FIFOTH register (or 0 to leave unset) + * @dma_64bit_address: True only for devices supporting 64 bit DMA * @mmc: Pointer to generic MMC structure for this device * @priv: Private pointer for use by controller */ @@ -161,6 +174,7 @@ struct dwmci_host { int dev_id; int buswidth; u32 fifoth_val; + int dma_64bit_address; struct mmc *mmc; void *priv; @@ -196,6 +210,17 @@ struct dwmci_idmac { u32 next_addr; } __aligned(ARCH_DMA_MINALIGN); +struct dwmci_idmac_64addr { + u32 flags; + u32 _res1; + u32 cnt; + u32 _res2; + u32 addrl; + u32 addrh; + u32 next_addrl; + u32 next_addrh; +} __aligned(ARCH_DMA_MINALIGN); + static inline void dwmci_writel(struct dwmci_host *host, int reg, u32 val) { writel(val, host->ioaddr + reg);