From patchwork Thu Mar 12 14:24:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 11434351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AA8B913 for ; Thu, 12 Mar 2020 14:24:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 077F120650 for ; Thu, 12 Mar 2020 14:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727486AbgCLOY6 (ORCPT ); Thu, 12 Mar 2020 10:24:58 -0400 Received: from mga14.intel.com ([192.55.52.115]:32517 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727340AbgCLOY6 (ORCPT ); Thu, 12 Mar 2020 10:24:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2020 07:24:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,545,1574150400"; d="scan'208";a="266348050" Received: from ahunter-desktop.fi.intel.com ([10.237.72.167]) by fmsmga004.fm.intel.com with ESMTP; 12 Mar 2020 07:24:56 -0700 From: Adrian Hunter To: Ulf Hansson , Chaotian Jing , Seo@vger.kernel.org, Kyungmin Cc: linux-mmc Subject: [PATCH RFC 3/3] mmc: core: Do not change frequency before switch from HS400 Date: Thu, 12 Mar 2020 16:24:05 +0200 Message-Id: <20200312142405.9813-4-adrian.hunter@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312142405.9813-1-adrian.hunter@intel.com> References: <20200312142405.9813-1-adrian.hunter@intel.com> Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Do not change frequency before switch from HS400 but in case of error try again after frequency change. Signed-off-by: Adrian Hunter --- drivers/mmc/core/mmc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 3e2ad728b55e..e2b3d7505d6c 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1235,20 +1235,27 @@ int mmc_hs400_to_hs200(struct mmc_card *card) int err; u8 val; - /* Reduce frequency to HS */ - max_dtr = card->ext_csd.hs_max_dtr; - mmc_set_clock(host, max_dtr); - /* Switch HS400 to HS DDR */ val = EXT_CSD_TIMING_HS; err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, val, card->ext_csd.generic_cmd6_time, 0, false, true, true); - if (err) - goto out_err; mmc_set_timing(host, MMC_TIMING_MMC_DDR52); + /* Reduce frequency to HS */ + max_dtr = card->ext_csd.hs_max_dtr; + mmc_set_clock(host, max_dtr); + + if (err) { + err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_HS_TIMING, val, + card->ext_csd.generic_cmd6_time, 0, false, + true, true); + } + if (err) + goto out_err; + err = mmc_switch_status(card, true); if (err) goto out_err;