From patchwork Fri Sep 3 13:16:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1524305 X-Patchwork-Delegate: twarren@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=MvpByfOI; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H1JJH4Qnxz9sCD for ; Fri, 3 Sep 2021 23:18:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8DD338358C; Fri, 3 Sep 2021 15:17:20 +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="MvpByfOI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 610838357A; Fri, 3 Sep 2021 15:17:06 +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=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 1ED2A83574 for ; Fri, 3 Sep 2021 15:16:46 +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=thierry.reding@gmail.com Received: by mail-wm1-x332.google.com with SMTP id 79-20020a1c0452000000b002e6cf79e572so3773872wme.1 for ; Fri, 03 Sep 2021 06:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9RfdJWZ2+9m8KHYTbk3Jz0ixVbDNHuNH0TUPaTl94GI=; b=MvpByfOIxCvL+P7LwUy878AGNrx2AV2cOB+Jyy9BhTg3YsKHE2g8bcrVYnhsvh/mLi UclOXLUjoYi+VSG7BNfCjTCSGcmFgJUX1/tOwQuZ3ii+mBPNMaIWJzgwD86biMDBu4C/ WFvRxGoXq+S5Glsc/VTBocFbb/+ndB2k9SKrrOFQEmBDehjYx4Com4Ol5gklgesspX2c 4Us2cHnB7fu4DM1C4WhiS32ErKfAKJEz+LMeCAdUjvoUrMEAvH7KxDhwuwGaYDcoeAWm tdxSP76c51dEeFOSu43dmH1MoCcLUWfHlJ5dKL5Gg8lkMHP3qqFeSAfnvIKu0FCKLeSD Sdqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9RfdJWZ2+9m8KHYTbk3Jz0ixVbDNHuNH0TUPaTl94GI=; b=lziewAeH0WWGLkYAbMLN1WNOYHoJMj1GXWS86YJ3bl2y3bPHj92HBAKYFv7sT11lI8 LQ0Y9XGIFPN0VDR4fph+jhLyIykjE20KlJYZsN95qy7ddl/qxhTA8gmCpcke5Hqkqyz8 oSykxXZxQGpxcgmUV0/AvfwPqwLc5zzkvfZTi3pNhm6CVv99/RTODC4Uzj6IXiK8oQ9i t5FrVQtBj/6muFV9kDnRSWBtgT/26hCNmB+FAkAl6SL049xqBbxVvbdCQhnEwOyVk3q2 OtVZrFnFJ58QxxE6bP5QpVLndLZO3gVX13g+8E3P2QszLCnfgg9ZfYGRyKD8eJLE0Ueo 2QEw== X-Gm-Message-State: AOAM531GINxiQ/DI/MCpctNKVy0dvkOPVqJNw9dlzlelefo4DLhGXPjy XthhFxx8CcnsSXUrt2w3Tx8= X-Google-Smtp-Source: ABdhPJwwF0rDYwnvkfkF6XZj0tNjZ8RlLFRUWNw9sIcbmvEcVcB49gvOxU44fliQOdMnA23k73ozHQ== X-Received: by 2002:a1c:7413:: with SMTP id p19mr379398wmc.30.1630675005653; Fri, 03 Sep 2021 06:16:45 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id h16sm4662467wre.52.2021.09.03.06.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:16:44 -0700 (PDT) From: Thierry Reding To: Tom Warren Cc: Simon Glass , u-boot@lists.denx.de Subject: [PATCH 6/9] ARM: tegra: Support multiple reserved memory regions Date: Fri, 3 Sep 2021 15:16:22 +0200 Message-Id: <20210903131625.2153838-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210903131625.2153838-1-thierry.reding@gmail.com> References: <20210903131625.2153838-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Thierry Reding Support multiple reserved memory regions per device to support platforms that use both a framebuffer and color conversion lookup table for early boot display splash. While at it, also pass along the name, compatible strings and flags of the carveouts. Signed-off-by: Thierry Reding Reviewed-by: Simon Glass --- board/nvidia/p2371-2180/p2371-2180.c | 55 +++++++++++++++++++++------- board/nvidia/p2771-0000/p2771-0000.c | 55 +++++++++++++++++++++------- board/nvidia/p3450-0000/p3450-0000.c | 55 +++++++++++++++++++++------- 3 files changed, 126 insertions(+), 39 deletions(-) diff --git a/board/nvidia/p2371-2180/p2371-2180.c b/board/nvidia/p2371-2180/p2371-2180.c index 137c7d3b12c3..f5126c552b00 100644 --- a/board/nvidia/p2371-2180/p2371-2180.c +++ b/board/nvidia/p2371-2180/p2371-2180.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -125,24 +126,52 @@ static void ft_mac_address_setup(void *fdt) static int ft_copy_carveout(void *dst, const void *src, const char *node) { - struct fdt_memory fb; + unsigned int index = 0; int err; - err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL, - NULL, NULL, NULL); - if (err < 0) { - if (err != -FDT_ERR_NOTFOUND) - printf("failed to get carveout for %s: %d\n", node, + while (true) { + const char **compatibles = NULL; + unsigned int num_compatibles; + struct fdt_memory carveout; + unsigned long flags; + char *copy = NULL; + const char *name; + + err = fdtdec_get_carveout(src, node, "memory-region", index, + &carveout, &name, &compatibles, + &num_compatibles, &flags); + if (err < 0) { + if (err != -FDT_ERR_NOTFOUND) + printf("failed to get carveout for %s: %d\n", + node, err); + + return err; + } + + if (name) { + const char *ptr = strchr(name, '@'); + + if (ptr) { + copy = strndup(name, ptr - name); + name = copy; + } + } else { + name = "carveout"; + } + + err = fdtdec_set_carveout(dst, node, "memory-region", index, + &carveout, name, compatibles, + num_compatibles, flags); + if (err < 0) { + printf("failed to set carveout for %s: %d\n", node, err); + return err; + } - return err; - } + if (copy) + free(copy); - err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb, - "framebuffer", NULL, 0, 0); - if (err < 0) { - printf("failed to set carveout for %s: %d\n", node, err); - return err; + index++; } return 0; diff --git a/board/nvidia/p2771-0000/p2771-0000.c b/board/nvidia/p2771-0000/p2771-0000.c index 3d2653d1f075..46c36a22db5e 100644 --- a/board/nvidia/p2771-0000/p2771-0000.c +++ b/board/nvidia/p2771-0000/p2771-0000.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "../p2571/max77620_init.h" @@ -101,24 +102,52 @@ static void ft_mac_address_setup(void *fdt) static int ft_copy_carveout(void *dst, const void *src, const char *node) { - struct fdt_memory fb; + unsigned int index = 0; int err; - err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL, - NULL, NULL, NULL); - if (err < 0) { - if (err != -FDT_ERR_NOTFOUND) - printf("failed to get carveout for %s: %d\n", node, + while (true) { + const char **compatibles = NULL; + unsigned int num_compatibles; + struct fdt_memory carveout; + unsigned long flags; + char *copy = NULL; + const char *name; + + err = fdtdec_get_carveout(src, node, "memory-region", index, + &carveout, &name, &compatibles, + &num_compatibles, &flags); + if (err < 0) { + if (err != -FDT_ERR_NOTFOUND) + printf("failed to get carveout for %s: %d\n", + node, err); + + return err; + } + + if (name) { + const char *ptr = strchr(name, '@'); + + if (ptr) { + copy = strndup(name, ptr - name); + name = copy; + } + } else { + name = "carveout"; + } + + err = fdtdec_set_carveout(dst, node, "memory-region", index, + &carveout, name, compatibles, + num_compatibles, flags); + if (err < 0) { + printf("failed to set carveout for %s: %d\n", node, err); + return err; + } - return err; - } + if (copy) + free(copy); - err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb, - "framebuffer", NULL, 0, 0); - if (err < 0) { - printf("failed to set carveout for %s: %d\n", node, err); - return err; + index++; } return 0; diff --git a/board/nvidia/p3450-0000/p3450-0000.c b/board/nvidia/p3450-0000/p3450-0000.c index cdedea18a176..2c709d9b8117 100644 --- a/board/nvidia/p3450-0000/p3450-0000.c +++ b/board/nvidia/p3450-0000/p3450-0000.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -125,24 +126,52 @@ static void ft_mac_address_setup(void *fdt) static int ft_copy_carveout(void *dst, const void *src, const char *node) { - struct fdt_memory fb; + unsigned int index = 0; int err; - err = fdtdec_get_carveout(src, node, "memory-region", 0, &fb, NULL, - NULL, NULL, NULL); - if (err < 0) { - if (err != -FDT_ERR_NOTFOUND) - printf("failed to get carveout for %s: %d\n", node, + while (true) { + const char **compatibles = NULL; + unsigned int num_compatibles; + struct fdt_memory carveout; + unsigned long flags; + char *copy = NULL; + const char *name; + + err = fdtdec_get_carveout(src, node, "memory-region", index, + &carveout, &name, &compatibles, + &num_compatibles, &flags); + if (err < 0) { + if (err != -FDT_ERR_NOTFOUND) + printf("failed to get carveout for %s: %d\n", + node, err); + + return err; + } + + if (name) { + const char *ptr = strchr(name, '@'); + + if (ptr) { + copy = strndup(name, ptr - name); + name = copy; + } + } else { + name = "carveout"; + } + + err = fdtdec_set_carveout(dst, node, "memory-region", index, + &carveout, name, compatibles, + num_compatibles, flags); + if (err < 0) { + printf("failed to set carveout for %s: %d\n", node, err); + return err; + } - return err; - } + if (copy) + free(copy); - err = fdtdec_set_carveout(dst, node, "memory-region", 0, &fb, - "framebuffer", NULL, 0, 0); - if (err < 0) { - printf("failed to set carveout for %s: %d\n", node, err); - return err; + index++; } return 0;