From patchwork Tue Aug 15 07:27:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 9901191 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C55E060244 for ; Tue, 15 Aug 2017 07:34:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4E38203C0 for ; Tue, 15 Aug 2017 07:34:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A95332766D; Tue, 15 Aug 2017 07:34:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 450C6203C0 for ; Tue, 15 Aug 2017 07:34:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753222AbdHOHd6 (ORCPT ); Tue, 15 Aug 2017 03:33:58 -0400 Received: from mga05.intel.com ([192.55.52.43]:2148 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753185AbdHOHd5 (ORCPT ); Tue, 15 Aug 2017 03:33:57 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 15 Aug 2017 00:33:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,376,1498546800"; d="scan'208";a="890039038" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by FMSMGA003.fm.intel.com with ESMTP; 15 Aug 2017 00:33:54 -0700 Subject: Re: [RFC PATCH 1/7] mmc: sdhci: Add quirk to indicate no CRC stripping in MMC_RSP_136 To: Kishon Vijay Abraham I , Ulf Hansson , Tony Lindgren , Rob Herring Cc: nsekhar@ti.com, linux-omap@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170807160142.12134-1-kishon@ti.com> <20170807160142.12134-2-kishon@ti.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <872c7194-3d48-47e5-6396-7189bf841a42@intel.com> Date: Tue, 15 Aug 2017 10:27:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170807160142.12134-2-kishon@ti.com> Content-Language: en-US Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 07/08/17 19:01, Kishon Vijay Abraham I wrote: > TI's implementation of sdhci controller used in DRA7 SoC's doesn't > strip CRC in responses with length 136 bits. Add quirk to indicate > the controller does not strip CRC in MMC_RSP_136. If this quirk is > set sdhci library shouldn't shift the response present in > SDHCI_RESPONSE register. > > Signed-off-by: Kishon Vijay Abraham I > --- > drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- > drivers/mmc/host/sdhci.h | 2 ++ > 2 files changed, 21 insertions(+), 8 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index ecd0d4350e8a..ece3751d2a25 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -1182,14 +1182,25 @@ static void sdhci_finish_command(struct sdhci_host *host) > > if (cmd->flags & MMC_RSP_PRESENT) { > if (cmd->flags & MMC_RSP_136) { > - /* CRC is stripped so we need to do some shifting. */ > - for (i = 0;i < 4;i++) { > - cmd->resp[i] = sdhci_readl(host, > - SDHCI_RESPONSE + (3-i)*4) << 8; > - if (i != 3) > - cmd->resp[i] |= > - sdhci_readb(host, > - SDHCI_RESPONSE + (3-i)*4-1); > + if (!(host->quirks2 & SDHCI_QUIRK2_NO_CRC_STRIPPING)) { This is about the 136-bit response so let's put that in the quirk name. How about SDHCI_QUIRK2_RSP_136_HAS_CRC > + /* > + * CRC is stripped so we need to do some > + * shifting. > + */ > + for (i = 0; i < 4; i++) { > + cmd->resp[i] = > + sdhci_readl(host, SDHCI_RESPONSE > + + (3 - i) * 4) << 8; > + if (i != 3) > + cmd->resp[i] |= > + sdhci_readb(host, SDHCI_RESPONSE > + + (3 - i) * 4 - 1); > + } > + } else { > + for (i = 0; i < 4; i++) > + cmd->resp[i] = > + sdhci_readl(host, SDHCI_RESPONSE + > + (3 - i) * 4); > } This is all very jammed up against the 80 column margin. Please make a new patch to separate it into a new function sdhci_read_rsp_136() and then another patch to add the quirk. i.e. completely untested! From: Adrian Hunter Date: Tue, 15 Aug 2017 10:22:09 +0300 Subject: [PATCH] mmc: sdhci: Tidy reading 136-bit responses Read each register only once and move the code to a separate function so that it is not jammed against the 80 column margin. Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 32a0e8f6fb04..21d0b36d642f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1173,6 +1173,23 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) } EXPORT_SYMBOL_GPL(sdhci_send_command); +static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd) +{ + int i, reg; + + for (i = 0; i < 4; i++) { + reg = SDHCI_RESPONSE + (3 - i) * 4; + cmd->resp[i] = sdhci_readl(host, reg); + } + + /* CRC is stripped so we need to do some shifting */ + for (i = 0; i < 4; i++) { + cmd->resp[i] =<< 8; + if (i != 3) + cmd->resp[i] |= cmd->resp[i + 1] >> 24; + } +} + static void sdhci_finish_command(struct sdhci_host *host) { struct mmc_command *cmd = host->cmd; @@ -1182,15 +1199,7 @@ static void sdhci_finish_command(struct sdhci_host *host) if (cmd->flags & MMC_RSP_PRESENT) { if (cmd->flags & MMC_RSP_136) { - /* CRC is stripped so we need to do some shifting. */ - for (i = 0;i < 4;i++) { - cmd->resp[i] = sdhci_readl(host, - SDHCI_RESPONSE + (3-i)*4) << 8; - if (i != 3) - cmd->resp[i] |= - sdhci_readb(host, - SDHCI_RESPONSE + (3-i)*4-1); - } + sdhci_read_rsp_136(host, cmd); } else { cmd->resp[0] = sdhci_readl(host, SDHCI_RESPONSE); }