From patchwork Thu Apr 5 20:19:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 132887 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6712537ljb; Thu, 5 Apr 2018 13:20:11 -0700 (PDT) X-Received: by 2002:a19:e418:: with SMTP id b24-v6mr14151973lfh.61.1522959611204; Thu, 05 Apr 2018 13:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522959611; cv=none; d=google.com; s=arc-20160816; b=Azs25e7IcrXoadH3btQ1MOWhDHRbO0nhNKAFWKkLiiN81avAUyUbUhyHRCXwu8XOmq Nnfo0zhffMrIUGnVRDhK+oXR4/MDCbuAYyuNLlYYDr2y9zSq2Yn11BYAMx09Qz+f6bPe R2NGxA0ntYnNdIPrDGRYNTfqbLwaeSqZzpEEjKeu4NGcU+13Tsae7GkQx/iQXeAN+a3O SRnw4KwnmO+As1FXv2+bJ2Iv7Hy7nenteSET1tgnXh+3mM3lyIpo99pwR7j3D6Wc/3e1 gPnPldn7EIlAa4BOIwD4C7C0EKXv2+e+MU1L9ReMpysZkjJ7OZUkP+H24n2Oa1hTHvbR 0ogg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=P+n6KYJ/751SQqDpKzbVQJs59emJ3Z8ZwiYRMTp5UjU=; b=I7Q1BMQQUDPVfFI5C7xatKaGz8zKdWU/PthTQXR09rk5nHoK0OseM7jdYJCyAn70GL wPEDnY3ILa9uGCRzHWdS1gS91A+ibOntPOsmSdcgUYa+fkj3Ko0Kebz3JID5tN8/3out 3ATdGmNL8PSHDs4WT/rWbBBUYhYs82QaWjjzhVUmRmLjud8okNsGPVuURw7Cz8bIGR4A bIS5Wd/2PcBX0sVGE6A6Y+G04pjH/Bna8au2DqKFm8bzDlBGpqCcpvkHWXQXSBvxBLFx j20JkULizJL8XistV9kyMhP6Kcs/xZ10I2eJnO/jKAvrDZ22BlyR6iUv7qCfLbn5mZ86 5r/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ktsNhdIk; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h78-v6sor2075507lfb.67.2018.04.05.13.20.11 for (Google Transport Security); Thu, 05 Apr 2018 13:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ktsNhdIk; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P+n6KYJ/751SQqDpKzbVQJs59emJ3Z8ZwiYRMTp5UjU=; b=ktsNhdIkWBKJqAtIkr70l8eFzMvv9Jfc5QYLXBC5P1o+FC6YvhT0PME/NoXPUNrxep 8nxms4lmxWvDtVK+mNK+RceZzn7D5urN5jhnkwz4ZdAR+HG4BUiwsEsPe2T8hlkYqm/+ s5V5eqtSZ+lKbb6kbidB4rNo2XRdnfn7Qqr/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P+n6KYJ/751SQqDpKzbVQJs59emJ3Z8ZwiYRMTp5UjU=; b=ChkCm/mYSpA/Rl59aqwI2Yabmm9TupNLu5vb6dlNg0GLw6x+QV6fwhtRH56cRrYCVv A0AUarfovWG7L0Q+DwoEGj/LfqyL0AbPKJi/zwvEwPdws44j8tG0ngvUdm+U3aR6i0Hf 3KoR5+PD1iyqmIUta5fdz0A1+Dt+GcW9w2a0t9qC9Wd9U4EfnFC9ceBM+eYbfPGsZWkb 0rxhV+1dbtipzYaGYVXokuCvh/57ck1DaNjfucTBRFiApk5plVUaKLSrl0CgVW5Nc9EJ H54A2vvQ9WH/zvR2PpZcRf+/Qq/knHBrQsbNPbEhDqG0xeHU75UfE7rB69kDUEYok+Bb KtdA== X-Gm-Message-State: ALQs6tChflvIUIK2oBC8LP1bBcYcjihG7eWk1DJu8reeunCi9YOCISgK /MS/wDDTrnzo2a60XLGwTP8quxpp X-Google-Smtp-Source: AIpwx4+v351sTqTrHKpterceRdrijxHJfOcHr4GS5rmCie/IvC2Ugx5SusSFE1nn5vRUl9+wBZ4zyQ== X-Received: by 2002:a19:d403:: with SMTP id l3-v6mr9262478lfg.51.1522959610950; Thu, 05 Apr 2018 13:20:10 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h66-v6sm1687533lfi.89.2018.04.05.13.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 13:20:10 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson , Hans de Goede , Quentin Schulz Subject: [PATCH 1/5] mmc: core: Re-factor some code for SDIO re-initialization Date: Thu, 5 Apr 2018 22:19:50 +0200 Message-Id: <1522959594-3411-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> References: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> The mmc_sdio_init_card() function has a couple of callers. In the re-initialization cases, some additional reset commands are issued before mmc_sdio_init_card() is called. As these additional reset commands are the same, let's move these into a new static function, mmc_sdio_reinit_card() and call mmc_sdio_init_card() from there. In this way we avoid the open coding. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index c599a62..c20168a 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -801,6 +801,22 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, return err; } +static int mmc_sdio_reinit_card(struct mmc_host *host, bool powered_resume) +{ + int ret; + + sdio_reset(host); + mmc_go_idle(host); + mmc_send_if_cond(host, host->card->ocr); + + ret = mmc_send_io_op_cond(host, 0, NULL); + if (ret) + return ret; + + return mmc_sdio_init_card(host, host->card->ocr, host->card, + powered_resume); +} + /* * Host is being removed. Free up the current card. */ @@ -948,14 +964,7 @@ static int mmc_sdio_resume(struct mmc_host *host) /* No need to reinitialize powered-resumed nonremovable cards */ if (mmc_card_is_removable(host) || !mmc_card_keep_power(host)) { - sdio_reset(host); - mmc_go_idle(host); - mmc_send_if_cond(host, host->card->ocr); - err = mmc_send_io_op_cond(host, 0, NULL); - if (!err) - err = mmc_sdio_init_card(host, host->card->ocr, - host->card, - mmc_card_keep_power(host)); + err = mmc_sdio_reinit_card(host, mmc_card_keep_power(host)); } else if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { /* We may have switched to 1-bit mode during suspend */ err = sdio_enable_4bit_bus(host->card); @@ -978,8 +987,6 @@ static int mmc_sdio_power_restore(struct mmc_host *host) { int ret; - mmc_claim_host(host); - /* * Reset the card by performing the same steps that are taken by * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe. @@ -997,20 +1004,12 @@ static int mmc_sdio_power_restore(struct mmc_host *host) * */ - sdio_reset(host); - mmc_go_idle(host); - mmc_send_if_cond(host, host->card->ocr); - - ret = mmc_send_io_op_cond(host, 0, NULL); - if (ret) - goto out; + mmc_claim_host(host); - ret = mmc_sdio_init_card(host, host->card->ocr, host->card, - mmc_card_keep_power(host)); + ret = mmc_sdio_reinit_card(host, mmc_card_keep_power(host)); if (!ret && host->sdio_irqs) mmc_signal_sdio_irq(host); -out: mmc_release_host(host); return ret; From patchwork Thu Apr 5 20:19:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 132888 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6712556ljb; Thu, 5 Apr 2018 13:20:12 -0700 (PDT) X-Received: by 10.46.93.219 with SMTP id v88mr14615322lje.88.1522959612648; Thu, 05 Apr 2018 13:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522959612; cv=none; d=google.com; s=arc-20160816; b=T5jW9rdoW7GSAwarsfd9n33iefzjEgxBlQQyaRz3mw9dzpNWSrzePHi9/7IOcfxgdL 8t2XV74ic0Nus5LqaEXd79Pfxi6H4e9iROOekLahgfvKaXqYGMUeIUU4nroBqroCpJ8n Qsz5bxX4bmZuo8kWonQWUhLT6f2jNti9qYx2W4MfKtUnWoXzF1XbtbSA7fWpdedfpLcO 4/K9dyoZD2e3FTN/ElYiYjEfNXfIVZCC0Or1EQJ5JBjshUHi/n3+qCL1srFg6yqrE94f THuv6CeyRoF5lG+S6lTgSJQq7CuMqdr9xzrDPzh5YbC5OEi9EDKtXyg3y2LAu7fEZfzD jsLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=k0+qaNqsFyizIaV35d7sXR0E1loyJuPdJPmi06Ym9W4=; b=Iw8IWr2Ief6rTAFYLRlHpCZv7TBmwjMRa1RyJ6hznmBI+5NcsGjECPNJ/69MgeT1LB rogY/AVj9CBb8a10TUveBA5LrAT0bSkcLT38mxBiJgT77Db4sN9bk2przVn1YiOsrbMG aTLcMn4vxvO8Z4pdUBU2UY6Wz/jOmikDFQ6f71xKbQUDWhmlCgM+MCKuoIcwofon8maE Zd6nZf7yz3S+e79UlAmMisFPdSLycbe4W9To7BYcnb2DcBkK8NG8r00FqDJFe4bLjRLw ckCcMTPGAmnYqQ1nwgXM8AUUZch7Co0buMaYii4KJ1XTHB59pU+zfHA4F6gxHvNHFep3 nFIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMIXah7O; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m38-v6sor2220322lfi.52.2018.04.05.13.20.12 for (Google Transport Security); Thu, 05 Apr 2018 13:20:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMIXah7O; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k0+qaNqsFyizIaV35d7sXR0E1loyJuPdJPmi06Ym9W4=; b=hMIXah7OkVrSXpDX9LW3xNbxSyRLhK4N1/4O6iPcGOYYmqY75k1hSrT8nHIgL19vXL pNruVxviDg+mBNKGnh8a5bW2BzrFZrM7yU+WOpWWT6Q9VpIc+pHDV+x+Djmw5U1VIbWU 5TKjqibHHy/VdxiDhirgghton3/scXmFcp1Ks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k0+qaNqsFyizIaV35d7sXR0E1loyJuPdJPmi06Ym9W4=; b=UbLeRcdftL7RAARC6sL7G3CpW5CaeL/WlA8cz1xa5ZimDNEZxaaVPsn3KI39fdbkiO m18uC8SH+0d6iqc5s64i/ltB3b3a8kGeDU8Q5CI/JeP0pkmzQ8Z2nDxca6Z5UCeP7Tgf n3fIVMeyEk84e0c7WwfuP/LPpI1cyfSAac3M1zpxqCV/CwbYiTn77Vg0fCcPLjSWGQsa /9Xdh92Uyo0o8EvU2LqKdzS2eNEV6Xx+xLgv3w6DfasI39kMJvLxQDOMYfBRr+G00ohi z93sXO70JLjVdLKUbUPd97kCv3cvUrKwpG+1FOhI/LVk+A2Hif5ud0aJHHWt87naewY5 YBYg== X-Gm-Message-State: ALQs6tBJ3Z9843WfESD+9u3C4TkKnICcZWU/wznbmz3BhJdSyVaaWJLk BV/03TjPe1XZ8IRz45+dYZ2faVKY X-Google-Smtp-Source: AIpwx48WUa1f5mXtxrF4jCUqD7MNK/vmDr0hogWk/WiR8VIZXrLnwxXhXH0H8MmkUtx3oaMQ42GNww== X-Received: by 2002:a19:e995:: with SMTP id j21-v6mr830246lfk.119.1522959612282; Thu, 05 Apr 2018 13:20:12 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h66-v6sm1687533lfi.89.2018.04.05.13.20.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 13:20:11 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson , Hans de Goede , Quentin Schulz Subject: [PATCH 2/5] mmc: core: Rename ->reset() bus ops to ->hw_reset() Date: Thu, 5 Apr 2018 22:19:51 +0200 Message-Id: <1522959594-3411-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> References: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> The bus ops ->reset() executes a full HW reset of the card, as the calling function mmc_hw_reset() also indicates by its name. Let's convert to follow the similar names, for both the bus ops callback and for the corresponding bus ops functions, as to clarify the purpose of code. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 6 +++--- drivers/mmc/core/core.h | 2 +- drivers/mmc/core/mmc.c | 4 ++-- drivers/mmc/core/sd.c | 4 ++-- drivers/mmc/core/sdio.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 121ce50..3e17c62 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2435,16 +2435,16 @@ int mmc_hw_reset(struct mmc_host *host) return -EINVAL; mmc_bus_get(host); - if (!host->bus_ops || host->bus_dead || !host->bus_ops->reset) { + if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) { mmc_bus_put(host); return -EOPNOTSUPP; } - ret = host->bus_ops->reset(host); + ret = host->bus_ops->hw_reset(host); mmc_bus_put(host); if (ret) - pr_warn("%s: tried to reset card, got error %d\n", + pr_warn("%s: tried to HW reset card, got error %d\n", mmc_hostname(host), ret); return ret; diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index d6303d6..367ed11 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -32,7 +32,7 @@ struct mmc_bus_ops { int (*power_restore)(struct mmc_host *); int (*alive)(struct mmc_host *); int (*shutdown)(struct mmc_host *); - int (*reset)(struct mmc_host *); + int (*hw_reset)(struct mmc_host *); }; void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 6f8ebd6..89c99d9 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -2117,7 +2117,7 @@ static int mmc_can_reset(struct mmc_card *card) return 1; } -static int mmc_reset(struct mmc_host *host) +static int _mmc_hw_reset(struct mmc_host *host) { struct mmc_card *card = host->card; @@ -2151,7 +2151,7 @@ static const struct mmc_bus_ops mmc_ops = { .runtime_resume = mmc_runtime_resume, .alive = mmc_alive, .shutdown = mmc_shutdown, - .reset = mmc_reset, + .hw_reset = _mmc_hw_reset, }; /* diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index baf3d5d..b169f34 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1214,7 +1214,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) return 0; } -static int mmc_sd_reset(struct mmc_host *host) +static int mmc_sd_hw_reset(struct mmc_host *host) { mmc_power_cycle(host, host->card->ocr); return mmc_sd_init_card(host, host->card->ocr, host->card); @@ -1229,7 +1229,7 @@ static const struct mmc_bus_ops mmc_sd_ops = { .resume = mmc_sd_resume, .alive = mmc_sd_alive, .shutdown = mmc_sd_suspend, - .reset = mmc_sd_reset, + .hw_reset = mmc_sd_hw_reset, }; /* diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index c20168a..0124e0e 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1038,7 +1038,7 @@ static int mmc_sdio_runtime_resume(struct mmc_host *host) return ret; } -static int mmc_sdio_reset(struct mmc_host *host) +static int mmc_sdio_hw_reset(struct mmc_host *host) { mmc_power_cycle(host, host->card->ocr); return mmc_sdio_power_restore(host); @@ -1054,7 +1054,7 @@ static const struct mmc_bus_ops mmc_sdio_ops = { .runtime_resume = mmc_sdio_runtime_resume, .power_restore = mmc_sdio_power_restore, .alive = mmc_sdio_alive, - .reset = mmc_sdio_reset, + .hw_reset = mmc_sdio_hw_reset, }; From patchwork Thu Apr 5 20:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 132889 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6712566ljb; Thu, 5 Apr 2018 13:20:13 -0700 (PDT) X-Received: by 2002:a19:1198:: with SMTP id 24-v6mr14852372lfr.85.1522959613763; Thu, 05 Apr 2018 13:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522959613; cv=none; d=google.com; s=arc-20160816; b=ev//IHHAiEfOw+f+DARGhD3kUyfcV3k/6nZg665y6IiWYUdpElLVkO7hOWHndg+RvO 7YBz69zoy/dINO24WR4J2DowkJV0HkmagmKZOwShp719GFC1nZED+zpclc0ut9fCT2+R dtTMl+2TSUuDr1wuorWtV0O2tfiohaTCOBDMcu4/X0n15SJN2PG7C4ZLogeASQa7oiV3 90uqkVf1gnYNdBZnIO83KTPAsIpBKRla+9G1ys9Hc2RJda2N8YeYzlMf97XymMa5SQZS 5nIz4ZAK4vWkTG0dvr6XuIvs4eAp5h3/uMnbvzf6EqTqscIHc4i6091lp3b/nkAtZ1b4 COPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=sH1eBEImgofsuFHCzgFCJq8shVTDDsWWgIXJKvMm2jg=; b=AQgp8A93pWlaKkwTGKSjxCJUIFH554DFuA55Pk1XPjQp0cktyHs3lWHnx6D+wd/4uM LXP6XkC61nwniKM0YzKau+zD/tKlPiIyKwGOPTeA5G2i3PTbQpuKAotshhHE1o/ehAJg uxel1I5PWp/DE4sgYX9M7YKMnms8vaHvnXKnBrm9llzL4f8shyviPTxJ+F4ttyGpD4/i E9/Mrji4jx0zM3ezHNofGBOsByBNsaUdKk0abJD8xE+qP13wHychQK/xdwh5lyUu8mIx 3AySsVyti49hrYGesN9kD7doBZ3F7BPS8OTP6Kv5oloVd9WCqtr8dkwJjmMukDJs7ngj +f0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H5ODIljS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v75-v6sor2181414lfa.72.2018.04.05.13.20.13 for (Google Transport Security); Thu, 05 Apr 2018 13:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H5ODIljS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sH1eBEImgofsuFHCzgFCJq8shVTDDsWWgIXJKvMm2jg=; b=H5ODIljSO/9glkaBCidu7kroBOyLzL2F1gf+9OMWAXzcTNIKZrfXHyyp7yZkJ/BY5k PMS30yQjQA3t0xMGISbr9SRUFs16XGbNw5u7ooDlyeunDsiXqIgIw9GmPQ8V2dXddru0 bs/mcYhAFXV5+JY8bi21n0h5fIbQE/Ys746eA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sH1eBEImgofsuFHCzgFCJq8shVTDDsWWgIXJKvMm2jg=; b=D2qJX7QjXv21r9fn5o71Ep74YDqTlo8kpebXPufD3QekK7KUY0/G6ItOzW7k2v+60y xn5dj7TfH2UJnonfUMO/Y1qqqgpuR8171OwnIXLQ+8p691sN6WEZJx+n7JXX/nMnq8OH 7WQn5jtY4ThRhBbx+jPUu6AqF4ufsPMvt/YFQ3TJCU0tELzXKzJ/lRFB9lIh43/DS0sR 2w3vDr10OZ+I2Zfbes2h9yy2DUFqKxOgZIsQh7+c8nZj8+knibk9KpPC3JVvIGYF88/a Ug+01Z4ljvxK3Ek4C3ffx86f/tBz9xEy5ReS0GkF5aQcifZRCvxOoDfzv/6S/C9BGq8L 8nEA== X-Gm-Message-State: ALQs6tBklk1hZlS2JWp5RoR9rEwRHINbMgLrKu4l4tlD9jSr7WgxPQJy hsjKV5Oa/ZkQ0700cbdp+uIrKEbe X-Google-Smtp-Source: AIpwx4/ru4j1zPiaV9oIHN6auBCCOu2sLquJQxPzeH72+bw4AvVibvVzqPHjwvj05C7ysB4OJnZJPg== X-Received: by 2002:a19:a003:: with SMTP id j3-v6mr14010614lfe.8.1522959613533; Thu, 05 Apr 2018 13:20:13 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h66-v6sm1687533lfi.89.2018.04.05.13.20.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 13:20:12 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson , Hans de Goede , Quentin Schulz Subject: [PATCH 3/5] mmc: core: Export a function mmc_sw_reset() to allow soft reset of cards Date: Thu, 5 Apr 2018 22:19:52 +0200 Message-Id: <1522959594-3411-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> References: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> It's rather common that a firmware is loaded into an SDIO func device memory, by the corresponding SDIO func driver during ->probe() time. However, to actually start running the new firmware, sometimes a soft reset (no power cycle) and a re-initialization of the card is needed. This is for example the case with the Espressif ESP8089 WiFi chips, when connected to an SDIO interface. To cope with this scenario, let's add a new exported function, mmc_sw_reset(), which may be called when a soft reset and re-initialization of the card are needed. The mmc_sw_reset() is implemented on top of a new bus ops callback, similar to how the mmc_hw_reset() has been implemented. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 24 ++++++++++++++++++++++++ drivers/mmc/core/core.h | 1 + include/linux/mmc/core.h | 1 + 3 files changed, 26 insertions(+) -- 2.7.4 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 3e17c62..7a79dc1 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2451,6 +2451,30 @@ int mmc_hw_reset(struct mmc_host *host) } EXPORT_SYMBOL(mmc_hw_reset); +int mmc_sw_reset(struct mmc_host *host) +{ + int ret; + + if (!host->card) + return -EINVAL; + + mmc_bus_get(host); + if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) { + mmc_bus_put(host); + return -EOPNOTSUPP; + } + + ret = host->bus_ops->sw_reset(host); + mmc_bus_put(host); + + if (ret) + pr_warn("%s: tried to SW reset card, got error %d\n", + mmc_hostname(host), ret); + + return ret; +} +EXPORT_SYMBOL(mmc_sw_reset); + static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) { host->f_init = freq; diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 367ed11..a141ec0 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -33,6 +33,7 @@ struct mmc_bus_ops { int (*alive)(struct mmc_host *); int (*shutdown)(struct mmc_host *); int (*hw_reset)(struct mmc_host *); + int (*sw_reset)(struct mmc_host *); }; void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 9275193..134a648 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -177,6 +177,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries); int mmc_hw_reset(struct mmc_host *host); +int mmc_sw_reset(struct mmc_host *host); void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); #endif /* LINUX_MMC_CORE_H */ From patchwork Thu Apr 5 20:19:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 132890 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6712596ljb; Thu, 5 Apr 2018 13:20:15 -0700 (PDT) X-Received: by 10.46.47.7 with SMTP id v7mr7652295ljv.56.1522959615491; Thu, 05 Apr 2018 13:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522959615; cv=none; d=google.com; s=arc-20160816; b=hV4ljJcus2+6yafbt4nM477pIcbFJAmDqjyMHT0Rmj84WQRYrRMIYlmnbwQgltgpK4 R2Lynzbqf+CRHC0B8po4iQmgipxqVZlegfKVDQurLCsmVQn5YeC9HPvgBXCRDqgq7XsZ 8GtPcttUOuBfSHYshWBK7J2s2qOjJKW7mQJsP0Zx7FABfVGY+lFfCxm18gKWXDy1Pf4H A72xMvBvT+Cb0LCVSh7bKODf3Yl2UI5yKg30oNIEPGARfV8hFbNGpKJ54/6RjZ3A678l sWfBvp780XufnJ4akkOHTCARcaXqEwls9hrehbDreWjRA4o5PDbLB2kVkNYDLBWNFMSY 56UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OptpziPx683JCkBELj69jcOaQsaEaXsSXtIDSRFYKv8=; b=Q+MfwPeZwnpgsT/4N0cMMXgWRyD8NZnGQNeS/9MnR/Y8+zlfS+2tcDG+mXdWInPLbF yrhP3DdB5ajVmU/c5g4lVIL29Fc7Iwg4POj2O+HINXDIb9rh2LvZP8oEIepefQXeXwHQ zv4JKSNJBv7j66hPCZhZwhIk0zHd51hfFw6bx8he4yIrtHBBYiD14mMDi18buc09f5yt 3j5+Qln99kkxA83U5segwyQYunLvxXGBYNxk/E46Nn4qBn20B8H82j+jtUVMjX/tpvoB v9KkJUGv9VkaE5UVtVhTh+pogEVkR2RzHYyWTE66YnV3xJT+z0ZL0rhn65G91CSNb/Qz IGpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FGq4/Oce; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j20sor2083386lje.7.2018.04.05.13.20.15 for (Google Transport Security); Thu, 05 Apr 2018 13:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FGq4/Oce; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OptpziPx683JCkBELj69jcOaQsaEaXsSXtIDSRFYKv8=; b=FGq4/OceCapwNBfCG3tLro4C9wUKqM754Od6RRCmRLiWQ7yfTdWlKr3mE+pzZ3V7nV HjeFDNY+I7KY7le+COHVlvmW7JrTbSEt7tstD3K16oKA6vxBMcekegBKyYJQ5z4xgz5w sGf33amqrZuc8z3XB6MU8mh0Nq9hkLzcS4k0s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OptpziPx683JCkBELj69jcOaQsaEaXsSXtIDSRFYKv8=; b=mW0+LAvQCo1B2c6F4UY2XodsFKwdCmvXv6ob0/WJKvdcHaTBhRa7EijUPcs7/zi7ym UMl/Df1IVNSJ9Yt/JToP6XLo2+rYP5zYQ+ob6wnnl5OPk4JH4SAIhlnrgI4mw6fWIiHR 4e8XtY3g9YvWHJe3J4QFo6pHCiPw/6BXIpGcYM+Edu37WDqSmn2IGTwqR9KTb20Cs7Pa UWDBTvd5iXqvCwR327wZBlCplw/GTg8r1/gK0ltOGOOS7oHAOFtLQ2Ql/Wx+f4BGTMFS dU69pEzSz4IAXUm5Sg5ma4fkCjak7Npw/zK/H4mkp/28XoROiGeGVCvUiK3DzGx8/SJ3 IP2Q== X-Gm-Message-State: ALQs6tAl8yTlx2X8p4SvkUwqN9lUG4QmWd3YOkMKVVj7lgih1X8QPvgs tNSoTbig2FkVz9EU7aQxwRtaK9zD X-Google-Smtp-Source: AIpwx48knCDBybONJ+i1uI3Wogb72v4Ma/hkpzivkCj8prv8a85xMofbjPR+Prxn4H3FRJu0EynYBg== X-Received: by 10.46.152.203 with SMTP id s11mr1380616ljj.92.1522959615159; Thu, 05 Apr 2018 13:20:15 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h66-v6sm1687533lfi.89.2018.04.05.13.20.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 13:20:14 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson , Hans de Goede , Quentin Schulz Subject: [PATCH 4/5] mmc: core: Share internal function to set initial signal voltage Date: Thu, 5 Apr 2018 22:19:53 +0200 Message-Id: <1522959594-3411-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> References: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> Move the corresponding code for setting the initial signal voltage, from mmc_power_up() into a new function, mmc_set_initial_signal_voltage(). Make the function internally available to the mmc core, as to allow the following changes to make use of it. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 19 ++++++++++++------- drivers/mmc/core/core.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 7a79dc1..2c1a220 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1484,6 +1484,17 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) } +void mmc_set_initial_signal_voltage(struct mmc_host *host) +{ + /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */ + if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330)) + dev_dbg(mmc_dev(host), "Initial signal voltage of 3.3v\n"); + else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) + dev_dbg(mmc_dev(host), "Initial signal voltage of 1.8v\n"); + else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120)) + dev_dbg(mmc_dev(host), "Initial signal voltage of 1.2v\n"); +} + int mmc_host_set_uhs_voltage(struct mmc_host *host) { u32 clock; @@ -1646,13 +1657,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) /* Set initial state and call mmc_set_ios */ mmc_set_initial_state(host); - /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */ - if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330)) - dev_dbg(mmc_dev(host), "Initial signal voltage of 3.3v\n"); - else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) - dev_dbg(mmc_dev(host), "Initial signal voltage of 1.8v\n"); - else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120)) - dev_dbg(mmc_dev(host), "Initial signal voltage of 1.2v\n"); + mmc_set_initial_signal_voltage(host); /* * This delay should be sufficient to allow the power supply diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index a141ec0..9d8f09a 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -52,6 +52,7 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr); int mmc_host_set_uhs_voltage(struct mmc_host *host); int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); +void mmc_set_initial_signal_voltage(struct mmc_host *host); void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr, From patchwork Thu Apr 5 20:19:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 132891 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6712617ljb; Thu, 5 Apr 2018 13:20:17 -0700 (PDT) X-Received: by 10.46.131.86 with SMTP id l22mr12117105ljh.82.1522959616865; Thu, 05 Apr 2018 13:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522959616; cv=none; d=google.com; s=arc-20160816; b=YYS6SzQ4HQs9vXm33dURcm/PlgSQZl7jAs4Ia8hWT+U75Gy/v1A15+9dpDyP0wTGm7 g7uaunD6V+q3kii23kA3l+KXDc68a4Ggs7Nu6rLR5bQBomrPhIWRk1w2GB5uoctXpeXD VyVAR/YRJ1k3T8F62WzM2QHJ9Y5KmzINQPcBrUHhP8cydYN8lnGU7AvoWfFI7UWfCqIS EJ0OmnfIL3nQVuO1Hx8JALAgy5MxPm0Rb+/wZz+yqdIKYmduTe35/ahZSgNAeSHWe0rT uqZ6rpx145uilY9IYcgfOjuUSz3LMMafJYrecyxt3QwpJ1ye7FLDDbL2lMvvSL1Q5aQF bYtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=52tzABuodpZcB+ctMAWGAnP3SmQEmLuAxhIk0ERWGk8=; b=nL3Jc9p2wCBFS9J8JU5rufg2Idfh8QLwc2hROrrxKdKweX08qlMzU3zFujUjrYgT+B mv8SoEnGRESrcGiIrEh0e+VMFfJ50qwRi0iSpdVpWpypdRWKh4+HSRjoZ8122eKSI1Uu nKBjEGwev+dXoWxfpxD1LaD2mBUGRKf2btHySqp69UQrCYeY/T5Xbb3N/UC2mVDqXu74 oYASjRkNNXIT1m0sSJcP1IxBA4p0G/88IwcPDGbV/iCjG4s+b4qBunH4lyvzXYKrHb5S DuIrpVNdHDaFfhB/6Btir4mgKVtl7NEJQELd5fy2/3Lne4cEYKLLYa2B8Fh5OAlDZKDr je8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F1rQuhIv; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v23sor2159010ljc.114.2018.04.05.13.20.16 for (Google Transport Security); Thu, 05 Apr 2018 13:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F1rQuhIv; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=52tzABuodpZcB+ctMAWGAnP3SmQEmLuAxhIk0ERWGk8=; b=F1rQuhIvouOrYJX5xEhK5YoZQM/jrX8tsupZwsxWwfAdsEBi5b+K1tZdlBFzPGY4oO ExxsOt7Pvssbz5kgGrJio4KmN1LiTJzY01m3YqBO2TgPqMhyqBWYxTUYtSRtxOFb6odd JS7UOb50UXFaUrAUxicgRpWOGDqIUvrTwNHjE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=52tzABuodpZcB+ctMAWGAnP3SmQEmLuAxhIk0ERWGk8=; b=H2OsOkyzCmJFDyZbnr5Ad4rCJ0ME0QIzkNY24r7HzPHfl8mBasjT2wqQ1DPgMLa/3E X+G/BIHT76cqk9iEUrXWYlgWHqI3Pv3EB/fhcA5P5TciCGKlJJ9IMDIBtYSt5HM2J2jp 9/+FWgNK5mOCnVXPK6bO4TJYo40Inb160SUnIoeSaUwqovo0qNPrvyfm3G5ruTdYHLSs Ey+o78AuwD7EuoKn6J245RLOTHFyGIPJV9vF1Ts0LfRZly5iF2XoMj4UUH1dAQ8VIZ1N rQPiktaqyLxWYm6IORuz0uJ+ihlU3OWheQl65nk9/YUlU0c2BVnfKyWCjoU8hfDEYbcp 26wA== X-Gm-Message-State: ALQs6tCG1jgVeZk/kfmJ9eesONklxRYW8D+os9BDCE/bhA/x1F0kS0DK XqG9tmz/ncMszrGpl3Z50vnqR/Lz X-Google-Smtp-Source: AIpwx48LtnwiCCl0teXnPKyJfQeedY7y/kAuYI5na0jH1oQ1Vylj/hHPExR7xxu6bSt8zhPslU4ldA== X-Received: by 10.46.25.28 with SMTP id p28mr7817780lje.127.1522959616658; Thu, 05 Apr 2018 13:20:16 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h66-v6sm1687533lfi.89.2018.04.05.13.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 13:20:16 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson , Hans de Goede , Quentin Schulz Subject: [PATCH 5/5] mmc: core: Implement ->sw_reset bus ops for SDIO Date: Thu, 5 Apr 2018 22:19:54 +0200 Message-Id: <1522959594-3411-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> References: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> Let's implement the ->sw_reset() bus ops to allow SDIO func drivers, in particular, to make a SW reset without doing a full power cycle of the SDIO card. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.7.4 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 0124e0e..088c80c 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1044,6 +1044,18 @@ static int mmc_sdio_hw_reset(struct mmc_host *host) return mmc_sdio_power_restore(host); } +static int mmc_sdio_sw_reset(struct mmc_host *host) +{ + mmc_set_clock(host, host->f_init); + sdio_reset(host); + mmc_go_idle(host); + + mmc_set_initial_state(host); + mmc_set_initial_signal_voltage(host); + + return mmc_sdio_reinit_card(host, 0); +} + static const struct mmc_bus_ops mmc_sdio_ops = { .remove = mmc_sdio_remove, .detect = mmc_sdio_detect, @@ -1055,6 +1067,7 @@ static const struct mmc_bus_ops mmc_sdio_ops = { .power_restore = mmc_sdio_power_restore, .alive = mmc_sdio_alive, .hw_reset = mmc_sdio_hw_reset, + .sw_reset = mmc_sdio_sw_reset, };