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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C279C64ED6 for ; Sun, 26 Feb 2023 11:18:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 192BF85927; Sun, 26 Feb 2023 12:18:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="oU4mkyjW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 14C9685941; Sun, 26 Feb 2023 12:18:37 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 328EF8582C for ; Sun, 26 Feb 2023 12:18:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A293260C1F; Sun, 26 Feb 2023 11:18:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6CD8C433EF; Sun, 26 Feb 2023 11:18:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677410312; bh=aClJ2ZVcCvERpDNrao5i3aYBNEa2AZkfdNq5orNUX3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oU4mkyjWel7a/odMGMBXhV/Mpydd2TZUCPlrZuF9wXxsB24YaW8obXAXLR6S9zUEb uaj/0ttpPZzzYZe/18UJU8GyWdptjDWJAErE2lFaKb3wDiyHOOQ4h4X+9vjDRMFU74 PzwYzdNgF13oA+3K8V4riqKG2xdIr3PNx1LjFfZt8wky1gDKIZvjL+YOWSN12xEwEz 2eMFFkShYtGKsmtlT6VQZpgTv2H9NKkbzU8ZGZ6Q4dhN4dePODoli5rnJ4u+LxtFtG bCiNTSkxVzRasYa0DLIQnXnt5Q3c+YMhqKk6+riMohX6fj+TYMx1CNRM0qF61s05W9 CN5pj1GD4pnxA== Received: by pali.im (Postfix) id DF7569D5; Sun, 26 Feb 2023 12:18:28 +0100 (CET) Date: Sun, 26 Feb 2023 12:18:28 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Martin Rowe Cc: josua@solid-run.com, mibodhi@gmail.com, sr@denx.de, u-boot@lists.denx.de Subject: Re: [PATCH 1/2] arm: mvebu: clearfog: Fix MMC detection Message-ID: <20230226111828.3fos2osn2d6uzjoe@pali> References: <20230221201925.9644-1-pali@kernel.org> <20230225014220.13166-1-martin.p.rowe@gmail.com> <20230225014220.13166-2-martin.p.rowe@gmail.com> <20230225214956.3ppsg2suvq3jlkgj@pali> <20230225221434.jffmy5uyuhwnla2k@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Sunday 26 February 2023 01:45:16 Martin Rowe wrote: > On Sat, 25 Feb 2023 at 22:14, Pali Rohár wrote: > > On Saturday 25 February 2023 22:49:56 Pali Rohár wrote: > > > On Saturday 25 February 2023 11:42:19 Martin Rowe wrote: > > > > A388 Clearfog MMC is either SD Card or eMMC with different behaviour for > > > > both. Setting MMC_BROKEN_CD allows both to correctly detect MMC. > > > > > > > > Signed-off-by: Martin Rowe > > > > > > It looks like a hack but I think we do not have a better option for now. > > > > > > If I understand the issue correctly then card-detect pin is unconnected > > > for eMMC variant and used for checking if SD card is present for SD > > > variant. Unconnected pin seems to have some internal pull-up/down which > > > reports not-present state for eMMC variant. eMMC does not have any > > > presence signal, so card-detect pin must be ignored for eMMC. > > > > > > This looks like a chicken and egg problem and the only option to support > > > both variants is to ignore card-detect pin and always try to initialize > > > device connected to mmc controller (which may be eMMC or SD). > > > > Hm... maybe better way could be to edit armada-388-clearfog-u-boot.dtsi > > file and add there this? /delete-property/ cd-gpios; > > I just tried this and the device is not detected again; adding > "non-removable" seems to be required if changing the dts. > > > > I do not know if there is a better option for ignoring card-detect pin > > > in u-boot, so: > > I should point out that I did investigate runtime detection. But how you want to do that runtime detection? As I pointed above I think it is impossible do runtime detection because it is chicken and egg problem. You can patch fdt only after u-boot initialize mmc, so this can be used just for patching kernel fdt. > Patching > the fdt alone didn't seem to work using the hooks that were available, > so I started looking into how MMC was being initialised to figure out > if there was something changing the state of the device before it was > returned to BootROM. I ended up in drivers/mmc/mmc.c mmc_start_init > trying to figure out how we always end up with the "MMC: no card > present" message in the eMMC case. I was going to write some extra > logic around the mmc_getcd call, but realised there was already an > ifndef with a config that seemed like this exact use-case. Given that > config solved the problem it seemed like the cleanest solution. > > > > Acked-by: Pali Rohár > > > > > > > --- > > > > configs/clearfog_defconfig | 3 +-- > > > > configs/clearfog_sata_defconfig | 8 ++++---- > > > > 2 files changed, 5 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig > > > > index 8cd35f9f1a..24e7c16ac7 100644 > > > > --- a/configs/clearfog_defconfig > > > > +++ b/configs/clearfog_defconfig > > > > @@ -46,7 +46,6 @@ CONFIG_CMD_USB=y > > > > CONFIG_CMD_TFTPPUT=y > > > > CONFIG_CMD_CACHE=y > > > > CONFIG_CMD_TIME=y > > > > -CONFIG_CMD_MVEBU_BUBT=y > > > > CONFIG_ENV_OVERWRITE=y > > > > CONFIG_ENV_MIN_ENTRIES=128 > > > > CONFIG_ARP_TIMEOUT=200 > > > > @@ -59,7 +58,7 @@ CONFIG_DM_I2C=y > > > > CONFIG_SYS_I2C_MVTWSI=y > > > > CONFIG_I2C_EEPROM=y > > > > CONFIG_SPL_I2C_EEPROM=y > > > > -CONFIG_SUPPORT_EMMC_BOOT=y > > > > +CONFIG_MMC_BROKEN_CD=y > > > > CONFIG_MMC_SDHCI=y > > > > CONFIG_MMC_SDHCI_SDMA=y > > > > CONFIG_MMC_SDHCI_MV=y > > > > diff --git a/configs/clearfog_sata_defconfig b/configs/clearfog_sata_defconfig > > > > index e9b36150ea..84f900bf50 100644 > > > > --- a/configs/clearfog_sata_defconfig > > > > +++ b/configs/clearfog_sata_defconfig > > > > @@ -6,11 +6,14 @@ CONFIG_TEXT_BASE=0x00800000 > > > > CONFIG_SPL_LIBCOMMON_SUPPORT=y > > > > CONFIG_SPL_LIBGENERIC_SUPPORT=y > > > > CONFIG_NR_DRAM_BANKS=2 > > > > +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y > > > > +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 > > > > CONFIG_TARGET_CLEARFOG=y > > > > CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA=y > > > > CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" > > > > CONFIG_SPL_TEXT_BASE=0x40000030 > > > > CONFIG_SPL_SERIAL=y > > > > +CONFIG_SPL_STACK=0x4002c000 > > > > CONFIG_SPL=y > > > > CONFIG_DEBUG_UART_BASE=0xf1012000 > > > > CONFIG_DEBUG_UART_CLOCK=250000000 > > > > @@ -18,8 +21,6 @@ CONFIG_SYS_LOAD_ADDR=0x800000 > > > > CONFIG_DEBUG_UART=y > > > > CONFIG_AHCI=y > > > > CONFIG_DISTRO_DEFAULTS=y > > > > -CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y > > > > -CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000 > > > > CONFIG_BOOTDELAY=3 > > > > CONFIG_USE_PREBOOT=y > > > > CONFIG_SYS_CONSOLE_INFO_QUIET=y > > > > @@ -31,7 +32,6 @@ CONFIG_SPL_BSS_START_ADDR=0x40023000 > > > > CONFIG_SPL_BSS_MAX_SIZE=0x4000 > > > > CONFIG_SPL_SYS_MALLOC_SIMPLE=y > > > > # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set > > > > -CONFIG_SPL_STACK=0x4002c000 > > > > CONFIG_SPL_I2C=y > > > > CONFIG_SYS_MAXARGS=32 > > > > CONFIG_CMD_TLV_EEPROM=y > > > > @@ -46,7 +46,6 @@ CONFIG_CMD_USB=y > > > > CONFIG_CMD_TFTPPUT=y > > > > CONFIG_CMD_CACHE=y > > > > CONFIG_CMD_TIME=y > > > > -CONFIG_CMD_MVEBU_BUBT=y > > > > CONFIG_ENV_OVERWRITE=y > > > > CONFIG_ENV_MIN_ENTRIES=128 > > > > CONFIG_ARP_TIMEOUT=200 > > > > @@ -59,6 +58,7 @@ CONFIG_DM_I2C=y > > > > CONFIG_SYS_I2C_MVTWSI=y > > > > CONFIG_I2C_EEPROM=y > > > > CONFIG_SPL_I2C_EEPROM=y > > > > +CONFIG_MMC_BROKEN_CD=y > > > > CONFIG_SUPPORT_EMMC_BOOT=y > > > > CONFIG_MMC_SDHCI=y > > > > CONFIG_MMC_SDHCI_SDMA=y > > > > -- > > > > 2.39.2 > > > >