From patchwork Mon Mar 27 11:24:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Rowe X-Patchwork-Id: 1761520 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cs3jx+8d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PlVpB4f39z1yXq for ; Mon, 27 Mar 2023 22:24:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BADA86095; Mon, 27 Mar 2023 13:24:27 +0200 (CEST) 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="cs3jx+8d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E43B85D3A; Mon, 27 Mar 2023 13:24:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 EA2AD86095 for ; Mon, 27 Mar 2023 13:24:21 +0200 (CEST) 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-x1035.google.com with SMTP id fy10-20020a17090b020a00b0023b4bcf0727so8456003pjb.0 for ; Mon, 27 Mar 2023 04:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679916260; 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=JEaeRgPJswcfW73KsXWyA4s5Ck4BGzmeZvgOtSMmUlA=; b=cs3jx+8dPQ9VrSlxbbYd4KGFGQeHQl5fS3v1G23UF4YWM/Z5+gP9oyxy4mP0yttBXr 4UBA5iNgMwnsDp4mwxU40qnZJeDvVgc+BY6kIoc/AfBboJa/mAFWd2YpSZYZfa97CikZ Q+VNPoGLYGhDYNSE9njvkwkBByXFSUeUagc3PT6ESzVh1Y6KyG+Lo8k7AAUkEbYnNbX6 wCUmb+WRgvve6V143QSWrsjb2CTbEbbPj59UayfwnmhE3XfUG8sV1Wl+XTv5uP3gLqR+ 6Qi4hZMlM0a8jThGx2LwzXJNM+HmE90PrVi2EZQ6usZaaxknutwJg4BDEE1D7UbTtNGn mllw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679916260; 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=JEaeRgPJswcfW73KsXWyA4s5Ck4BGzmeZvgOtSMmUlA=; b=bGRY7w2lnMZdruVfeQ1hdY6dgxMWqAl+1/O+VLrqO809cB2hoR7NywlwzEBS+h2Ymu /ekHOhGsu4bAFh8eHDuwoXCvn10eq3WtDDHztn9t8fnBHdeZ5R5LmZQu2N6eM8NNUZ52 7did/ge/DPX0V52cxl7zs8FoXnNdDGg86uMZYM2w3kow0b6cTH0sW3Lsc/E06IxOXFHn c4EtrNzGbtQnVgEofugRhcz5ejD6mtAv7RPRJtTskg2nUqEOWrJLzIVX/zp2+wE1Etvq 6hjyCDrGb6N8UkE4fgTME2Aq11KBzYzQrlH5sVq5YbDfz92WVZIKjCy4FYHR56vR1Nkq XIuQ== X-Gm-Message-State: AO0yUKUo4the4jiJUr/IwD3Um+IKOOH6wePk378OfCJgXvvtuKyNbrzG vTIujjuuhFGiu+CDirSqQSI= X-Google-Smtp-Source: AK7set+lQ6JoIGNhvGsu5IiAYjgVzYYN55dm7KEouC4X1UsYZuaWhQES44dAgydhSqbsRKCKTa6hCA== X-Received: by 2002:a05:6a20:4d93:b0:da:5ab7:8cf3 with SMTP id gj19-20020a056a204d9300b000da5ab78cf3mr10634353pzb.30.1679916260270; Mon, 27 Mar 2023 04:24:20 -0700 (PDT) Received: from hawking.mbtj.net (124-148-102-134.tpgi.com.au. [124.148.102.134]) by smtp.gmail.com with ESMTPSA id a25-20020a62e219000000b00590ede84b1csm19439628pfi.147.2023.03.27.04.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 04:24:20 -0700 (PDT) From: Martin Rowe To: pali@kernel.org, sr@denx.de Cc: josua@solid-run.com, jon@solid-run.com, mibodhi@gmail.com, u-boot@lists.denx.de, Martin Rowe Subject: [PATCH v3 3/3] arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt Date: Mon, 27 Mar 2023 21:24:09 +1000 Message-Id: <20230327112409.58545-1-martin.p.rowe@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <38fb92cd-6619-28be-d3ac-0576c4c919e5@denx.de> References: MIME-Version: 1.0 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.8 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 Reviewed-by: Stefan Roese --- Resend with correct header Fixed spacing and removed __maybe_unused arch/arm/mach-mvebu/Kconfig | 1 + board/solidrun/clearfog/clearfog.c | 33 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 1f0dbef1c6..b1f2e97ae7 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -107,6 +107,7 @@ config TARGET_CLEARFOG bool "Support ClearFog" select 88F6820 select BOARD_LATE_INIT + select OF_BOARD_SETUP config TARGET_HELIOS4 bool "Support Helios4" diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c index 03adb591d8..6edb422155 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,35 @@ 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 that it will be detected by Linux. + */ +int ft_board_setup(void *blob, struct bd_info *bd) +{ + int node; + + if (has_emmc()) { + node = fdt_node_offset_by_compatible(blob, -1, "marvell,armada-380-sdhci"); + if (node < 0) + return 0; /* Unexpected eMMC device; patching not supported */ + + puts("Patching FDT so that eMMC is detected by OS\n"); + return fdt_setprop_empty(blob, node, "non-removable"); + } + + return 0; +}