From patchwork Wed Jul 15 10:08:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1501 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 616FF3F1DD for ; Wed, 15 Jul 2020 12:09:48 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id z187sf2414139pgd.11 for ; Wed, 15 Jul 2020 03:09:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1594807787; cv=pass; d=google.com; s=arc-20160816; b=hBym535S3OfA3LBgbptNSllBNX0TzNGhfqpT2TB9QHnRj+rarzPsZtduMiBcRXIwED OkQ+qGiUto44/mFavO9o8uW9HUOBmWZBEmU6QrQwoDXuElVXUqdlWS7w+b19Cwdp+ghb PXiI/KNzuXNDfnLNDN3t1/IpdoQfQN9DEXSqwdhUxqcEEBnqhu2uFI4PGCs9LTx15Bb4 Gk39I5LqKzuHIU+9JKzH6cUON1/nhP/mmXz1/DlOyVF+2kkeZUfNbg/DDjcV/709EnGD CfcCnAFECDHTxm0Nr2GkDm45MQBz/pIeToLRLj3iFyF8W1kDzqluGqpc0KBaKlr4EYGL 4ewg== 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=7TL/jK+eYvc0ZWUSvzk7D2UdAYbPOmJ4VJWZDU17XB4=; b=Jzdhil8My3S3K/2bx4bWvOHjIIcKIw6Tyz4A2WWNtIQmjad5JnNz/VuTrpQvYSm6BG u/SaD5JLGWQ3YOhukFD1gT6U1h9wFXWbs5SI4SjA6AeZs5m/iBYmI6zNtYnltUSggRlH /t3EKSgll471Emzh8G77trjL2vv38pS6uyWA1k8Ry6X48LLLLpVHsHSR4aRU2XiAAbWw NnBDoTAqFFhBil8QL6DQpeGU8C91NovjMofj8QN1EwCDM4ysZO7tKFnCg3W0wSBuBIgF yePdwQNI2/5Jvg2CbgEc7yRLPjgz8OfBQz4Ja6Y2MwT+CpSU22O7N4B2oM1B0i45ML34 IJxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=K6uSPf+G; 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=7TL/jK+eYvc0ZWUSvzk7D2UdAYbPOmJ4VJWZDU17XB4=; b=fexzoDo/gF88vwg97d0BPvQNUyVRjrvt3QCXC1yKUoAkJ2JjyR6OA0MPJWCElZy4W+ kxdp30CoILy/wnr2yIzrh4KNVIEr9jx3uTqItViOxUsdo5DH6+eLDBd0AM5w/pg1sBPw NqWZjmwK2vX0ATlmux81bsDoJeAoPNww/6oJo= 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=7TL/jK+eYvc0ZWUSvzk7D2UdAYbPOmJ4VJWZDU17XB4=; b=Ev581nQ7xLeWvR2ddQkKruIGBjV0AINvYDFBNLQeNAlva6EvZylqpfHFNrgAn+ioVQ hKi0+1yy/DQnt3lJxyR/WiKYDcwmtJTqXKKmTtvkA3KQ6T6FChnvysmGMlrltDJhQcQv 786vrnyTHwPzInS/CDoV7bC6JK0AZetTtArh9oYHRpbUa79xhYP/jZFHWu4NXV1FBKwo ud/K1hSOyahh7VV0TZ1J+COTE6HhQ4NSODYoJje9MZ2xHDlJI0zkCguj33WxrIbNvbtJ kzCOmPV24M1uUR6BV4DPrOK2aVFgRHH0q35nVs5BBwjTUiAnhNzpBA4Mtrsn59nmVzwo UqLA== X-Gm-Message-State: AOAM531s028YHX702qrvFqxUMtsqp59sra2mgu6C2/UO6aV/3ismqh2J sMN8yR3Fsc3ppdIsU6LOtghOFJ8g X-Google-Smtp-Source: ABdhPJxjxmqMXMQDiMUiWzxXTy0QpD688x7q1tjkuNdmAPWKVSpProuzd0o/dQ17vDaBjEkorXDKZA== X-Received: by 2002:a17:90a:71c1:: with SMTP id m1mr9488568pjs.22.1594807787237; Wed, 15 Jul 2020 03:09:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:52ca:: with SMTP id z10ls710046pgp.10.gmail; Wed, 15 Jul 2020 03:09:46 -0700 (PDT) X-Received: by 2002:a63:5b05:: with SMTP id p5mr7273292pgb.143.1594807786727; Wed, 15 Jul 2020 03:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594807786; cv=none; d=google.com; s=arc-20160816; b=piBYNCiRtpMVVbR0p9SyrZQtj0PvOi7Wqmh55x+cduAK+MAzr/zcAEvy6+gothuWS8 pjBstkSbf5dMAg/Y/JB7Tq85be4n+MQ+YSZWyMfo0raa338kTAu8I7WBdGsj4i9Ji2JE +tstwHNOmaNrBdyZQLqI3J+90TCd8f60TctZeH6h0kV+nj6HXzdBGeZYsCuJWRukTjfh wrc6jem6p8cXUMyY9/qIotfj5BWx1ol/6oC/Vg+KwbI0IEClKKDR4DUNqP0Wm4FX6pM8 0uJ27GH3Hpsg/bEwKhdbdB9ymFRSF3IiRbHVjOZpgTmw2WwVurCD0UrtGYdjR4sN9vIK BcDQ== 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=+vT6tXg3RzsaVu0o6uM5H17ZBy115+jPvGnVuu9Rp7M=; b=KMz7JYppUfwyNEhnZa/fziozFuWryuhuzJI9H1OAS8sITIAXOVZaKNLQF166fxuO63 k+01DgDCAq+gM4ii+UX3qTfy5c7mhNFE1y/qR3Z5LB+1z/PPT3840HHjN6IVqphJp+G8 CcxE9Dsl+ukApoTfyxuwoy9tTDYADfo8Se1zkFlVkATb+GxBUF4vDnqu3J0F2QqipyCZ SFSRf+uSR7utmWIA9n9itSD+LDN9gLFLVCimYrzyYuJg3yYxEgBn61lYRwoH4wj7DD/d fIzfeEO/pair6ziqYKShSF+XDYfwXZVaHu/5Fcvo9MegrQhu2TJgFE5xYcWxVM6NXJyG JUzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=K6uSPf+G; 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 o3sor2006648pfu.54.2020.07.15.03.09.46 for (Google Transport Security); Wed, 15 Jul 2020 03:09:46 -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:a62:1610:: with SMTP id 16mr8144865pfw.113.1594807786440; Wed, 15 Jul 2020 03:09:46 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:9887:56a8:c916:cfdb]) by smtp.gmail.com with ESMTPSA id p127sm1658577pfb.17.2020.07.15.03.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 03:09:45 -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 , Bin Meng Subject: [PATCH v5 1/6] sifive: fu540: Add runtime boot mode detection Date: Wed, 15 Jul 2020 15:38:58 +0530 Message-Id: <20200715100903.161363-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200715100903.161363-1-jagan@amarulasolutions.com> References: <20200715100903.161363-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=K6uSPf+G; 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 v5: - rebase on master 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 27ff52f903..57753ba50b 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -128,14 +129,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