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 E9A8FC61DA4 for ; Sun, 5 Mar 2023 11:33:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2722485AA1; Sun, 5 Mar 2023 12:32:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="m5IugM2a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 60D9B85A1F; Sun, 5 Mar 2023 12:32:42 +0100 (CET) Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 10D3885D91 for ; Sun, 5 Mar 2023 12:32:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=martin.p.rowe@gmail.com Received: by mail-pj1-x102b.google.com with SMTP id me6-20020a17090b17c600b0023816b0c7ceso10478853pjb.2 for ; Sun, 05 Mar 2023 03:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678015955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kdY/B2zYO85SISm7pRfmjxRxgxIK1mQqf+AtY9Gxm6o=; b=m5IugM2a3cpYWlWgBzazK+iySDIU6Sp6Upr0T9rKzUGIMM4XU5EhdEwyrNfAJtdj3n mrMm6njnZAG4iefFxUXtrghT6TbXxrTXhR0vsa6ubN98PtJ4cdKT45yCKJRzXulP/xvd dJVNRs6pV4DfxDD5fP99hFf3Fo8unowGH4bqZMdxrAbopEAHnAOTc8l7L9kUR9NhvLMT 9wszH64+Xg5e6zGBWSqV3ucjkB44QjAckM5Tl8lTjI3349BdElFifGvnMAf5B3dAlcbi T8z6IGpdzIJEff10Nv2aGGGIH9hd217CZmqleFdZnlb79TziDPiilpPbVSChw17qtZf4 772w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678015955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kdY/B2zYO85SISm7pRfmjxRxgxIK1mQqf+AtY9Gxm6o=; b=LDcnL6mb5Mhbkj12laNpNUY9hHdCecJDdvr/YngcMC1NozuZDrQQ1gBGSty308DogY NcVBY+m/U/euMq/B1UY4l+c1cEdVERTHdV1KTAGxaqm8RDxv+HmRM0O2sKyQB+oDGz4Y O5XNfSIgiEaOsnCWgELyFD/k5Ro2Kc6Vp2gNew2T7JnYJicHBM4/tFGR8tNRrbfSaBcL ACCAodIMRkHhLQ8pHyzQOuDutohM90B6Y381arXAF1duSC99gaVhPs9jQ9vfE8Nq40zh LbC4ySunVCjCuPTD1h3/prur7hwIB/V3vw8Ziu7BUp9ffIaC3ESrheuApqfpIDNnuInb EUUg== X-Gm-Message-State: AO0yUKWFtD7zmisK73niaMymIE1rZ54tzCFEdiioG/ZGvIfE9kv+kOYr JlbeCzPYJtbQZ96DnrUYHDk= X-Google-Smtp-Source: AK7set8IN4WY1ZoUM+skVrw6heJl7SsN/X1AgR4WK26WbkhiHIhli6ZkZfFF7fXZYMqDxMgcAvDF/g== X-Received: by 2002:a17:90b:388f:b0:23a:63:6d37 with SMTP id mu15-20020a17090b388f00b0023a00636d37mr8012870pjb.6.1678015955446; Sun, 05 Mar 2023 03:32:35 -0800 (PST) Received: from hawking.mbtj.net (124-148-110-31.tpgi.com.au. [124.148.110.31]) by smtp.gmail.com with ESMTPSA id t10-20020a17090a4e4a00b002371e2ac56csm4106891pjl.32.2023.03.05.03.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 03:32:35 -0800 (PST) From: Martin Rowe To: pali@kernel.org Cc: josua@solid-run.com, jon@solid-run.com, mibodhi@gmail.com, sr@denx.de, u-boot@lists.denx.de, Martin Rowe Subject: [PATCH 4/4] arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt Date: Sun, 5 Mar 2023 21:31:00 +1000 Message-Id: <20230305113100.317824-5-martin.p.rowe@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230305113100.317824-1-martin.p.rowe@gmail.com> References: <20230305113100.317824-1-martin.p.rowe@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 [upstream of vendor commit 19a96f7c40a8fc1d0a6546ac2418d966e5840a99] The Clearfog devices have only one SDHC device. This is either eMMC if it is populated on the SOM or SDHC if not. The Linux device tree assumes the SDHC case. Detect if the device is an eMMC and fixup the device-tree so it will be detected by Linux. Ported from vendor repo at https://github.com/SolidRun/u-boot Signed-off-by: Martin Rowe --- board/solidrun/clearfog/clearfog.c | 42 ++++++++++++++++++++++++++++++ configs/clearfog_defconfig | 1 + configs/clearfog_sata_defconfig | 1 + configs/clearfog_spi_defconfig | 1 + 4 files changed, 45 insertions(+) diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c index 03adb591d8..cafead3a1a 100644 --- a/board/solidrun/clearfog/clearfog.c +++ b/board/solidrun/clearfog/clearfog.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -261,3 +262,44 @@ int board_late_init(void) return 0; } + +static bool has_emmc(void) +{ + struct mmc *mmc; + mmc = find_mmc_device(0); + if (!mmc) + return 0; + return (!mmc_init(mmc) && IS_MMC(mmc)) ? true : false; +} + +/* + * The Clearfog devices have only one SDHC device. This is either eMMC + * if it is populated on the SOM or SDHC if not. The Linux device tree + * assumes the SDHC case. Detect if the device is an eMMC and fixup the + * device-tree so it will be detected by Linux. + */ +int ft_board_setup(void *blob, struct bd_info *bd) +{ + __maybe_unused int offset, rc; + + if (has_emmc()) { + puts("Patching FDT so that eMMC is detected by kernel\n"); + offset = fdt_path_offset(blob, "/soc/internal-regs/sdhci@d8000"); + if (offset >= 0) { + rc = fdt_delprop(blob, offset, "cd-gpios"); + if (rc == -FDT_ERR_NOTFOUND) + return 0; /* Assume that the device tree is already customized for eMMC */ + if (rc) { + printf("Unable to remove cd-gpios for eMMC, err=%s\n", fdt_strerror(rc)); + return rc; + } + rc = fdt_setprop_empty(blob, offset, "non-removable"); + if (rc) { + printf("Unable to add non-removable for eMMC, err=%s\n", fdt_strerror(rc)); + return rc; + } + } + } + + return 0; +} diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index f9cfa94e77..45b093c6d8 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -21,6 +21,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y diff --git a/configs/clearfog_sata_defconfig b/configs/clearfog_sata_defconfig index b11d8746b0..081ebd7e7a 100644 --- a/configs/clearfog_sata_defconfig +++ b/configs/clearfog_sata_defconfig @@ -23,6 +23,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y diff --git a/configs/clearfog_spi_defconfig b/configs/clearfog_spi_defconfig index d6695f31e6..6b9e817f68 100644 --- a/configs/clearfog_spi_defconfig +++ b/configs/clearfog_spi_defconfig @@ -24,6 +24,7 @@ CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y -- 2.39.2