From patchwork Tue Jan 26 11:46:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 8120721 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3D6799F8AA for ; Tue, 26 Jan 2016 11:47:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91F1520274 for ; Tue, 26 Jan 2016 11:47:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F6EE20265 for ; Tue, 26 Jan 2016 11:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965086AbcAZLrq (ORCPT ); Tue, 26 Jan 2016 06:47:46 -0500 Received: from sauhun.de ([89.238.76.85]:58750 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964951AbcAZLrq (ORCPT ); Tue, 26 Jan 2016 06:47:46 -0500 Received: from [176.0.97.172] (port=42100 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1aO25w-0006H7-N0; Tue, 26 Jan 2016 12:47:44 +0100 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Dirk Behme , Kuninori Morimoto , Yoshihiro Shimoda Subject: [RFC 2/2] mmc: sdhi: on RCar, make use of CBSY bit Date: Tue, 26 Jan 2016 12:46:41 +0100 Message-Id: <1453808801-12510-3-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453808801-12510-1-git-send-email-wsa@the-dreams.de> References: <1453808801-12510-1-git-send-email-wsa@the-dreams.de> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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: Wolfram Sang Most registers need to wait until the command is completed, not necessarily until the bus is free. RCar SoCs can signal that via the CBSY bit, so let's use it instead of SCLKDIVEN to save a few ns of delay. Signed-off-by: Wolfram Sang --- drivers/mmc/host/sh_mobile_sdhi.c | 15 +++++++++++---- include/linux/mmc/tmio.h | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 12419acb8ac9f5..dd08e945b2d3dd 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -156,11 +156,13 @@ static void sh_mobile_sdhi_clk_disable(struct platform_device *pdev) clk_disable_unprepare(priv->clk); } -static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host) +static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host, u16 bit) { int timeout = 1000; + /* CBSY is set when busy, SCLKDIVEN is cleared when busy */ + u16 wait_state = (bit == STATUS2_CBSY ? STATUS2_CBSY : 0); - while (--timeout && !(sd_ctrl_read16(host, CTL_STATUS2) & (1 << 13))) + while (--timeout && (sd_ctrl_read16(host, CTL_STATUS2) & bit) == wait_state) udelay(1); if (!timeout) { @@ -173,18 +175,23 @@ static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host) static int sh_mobile_sdhi_write16_hook(struct tmio_mmc_host *host, int addr) { + u16 bit = STATUS2_SCLKDIVEN; + switch (addr) { case CTL_SD_CMD: case CTL_STOP_INTERNAL_ACTION: case CTL_XFER_BLK_COUNT: - case CTL_SD_CARD_CLK_CTL: case CTL_SD_XFER_LEN: case CTL_SD_MEM_CARD_OPT: case CTL_TRANSACTION_CTL: case CTL_DMA_ENABLE: case EXT_ACC: - return sh_mobile_sdhi_wait_idle(host); + if (host->pdata->flags & TMIO_MMC_IS_RCAR) + bit = STATUS2_CBSY; + /* fallthrough */ + case CTL_SD_CARD_CLK_CTL: + return sh_mobile_sdhi_wait_idle(host, bit); } return 0; diff --git a/include/linux/mmc/tmio.h b/include/linux/mmc/tmio.h index 5f5cd80e976500..6ae480d6fec891 100644 --- a/include/linux/mmc/tmio.h +++ b/include/linux/mmc/tmio.h @@ -63,6 +63,9 @@ #define TMIO_STAT_CMD_BUSY 0x40000000 #define TMIO_STAT_ILL_ACCESS 0x80000000 +#define STATUS2_CBSY BIT(14) /* only known on RCar */ +#define STATUS2_SCLKDIVEN BIT(13) + #define CLK_CTL_DIV_MASK 0xff #define CLK_CTL_SCLKEN BIT(8)