From patchwork Thu Apr 30 09:16:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185885 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1839187ilf; Thu, 30 Apr 2020 02:17:06 -0700 (PDT) X-Received: by 2002:a2e:2a82:: with SMTP id q124mr1625273ljq.155.1588238226353; Thu, 30 Apr 2020 02:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588238226; cv=none; d=google.com; s=arc-20160816; b=HBvIvfzUJtcvbYrdatqLQUiQMZYuHz8RvkFHUBl91mjJYwbiXMEBi/ccpG8guIHUSw MI5K67zwIV9apjI/b5y2YxdPn+8r7L5REFYEoI34ds7yq3+RPe079qTBdVDxxQkL4FDh XHZO7AGSylARz8bbuRa/cS2weDea10xiNEEF+YvjrI7wb4H7ptF0Xlzpg4yZL2hh6VzB ukU+8jKwkWfQWSrE6gRX5b30VIKp6vGyaz0K96yIAHrRynCyYcnTawntqfUn6UUQGvat tkdMLhA9M3iujuViG8WaIfSkVUDjtdIqHqXO3y7lIFG+KKXGxT2rhLrm7jONbuNHZ+eq w9tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Ff43pht+qFHl5p036giswtCScSev0q0blJQXIZAKC20=; b=edN9HRSE/pIat+fO+m+HG8cnI0pYkZ5lOI62cytot3YFqOY47GASSy+FCALi5BsmD1 kFPMSlFesFlmhekGCvodEinZ5UsLLGXxT23FoF1jQbJUcEvMonL/9D3/zP/efqCy/lS7 qN5wQ81d3TqqhFsoB6uLmu2rz/jLEAKYp5dToE0HF26/4RqX+ZiXxWaIPvecyzmiy608 auD1Myqv6Odk6WY82WE9DQGy1q2BhZ/6O1tetCRhhC/8Jxn9rXnt/yMjmnawHcgwvLBZ GXGJBoNQxPNSznUD6Ls3WjinXODw0yXRmGDi4MNEaLjctF/JNFUmuX6BaRtrNJCsVMcu qhNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Og8/7JTJ"; 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 b16sor3662656ljk.10.2020.04.30.02.17.06 for (Google Transport Security); Thu, 30 Apr 2020 02:17:06 -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="Og8/7JTJ"; 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 :mime-version:content-transfer-encoding; bh=Ff43pht+qFHl5p036giswtCScSev0q0blJQXIZAKC20=; b=Og8/7JTJYJemv2CsNUPSFYiakr+xBKDCkgdArRX5Xqf35BpVUW/YTXupVdJW7jepfl hemhXC/stNJ6O0+mecD9PPxCkdboCy2YVdazPoDE+VCy6Eu+mIRVWgL+4pPHUoU1gMLn /k/a5OJZBXk0ZSHQqEljU7pfPnb6JkEuoLY/uKj41xmUjQYu3pt3XbaMqUQTXv4qYQsQ MXYKcGgCOijeKWwGWzCXWy0n+phZinbiR1QSgqVQ0z3rXkP8dpg+qLmPJFuXCVha8ZSS 0m+I2G0mrv7jsuOiP0zjy4g10oRfkMdM7Ei6yyMpXbglrPvczNFdn2+32+FCNIc1Dgdg 9OMg== 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:mime-version:content-transfer-encoding; bh=Ff43pht+qFHl5p036giswtCScSev0q0blJQXIZAKC20=; b=dH2Zc01BuX7a3eGQUXNK52PlWitiS7aLKaHXGBylr2VttdICiD++5L38jEkL/xrNqU saRFpjGEX9HppBA36gdNJNiBAT61f4fYgISshOn9UcVqRpaksSTtx41AVrT9spBiRn2O ynJSCsi2EJJ9Y1qUdVTZ/x5FPQ9gM2yjzmj2OdFa7zya4qiuhpFuhI/428mwqUi8CbyJ Re1co/2NisSrtNe+v0lE/n5YCyVUnBj/0Z/prlfajz6hd9GhVd9vnwJVQH6cRTEHg3Xz 30BrvsQtS4TcRawKeepynwXATKXHbAOX09nos15BP5meT7ggg71LoxKmLBn5yYfURKDC HkFA== X-Gm-Message-State: AGi0Puakut+BsAtOVBi30Hgnbwo4/MeWnMoRZk3L+imd3Fi9plS7F5Zb 4CPYSKG8yFx+fx5W5YZWbfN0U6ai X-Google-Smtp-Source: APiQypI4IAdq5+e05nE8kgL8WQZa2DSx7F72JWKaL9wKVw6y33UQxZsjKluwOrxRzqWBKQ6Pn7r7Uw== X-Received: by 2002:a2e:9791:: with SMTP id y17mr1631612lji.174.1588238225886; Thu, 30 Apr 2020 02:17:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id x29sm4417818lfn.64.2020.04.30.02.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 02:17:05 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Douglas Anderson , Matthias Kaehlcke , Shawn Lin , Yong Mao , Chaotian Jing Subject: [PATCH 4/4] mmc: sdio: Align the initialization commands in retry path for UHS-I Date: Thu, 30 Apr 2020 11:16:40 +0200 Message-Id: <20200430091640.455-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200430091640.455-1-ulf.hansson@linaro.org> References: <20200430091640.455-1-ulf.hansson@linaro.org> MIME-Version: 1.0 According to the comment in mmc_sdio_reinit_card(), some SDIO cards may require a "[CMD5,5,3,7] init sequence", which isn't always obeyed in mmc_sdio_init_card(). Especially, when we end up retrying the UHS-I specific initialization, there is a missing CMD5. Let's update the code to make the behaviour consistent and let's also take the opportunity to clean up the code a bit, to avoid open coding. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 53 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 27 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 853ac65f0485..435de47a6ee0 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -543,13 +543,33 @@ static int mmc_sdio_init_uhs_card(struct mmc_card *card) return err; } -static void mmc_sdio_resend_if_cond(struct mmc_host *host, u32 ocr, - struct mmc_card *card) +static int mmc_sdio_pre_init(struct mmc_host *host, u32 ocr, + struct mmc_card *card) { + if (card) + mmc_remove_card(card); + + /* + * Reset the card by performing the same steps that are taken by + * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe. + * + * sdio_reset() is technically not needed. Having just powered up the + * hardware, it should already be in reset state. However, some + * platforms (such as SD8686 on OLPC) do not instantly cut power, + * meaning that a reset is required when restoring power soon after + * powering off. It is harmless in other cases. + * + * The CMD5 reset (mmc_send_io_op_cond()), according to the SDIO spec, + * is not necessary for non-removable cards. However, it is required + * for OLPC SD8686 (which expects a [CMD5,5,3,7] init sequence), and + * harmless in other situations. + * + */ + sdio_reset(host); mmc_go_idle(host); mmc_send_if_cond(host, ocr); - mmc_remove_card(card); + return mmc_send_io_op_cond(host, 0, NULL); } /* @@ -640,7 +660,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, if (rocr & ocr & R4_18V_PRESENT) { err = mmc_set_uhs_voltage(host, ocr_card); if (err == -EAGAIN) { - mmc_sdio_resend_if_cond(host, ocr_card, card); + mmc_sdio_pre_init(host, ocr_card, card); retries--; goto try_again; } else if (err) { @@ -712,7 +732,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, */ err = sdio_read_cccr(card, ocr); if (err) { - mmc_sdio_resend_if_cond(host, ocr_card, card); + mmc_sdio_pre_init(host, ocr_card, card); if (ocr & R4_18V_PRESENT) { /* Retry init sequence, but without R4_18V_PRESENT. */ retries = 0; @@ -813,28 +833,7 @@ static int mmc_sdio_reinit_card(struct mmc_host *host) { int ret; - /* - * Reset the card by performing the same steps that are taken by - * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe. - * - * sdio_reset() is technically not needed. Having just powered up the - * hardware, it should already be in reset state. However, some - * platforms (such as SD8686 on OLPC) do not instantly cut power, - * meaning that a reset is required when restoring power soon after - * powering off. It is harmless in other cases. - * - * The CMD5 reset (mmc_send_io_op_cond()), according to the SDIO spec, - * is not necessary for non-removable cards. However, it is required - * for OLPC SD8686 (which expects a [CMD5,5,3,7] init sequence), and - * harmless in other situations. - * - */ - - sdio_reset(host); - mmc_go_idle(host); - mmc_send_if_cond(host, host->card->ocr); - - ret = mmc_send_io_op_cond(host, 0, NULL); + ret = mmc_sdio_pre_init(host, host->card->ocr, NULL); if (ret) return ret;