From patchwork Thu Feb 13 03:27:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1237241 X-Patchwork-Delegate: yamada.m@jp.panasonic.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=M7PgZgpn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48J26K04nCz9s29 for ; Thu, 13 Feb 2020 14:28:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D2C281183; Thu, 13 Feb 2020 04:28:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.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=nifty.com header.i=@nifty.com header.b="M7PgZgpn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03EDF811F8; Thu, 13 Feb 2020 04:28:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9033D810E3 for ; Thu, 13 Feb 2020 04:28:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=yamada.masahiro@socionext.com Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id 01D3ReTM021921; Thu, 13 Feb 2020 12:27:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com 01D3ReTM021921 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1581564461; bh=1OFLviluThrZ+Dni//Fc+oxBkJIKEDskK3mrjCei4xQ=; h=From:To:Cc:Subject:Date:From; b=M7PgZgpn+lD/5HaSa+O1Z+/57+3DU9au+B7Bu4vQZz9zentnycQUNh+Qv2lRCVfQ6 OIYJsRYekuZ0RjGcy3GOju6tgXYA9L9VUYOpfQ5MV5w59AKVM+vbmiBhot/y/egVdb sOK4uVkyH/YCycSMab+zdhPK3/dfwt4tQB6LJutwlmNI/VGWcuOelLQjNQKndiJJAF arogBOCd9j6LMM/sc8GhWH12GmIl5PGJ3AJiMOn0rwykt8AVNersR3/t+R1Lx44cmd ZoseC4kVITjtHVGQbNf2qyT7IWKn6yMOTOm2JPJ0mhofEoGugO8ztvjPTnRdbC6RuU ZQsjKmnl8xwdA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Masahiro Yamada , Tom Rini Subject: [PATCH] ARM: uniphier: add sdscript, sdboot, sdupdate environment variables Date: Thu, 13 Feb 2020 12:27:37 +0900 Message-Id: <20200213032737.3284-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.1 at phobos.denx.de X-Virus-Status: Clean Add handy macros: - sdscript: source boot.scr in the file system of the SD media - sdboot : boot the kernel using the images in the file system of the SD media - sdscript: update the boot firmware in the SD media (in raw block sectors) Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/mmc-first-dev.c | 27 ++++++++++++++++++++++---- include/configs/uniphier.h | 11 +++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-uniphier/mmc-first-dev.c b/arch/arm/mach-uniphier/mmc-first-dev.c index 149e662070ff..e2f4f4eb5c7a 100644 --- a/arch/arm/mach-uniphier/mmc-first-dev.c +++ b/arch/arm/mach-uniphier/mmc-first-dev.c @@ -9,13 +9,14 @@ #include #include -static int find_first_mmc_device(void) +static int find_first_mmc_device(bool is_sd) { struct mmc *mmc; int i; for (i = 0; (mmc = find_mmc_device(i)); i++) { - if (!mmc_init(mmc) && IS_MMC(mmc)) + if (!mmc_init(mmc) && + ((is_sd && IS_SD(mmc)) || (!is_sd && IS_MMC(mmc)))) return i; } @@ -24,14 +25,14 @@ static int find_first_mmc_device(void) int mmc_get_env_dev(void) { - return find_first_mmc_device(); + return find_first_mmc_device(false); } static int do_mmcsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int dev; - dev = find_first_mmc_device(); + dev = find_first_mmc_device(false); if (dev < 0) return CMD_RET_FAILURE; @@ -44,3 +45,21 @@ U_BOOT_CMD( "Set the first MMC (not SD) dev number to \"mmc_first_dev\" environment", "" ); + +static int do_sdsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int dev; + + dev = find_first_mmc_device(true); + if (dev < 0) + return CMD_RET_FAILURE; + + env_set_ulong("sd_first_dev", dev); + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD( + sdsetn, 1, 1, do_sdsetn, + "Set the first SD dev number to \"sd_first_dev\" environment", + "" +); diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index b95fb9c93fa9..55fa85ed6256 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -160,6 +160,7 @@ "emmcboot=mmcsetn && run bootcmd_mmc${mmc_first_dev}\0" \ "nandboot=run bootcmd_ubifs0\0" \ "norboot=run tftpboot\0" \ + "sdboot=sdsetn && run bootcmd_mmc${sd_first_dev}\0" \ "usbboot=run bootcmd_usb0\0" \ "emmcscript=setenv devtype mmc && " \ "mmcsetn && " \ @@ -170,6 +171,10 @@ "ubifsmount ubi0:boot && " \ "ubifsload ${loadaddr} ${script} && " \ "source $loadaddr\0" \ + "sdscript=setenv devtype mmc && " \ + "sdsetn && " \ + "setenv devnum ${sd_first_dev} && " \ + "run loadscript_fat\0" \ "norscript=echo Running ${script} from tftp ... && " \ "tftpboot ${script} &&" \ "source $loadaddr\0" \ @@ -196,6 +201,12 @@ "nand write $loadaddr 0 0x00020000 && " \ "tftpboot $third_image && " \ "nand write $loadaddr 0x00020000 0x001e0000\0" \ + "sdupdate=sdsetn &&" \ + "mmc dev $sd_first_dev &&" \ + "tftpboot $second_image && " \ + "mmc write $loadaddr 0 100 && " \ + "tftpboot $third_image && " \ + "mmc write $loadaddr 100 f00\0" \ "usbupdate=usb start &&" \ "tftpboot $second_image && " \ "usb write $loadaddr 0 100 && " \