Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp347911pxu; Thu, 3 Dec 2020 01:37:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyE8wcXvxRjACPvKMOvug/wMuDBAAYRq7VZwQOAGcvCCYwuWTjQAvCvV2k2owE8dOthlvaR X-Received: by 2002:a50:d2d2:: with SMTP id q18mr1978947edg.346.1606988237509; Thu, 03 Dec 2020 01:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606988237; cv=none; d=google.com; s=arc-20160816; b=NtRxvBcL9HYrhcWT7uveiMGRKuHeqt7jj9Ccj0gTaMaKJHrgDqOFDZREO4yntK9GgO r6/GFqdkaB1m48s/V6EG0zSHCX/28KQaJU2H2kevn3Cx2dxQYE+HpaDnPSXH9wzfwSXb bsWZgAi0v54cce57HEdLNhjmbn4W51KGnI1oW1XAbpMLdoKJrLQKbtXroKcE73aw2ByD rsAyfaQueXiWVhY/P7XFHYoETA8OrRMr3mdM4D4mMgvV4tjBerbQMDZbN2NMKZdxfUxU qFSEdz17ZXj6bcYJq+OYGo6/71KapQIXJGyVsDRgwpj8Jg3tzYP4lwuaGJVBqnwKqB7k umCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mcCq21oyPMVXtK1/FM22qRkc4RXQbfkaQWoJDrmsx4c=; b=ml/xWp8pHkTsKzrZ4FWxQzD1zNS0DZh/+ZpTn+N0CyyJ6CCD687tcThGhluj9ix5xg 50q0XStA5EpvJV5BmG6LMkv2siMlw/LkrhTBNgnyz1al7gQ41P9TDPvwV5WtRzmgNcKT /TDXxHj4V1HRcuIFRoaHFIk/QBLKqIg3Td6J8iVobjpQX/BUrFXkx/lGs4iza8iAiY35 V9q0+2t6bI8sc4At6pSq2eXItZLbHGEqYq0R3jX0mE4L2LZNuRVH2QF2+uVxIIPGRkDD F6vyEuXsIjFuIbrYbSHu2A9fi7F4F17krXZFXfPpZYHSu+VmrzEFX54r0N/pIoHQMZQa gGYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si768470ejm.460.2020.12.03.01.36.54; Thu, 03 Dec 2020 01:37:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387496AbgLCJfC (ORCPT + 99 others); Thu, 3 Dec 2020 04:35:02 -0500 Received: from server-x.ipv4.hkg02.ds.network ([27.111.83.178]:37248 "EHLO mail.gtsys.com.hk" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgLCJfC (ORCPT ); Thu, 3 Dec 2020 04:35:02 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.gtsys.com.hk (Postfix) with ESMTP id 72BED20370C7; Thu, 3 Dec 2020 17:34:14 +0800 (HKT) X-Virus-Scanned: Debian amavisd-new at gtsys.com.hk Received: from mail.gtsys.com.hk ([127.0.0.1]) by localhost (mail.gtsys.com.hk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XaUp_DqSZvIZ; Thu, 3 Dec 2020 17:34:14 +0800 (HKT) Received: from s01.gtsys.com.hk (unknown [10.128.4.2]) by mail.gtsys.com.hk (Postfix) with ESMTP id 58AE720001F5; Thu, 3 Dec 2020 17:34:14 +0800 (HKT) Received: from armhf2.gtsys.com.hk (unknown [10.128.4.15]) by s01.gtsys.com.hk (Postfix) with ESMTP id 4FE1CC019FF; Thu, 3 Dec 2020 17:34:14 +0800 (HKT) Received: by armhf2.gtsys.com.hk (Postfix, from userid 1000) id 5286F200756; Thu, 3 Dec 2020 17:34:14 +0800 (HKT) From: Chris Ruehl To: Avri Altman Cc: Jack , Chris Ruehl , Ulf Hansson , Yoshihiro Shimoda , Wolfram Sang , Baolin Wang , Krishna Konda , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mmc: core: prepare hs400 update, code order Date: Thu, 3 Dec 2020 17:33:27 +0800 Message-Id: <20201203093338.10480-2-chris.ruehl@gtsys.com.hk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203093338.10480-1-chris.ruehl@gtsys.com.hk> References: <20201203093338.10480-1-chris.ruehl@gtsys.com.hk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch didn't change functionality just move mmc_select_hs400() and mmc_hs200_to_hs400() between mmc_select_hs400es() and mmc_select_hs200 and fix checkpatch --script warings. Signed-off-by: Chris Ruehl --- drivers/mmc/core/mmc.c | 184 ++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index ff3063ce2acd..5477786aded8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1142,98 +1142,6 @@ static int mmc_select_hs_ddr(struct mmc_card *card) return err; } -static int mmc_select_hs400(struct mmc_card *card) -{ - struct mmc_host *host = card->host; - unsigned int max_dtr; - int err = 0; - u8 val; - - /* - * HS400 mode requires 8-bit bus width - */ - if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && - host->ios.bus_width == MMC_BUS_WIDTH_8)) - return 0; - - /* Switch card to HS mode */ - 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); - if (err) { - pr_err("%s: switch to high-speed from hs200 failed, err:%d\n", - mmc_hostname(host), err); - return err; - } - - /* Prepare host to downgrade to HS timing */ - if (host->ops->hs400_downgrade) - host->ops->hs400_downgrade(host); - - /* Set host controller to HS timing */ - mmc_set_timing(host, MMC_TIMING_MMC_HS); - - /* Reduce frequency to HS frequency */ - max_dtr = card->ext_csd.hs_max_dtr; - mmc_set_clock(host, max_dtr); - - err = mmc_switch_status(card, true); - if (err) - goto out_err; - - if (host->ops->hs400_prepare_ddr) - host->ops->hs400_prepare_ddr(host); - - /* Switch card to DDR */ - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_BUS_WIDTH, - EXT_CSD_DDR_BUS_WIDTH_8, - card->ext_csd.generic_cmd6_time); - if (err) { - pr_err("%s: switch to bus width for hs400 failed, err:%d\n", - mmc_hostname(host), err); - return err; - } - - /* Switch card to HS400 */ - val = EXT_CSD_TIMING_HS400 | - card->drive_strength << EXT_CSD_DRV_STR_SHIFT; - err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_HS_TIMING, val, - card->ext_csd.generic_cmd6_time, 0, - false, true); - if (err) { - pr_err("%s: switch to hs400 failed, err:%d\n", - mmc_hostname(host), err); - return err; - } - - /* Set host controller to HS400 timing and frequency */ - mmc_set_timing(host, MMC_TIMING_MMC_HS400); - mmc_set_bus_speed(card); - - if (host->ops->hs400_complete) - host->ops->hs400_complete(host); - - err = mmc_switch_status(card, true); - if (err) - goto out_err; - - return 0; - -out_err: - pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), - __func__, err); - return err; -} - -int mmc_hs200_to_hs400(struct mmc_card *card) -{ - return mmc_select_hs400(card); -} - int mmc_hs400_to_hs200(struct mmc_card *card) { struct mmc_host *host = card->host; @@ -1425,6 +1333,98 @@ static int mmc_select_hs400es(struct mmc_card *card) return err; } +static int mmc_select_hs400(struct mmc_card *card) +{ + struct mmc_host *host = card->host; + unsigned int max_dtr; + int err = 0; + u8 val; + + /* + * HS400 mode requires 8-bit bus width + */ + if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && + host->ios.bus_width == MMC_BUS_WIDTH_8)) + return 0; + + /* Switch card to HS mode */ + 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); + if (err) { + pr_err("%s: switch to high-speed from hs200 failed, err:%d\n", + mmc_hostname(host), err); + return err; + } + + /* Prepare host to downgrade to HS timing */ + if (host->ops->hs400_downgrade) + host->ops->hs400_downgrade(host); + + /* Set host controller to HS timing */ + mmc_set_timing(host, MMC_TIMING_MMC_HS); + + /* Reduce frequency to HS frequency */ + max_dtr = card->ext_csd.hs_max_dtr; + mmc_set_clock(host, max_dtr); + + err = mmc_switch_status(card, true); + if (err) + goto out_err; + + if (host->ops->hs400_prepare_ddr) + host->ops->hs400_prepare_ddr(host); + + /* Switch card to DDR */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_BUS_WIDTH, + EXT_CSD_DDR_BUS_WIDTH_8, + card->ext_csd.generic_cmd6_time); + if (err) { + pr_err("%s: switch to bus width for hs400 failed, err:%d\n", + mmc_hostname(host), err); + return err; + } + + /* Switch card to HS400 */ + val = EXT_CSD_TIMING_HS400 | + card->drive_strength << EXT_CSD_DRV_STR_SHIFT; + err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_HS_TIMING, val, + card->ext_csd.generic_cmd6_time, 0, + false, true); + if (err) { + pr_err("%s: switch to hs400 failed, err:%d\n", + mmc_hostname(host), err); + return err; + } + + /* Set host controller to HS400 timing and frequency */ + mmc_set_timing(host, MMC_TIMING_MMC_HS400); + mmc_set_bus_speed(card); + + if (host->ops->hs400_complete) + host->ops->hs400_complete(host); + + err = mmc_switch_status(card, true); + if (err) + goto out_err; + + return 0; + +out_err: + pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), + __func__, err); + return err; +} + +int mmc_hs200_to_hs400(struct mmc_card *card) +{ + return mmc_select_hs400(card); +} + /* * For device supporting HS200 mode, the following sequence * should be done before executing the tuning process. -- 2.20.1