From patchwork Thu Jun 4 20:39:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1333 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0E6D83F086 for ; Thu, 4 Jun 2020 22:40:41 +0200 (CEST) Received: by mail-pl1-f199.google.com with SMTP id m4sf5468937pll.11 for ; Thu, 04 Jun 2020 13:40:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1591303240; cv=pass; d=google.com; s=arc-20160816; b=eG3Qb9VPPQkaHy4uagOljVt9n6MIw7B57xa4dipMuhvDKUnEz51wyeYee0TdB3kQOx jchpPTxX8e20PSbv1T8ZvkJqfp748lqxiTBLleLkg+g2V8j25/JtaETVbz0sIeK2SfYZ nm1zpkEioQhE8gqtJXoiqk+hUcnFIWsxOZYxYcIsCz/wI53LX8Oa+vy8r7FLmShKMe5E uQ5EsDARTFgGYS1TmSjIpH3fe8d6bVZt+TcNK+NCH509doYt3zryseI36Gp5aS5U5W4y 5edTdhvbSu6ToCjRKwqNIqIcDxiigCoaAyroGukTs547JkBUM4jOnNuwW5GrW4s6OFG1 KZsg== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=as+UUu8xPRmBQ1pS07EmAzsJh7kBBdU3iMaLyjs/FdA=; b=TMWKjD7gKi/X2QSszEufqvyPwnc5Hh7s9XEhIPvvTmeg46Q/2Fed2mF394HTMm6QUC 3Gbeibb2wyG95APgi96r5dHULu/WJA0yPLDhWv+Q85casM4a3lqqh6hTbBG6KWugN3FC asQHxt/DCHccMhV9IC8yElY3zqRVcLcAFcgSOk1JZ5ZyFIv4hTi6W12I0wwxpOyR2Jbc bUJOlnW8aZGNC6mItwA7tb0dltBIgV7mLuLF0R9V9atg2kojgURjyafe1I+0GYXzAl1L uhNPK6pJL40YkOpxgtzlz4v4ZVSQ7jj/Q2qxJyIGdlpzKJEqK7JXS0vNK7HNe6vWrsXC YQNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=go4ikuMi; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@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:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=as+UUu8xPRmBQ1pS07EmAzsJh7kBBdU3iMaLyjs/FdA=; b=KZLf/SJnWosdZzZWbj3MBKGK8uLuwkCl2XdyGbMoYIIe3eVtRZ6gR1M48H3AG4JDF2 K+t726l90WlHJ4nzhl8JD5SeHj08YNDm9iXeUummg8cQTD20ccI0KiPIG4VSaId7ZUnI MU39tqLh09g8P1BD95b9pJzuA1QphU9emZsyQ= 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: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=as+UUu8xPRmBQ1pS07EmAzsJh7kBBdU3iMaLyjs/FdA=; b=HPIKsl1GJ2QVNCboCjlcylmDvXlzS2R7XRBj2lPaE3BG+psRSelJZDCWW/0+Mcal6/ +FdPl1TmgLCki6MIKieXt6QNe1GKx2qEbjOoxuh123w9BIj4vpSnjwUanfyzJiQHGBHh nouxKQqqGZpCoQX41AKXppr278Xv2G3D5qJR0b8rr4RaUHW/GUl+ltiU98H7hXxUc+2v d1kqbIccEhnsEuWWPVxvRJkPrsgMa86UtYfSdOm8tudzrLg3/GF3XUgxN3aG7xApOvYz i/9FXPCScVn9RSWof2aT3XcIEt0C1yuwfpP9VmWeQ7UCeRQ+M9DYJHSiOEBD8V+OWSII Z88A== X-Gm-Message-State: AOAM532xZEdV7GUNlEoqa3FzALZFZRj1JpGplC2/JqOVJ5HsvPGpmpWe BcRB+R6+PczAstPIT1p7A56ifSg1 X-Google-Smtp-Source: ABdhPJwl5opl0/j6iZ4yBeAtHdeG5+TzSImBCitFTVINdy0Rm4+wsDFQX1EaAuUjmRswMaRB5Kh0vw== X-Received: by 2002:a17:90a:df98:: with SMTP id p24mr8039272pjv.135.1591303239839; Thu, 04 Jun 2020 13:40:39 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:668c:: with SMTP id b12ls1909317pgw.10.gmail; Thu, 04 Jun 2020 13:40:39 -0700 (PDT) X-Received: by 2002:a63:f14a:: with SMTP id o10mr6359772pgk.216.1591303239385; Thu, 04 Jun 2020 13:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591303239; cv=none; d=google.com; s=arc-20160816; b=PIaWpuSvMUC0FaK1rUaQSVkNaUOPeJ618786wWglPSdoaprKaNjowCAYhd8OKWllp5 5Oy36cfgMglWYiszl+pLPmf+86kXGDPaUZWNIWHOC8hXp5A7AEYREmO850qjzXxFie4n gRSFaGEgYP3HZSNwoXwFb7lJj8c+7bD17Fcunu7ijjUS9UAIWFcG9xmwjFG39Q2CBHxx APFdBrUJA1iauPC4KLNyfdgpzTSCMFndBuAOtn8KQBJft1litguuEgZyIKrS3ntOACZX iTQs+syD6z9d48goSojb8n3igEZPGuSpJoU2DjPcsqaqwgTceUGXqXcxtfhhgg3e3TIU irWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qBs9NXhmKyxWNitQSUfRNDBZ0b9I2KYjGOHdfUHu5/c=; b=n7Yr0SvWBf14uB0Ebi0RqBT+uQZTPA62lKRL0S1vQhc3uUKpGSiTLgRGVKKy+MTgYX D4DU5UWrC+/FJI37tyApOZ+Cp2T9wdUPMKPI/Cv/LjFRq6pVNAciWncvayqq4uahjHqp G6hXUeas405/eMxV4sL+MSJSJiMH+FuyEV7tpKVpp2TSpAH1gNLXzf2sDs0kHcAKFM3J 5RzfC37846EhLrHROWgvQ2wdsAnK9WYFm7hI0JLPfefnZ7y12NtVRfZDk/AEUcgrZG+c 6u9d/KMoGyBMxBzhdzWOrsPzGvohA/7yCstpPPXoNf6kuJN9MDIvh0D4YGNDYTRi9GOJ 9LWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=go4ikuMi; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s19sor4143532plq.37.2020.06.04.13.40.39 for (Google Transport Security); Thu, 04 Jun 2020 13:40:39 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:bd95:: with SMTP id q21mr6777176pls.238.1591303238954; Thu, 04 Jun 2020 13:40:38 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:41f4:94a8:1af3:a574]) by smtp.gmail.com with ESMTPSA id cm13sm6463775pjb.5.2020.06.04.13.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 13:40:38 -0700 (PDT) From: Jagan Teki To: Rick Chen , Atish Patra , Palmer Dabbelt , Bin Meng , Paul Walmsley , Anup Patel , Sagar Kadam Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v3 1/6] sifive: fu540: Add runtime boot mode detection Date: Fri, 5 Jun 2020 02:09:44 +0530 Message-Id: <20200604203949.550290-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200604203949.550290-1-jagan@amarulasolutions.com> References: <20200604203949.550290-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=go4ikuMi; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" 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 to detect boot mode at runtime for SiFive FU540 boards. Signed-off-by: Jagan Teki Reviewed-by: Bin Meng Tested-by: Bin Meng --- Changes for v3: - new patch board/sifive/fu540/fu540.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index fa705dea71..a35b79ace3 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -120,14 +121,26 @@ int board_init(void) } #ifdef CONFIG_SPL +#define MODE_SELECT_REG 0x1000 +#define MODE_SELECT_QSPI 0x6 +#define MODE_SELECT_SD 0xb +#define MODE_SELECT_MASK GENMASK(3, 0) + u32 spl_boot_device(void) { -#ifdef CONFIG_SPL_MMC_SUPPORT - return BOOT_DEVICE_MMC1; -#else - puts("Unknown boot device\n"); - hang(); -#endif + u32 mode_select = readl((void *)MODE_SELECT_REG); + u32 boot_device = mode_select & MODE_SELECT_MASK; + + switch (boot_device) { + case MODE_SELECT_QSPI: + return BOOT_DEVICE_SPI; + case MODE_SELECT_SD: + return BOOT_DEVICE_MMC1; + default: + debug("Unsupported boot device 0x%x but trying MMC1\n", + boot_device); + return BOOT_DEVICE_MMC1; + } } #endif