From patchwork Mon Apr 15 07:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Clark X-Patchwork-Id: 13629525 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E8C5C4345F for ; Mon, 15 Apr 2024 07:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zs0bJQRp/QaPhX8FpoVwxMg/wIIinwsIUggEWBDcWqU=; b=x5bFPcQsSFQeZU wff/yHuCj6Jw8zVhXCrvOClfH+2c7wcgHWdn+uKflTLs/gfwKbqFgUoj/2rQfYZBud+31GMDn51vY 52dL2VhnozVBKN8XzAGV/lOPAq5P4O1ep/yodMvVxYPPF6SIzoJHBxI1/wqTf/dgyjVZ55wsJ5SIi dGXnFZirP4BFQ7atiSgYI2noIMycGLwrTQYThY7MZM4/r3Z1GxqoFIcI2lSdlk89egP1E3UlLoUcS YehHwT/TAho6G5w46W5J8lH3vVGRuanlt8IP3B/PQqG62EYYBNwAaEYmCAjqUchyrrscauCePvLZj x1OQsgUHWP194K9i/VkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwGQX-00000007HAE-3q9S; Mon, 15 Apr 2024 07:06:53 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwGQU-00000007H9n-2pi1 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 07:06:52 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e0bec01232so22412945ad.3 for ; Mon, 15 Apr 2024 00:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713164808; x=1713769608; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2kB+FGGZ1O8+acAP7LbuhoplMsezAErVFwb8wVQ9L3g=; b=GD5DVZEWyrmyfcW2+oV/3Onp4JeeGmka9U7ezkL042UdM9N5aCdBEv+gyr/giSA0M6 JbKl555NPp+mtfJ1z5tVcgv1UGFBfGnAQN9pJ+R51m6VD5NhdU7hOCjnfYfCzYfUb9jk hmOIsGgGS2rUOokPcwA+ky05JonC7OuV0H9sHnyXi6kdHbh6frbqH1CdBgzROP3rjiRm Jfa0TgYswHASBDodM2kguGvftBh2pReTV8PAazzJs3Ib/JNnm0pxR1ctOp41b6AKJRmm h5PffQKdCeEXWwoVrUulc/cIfjrVOJpb45kYOKh4myXBC6ynhXm+Vnvp1xIx1Wz645Wl KaIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713164808; x=1713769608; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2kB+FGGZ1O8+acAP7LbuhoplMsezAErVFwb8wVQ9L3g=; b=pw5xyIZ0Yf1+euHzOVI7/yOSXa/ZxbSrmmhOGeChGZy2iBU+bzIj5w7IQqIbEjmfTJ f0tUBFTsH3Huy6j2b2RedtX4sGP5DW1RBC8eLvh/KJXYqSjLjcEgJ2HviUxySngpOObx pGkfwZQsipjmhNUr4P2F1Z9kAUY0QLMGIJD+p/ilkWvBO2Jc4wR+GV7/ReQzEyEJUAZs a+noa1o6sVsVIiuuHFLHT7CAIYU10poYAElYGpPVxnmSJFICxgyyzHJB6UgroksAr8y7 ydzC7XYB3ugr06Emoc1E9yDgAArGUPiSm6BdFTKJ+FHWgmUCDeRChbkaHMjagpCMgFMl UQRg== X-Forwarded-Encrypted: i=1; AJvYcCWUWiN4JqofSUj7g+ha2gEgCfhYVRfAaXAQozh/N9Ds9qRfMk+btjd3CgiPF3iYKTHNp6AijnaLJyHa8pFpa+VdfFDqanRm59WpaZY07rpYJ4oogdQ= X-Gm-Message-State: AOJu0YyTGSlZGyYCqyM54ROZgI5sE3Akn51PUBLtkhO/0uvJI6zJ6OkA DZA8UOCcEWOo82pHnblb1JDFWz6p8mBOxcLAIXk+lTgvVKE0D/ro X-Google-Smtp-Source: AGHT+IHbW9V0dfDw+DWClhgSHiLxrom5pEzPyCvBJsgmCR1dx0pvZ9ygwXh0Tta3KFvhhHZ2Iw0gkw== X-Received: by 2002:a17:902:6909:b0:1e4:9c2f:d4f7 with SMTP id j9-20020a170902690900b001e49c2fd4f7mr7161372plk.28.1713164808070; Mon, 15 Apr 2024 00:06:48 -0700 (PDT) Received: from den-build.fareast.nevint.com ([116.228.68.226]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001e503c555afsm7200909pld.97.2024.04.15.00.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 00:06:47 -0700 (PDT) From: Richard Clark To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, richard.xnu.clark@gmail.com Subject: [PATCH] sdhci: Fix SD card detection issue Date: Mon, 15 Apr 2024 15:06:20 +0800 Message-Id: <20240415070620.133143-1-richard.xnu.clark@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_000650_751265_03BC553E X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The mmc_gpio_get_cd(...) will return 0 called from sdhci_get_cd(...), which means the card is not present. Actually, the card detection pin is active low by default according to the SDHCI psec, thus the card detection result is not correct, more specificly below if condition is true in mmc_rescan(...): ... if (mmc_card_is_removable(host) && host->ops->get_cd && host->ops->get_cd(host) == 0) { ... goto out; } The SD card device will have no chance to be created. This commit fixes this detection issue via the MMC_CAP2_CD_ACTIVE_HIGH cap2 flag, parsed from the 'cd-inverted' property of DT. Signed-off-by: Richard Clark --- drivers/mmc/host/sdhci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c79f73459915..79f33a161ca8 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2483,6 +2483,9 @@ static int sdhci_get_cd(struct mmc_host *mmc) * Try slot gpio detect, if defined it take precedence * over build in controller functionality */ + if (!(mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)) + gpio_cd = !gpio_cd; + if (gpio_cd >= 0) return !!gpio_cd;