From patchwork Wed Aug 21 13:50:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 2847751 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9BD3BBF546 for ; Wed, 21 Aug 2013 13:50:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60FC320490 for ; Wed, 21 Aug 2013 13:50:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01224203D9 for ; Wed, 21 Aug 2013 13:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751719Ab3HUNuw (ORCPT ); Wed, 21 Aug 2013 09:50:52 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:44177 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816Ab3HUNuv (ORCPT ); Wed, 21 Aug 2013 09:50:51 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MRV00AQKVSQBOD0@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Wed, 21 Aug 2013 22:50:50 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.49]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 80.3A.17404.AB5C4125; Wed, 21 Aug 2013 22:50:50 +0900 (KST) X-AuditID: cbfee68d-b7f096d0000043fc-c3-5214c5bad01c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D6.2B.32250.AB5C4125; Wed, 21 Aug 2013 22:50:50 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MRV00FW2VSQZ240@mmp1.samsung.com>; Wed, 21 Aug 2013 22:50:50 +0900 (KST) From: Seungwon Jeon To: linux-mmc@vger.kernel.org Cc: 'Chris Ball' , 'Jaehoon Chung' , 'Alim Akhtar' References: In-reply-to: Subject: [PATCH 08/14] mmc: dw_mmc: control card read threshold Date: Wed, 21 Aug 2013 22:50:50 +0900 Message-id: <002d01ce9e75$72443d00$56ccb700$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac03z3aCvVFr8FaITt2vKVQKst76fw3OcIrwS9fJ1BA= Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsVy+t8zQ91dR0WCDF6/0rF4MG8bm8X21xvZ LG78amO1OPK/n9GBxePQlbWMHn1bVjF6fN4kF8AcxWWTkpqTWZZapG+XwJXR1fKSpeCoTMWE rsVMDYzzxbsYOTkkBEwkrkz+yA5hi0lcuLeeDcQWEljGKDH3r28XIwdYzaGF3l2MXEDhRYwS t65fZ4Zw/jBKnNm8FayBTUBL4u+bN8wgtoiArMTPPxfA4swCZRJv79xnBhkkJMAtsbo5CCTM KcAjse5PJ1i5sIC9xJX7x8BuYBFQlXg+bQYriM0rYCtx8OcWFghbUOLH5HssIGOYBdQlpkzJ hZguL7F5zVtmiDPVJR791YU4wEri8PIjrBAlIhL7XrxjBLlYQuAUu8Sqa1+YIFYJSHybfIgF oldWYtMBZkgoSEocXHGDZQKjxCwki2chLJ6FZPEsJBsWMLKsYhRNLUguKE5KLzLUK07MLS7N S9dLzs/dxAiJwd4djLcPWB9iTAbaPpF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omSSotbBu+86 NKsO/P/BxXX4cl3iRLk8B8fzi5cxrN6w4CLzCS2lRVcM+bSuGXvtXVgv66PGITU/ge+xU+3H bCEB9+n+RQl31NiOayuxFGckGmoxFxUnAgAT6gNMNQMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 1b6f8985c0e77ac0022f86d80408cbc7b5b01ae1 Mon Sep 17 00:00:00 2001 From: Seungwon Jeon Date: Tue, 13 Aug 2013 16:03:18 +0900 Subject: [PATCH 08/14] mmc: dw_mmc: control card read threshold Card Read Threshold should be ensured that the card clock does not stop in the middle of a block of data being transferred from the card to the Host. Specially, clock stop is allowed in fast transfer such as HS200 or SDR104 mode. And so, it should be enabled. Signed-off-by: Seungwon Jeon --- drivers/mmc/host/dw_mmc.c | 38 ++++++++++++++++++++++++++++++++++++-- drivers/mmc/host/dw_mmc.h | 3 +++ include/linux/mmc/dw_mmc.h | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index b8ba707..486024c 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -570,6 +570,37 @@ done: #endif } +static void dw_mci_ctrl_rd_thld(struct dw_mci *host, struct mmc_data *data) +{ + unsigned int blksz = data->blksz; + u32 blksz_depth, fifo_depth; + u16 thld_size; + + WARN_ON(!(data->flags & MMC_DATA_READ)); + + if (host->timing != MMC_TIMING_MMC_HS200 && + host->timing != MMC_TIMING_UHS_SDR104) + goto disable; + + blksz_depth = blksz / (1 << host->data_shift); + fifo_depth = host->fifo_depth; + + if (blksz_depth > fifo_depth) + goto disable; + + /* + * If (blksz_depth) >= (fifo_depth >> 1), should be 'thld_size <= blksz' + * If (blksz_depth) < (fifo_depth >> 1), should be thld_size = blksz + * Currently just choose blksz. + */ + thld_size = blksz; + mci_writel(host, CDTHRCTL, SDMMC_SET_RD_THLD(thld_size, 1)); + return; + +disable: + mci_writel(host, CDTHRCTL, SDMMC_SET_RD_THLD(0, 0)); +} + static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) { int sg_len; @@ -627,10 +658,12 @@ static void dw_mci_submit_data(struct dw_mci *host, struct mmc_data *data) host->sg = NULL; host->data = data; - if (data->flags & MMC_DATA_READ) + if (data->flags & MMC_DATA_READ) { host->dir_status = DW_MCI_RECV_STATUS; - else + dw_mci_ctrl_rd_thld(host, data); + } else { host->dir_status = DW_MCI_SEND_STATUS; + } if (dw_mci_submit_data_dma(host, data)) { int flags = SG_MITER_ATOMIC; @@ -867,6 +900,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) regs &= ~((0x1 << slot->id) << 16); mci_writel(slot->host, UHS_REG, regs); + slot->host->timing = ios->timing; if (ios->clock) { /* diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index 4002c84..4b8e19d 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h @@ -53,6 +53,7 @@ #define SDMMC_IDINTEN 0x090 #define SDMMC_DSCADDR 0x094 #define SDMMC_BUFADDR 0x098 +#define SDMMC_CDTHRCTL 0x100 #define SDMMC_DATA(x) (x) /* @@ -146,6 +147,8 @@ #define SDMMC_IDMAC_SWRESET BIT(0) /* Version ID register define */ #define SDMMC_GET_VERID(x) ((x) & 0xFFFF) +/* Card read threshold */ +#define SDMMC_SET_RD_THLD(v, x) (((v) & 0x1FFF) << 16 | (x)) /* Register access macros */ #define mci_readl(dev, reg) \ diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 4ec9dcc..a829f7e 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -130,6 +130,7 @@ struct dw_mci { struct mmc_command *cmd; struct mmc_data *data; unsigned int prev_blksz; + unsigned char timing; struct workqueue_struct *card_workqueue; /* DMA interface members*/