From patchwork Mon Dec 1 16:02:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 41785 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 862E820672 for ; Mon, 1 Dec 2014 16:02:37 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf6816913lab.3 for ; Mon, 01 Dec 2014 08:02:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=vvXNxA7ko7F4V+pwHlfA19oVlgDKVZ6hXtcEeBA7JIo=; b=Rwzd4RWlyiNAw8ifON+C/uwVibdEDO8Cynv8B16B7uLAinehK5A9YHSS6cI0I/o2MD 2xBk5vPzLlQ1SBmatxvcZW1bWsn5iVVU7WuRkceZODYcqzbN8TI3hcJDI09ygnRqdTyW CX3hexkNTBOTTW169SvMcoJOhOS7KygHDEKzvkeET+BLQGRP0muYsGL3VdyKwAK0DzB1 21wXGH8lDsXhLrv3YMo/SJVaPsBltMjmWatzUMAF2FXBrJuT4hdNDVpYMgP7OGqJBwuQ w5/radNdZ0zMLuHD8tDwJJRQarK68Ext4G5SSQVj6cpG2U/VN6HKbb3/lYrsS8HV99k9 zmGg== X-Gm-Message-State: ALoCoQnbRycGTLmOqE/0wg+TsCqQWuwyZQmlNbN81OIwyO00cGsangQHINH8gRXPOM7WXm1eZfVX X-Received: by 10.152.44.195 with SMTP id g3mr4239616lam.2.1417449756528; Mon, 01 Dec 2014 08:02:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.170 with SMTP id d10ls1037865lad.37.gmail; Mon, 01 Dec 2014 08:02:36 -0800 (PST) X-Received: by 10.152.6.166 with SMTP id c6mr57558308laa.20.1417449756011; Mon, 01 Dec 2014 08:02:36 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id ax5si12163522lbc.9.2014.12.01.08.02.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:02:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id ge10so9103342lab.3 for ; Mon, 01 Dec 2014 08:02:35 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr56769495lbc.23.1417449755368; Mon, 01 Dec 2014 08:02:35 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp316922lbc; Mon, 1 Dec 2014 08:02:30 -0800 (PST) X-Received: by 10.152.29.97 with SMTP id j1mr50725237lah.3.1417449746887; Mon, 01 Dec 2014 08:02:26 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id xk6si18093098lbb.22.2014.12.01.08.02.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 08:02:26 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so8992501lbd.34 for ; Mon, 01 Dec 2014 08:02:26 -0800 (PST) X-Received: by 10.112.61.169 with SMTP id q9mr22203322lbr.12.1417449737035; Mon, 01 Dec 2014 08:02:17 -0800 (PST) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id xe10sm4813961lbb.37.2014.12.01.08.02.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Dec 2014 08:02:16 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Chris Ball Cc: Seungwon Jeon , Jaehoon Chung , Shawn Guo , Sascha Hauer , Aisheng Dong , Stephen Boyd , Minda Chen , Barry Song Subject: [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert to mmc_send_tuning() Date: Mon, 1 Dec 2014 17:02:07 +0100 Message-Id: <1417449730-5880-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417449730-5880-1-git-send-email-ulf.hansson@linaro.org> References: <1417449730-5880-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Instead of having a local function taking care of sending the tuning command, let's use the common mmc_send_tuning() API provided by the mmc core. In this way the request will be handled as any other request by sdhci core. As an effect of this change, the pm_runtime_get_sync() call at esdhc_prepare_tuning() isn't needed any more. This patch will also introduce another change in behavior, since before the response pattern to the tuning command wasn't verified by sdhci-esdhc-imx. The mmc_send_tuning() does that. Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdhci-esdhc-imx.c | 68 ++------------------------------------ 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 0135f00..a33d64c 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -65,8 +65,6 @@ /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */ #define ESDHC_TUNING_START_TAP 0x1 -#define ESDHC_TUNING_BLOCK_PATTERN_LEN 64 - /* pinctrl state */ #define ESDHC_PINCTRL_STATE_100MHZ "state_100mhz" #define ESDHC_PINCTRL_STATE_200MHZ "state_200mhz" @@ -692,8 +690,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) /* FIXME: delay a bit for card to be ready for next tuning due to errors */ mdelay(1); - /* This is balanced by the runtime put in sdhci_tasklet_finish */ - pm_runtime_get_sync(host->mmc->parent); reg = readl(host->ioaddr + ESDHC_MIX_CTRL); reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL | ESDHC_MIX_CTRL_FBCLK_SEL; @@ -704,54 +700,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS)); } -static void esdhc_request_done(struct mmc_request *mrq) -{ - complete(&mrq->completion); -} - -static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode, - struct scatterlist *sg) -{ - struct mmc_command cmd = {0}; - struct mmc_request mrq = {NULL}; - struct mmc_data data = {0}; - - cmd.opcode = opcode; - cmd.arg = 0; - cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; - - data.blksz = ESDHC_TUNING_BLOCK_PATTERN_LEN; - data.blocks = 1; - data.flags = MMC_DATA_READ; - data.sg = sg; - data.sg_len = 1; - - mrq.cmd = &cmd; - mrq.cmd->mrq = &mrq; - mrq.data = &data; - mrq.data->mrq = &mrq; - mrq.cmd->data = mrq.data; - - mrq.done = esdhc_request_done; - init_completion(&(mrq.completion)); - - spin_lock_irq(&host->lock); - host->mrq = &mrq; - - sdhci_send_command(host, mrq.cmd); - - spin_unlock_irq(&host->lock); - - wait_for_completion(&mrq.completion); - - if (cmd.error) - return cmd.error; - if (data.error) - return data.error; - - return 0; -} - static void esdhc_post_tuning(struct sdhci_host *host) { u32 reg; @@ -763,21 +711,13 @@ static void esdhc_post_tuning(struct sdhci_host *host) static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) { - struct scatterlist sg; - char *tuning_pattern; int min, max, avg, ret; - tuning_pattern = kmalloc(ESDHC_TUNING_BLOCK_PATTERN_LEN, GFP_KERNEL); - if (!tuning_pattern) - return -ENOMEM; - - sg_init_one(&sg, tuning_pattern, ESDHC_TUNING_BLOCK_PATTERN_LEN); - /* find the mininum delay first which can pass tuning */ min = ESDHC_TUNE_CTRL_MIN; while (min < ESDHC_TUNE_CTRL_MAX) { esdhc_prepare_tuning(host, min); - if (!esdhc_send_tuning_cmd(host, opcode, &sg)) + if (!mmc_send_tuning(host->mmc->card)) break; min += ESDHC_TUNE_CTRL_STEP; } @@ -786,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) max = min + ESDHC_TUNE_CTRL_STEP; while (max < ESDHC_TUNE_CTRL_MAX) { esdhc_prepare_tuning(host, max); - if (esdhc_send_tuning_cmd(host, opcode, &sg)) { + if (mmc_send_tuning(host->mmc->card)) { max -= ESDHC_TUNE_CTRL_STEP; break; } @@ -796,11 +736,9 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) /* use average delay to get the best timing */ avg = (min + max) / 2; esdhc_prepare_tuning(host, avg); - ret = esdhc_send_tuning_cmd(host, opcode, &sg); + ret = mmc_send_tuning(host->mmc->card); esdhc_post_tuning(host); - kfree(tuning_pattern); - dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n", ret ? "failed" : "passed", avg, ret);