From patchwork Mon Nov 15 18:15:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 1770 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3066C3F1D5 for ; Mon, 15 Nov 2021 19:15:58 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id i19-20020a05640242d300b003e7d13ebeedsf2290172edc.7 for ; Mon, 15 Nov 2021 10:15:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1637000158; cv=pass; d=google.com; s=arc-20160816; b=rLx17xD8RqvzQMGNvKcjmJP0MSz6X5Rh46jMBkppUmxqxI6sSWfc17pUy0m2yvTZef o8xqzFi4YcBUAbWLsxXxFu1HKhbeXS+7W3eL1LGk5WUElIZfufKTDtkxr0bTTejtcUDj NBdvV07YtkBT4g07Ub8eG1kBdfxa2ocGJO6jT3EhAV/Py6qA5VKKFDqxW9ZV6cpNhGMI cYZ1zHV4ALttW8CIQxCqQPhR8kh5WZxI4sSuq9A/ImJsLVZPsY8r8GtgzExo8WJiGLeA YUCBaJWIlHmMrKIXpBJiFXZ9vLa7LmQjjz7IRmVSmqaauu25aR6lGKU5NnCoGaueBz/C njNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=y/oP8ixZv40ECHJR64CwNvbko0PjMC9BrMakI+QAxYY=; b=apL+aVZTYuv3Ju1OqCsZ8iTahvdj7lLhVWvPPBDnLvn03h/WgtWtXW1244Yubb+kwz p73AtyPJtz6D8NBWZ6WKvRjVn4XJuixT+vzdw5x/r9BjpdL3xUxUjl6CEkcgCzh3hnbq 6l7QZ/7HPItHweuQT3k5IOrAuJ4wO++CSResUf0i76FEAG0ON4gEcN+Xxixf0L9TLKfo /rFnEcBjVq7+S4DeB+iXfowOCdtY/XRbWyCo8zL5ggLleuyxhd0zZ6GUvncsrM2WnVRC FC7rh+i96e7PQKkZlWUuyP3toWLXinDqbUsdMk6M0NGy7y54sfZThN0RxRv8UZkgyA1N nkow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cRonoVCH; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=y/oP8ixZv40ECHJR64CwNvbko0PjMC9BrMakI+QAxYY=; b=Ao0gspi0R14mhWqWPrDAIoCldRP98iJfRJdZioXUw8dIFuJY9rJLHkXLxIPnDtBGGW 7TB82f+b+LF7cEPoudd+oCdmjRFE7kjMN2pWBHf/Z9Exvvrikj2e9u2XpDJhk05HcXn5 ybc5ME6ortBr4EsRFCNsWjinQRVn6qcqHJm+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=y/oP8ixZv40ECHJR64CwNvbko0PjMC9BrMakI+QAxYY=; b=46t5vy01T6xcY0yZ+SSTGsBOkOT3ah7L3DGkURtnFYilFrcwdU+zFSY/ZvTQfk0P/W XucmvFjM9tcF7ETOODh0PcmntoFlry8WN8pbYh7mzNJPs3q0nRHyEH+CpR449cZnxZ+3 Iqtwalyixp3T+vojx/VnkLMCrhJZqmMIljb1W+ZhlT+BWY3KsrHhQHGjgmnnGw+xJu95 RFKlhkyBPOd3eO+V+mwTEzEaxX3YOLaWHFTTiqzxFzXtqyTMP3b1ywPWGSFAiFi0g6zO o5eJk8syaBUTHd2uQXfxKoaJCMTWBV1oCMNvETrazIgyN1ABUpZhVa98O4Nv950+Wqap lDrw== X-Gm-Message-State: AOAM530XEYs77KN8GqC1u8VDyn9cwmzhvuHvt5hnRA8kQy7LzLd0piCN epq+urbhyVfvuKY15twnBPuGEplz X-Google-Smtp-Source: ABdhPJwVDA/pDFVtJDNPPlGJOfVuR23qn92CocBQieDseFLXBZ7budV8chpB6qyvUkubZxWlxRjLjA== X-Received: by 2002:a17:907:7094:: with SMTP id yj20mr1175348ejb.265.1637000158038; Mon, 15 Nov 2021 10:15:58 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:8e41:: with SMTP id 1ls55428edx.0.gmail; Mon, 15 Nov 2021 10:15:57 -0800 (PST) X-Received: by 2002:a05:6402:405:: with SMTP id q5mr1036382edv.62.1637000156978; Mon, 15 Nov 2021 10:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637000156; cv=none; d=google.com; s=arc-20160816; b=JXWOxNrhnykFDTjZR+fzjaVj3mHLQkOQwvg4wZr0os4JUctQ/cyb84rL7wqmwTxQoe SyWraYhWYBEaTasY0SoAFUK1LWkXAMTQsI0jVZjYX9qVmVmyj9J1xqZvzEFhfE28jeCR c4qg6WjWUkNWLW7/JPwOTJ1f2u52asWzQOTO0DU5mZzFgdAfOv5aWP98kd5N8gimpb12 kYzkfA7ifrtoO3hMLmcNYbMsk/RtaGjxyWSPNDKqUnJmSlRu6p6MIj8UL8cG9mLoD1wp fu/QGRAEEvdYrHo8t9GhjDfnaO/J3LY66CJSetWQ8ayMvvQ4aiJwXeoQbj6l2nnFjKYL y2aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=KBWhebpyINUBNbC8rNJvqtpeRn3etxk/c+jk/zZe3Vg=; b=y5NBrPzTlLOcZK/cvAvwAH0ncG2+wKhChGVIf8XnnK2crRFm4rI5ya8KgUzniwupTN O1mH47orZxWKbKwYPzVamrhPdSwJuNXMxFZHsBEBMK+ND47F3vL589ZaIMNXTRbG3r6K yUTuI6jWZfpmMBbsa7f5pWIO/vAgSH0P6GAe7wAuSlkTPb4dTmg204SabXI3GoCew2V9 8j6hsa8ixuGmkJx5YEZYz6zY0nzxnawrGKbDE05CLxN+AHQUKZNr4vRrMeW5e4b4BqWe DphHrIPwAaclvQ/npn1LwUd5H9y09Q1NNyryAlljSBGNzqW9czvIb/Wmm491JkYzu+qB vsRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cRonoVCH; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id i5sor1398240edc.27.2021.11.15.10.15.56 for (Google Transport Security); Mon, 15 Nov 2021 10:15:56 -0800 (PST) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a50:da06:: with SMTP id z6mr886137edj.355.1637000156733; Mon, 15 Nov 2021 10:15:56 -0800 (PST) Received: from panicking.amarulasolutions.com ([2.196.210.5]) by smtp.gmail.com with ESMTPSA id e12sm6935089ejs.86.2021.11.15.10.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 10:15:56 -0800 (PST) From: Michael Trimarchi To: Ye Li , Stefano Babic , Fabio Estevam Cc: u-boot@lists.denx.de, Ariel D'Alessandro , linux-amarula@amarulasolutions.com, Anthony Brandon Subject: [PATCH] cmd_nandbcb: Support secondary boot address of imx8mn Date: Mon, 15 Nov 2021 19:15:52 +0100 Message-Id: <20211115181553.74830-1-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cRonoVCH; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add support of secondary boot address for imx8mn. The secondary boot address is hardcoded in the fuse. The value is calculated from there according to the algo. The fuse IMG_CNTN_SET1_OFFSET (0x490[22:19]) is defined as follows: • Secondary boot is disabled if fuse value is bigger than 10, n = fuse value bigger than 10. • n == 0: Offset = 4MB • n == 2: Offset = 1MB • Others & n <= 10 : Offset = 1MB*2^n • For FlexSPI boot, the valid values are: 0, 1, 2, 3, 4, 5, 6, and 7. Tested remove the first one image and have the board still booting on second one. This implementation cover one architecture Signed-off-by: Michael Trimarchi --- arch/arm/mach-imx/cmd_nandbcb.c | 41 +++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/cmd_nandbcb.c b/arch/arm/mach-imx/cmd_nandbcb.c index 09622c13c9..348f8b626a 100644 --- a/arch/arm/mach-imx/cmd_nandbcb.c +++ b/arch/arm/mach-imx/cmd_nandbcb.c @@ -132,6 +132,7 @@ static struct platform_config imx8q_plat_config = { /* boot search related variables and definitions */ static int g_boot_search_count = 4; +static int g_boot_secondary_offset; static int g_boot_search_stride; static int g_pages_per_stride; @@ -275,9 +276,9 @@ static int nandbcb_set_boot_config(int argc, char * const argv[], boot_stream2_address = ((maxsize - boot_stream1_address) / 2 + boot_stream1_address); - if (boot_cfg->secondary_boot_stream_off_in_MB) + if (g_boot_secondary_offset) boot_stream2_address = - (loff_t)boot_cfg->secondary_boot_stream_off_in_MB * 1024 * 1024; + (loff_t)g_boot_secondary_offset * 1024 * 1024; max_boot_stream_size = boot_stream2_address - boot_stream1_address; @@ -1269,6 +1270,36 @@ static bool check_fingerprint(void *data, int fingerprint) return (*(int *)(data + off) == fingerprint); } +static int fuse_secondary_boot(u32 bank, u32 word, u32 mask, u32 off) +{ + int err; + u32 val; + int ret; + + err = fuse_read(bank, word, &val); + if (err) + return 0; + + val = (val & mask) >> off; + + if (val > 10) + return 0; + + switch (val) { + case 0: + ret = 4; + break; + case 1: + ret = 1; + break; + default: + ret = 2 << val; + break; + } + + return ret; +}; + static int fuse_to_search_count(u32 bank, u32 word, u32 mask, u32 off) { int err; @@ -1506,6 +1537,12 @@ static int do_nandbcb(struct cmd_tbl *cmdtp, int flag, int argc, g_boot_search_count); } + if ((plat_config.misc_flags) & FIRMWARE_SECONDARY_FIXED_ADDR) { + if (is_imx8mn()) + g_boot_secondary_offset = fuse_secondary_boot(2, 1, 0xff0000, 16); + + } + cmd = argv[1]; --argc; ++argv;