From patchwork Mon Nov 28 17:39:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 84434 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1241583qgi; Mon, 28 Nov 2016 09:39:27 -0800 (PST) X-Received: by 10.84.148.134 with SMTP id k6mr51327951pla.57.1480354767262; Mon, 28 Nov 2016 09:39:27 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67si36904219pgc.72.2016.11.28.09.39.26; Mon, 28 Nov 2016 09:39:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752136AbcK1RjZ (ORCPT + 5 others); Mon, 28 Nov 2016 12:39:25 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35250 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751033AbcK1RjY (ORCPT ); Mon, 28 Nov 2016 12:39:24 -0500 Received: by mail-wm0-f51.google.com with SMTP id a197so212857174wmd.0 for ; Mon, 28 Nov 2016 09:39:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Q5jp/4RKVj0uoM9x4s41Ww0KWAq71y6baMb4buVSy9s=; b=QFl7JF7LmxnXt5agSi8JB6sWnEGzC/VCeMGh5ltNSOWnmPibgaExZxFeNdjLiYHrlZ rl+L7MQLUbefH7m5g6nghz+0eYdhv6u9NZhuBQMgQrjaHs8hQGhW0CCQPD0bg2VLybc4 eJrUBw+TAkSTxhfD/j06yleto3v4bpRAva29M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Q5jp/4RKVj0uoM9x4s41Ww0KWAq71y6baMb4buVSy9s=; b=P0Ghko2l9tirgyc0x4xzw++a7wb6091XLsV323XqgdBr/61A30bYQhL0EeDqe5GrtA OL7J83od+j8NHvjNwf6mtFyZ+q9+H1x+0ZVOKdvGdBwI95uT3wLDMV17rbaySqhV42f9 GrXwUA8AYr+xCS3RIFa2/HgQ173FeSI8/ZWV+ww5vvQZCJi5Vj3HuH1axk4qHXiRspLy NwI8zHk5WW2GCydPLXRjRrafL2mS36PnBz11B5t+wa7c8CIBeS9h54aRIvu+tTSWbRhz vvcj2DcUQQDGnMtBnLfcBoIdvkLGGcgMhixS6/29n/DPU9koNoIdqX8zgoInsj2dGSil e5qA== X-Gm-Message-State: AKaTC01ljmy0tFoFM+QJUzNqQkkDJop354K5k0c53yPAI4CnoREMcOMxlbIVysaGwUAcjSsT X-Received: by 10.28.63.16 with SMTP id m16mr20706895wma.113.1480354762589; Mon, 28 Nov 2016 09:39:22 -0800 (PST) Received: from mms-0441.wifi.mm-sol.com ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id i132sm29933067wmf.14.2016.11.28.09.39.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 09:39:21 -0800 (PST) From: Georgi Djakov To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, riteshh@codeaurora.org, georgi.djakov@linaro.org Subject: [PATCH v2] mmc: sdhci-msm: Add sdhci_reset() implementation Date: Mon, 28 Nov 2016 19:39:20 +0200 Message-Id: <20161128173920.25334-1-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.10.2 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On apq8016, apq8084 and apq8074 platforms, writing to the software reset register triggers the "power irq". We need to ack and handle the irq, otherwise the following message appears: mmc0: Reset 0x1 never completed. sdhci: =========== REGISTER DUMP (mmc0)=========== sdhci: Sys addr: 0x00000000 | Version: 0x00002e02 sdhci: Blk size: 0x00004000 | Blk cnt: 0x00000000 sdhci: Argument: 0x00000000 | Trn mode: 0x00000000 sdhci: Present: 0x01f80000 | Host ctl: 0x00000000 sdhci: Power: 0x00000000 | Blk gap: 0x00000000 sdhci: Wake-up: 0x00000000 | Clock: 0x00000003 sdhci: Timeout: 0x00000000 | Int stat: 0x00000000 sdhci: Int enab: 0x00000000 | Sig enab: 0x00000000 sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000 sdhci: Caps: 0x322dc8b2 | Caps_1: 0x00008007 sdhci: Cmd: 0x00000000 | Max curr: 0x00000000 sdhci: Host ctl2: 0x00000000 sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x0000000000000000 sdhci: =========================================== Fix it by implementing the custom sdhci_reset() function, which performs the software reset and then handles the irq. Signed-off-by: Georgi Djakov --- Changes since v1: (https://lkml.org/lkml/2016/11/22/411) * Perform the software reset by just writing to the SDHCI_SOFTWARE_RESET register and then check for the irq. drivers/mmc/host/sdhci-msm.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 32879b845b75..157ae07f9309 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -1019,6 +1019,33 @@ static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock) __sdhci_msm_set_clock(host, clock); } +void sdhci_msm_reset(struct sdhci_host *host, u8 mask) +{ + unsigned long timeout = 100; + + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); + + if (mask & SDHCI_RESET_ALL) { + host->clock = 0; + + /* + * SDHCI_RESET_ALL triggers the PWR IRQ and we need + * to handle it here. + */ + sdhci_msm_voltage_switch(host); + } + + while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) { + if (timeout == 0) { + pr_err("%s: Reset 0x%x never completed.\n", + mmc_hostname(host->mmc), (int)mask); + return; + } + timeout--; + mdelay(1); + } +} + static const struct of_device_id sdhci_msm_dt_match[] = { { .compatible = "qcom,sdhci-msm-v4" }, {}, @@ -1028,7 +1055,7 @@ MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match); static const struct sdhci_ops sdhci_msm_ops = { .platform_execute_tuning = sdhci_msm_execute_tuning, - .reset = sdhci_reset, + .reset = sdhci_msm_reset, .set_clock = sdhci_msm_set_clock, .get_min_clock = sdhci_msm_get_min_clock, .get_max_clock = sdhci_msm_get_max_clock,