From patchwork Mon Nov 15 18:16:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1771 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 219063F1D5 for ; Mon, 15 Nov 2021 19:16:14 +0100 (CET) Received: by mail-ed1-f72.google.com with SMTP id v22-20020a50a456000000b003e7cbfe3dfesf2630808edb.11 for ; Mon, 15 Nov 2021 10:16:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1637000174; cv=pass; d=google.com; s=arc-20160816; b=u7/igBwB2GpnR1426/dwk+QFEP56q5qwKbV+rb7cHrII7IPBPGshgEm1+6pJXYRPY7 UkLg8oxqK7l02Vk4/8YCU8MAioCUb/xzlspw+8F5aeO8N5XHOxpl5N1MOSC43JPu/PTp DNRYkexDr3fcdVVpE3rnAQXtY0ut224dZShGzWVtij8x5kHaUfJkMzK/t/4pGR+TmJBe cPrOMCz5TeROWT1NrrHghC++RV051os52v1t8tdJSI6TNUci+3N78LY/3VlGn6F/IJdc tZOxA4grxf7PhzFMXCW26jHb68pa5e6O7DWdyWnjKUJ9YQrPlMz23Qqh68yJNj/NASm1 767w== 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=02OKq4ii/i/6fVOFQE9KQFh7WX1S8CFdkJIMFk5j3lvhW1CnxoXQOLJnnhT1vBeTYR GIAoFDf8E/KYE6tX+X0RiZrq1HvdwD1kJIB2pPZwfVDYsRMj7dgYOnSCB5QTM6XP+40r cS/oiXiH+zqrDU75CeIvz1Mzi7lv978dnWHtnhoL0z8xpzf354xZrncC30Qxh7xM/0ZG c/UUcVvtttfSJuiRelNSwEAVnHUETLRm/xmcu8XivllocC0yhQf6AmJ7/rWsPvF/YmOh Lhp+hEKcb9N8AVXUo4WhICcxjQNxzO0KGKrgqx0/jga2IvabZk0iP0VmoumI3R4hAFkJ jErg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MGIcMjNY; 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=C9NdsEbKJuBQ6/nkptTCDkaTtR56NBalk730u7v3eOjWOlUfskzeCtFUYEHvXZ+Rln G9P1JnbstLxmjugeHJgEOc6ETlRB3ivR/mECAiXqFBHgznbClTcJf3HmaVxE2ELsicC9 qoj35lN9J9S0FTZ1zpPnB8cOnguXc6KUrB1RI= 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=h0LImOxvorrgxdsakGJcI3nprOJ/0G5jsLjfQetylLjLebFw1OB69DteVOyxuroNdE paSZllcvh3Pst+VE0LJiKDbE/HQbVTbl0JJSh0piSZ0+8w/YC0Zv1exHPAe1t1vX69eR fAUGZ7Xt7NmGLdenmK7FWNEBI409YwsQNm7BlfmaIWaz4hpWIyn9+ANmT0krGthuNrQm ZkaEybMcyCs9SxMhW1UNSSP4wLwUbc4zexkSkeg8bvlyN/l1lv1dAxxxbnb9vsYAWMVn eln4kJmx6c0/8sLHikf/EnKJ6P6EEuotljkscfnJQ5sFnrG2VlErEaedMuOie+whZRZM Zxdg== X-Gm-Message-State: AOAM531hOzEce/pvhXIDyjMABbHMrXljm6AxL6yGE9IEqVgorfqvgSQ0 UJUlxYeKm4HyEu1/pY7Ulljzi3ZG X-Google-Smtp-Source: ABdhPJycRLy/PmXZqkEIfKEIB4QNmGG58ySkwnqGSU2zudmGn/8FwnmW1kBT3il0U3NDqBF04ILOXw== X-Received: by 2002:a17:907:96aa:: with SMTP id hd42mr1216811ejc.385.1637000173973; Mon, 15 Nov 2021 10:16:13 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:fd09:: with SMTP id i9ls55305eds.3.gmail; Mon, 15 Nov 2021 10:16:13 -0800 (PST) X-Received: by 2002:a05:6402:280c:: with SMTP id h12mr1024789ede.120.1637000172976; Mon, 15 Nov 2021 10:16:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637000172; cv=none; d=google.com; s=arc-20160816; b=pQRIj3+i3FPxTvuShkwueFQCBWeWnFLcAZ3pLJsxs64PQ6VAYSx5hoIwNwZIJ6euR6 9pyVr4qHg0h0Evn4Z31CNGZVrozFEfkNryBG1TfDxg+jiB53jLFuYPWnozP2X0OcvFqK FnKdz+oUAknfcDQNKAOEy/0ybGuPG0k3PJpq1dSnB9sqarLLaA0Bnc+EnS4OyL0x7jSi /+lbkGlDSW6oYQuMfflyeR1foqDfDC3kZpRKYTLAwx2jywOsB21dxpdCFGn+imNzN5Fo P2yoxwQINUTG9iMfIOb2PqHQkmxKhhY+V6N+pE/q+zx6FvwpdBpwphqAwN1vcZrxMuOz YsHw== 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=I78rqf1sMxrqnIyEoHHhLi8eo48X7gzAo27Dah9R3u41GFHoM+5EK49hJ2BxZ6bJ/R HRdxKr9bWofjtOxD4cY1hV/K87unMBStaYMlOIeaiiMDMYmuyI9EJRprwO6Mmzhjm+1I VPjAwGeZAFWvXg73IQYgihfreOVNX2T/2tG434RyY6P1CD043PLSCQMWHM3s/LB/o1eY OeNegHIbrtes/eExv4jPwAR1DJYBGzi5so3fx52DxHjUwx3HSJ+4z2iMKBZ1Ysq7K793 98ZKDJeV0VvR2MNj23yvYqxFCL7Y1tfwauIOxRtMFYCTAO71vYLSLa269WHW2ffFSdBv B22g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MGIcMjNY; 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 u15sor3592364edv.8.2021.11.15.10.16.12 for (Google Transport Security); Mon, 15 Nov 2021 10:16:12 -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:a05:6402:3586:: with SMTP id y6mr995635edc.332.1637000172723; Mon, 15 Nov 2021 10:16:12 -0800 (PST) Received: from panicking.amarulasolutions.com ([2.196.210.5]) by smtp.gmail.com with ESMTPSA id j15sm7952705edl.34.2021.11.15.10.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 10:16:11 -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:16:09 +0100 Message-Id: <20211115181609.74898-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=MGIcMjNY; 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;