Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp419291rdh; Sat, 23 Sep 2023 17:12:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzEzX0gyUYMofHaVvfszGgYm2Ob1adSe9rBQqwaFfEM+SPVj/0p6K4h9TvY89ZKDcyC6+f X-Received: by 2002:a05:6a20:8e03:b0:13e:fb5e:b460 with SMTP id y3-20020a056a208e0300b0013efb5eb460mr9292776pzj.0.1695514324941; Sat, 23 Sep 2023 17:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695514324; cv=none; d=google.com; s=arc-20160816; b=TlYeTkTkxIzEMa2kyvGDpMLMZ9mc941Dds9ItuETyDs/z5Lw3rwfNzMTArnAjcD6Fe BGB/PB9iGqMGIX1r8o1w1ElOkXE2sWVLn8546l+8IzrV0VBdwWPD1uCYN8LhJufAjMeT 2e16FSa8Ao/jt/4B4mc3C597c9JEnhpoQrAQpQYtGew0WXt9TWZvZLz47b9+vlXhZ4jq 4LfzWsqVzm/uyDsUCjmryM7VOGnlyU4GwkWfd6VIHpKxyM7yRKq3u4NGR36pudbHUWB3 EuYYrct/yBPou4+OdXm9EEDsPSuyjRrvT55dCYZzencDp9jARtzDQvbYtLaAO7uJagnW vLZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gb8IgGF6U/jzWDiENgaHWyfhk6nOAXP9WOymk/x8GAI=; fh=dcZ0BW3sIYlAl7jbvtjEhyPcsoL3LpUWWJA622XDRIc=; b=zOfy9n7bjwodQtvznxq6XtCu9st/uA5/Jh6qdcWNrdVqg9ZPamG0iUFKl+dnmPmUEF uA3OsUxHCFVxFIyHdJX4OxD3vxMM6IYlJUCVgX+XYYyi8cN/CYexF1adIsbMxDOgQUFj 4yY0p8VqSYX1YO80JO8l+aLz5N2fBnbFmQICNPWrsdQnQI5+vR3ixji/VYAOgU/YMmzv SOv9YPhwmbvFtV5+7ooGBggmAqNlRMBCw5tB1+FZ59j5ii3aruDxLsFBSbanobnli6Kg eSwd6kANQE9HoojRO0/NEIGfVUqKEeL9nQmV0mY9PLPl9D+WwtOv0qaF3chydhVuoDYM 97Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LemcwzO/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00573e7fd674esi6356646pgb.661.2023.09.23.17.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 17:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LemcwzO/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 708A683B5A3F; Sat, 23 Sep 2023 07:23:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbjIWOXf (ORCPT + 99 others); Sat, 23 Sep 2023 10:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbjIWOXe (ORCPT ); Sat, 23 Sep 2023 10:23:34 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 374EB19A; Sat, 23 Sep 2023 07:23:28 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-570a432468bso3804279a12.0; Sat, 23 Sep 2023 07:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695479007; x=1696083807; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gb8IgGF6U/jzWDiENgaHWyfhk6nOAXP9WOymk/x8GAI=; b=LemcwzO/s3ZF/DT1p6RlfWzE1+Z9twyOPxqhRIfwqp42PLz+83iDmk4VUoqwN48dpu Z4FvEeyZC+bxwVBFLEwyO3FFr78lEQqCZohAfBPB8ea+Ih12hD//uhUPZS/GjEEGt1Lq 7eFXqQ63RuMgsdbxBFFdy1fnr8E0g3/AkAHiUiCK8lzIpFDeCPQYLcIZxgNm01x4vsHP a7HR9HZeaHX+MQq+lqTX9koI/oulrniDBUatt7YW8QbW/c5jQOR+6O8yIgkorVjN8ZMz zypLVJXYK/h+vcvQzzA4o3bXjyiYmeC1Uie0el9s0W+dk8Q0+hyWt186QRO8CiP4X/Kr 5ZIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695479007; x=1696083807; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gb8IgGF6U/jzWDiENgaHWyfhk6nOAXP9WOymk/x8GAI=; b=J53BI4PzajH5v1I/10SZLASmZTWVTAaEkOI9znntjGrK2aJv8BPaUdZpypKjkCSdZt D1SAyQS6C0O+4h85F+bsjXaZHcwb/2uJvoFSX4nKPcVN51uLqqRuJNQAVe9oFvrg14xT P/+PBIr/XdNVnHxTUsQu6I4BZrXVCdiB5OIQ6qsbeVJddHrK0Ev4UgWX794EZ6EmAh3S IFguZUAzpv8oqh2rPnchrHrtshEbwJfH1ZZ703NEKuNjlfu33DuvKx2Q2yF80IxCjXYU djpL4pNz+7oWk0DKKia7NeYeG6dfVg4+2SUPseTKKGK8pJcdRM+P80whx8yZw+KviD5/ sVlg== X-Gm-Message-State: AOJu0YyiUPaOmPJ2Oaua/gZn9p7/PaKjhPOFfGcyWlMLa1iJcuYTpfmM P+2ZTrf6DJM+ctChAvi7j0x0C2OBuBn/q0wnXWg= X-Received: by 2002:a17:90a:72c6:b0:273:dfb1:2439 with SMTP id l6-20020a17090a72c600b00273dfb12439mr7971263pjk.21.1695479007640; Sat, 23 Sep 2023 07:23:27 -0700 (PDT) MIME-Version: 1.0 References: <20230830092314.624212-1-mathieu.moneyron@gmail.com> <096e9122-23b8-5a36-7779-28994187c620@intel.com> <9a311ce3-0d29-af39-5533-c1cad6de1300@microchip.com> In-Reply-To: <9a311ce3-0d29-af39-5533-c1cad6de1300@microchip.com> From: Mathieu Moneyron Date: Sat, 23 Sep 2023 16:23:16 +0200 Message-ID: Subject: Re: [PATCH] mmc: Fix force card detect in sdhci To: Aubin Constans Cc: Adrian Hunter , Ulf Hansson , Alexandre Belloni , Eugen Hristev , Ludovic Desroches , Nicolas Ferre , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Sat, 23 Sep 2023 07:23:38 -0700 (PDT) X-Spam-Level: ** Hi Aubin, Thanks for your feedback. I'll try my best to give clear explanations. On Sat, Sep 23, 2023 at 2:44=E2=80=AFPM Aubin Constans wrote: > > On 04/09/2023 09:38, Adrian Hunter wrote: > > + Eugen Hristev > > On 30/08/23 12:23, mathieu wrote: >> On the ATMEL = at91 when using > the non-removable flag in device tree >> and not using the card-detect > pin inside the device-tree pinctrl, >> the card detect pin is physically > still used which can cause >> unknown behaviour when this pin is used > for other purposes. > Hi Mathieu, > > On which SoC(s) exactly, has this behaviour been observed? This has been observed on SAMA5D27. > > > Also, has this issue been discussed in any separate support request, in s= uch > case we could retrieve some background from it? > > By "unknown behaviour", do you mean "the card insertion status would > follow whatever electrical level is seen on the card-detect pin"? For instance our board design has the PA13 (card detect) pin wired to drive= a 3v3 power supply. The fixed regulator driver configure this pin as output (described in the d= evice tree). But what I observed is that the sdmmc driver still want to use PA13 as the = card detect signal which is then configured as an input. This cause the 3v3 powe= r to drop. By "unknown behavior" I mean the configuration of this pin as card detect s= ets unwanted electrical levels to what's connected to this pin. > > > >> >> From my interpretation this seems to be caused by a hardware desig= n > >> flaw and the real hardware is not working as intended by the >> > documentation. >> > >> > >> Signed-off-by: Mathieu Moneyron > >> > >> --- > >> drivers/mmc/host/sdhci-of-at91.c | 5 +++++ > >> 1 file changed, 5 insertions(+) > >> > >> diff --git a/drivers/mmc/host/sdhci-of-at91.c > >> b/drivers/mmc/host/sdhci-of-at91.c > >> index 69fef88e7..4fd6bfbf6 100644 > >> --- a/drivers/mmc/host/sdhci-of-at91.c > >> +++ b/drivers/mmc/host/sdhci-of-at91.c > >> @@ -51,10 +51,15 @@ struct sdhci_at91_priv { > >> static void sdhci_at91_set_force_card_detect(struct sdhci_host *host) > >> { > >> u8 mc1r; > >> + u8 ctrl; > >> > >> mc1r =3D readb(host->ioaddr + SDMMC_MC1R); > >> mc1r |=3D SDMMC_MC1R_FCD; > >> writeb(mc1r, host->ioaddr + SDMMC_MC1R); > >> + > >> + ctrl =3D readb(host->ioaddr + SDHCI_HOST_CONTROL); > >> + ctrl |=3D SDHCI_CTRL_CDTEST_INS | SDHCI_CTRL_CDTEST_EN; > >> + writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); > >> } > >> > >> static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned > >> int clock) > > Kind regards, > Aubin > Kind regards, Mathieu