Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2527327rdb; Sun, 3 Dec 2023 22:50:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsZSwcxcPmSvuek35lEhgh3rjLPOmYKI/lADqnsg92c/9OlzqfSvBts3x5W4yILN0tn2+2 X-Received: by 2002:a05:6358:9994:b0:168:e68f:ad59 with SMTP id j20-20020a056358999400b00168e68fad59mr5252287rwb.2.1701672617059; Sun, 03 Dec 2023 22:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701672617; cv=none; d=google.com; s=arc-20160816; b=nPffkUBIHw8Ja+Ly7rGCuH3UyCenjeIT3RqVD7yQ6St5/8Kymv+qXA/0TWPxVQvegf US4lk3rIawsTjG8t9cCbgAXtvF+OK90obwM4HiwOW6pIl2jZ5gIwEDK8Gwf1GakCGOlW 1KtUJANJOL2wkP1CGZsK3X76InbxJltER09y0wQCklS8Q0iNPLPvbEXrZzyHoyMtogfy KyKIgsBrRI7DHsmG9wYUozjDYkC9N9KstlpGJDp0d2YpZWsdanmZhwRYrJ/GiCH8xqpe je1TQ3lcx/inxTe7CwyhYqx4o4zl6cCksZc8B9tzPeR7vTwrOb1Ydd8dLUMQqWpEUD2x owIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=pUQNNbpFKtNjyfHrUD+0H0FurLEIE40YSSnxg9msFFc=; fh=EOWwISSUy3TLtLo1RAmMIFkh/CxXiTWGS9ALoL0FNnA=; b=Y3tKFJ9e5vc00G4eDRAStwcjWsXJT9RZaCjVTosPlFy7epCto9chV8/gqSFYh1Lt0F qJ8R9ua/IemddeI3GOS5vFVqwaJ8Nr1bAr1sRjmubDOIRf1jgKaSTvErsJ6ffiI9z4Hk Adl1xVxuGeNeoQujJ6+QMHQcTcQACwDtZUIvL4e6IaidZWNECHg/XjsW/j5aMSUEgibu qZd2jll9uL0297fYsWGBTgj4jO4G/065Y6aTtK7kemzE32Bzz8XmFp1ae3cRGbd5ldi6 W/a0Qy0kG11XrvDQciuZPMf4Xqja7KE6I3efyCz2TqSd6Pf0Mu0ju7bnCyyh6yXBc9jZ bk5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h8-20020a056a00218800b006cba60de063si7338788pfi.22.2023.12.03.22.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 22:50:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CAC178060462; Sun, 3 Dec 2023 22:50:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjLDGuC (ORCPT + 99 others); Mon, 4 Dec 2023 01:50:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjLDGuB (ORCPT ); Mon, 4 Dec 2023 01:50:01 -0500 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 991FCD3; Sun, 3 Dec 2023 22:50:06 -0800 (PST) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3B46niDT069714; Mon, 4 Dec 2023 14:49:44 +0800 (+08) (envelope-from Wenchao.Chen@unisoc.com) Received: from SHDLP.spreadtrum.com (shmbx05.spreadtrum.com [10.29.1.56]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4SkDf83GJWz2Nr542; Mon, 4 Dec 2023 14:44:00 +0800 (CST) Received: from xm9614pcu.spreadtrum.com (10.13.2.29) by shmbx05.spreadtrum.com (10.29.1.56) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 4 Dec 2023 14:49:43 +0800 From: Wenchao Chen To: , , , CC: , , , , , Wenchao Chen Subject: [PATCH] mmc: sprd: Fix eMMC init failure after hw reset Date: Mon, 4 Dec 2023 14:49:34 +0800 Message-ID: <20231204064934.21236-1-wenchao.chen@unisoc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.2.29] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To shmbx05.spreadtrum.com (10.29.1.56) X-MAIL: SHSQR01.spreadtrum.com 3B46niDT069714 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 03 Dec 2023 22:50:14 -0800 (PST) Some eMMC devices that do not close the auto clk gate after hw reset will cause eMMC initialization to fail. Signed-off-by: Wenchao Chen --- drivers/mmc/host/sdhci-sprd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index 6b8a57e2d20f..bed57a1c64b5 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -239,15 +239,19 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host, div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8); sdhci_enable_clk(host, div); + val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI); + mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN | SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN; /* Enable CLK_AUTO when the clock is greater than 400K. */ if (clk > 400000) { - val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI); - mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN | - SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN; if (mask != (val & mask)) { val |= mask; sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI); } + } else { + if (val & mask) { + val &= ~mask; + sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI); + } } } -- 2.17.1