From patchwork Wed Dec 21 11:28:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 636529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74073C10F1B for ; Wed, 21 Dec 2022 11:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiLUL25 (ORCPT ); Wed, 21 Dec 2022 06:28:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234537AbiLUL2z (ORCPT ); Wed, 21 Dec 2022 06:28:55 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2055.outbound.protection.outlook.com [40.107.15.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7C42315C for ; Wed, 21 Dec 2022 03:28:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8jVsa4ason55HmA6Nj5yGTfyeFgpfgYLK5cafefW80mbfkt1Qgx4Enh2XDgsIQFjQ5G9hkYHO+3y38eOUC71S+9I9JUoB4b+FO1sIQZZwYVelFNtpwoDl5HRXzfUCRfjimrc4fPTD7JcDTl9CVycoQXjm80B7lpjZk4zXBjfQHHB6BwNr0qEDq3OzGLL/ovJQxjEpycCaGYpa6pWzMYU+HzqSq+IR51YnL+ARNUQNEggoYxv1jN7+i3Voo/1C51qpKvH1JWSTOLIC4CgvLu0IFBoscv7Iqer3Sc8m+pCUoj7PdHZ9RWL486f8Q6fxL4xTdfeLVrbxonag3r6O/EWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f8uRlppJfmpn0m29G7TvPlOTMdCnlTuaGNK/V/1nB7M=; b=an3gOMJgQ5CwftD/mZAHBm7scyPWSPiW5wkFxwheGNBLGs8RF2RqV44fnTVQ/LfWtRN1MBXW1Tf2fsXStyKjXCo0Xmxr1JFn8xQz2Zzrq+hsO9l2sWirf5ZLw2Ae8cTUxe1dKiC7PUekgiaPFLIG3E01rm2pAv9gQYbrI2V3CpSiyWyh+7WWukLWpC85GV95qrWQimGvwFz0uROGveZmRiVCESwU0ih7i/hjty6sgiBEP3zDyq4iwM351oWC+KhiRw50W9GdmH1ip1fO679OoZ0lbpFBWfdi2gOewvlQqFXbPRRS0riqifJhZkrRcnnUDDDJT2hFL2znwbmPAMH5zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f8uRlppJfmpn0m29G7TvPlOTMdCnlTuaGNK/V/1nB7M=; b=GV2mkIh7CY7FUo7oJl/h17ze31X7FVn+JCmnPg1jSUZhsI3XjeZddqKAjjyMMr+sXUo5MxpFrmcM8xNKqId1KWHs52xMbuqs6W38FBdN7YSaKaNVhV6HqZVfRmejSVVSgmRfGqhCVqc1wWEpj19bvEznAZ14XNHWj59+uVvngy4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4010.eurprd04.prod.outlook.com (2603:10a6:5:21::30) by PAXPR04MB8575.eurprd04.prod.outlook.com (2603:10a6:102:216::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 11:28:51 +0000 Received: from DB7PR04MB4010.eurprd04.prod.outlook.com ([fe80::7479:76ef:8e5:da0b]) by DB7PR04MB4010.eurprd04.prod.outlook.com ([fe80::7479:76ef:8e5:da0b%6]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 11:28:51 +0000 From: haibo.chen@nxp.com To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-mmc@vger.kernel.org, kgroeneveld@lenbrook.com, haibo.chen@nxp.com Subject: [PATCH v2 1/3] mmc: sdhci-esdhc-imx: simplify the auto tuning logic Date: Wed, 21 Dec 2022 19:28:51 +0800 Message-Id: <20221221112853.789675-2-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221221112853.789675-1-haibo.chen@nxp.com> References: <20221221112853.789675-1-haibo.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0227.apcprd06.prod.outlook.com (2603:1096:4:68::35) To DB7PR04MB4010.eurprd04.prod.outlook.com (2603:10a6:5:21::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4010:EE_|PAXPR04MB8575:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ff57bae-7b6f-4745-2c00-08dae3468906 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9kREcJidOmtQT5v3dLysmKEnEyOMZNATuryfpmy3H2rVdidxvbXHj3vfuyI4U6tfq1F2iqQiQ5GzlzD/KpBBOHRn2mz3pUyJFzQVk4cGqsH2eD0tLRnaCJCXsus8vO12NGiNWAmc08QizuJHuTwBt2SaSOusB9p+Ee2f8EC+aUGsxjeppXh9zXZv65Z2sIUEv4aTIHB7nbMPj05fyKZQyIyIs0+i3quKlrHxYtS2TsYZhFIxHZtw1cfpfVb6fwR3W5RLZcZxRyCMlfuovc/UB70xEAuZB5Mr2qLZwGZ1kJlhwsPJKdjiT0A4wiLOdTMJEW6Zk2JE5pT9uYT0x6BMqDi7oQjv9n/LqyWA2jhFFYiWMnc4BZOb/VmIOp2N2W74FXQvYdIB/zn4LT4TWSgdVHewtnr16pfNMHFKnFTaTD+W95OJIlhvQx4KPtCmTiz0LNf7U9x45ZuSepg31Dh+xiTHutdXBJvW+e9ag5SYiZv5Nt0+q+yoRtSwZ9XMnj9bTY3ihcIBDBBr2NPzoWLXGwsNTDSe2e58tOzLj47wDq22QHmZf6lbZilfF0cB/kqfU+bwaNXVC1XwKxDFEpo3x6zpsY9x+tAl8GhFcH4+3Ofj72U+zv+NxJta89Ynam77gXVyOXe157JplvBK8EzZXgKQpkscx0hgXCpoFCU3ohJxZXbjao2grYTe+kCVx10qMAFdIc6sdkoBfj1RuBq/oA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB4010.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(376002)(366004)(396003)(346002)(451199015)(6506007)(52116002)(2906002)(6486002)(478600001)(26005)(2616005)(66476007)(36756003)(66556008)(66946007)(4326008)(41300700001)(8676002)(1076003)(316002)(6512007)(9686003)(8936002)(186003)(5660300002)(83380400001)(38350700002)(86362001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /NGPG/vdjHVIFmSfh2ppIYhEFP7s7KnPDTecOTujjNUrXDikZmwkEJ2YLmhzN1l94afJHoBUmPTMTFswX1a4jgIniD59lWsrP+NnIeTjbSrVeK6uvNJK6Gsa5/XOgGRTfuRiOk8yQwqM1JbgGtzyuM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WCCm8grv1zWjMr6sEe60CGmX30zzrY0qoGQl95H9gt483XKxM+cxI7qtswH7pP3mvU8HhICVWdGqua6fsZGmDXEewu4DO5Xq0hQgmzdRB+W2w1CdcXln3DnX4oEalv8UlXETHWc3ojFg5rnlUyh8R5mgxVwXDmaNWRZqyae2ECWQpyxvZIKT4uBJvv+zcu0HfCJq4SylQ6tim6M8pGgkkTrSlWLfdC0tO05aclVkWM8gRJsT5R+kLS6RiyvWflWUTh3XDuWRK0mUWGEvTIRmqHISfcuXrRSb4HGSxQUmv7FvHLR8TD9P5GAEcccyJnKkWm3Arr3SH4rSUwE03lLnRlfz87ThzDr93agOfqpTMNyD+DtfU+u6ljOjb3 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ff57bae-7b6f-4745-2c00-08dae3468906 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4010.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 11:28:51.5257 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xi1CcesZveAmO41W599Ur2gAAFs/uJiYbxIMWSWUKhtKyEqKYp6eX6NOfokIKGOP7Ou1cXNiQ9BGQwc8J9HhGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8575 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Haibo Chen Clear auto tuning bit when reset tuning, and enable auto tuning only after tuning done successfully for both standard tuning and manual tuning. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 89ef0c80ac37..bf8d6f60a9ee 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -429,9 +429,10 @@ static inline void esdhc_wait_for_card_clock_gate_off(struct sdhci_host *host) } /* Enable the auto tuning circuit to check the CMD line and BUS line */ -static inline void usdhc_auto_tuning_mode_sel(struct sdhci_host *host) +static inline void usdhc_auto_tuning_mode_sel_and_en(struct sdhci_host *host) { u32 buswidth, auto_tune_buswidth; + u32 reg; buswidth = USDHC_GET_BUSWIDTH(readl(host->ioaddr + SDHCI_HOST_CONTROL)); @@ -450,6 +451,10 @@ static inline void usdhc_auto_tuning_mode_sel(struct sdhci_host *host) esdhc_clrset_le(host, ESDHC_VEND_SPEC2_AUTO_TUNE_MODE_MASK, auto_tune_buswidth | ESDHC_VEND_SPEC2_AUTO_TUNE_CMD_EN, ESDHC_VEND_SPEC2); + + reg = readl(host->ioaddr + ESDHC_MIX_CTRL); + reg |= ESDHC_MIX_CTRL_AUTO_TUNE_EN; + writel(reg, host->ioaddr + ESDHC_MIX_CTRL); } static u32 esdhc_readl_le(struct sdhci_host *host, int reg) @@ -681,14 +686,11 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) } else { v &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; m &= ~ESDHC_MIX_CTRL_FBCLK_SEL; - m &= ~ESDHC_MIX_CTRL_AUTO_TUNE_EN; } if (val & SDHCI_CTRL_EXEC_TUNING) { v |= ESDHC_MIX_CTRL_EXE_TUNE; m |= ESDHC_MIX_CTRL_FBCLK_SEL; - m |= ESDHC_MIX_CTRL_AUTO_TUNE_EN; - usdhc_auto_tuning_mode_sel(host); } else { v &= ~ESDHC_MIX_CTRL_EXE_TUNE; } @@ -1022,13 +1024,15 @@ static void esdhc_reset_tuning(struct sdhci_host *host) /* Reset the tuning circuit */ if (esdhc_is_usdhc(imx_data)) { + ctrl = readl(host->ioaddr + ESDHC_MIX_CTRL); + ctrl &= ~ESDHC_MIX_CTRL_AUTO_TUNE_EN; if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) { - ctrl = readl(host->ioaddr + ESDHC_MIX_CTRL); ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; ctrl &= ~ESDHC_MIX_CTRL_FBCLK_SEL; writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { + writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; ctrl &= ~ESDHC_MIX_CTRL_EXE_TUNE; @@ -1054,6 +1058,7 @@ static void esdhc_reset_tuning(struct sdhci_host *host) static int usdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) { struct sdhci_host *host = mmc_priv(mmc); + int err; /* * i.MX uSDHC internally already uses a fixed optimized timing for @@ -1068,7 +1073,12 @@ static int usdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) * correct delay cell. */ esdhc_reset_tuning(host); - return sdhci_execute_tuning(mmc, opcode); + err = sdhci_execute_tuning(mmc, opcode); + /* If tuning done, enable auto tuning */ + if (!err && !host->tuning_err) + usdhc_auto_tuning_mode_sel_and_en(host); + + return err; } static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) @@ -1102,11 +1112,8 @@ static void esdhc_post_tuning(struct sdhci_host *host) { u32 reg; - usdhc_auto_tuning_mode_sel(host); - reg = readl(host->ioaddr + ESDHC_MIX_CTRL); reg &= ~ESDHC_MIX_CTRL_EXE_TUNE; - reg |= ESDHC_MIX_CTRL_AUTO_TUNE_EN; writel(reg, host->ioaddr + ESDHC_MIX_CTRL); } From patchwork Wed Dec 21 11:28:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 635897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84186C4332F for ; Wed, 21 Dec 2022 11:29:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234063AbiLUL3F (ORCPT ); Wed, 21 Dec 2022 06:29:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234274AbiLUL3E (ORCPT ); Wed, 21 Dec 2022 06:29:04 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2042.outbound.protection.outlook.com [40.107.15.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B63C10AF for ; Wed, 21 Dec 2022 03:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZWtlsoeU4/9X9xmU+hWuZpw4Ak7b5xYmfHcoqQFKWgA87SVaUFsOqjt/b0Z8KZPiWbxAm9NO2Swxn/bBjCNqtLG/+rpe07aSSjXvcPMjmBb3J3Pik8Qagbh3DUfvCDoK9nps7et54E7s2XH0Bj6Bo1IwIjiNNnMi2Zn0meItBKbKozqEhbRPxGXs9EkU5AG1iQ+zLYkQyCqtuxpki2ZFZEzPZn1nRwzSHIxf0GqlPLeRYzcKUBpQRVQlWl9AQojRvVed0LG7nSMZfCBXv212mZm/JlueMt54lO+xvxNqpErmw+47BAC3q1tLOWAqh690qaBVSk7vjSOsd02gunVmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mKZIZVAV7cvdwnLxIDpaw7Mk3dnd0ggHxmACbgFuV+Y=; b=SmJ5FZ1UxKiqclEa5yYVGHMhIQHP6YPEPHp1NCSOtdrO66xFnmn9aWOZ+Mn0JeklWRcK/igtnEPkKZRpSEwe58//SAr5v2auGG/a/1Bu2jDX0jmOYwhkfOLloVtIpJ94B7bySPwszalFeLJNZKrYZ0ntSSe6xxdFLLAv5WOoXsopDtrlCqt7sTcCtYtH8KRjGnq8fftD8yy8A/8pQNpNhtJRC6yA73hvh+/zdCzYVIXDh18+wX8L7fKlLiWY9zvONDU3jwtOyKb9rJQ3ABEfVj9bqvSDkddBjgGOyCsJVnXxOb+szL+NE4glXmGPUR0mHRdA/kUsuXT/61IuxjxTsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mKZIZVAV7cvdwnLxIDpaw7Mk3dnd0ggHxmACbgFuV+Y=; b=SWiNW5cI9pYBuclMCXC88hAbv7dwiEt1X8UT1d5LbvoO5zuZy0/EEUWoNAt70fIeaD3bOccjsZTSdD0jIlIb7FOgeloSrtyr0zhoFf2yGZdBynQsfkTUDm2NgmMS8LVhggMKmgVw5Dp4xIIQKJovDjNPQ3rPOpK4QlMDaoH1ocM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4010.eurprd04.prod.outlook.com (2603:10a6:5:21::30) by PAXPR04MB8575.eurprd04.prod.outlook.com (2603:10a6:102:216::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 11:29:00 +0000 Received: from DB7PR04MB4010.eurprd04.prod.outlook.com ([fe80::7479:76ef:8e5:da0b]) by DB7PR04MB4010.eurprd04.prod.outlook.com ([fe80::7479:76ef:8e5:da0b%6]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 11:28:55 +0000 From: haibo.chen@nxp.com To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-mmc@vger.kernel.org, kgroeneveld@lenbrook.com, haibo.chen@nxp.com Subject: [PATCH v2 2/3] mmc: let the host side can find card type during card init process Date: Wed, 21 Dec 2022 19:28:52 +0800 Message-Id: <20221221112853.789675-3-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221221112853.789675-1-haibo.chen@nxp.com> References: <20221221112853.789675-1-haibo.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0227.apcprd06.prod.outlook.com (2603:1096:4:68::35) To DB7PR04MB4010.eurprd04.prod.outlook.com (2603:10a6:5:21::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4010:EE_|PAXPR04MB8575:EE_ X-MS-Office365-Filtering-Correlation-Id: 581dd4d1-ad6b-4148-4488-08dae3468b10 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YJDPVkOmgO6Gnak37cXSc4y768cTq9xbdiMtDp7+QxdvE9FW9XlSM3xbUoaFNNHhWGwrHX0/KZU02KMLILzGTMew3lrHL1N7SZRFzuSa8hBF8krcGxj1NX0BjcjvV9M9yxC1tNI8HZWYAtVMrlqBHiO9Qk1KdPL8dY5x5VUGrX7KxBpJutN3HaTe7T6UgJ4WSfYecrOGsnuW4CELVbdSB7M113L8ybUX7jJIHo1At3XvEkbqag84kuIT9+otOftjSNpr7hb5xLiIziOtLgS+bmPZJN4yPa0FnP3FQzlT6apWrTpkgNQQXZn2VAtiFimbNDkXbrvWIK8r3Si6S3QQ8e1WbsQBbyNbFiKK0l4Q6SZsOBuFa4+66SZnir02VKB8BY+tsMIb89Yl7V84+DuqvXOcbyxdTDkZB4UHtlP9Wa3fTtwoN9WEPH7tAOTizPYmyuID/kcsTs8ei2giXs9BbSqFfPFlPyTxogeD5+dlVbkYZL2bvniaNpaspQUuKWOl6QA505UO+5c8ptiAzTsIZ5Tqv/8/SmBj2PCCxauQaW8d+7xqvg0f9O+5eORrHGTXg5cuZbD1/tHeP02FcpLVI0nG26ODuURj0Wpzv0EOCG1s4W43FMWFQ3SWaqqWH9QcUQ6iSsfYMRu3yqUTIjMW430pkoan9pgI1BdNPn5d7r4vsGQt+griGs9KxbT3er4Q7vB0Kx7Bkhk5UPaeEM8h+w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB4010.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(376002)(366004)(396003)(346002)(451199015)(6506007)(52116002)(2906002)(6486002)(478600001)(26005)(6666004)(2616005)(66476007)(36756003)(66556008)(66946007)(4326008)(41300700001)(8676002)(1076003)(316002)(6512007)(9686003)(8936002)(186003)(5660300002)(83380400001)(38350700002)(86362001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VeKDG6nNALcrnG3YhGdOrLhlIgsiOxVNSbBV5y7oZN/fD2yQxLVEV1ruJC2Z+lvAGFQDUc4cbKI6cNw9AlHJSYXzys5SfF1fxjUjephviDqZxRBNIXUai/GraLrOhAIUX06WwBuCTOfVLibZrhrR/QmKzQtcniI/4mN7nCt/fr6/wwc6y47pj51hO0JsRlsA08nHJnDP2giIGQhj///yIo6C5iiUDv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vhH8NBzXXfziF/X4SznCKVKxdGWb09UcaiHlMqFwP3xtJJo2HAsz0ZN72elzXVOBRbaQ0UNBIiJmi4c4LmmwluflbRGUBLS1Eliiil8xQ+LJ6fWrvXhgVs81EYf5nABpSMBtXps29/9mKnF6gCBFDlIUbqdnQGfzFeAd9e35Re5Ykp79PMxZXwEmc7FNlWh3zWmo1exD5WIC9e597COJAA/EnOEtDHH4pruqiA5F9+DE1MSDdVlCQwRbDVaIYpo2gH6hTcJmi7gIrzWMx24AJNKATldEHQ7Q2LqCxB8MI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 581dd4d1-ad6b-4148-4488-08dae3468b10 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4010.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 11:28:54.9473 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wk+md4iWrgcXrqcHONhSsVOlf0QqAwe6d5mwd0ie2QYlpKsjDHo8Wl1GIYrkEiknZqRCTnAac7UABmjjRtjlxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8575 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Haibo Chen During the card init, the host side sometimes may need to distinguish the card type to handle accordingly. So need to give host->card value earlier. Signed-off-by: Haibo Chen --- drivers/mmc/core/mmc.c | 9 +++++---- drivers/mmc/core/sd.c | 7 +++++-- drivers/mmc/core/sdio.c | 10 ++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 89cd48fcec79..63de76a51be3 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1658,6 +1658,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, goto err; } + host->card = card; + card->ocr = ocr; card->type = MMC_TYPE_MMC; card->rca = 1; @@ -1926,14 +1928,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, goto free_card; } - if (!oldcard) - host->card = card; - return 0; free_card: - if (!oldcard) + if (!oldcard) { mmc_remove_card(card); + host->card = NULL; + } err: return err; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 72b664ed90cf..147b188b916e 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1431,6 +1431,8 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, if (IS_ERR(card)) return PTR_ERR(card); + host->card = card; + card->ocr = ocr; card->type = MMC_TYPE_SD; memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); @@ -1563,12 +1565,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, goto free_card; } - host->card = card; return 0; free_card: - if (!oldcard) + if (!oldcard) { mmc_remove_card(card); + host->card = NULL; + } return err; } diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index f64b9ac76a5c..5bcf4ada4738 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -699,6 +699,9 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, if (IS_ERR(card)) return PTR_ERR(card); + if (!oldcard) + host->card = card; + if ((rocr & R4_MEMORY_PRESENT) && mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) { card->type = MMC_TYPE_SD_COMBO; @@ -800,8 +803,6 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, if (oldcard) mmc_remove_card(card); - else - host->card = card; return 0; } @@ -898,14 +899,15 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, goto remove; } - host->card = card; return 0; mismatch: pr_debug("%s: Perhaps the card was replaced\n", mmc_hostname(host)); remove: - if (oldcard != card) + if (oldcard != card) { mmc_remove_card(card); + host->card = NULL; + } return err; } From patchwork Wed Dec 21 11:28:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 636528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16422C10F1B for ; Wed, 21 Dec 2022 11:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234274AbiLUL3G (ORCPT ); Wed, 21 Dec 2022 06:29:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234448AbiLUL3F (ORCPT ); Wed, 21 Dec 2022 06:29:05 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2042.outbound.protection.outlook.com [40.107.15.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7606B1C91C for ; Wed, 21 Dec 2022 03:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iVfoG6HHkPu76tX7syTqSfxTeRC+0ffHKGmf0H/XILFsfRlTuI4rJIMmLVhKNiN2FF9EjagvRWCFwNQgZEKQmkk0Y/bTMEPxQJ1EOCgzJLCkXlWAc+r41FoaMHKoZjYlwNMslJMXaDKGHnfqBDpB9RmgnhlnozwrDqJKgEPzVc9JjSH/hcwuuebMrN5RfMnMWY8c7ZZ6DsMlXUlFoP79xm9ud3qO3OO8z6g/IjCLdP54PFhDfoYiEcWWtp2yVMIKlhh1TaV/xfSuQrQqezyYKdX4dMHq6fZaXmwJgj46mYfKmdHmwX0MufgKKQLLhVFLSHfBYIkJT0vWtd8u5o7S6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ML+5xwYbhq1bjMhLMHk5QsNLZV9gNogbY34IhWHg+fo=; b=IxMyb+MTzZ7CJ500Zk2Xm5e/u5NtpBS3rD6wPv/M3CdWxN3iXlzeDdAgZexOAndPA35EvdBxlT0tF+WDb/svDT1gPuvAQk6ahHjSOHR4aScoaQ8g8g+CzURouIANWkYg60F4n6xJnJxpwwbYsaEdm0ws8ZwPM7Wwjkc1UpTbcP8B0Y9f/uelWpquqoYQkl2RAJwSutdTzOlMufLGEky7O7WbIpSxV8VpxMV6/EAdoW/yAVup0RxDG9F2OtXihnv4hL+EOkSXWFpu8uLX2H4qsPRA1qIPcelReWgDigIo+OF3CTQ/rXOSuDvO9J8HcHoy3GjIKGXMQg9KPiZnwG7tng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ML+5xwYbhq1bjMhLMHk5QsNLZV9gNogbY34IhWHg+fo=; b=APuNQbf6DBrCYKeuZdGrllo6C4zbAS+mbCK6BjBkUBQNQq6dQBYe+h4rG8dUX8L1Fu21Rh3xdwhnjNYujZp/fHIkxs5mjeCRZnEKVaS92e+/3/ISzc1uC6AEkP+jEqjyZKAfVnQ0SNk/TIfEUe0rE8Tml43IegranFjnJk992i4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4010.eurprd04.prod.outlook.com (2603:10a6:5:21::30) by PAXPR04MB8575.eurprd04.prod.outlook.com (2603:10a6:102:216::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 11:29:01 +0000 Received: from DB7PR04MB4010.eurprd04.prod.outlook.com ([fe80::7479:76ef:8e5:da0b]) by DB7PR04MB4010.eurprd04.prod.outlook.com ([fe80::7479:76ef:8e5:da0b%6]) with mapi id 15.20.5924.016; Wed, 21 Dec 2022 11:29:01 +0000 From: haibo.chen@nxp.com To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-mmc@vger.kernel.org, kgroeneveld@lenbrook.com, haibo.chen@nxp.com Subject: [PATCH v2 3/3] mmc: sdhci-esdhc-imx: only enable DAT[0] and CMD line auto tuning for SDIO device Date: Wed, 21 Dec 2022 19:28:53 +0800 Message-Id: <20221221112853.789675-4-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221221112853.789675-1-haibo.chen@nxp.com> References: <20221221112853.789675-1-haibo.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0227.apcprd06.prod.outlook.com (2603:1096:4:68::35) To DB7PR04MB4010.eurprd04.prod.outlook.com (2603:10a6:5:21::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4010:EE_|PAXPR04MB8575:EE_ X-MS-Office365-Filtering-Correlation-Id: e490cca5-8003-4ab4-5d19-08dae3468d1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4VqiGSv+IERGtbt5BcLqvsYIT0CGlptWDc//zCWWmxOWHEaeckP2jMb3H/9zcCrOn0cLNPI95+9UfQoqV3PNLpxnbHKyz0B//0K/RsarD9HfO/zy5AtVndZ591pafVhId3oCS2jUItzHHugMRAeoUfLbdwZAaEi58QoE2QqxK11R3jamYo3GOQqgAgzTcWRnGTbSbBAEpgTYLee/X4uttT+OumBOm0abZMB9lT1ofUbGw1dcw1xZVDBUV+xuVrESMJ0VIH2ZhgkIgngrGymYGwWev8WwM1Y4x7i6ROVAK5W8uRUTYbdBIxa7ImrJ2EUGM64efF2QD27FfMml9P29pfRmQ+dU0sxSzj68OXhNHLPfgx8auRChumI1EgdlmpL5V4VsDJGVixlvQkz9m7xUQUeW0kFUiRBjnVfb7TFFE44A9Ptm3iQdVUBy/4UlvWD+OOfwAA8+r1tnDR1Dc+JVl/S5YKzhyshiiHGE+a8quWBRD8qiQ+y18d05l4tnh/CTDncda8uIlVpQrew/Pbk7E8EF9jmh6ITf1yoRLQtuhZ+pU9dASaJtBTj3sdlJ3Pnukr3w8PmOJkt31Nb+o5mcTEizMEE+QIatVdVf0aacBbeSIJ1aUj3LYCRTrmprZcT4Z8NTVbZR9+VDNAr3coUya+NeR9dsq+792jqmNgg8Z3OoWgFPYX3bYzzxZ4g1SATbVrUslfHXvMJp4nV/IRpEBA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB4010.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(376002)(366004)(396003)(346002)(451199015)(6506007)(52116002)(2906002)(6486002)(478600001)(26005)(6666004)(2616005)(66476007)(36756003)(66556008)(66946007)(4326008)(41300700001)(8676002)(1076003)(316002)(6512007)(9686003)(8936002)(186003)(5660300002)(83380400001)(38350700002)(86362001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aYFhe228x8ldbdDeS7pC2louGg61lmzHukOhcGAdAWpWfnDNKGR4WHIMg+qhcgpcvNM5nLAISQ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06Ab/1VHUgl5rYh7sfGKDaeGg22r6/5Os53XV6xH700mcntNyvjvEIyRtipZoxpyqwsG7AD8pmdtoz1mOmbHmtmHQUBrFEemtF8J0Gr4uTigADrSYtdHYcQQE2lCCmDTfH8BfmxW62lS30+U1EqjM47/yEHiJLfMEJBYSSqNstnRnyPFO54+/oLZhJghWBqCgWP0bLAy/k3SyyMjm8UnrHq8tHTJNogouBzfmKK7v08bOs9Lto/kN+5oII5b1nsFwXlTRj6ynXz6IZg60wBfTW/e5ELJIDbTIqokZNMJMlAA/7UhuZT+0UIxF5qE2WJcyAUMG/0kWvzbt7cGQxh5IXz2T8KmMer/JGXFObRj3JQWi0cevlB4MzgEN18Cf55BHz42LIRZYAxGP9mZpBoS47PLgR114skI8xciMdyPdEG1QJy8O9ePmgcUTBmknnc8wkL6YLqL86Ns X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e490cca5-8003-4ab4-5d19-08dae3468d1a X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4010.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 11:28:58.4314 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ryABpxXnq96I9uCHGpZ9u78As0rtiUJd5D1qEp7Gpe1OhJIFQKnzmGJhwP7yULyzDu8Qb9HsU3U91RtQuFfgtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8575 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Haibo Chen USDHC IP has one limitation: the tuning circuit can't handle the async sdio device interrupt correctly. When sdio device use 4 data lines, async sdio interrupt will use the shared DAT[1], if enable auto tuning circuit to check these 4 data lines, include the DAT[1], this circuit will detect this interrupt, take this as data on DAT[1], and adjust the delay cell wrongly, finally will cause the DATA/CMD CRC error. So for SDIO device, only enable DAT[0] and CMD line for auto tuning. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index bf8d6f60a9ee..d6ce4c8d23dc 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -448,6 +448,20 @@ static inline void usdhc_auto_tuning_mode_sel_and_en(struct sdhci_host *host) break; } + /* + * For USDHC, auto tuning circuit can not handle the async sdio + * device interrupt correctly. When sdio device use 4 data lines, + * async sdio interrupt will use the shared DAT[1], if enable auto + * tuning circuit check these 4 data lines, include the DAT[1], + * this circuit will detect this interrupt, take this as a data on + * DAT[1], and adjust the delay cell wrongly. + * This is the hardware design limitation, to avoid this, for sdio + * device, config the auto tuning circuit only check DAT[0] and CMD + * line. + */ + if (!host->mmc->card && mmc_card_sdio(host->mmc->card)) + auto_tune_buswidth = ESDHC_VEND_SPEC2_AUTO_TUNE_1BIT_EN; + esdhc_clrset_le(host, ESDHC_VEND_SPEC2_AUTO_TUNE_MODE_MASK, auto_tune_buswidth | ESDHC_VEND_SPEC2_AUTO_TUNE_CMD_EN, ESDHC_VEND_SPEC2);