From patchwork Mon May 22 16:16:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 100310 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp1467996obb; Mon, 22 May 2017 09:17:52 -0700 (PDT) X-Received: by 10.80.169.91 with SMTP id m27mr18526423edc.31.1495469872145; Mon, 22 May 2017 09:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495469872; cv=none; d=google.com; s=arc-20160816; b=lKbEzmK6nQMtsgNUhi0IncfJnpnoI8AAlD2DXAZy0H2BdRf02bGmi4VHBaBTbj6jJf 17tRv5+t60RlAEYl6JtACqXbfD7Z8nue2sA/FXlw6a1hEUWsmUfZ0lTA8u+PB9RaL4dm QQxle9F/51TI8n9wZaybGxdPlafVAb4/osYyH3lFg3WKTVQoDhvBELHtBIG6+IXn/bp+ CYuHxZS6TEqqAGdb2MfrNa6cyfEjnRDEBT3yTq+/Q+tebMuTXRczG9XT1qDa2QepJOwK nqcB+DwLZBiTinfYyHZ3i05GQnCdAGYlYtJ1Mx2VIb6GIK4cMh0225XhlLqb4GAXwqvr 37CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=Ayo4jrsqLy2kll/7Hin2IGvkULjV7+SNi1IZcquCDa8=; b=VBmcWCChpt/OT+QfhvU9dXbaDMNvvrusSQd5QzK7H9oYkGceSNfKoMu1k80flRp9iq VNvGpGywjBKOQGdSJvOF8wriRrB8LvMHCRmH8aZ6C89OQgPHZ8h149v1zNrOJBlmq6f2 +SMbbFo3U/HjZN9Php2Fdcbn8d2nttZClHmbl+it1pNeGh5xR+AqQLGYyuN3o3/+4wbA ZkUIio2SGF5+lRO6Ra295cyGIVqXMPq7m40IKRs0ogbQfOV84sou/5Oign2H1/+2KmP3 CGi1KzbBWu2HqeIkHwPnxElnnBq5975n5pxXS9Umf52JzfsnCdFctXnD5bS0+z88pxBz 2j6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id d33si16881804edd.290.2017.05.22.09.17.51; Mon, 22 May 2017 09:17:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 66FBAC21C92; Mon, 22 May 2017 16:17:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B2346C21C82; Mon, 22 May 2017 16:17:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3B0D6C21CA6; Mon, 22 May 2017 16:16:49 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.denx.de (Postfix) with ESMTPS id DCF5CC21C6D for ; Mon, 22 May 2017 16:16:46 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id h4so34116121lfj.3 for ; Mon, 22 May 2017 09:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DAs56OZ6FR3kNQxmYjtzrs2DKz/mdQ6gQuqgEo+peN4=; b=IldsNXomCA0m+j8SB3HYnHOj7/BAObYY4Ko+8FwabHxNQaeHIf8rtDh+A86/kR5D9U GsW1loy8Bk3HPd48TVVH1RVGB4uSdXfyebDQex9Yhv4IaYh9tK1qxWXD5RTF6FL8x82c xCmhi/8P+4XuOwJ1MXT+6Ucoh4C+E2hzZRNC4= 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; bh=DAs56OZ6FR3kNQxmYjtzrs2DKz/mdQ6gQuqgEo+peN4=; b=Cs2p7CCKYnqiNBVICcR/78vw136BI4wt46X7C4UvsnKIXRphqsK0N7Rw4xIEbSrmh+ uV0z70/6Vre8aSGl8UHkkBxcZ0hoaoOy4H3W2Msahk21NFHjuofzGxo+Ih+GoumUMjUB 6RodMy0KZe9Hg2Ig/XwMI9ug0IGbZAiZaybtYyCg9sg5osLCOhl/ALQ3P1PKSNKfSZLM oF1W0BUjMrAuMIbsJSx2zzX2Ae6fHIr83mXE5fTzHKYzb0nwpKhvKWiDEV6BNYZLeIjf 9ldD0ScBpHpqipgPAGBNDI6Gs/qmQDJSoKokuYORKxyVHrE1KmbPVqzwQuHZNX+FCFYn Vk8w== X-Gm-Message-State: AODbwcBzlPyU+fybRoQ1wYc0S+pXoPROJWfsWAKjAls1dX0EYHnlT9qj XARAkwKcL2E+5Wmy X-Received: by 10.46.21.21 with SMTP id s21mr6298748ljd.98.1495469806431; Mon, 22 May 2017 09:16:46 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id e10sm3219891ljb.68.2017.05.22.09.16.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 May 2017 09:16:45 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Mon, 22 May 2017 19:16:40 +0300 Message-Id: <20170522161642.13058-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170522161642.13058-1-semen.protsenko@linaro.org> References: <20170522161642.13058-1-semen.protsenko@linaro.org> Cc: Praneeth Bajjuri , Tom Rini Subject: [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch reuses new option, which allows us to expose variables from environment to "fastboot getvar" command. Those variables must be of "fastboot.%s" format. Signed-off-by: Sam Protsenko --- Changes in v2: - use get_device_type() instead of omap_get_cpu_type() - guard omap_set_fastboot_vars() with CONFIG_FASTBOOT_FLASH - use correct board names arch/arm/include/asm/omap_common.h | 6 ++ arch/arm/mach-omap2/utils.c | 115 +++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index c1a70b15d0..a4bfa0c451 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -643,6 +643,12 @@ void omap_die_id_get_board_serial(struct tag_serialnr *serialnr); void omap_die_id_usbethaddr(void); void omap_die_id_display(void); +#ifdef CONFIG_FASTBOOT_FLASH +void omap_set_fastboot_vars(void); +#else +static inline void omap_set_fastboot_vars(void) { } +#endif + void recalibrate_iodelay(void); void omap_smc1(u32 service, u32 val); diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c index 2d03ebfbd3..1d0b63350a 100644 --- a/arch/arm/mach-omap2/utils.c +++ b/arch/arm/mach-omap2/utils.c @@ -18,6 +18,121 @@ static void do_cancel_out(u32 *num, u32 *den, u32 factor) } } +#ifdef CONFIG_FASTBOOT_FLASH +static void omap_set_fastboot_cpu(void) +{ + char *cpu; + u32 cpu_rev = omap_revision(); + + switch (cpu_rev) { + case DRA752_ES1_0: + case DRA752_ES1_1: + case DRA752_ES2_0: + cpu = "DRA752"; + break; + case DRA722_ES1_0: + case DRA722_ES2_0: + cpu = "DRA722"; + break; + default: + cpu = NULL; + printf("Warning: fastboot.cpu: unknown CPU rev: %u\n", cpu_rev); + } + + setenv("fastboot.cpu", cpu); +} + +static void omap_set_fastboot_secure(void) +{ + const char *secure; + u32 dev = get_device_type(); + + switch (dev) { + case EMU_DEVICE: + secure = "EMU"; + break; + case HS_DEVICE: + secure = "HS"; + break; + case GP_DEVICE: + secure = "GP"; + break; + default: + secure = NULL; + printf("Warning: fastboot.secure: unknown CPU sec: %u\n", dev); + } + + setenv("fastboot.secure", secure); +} + +static void omap_set_fastboot_board_rev(void) +{ + const char *board_rev; + + board_rev = getenv("board_rev"); + if (board_rev == NULL) + printf("Warning: fastboot.board_rev: unknown board revision\n"); + + setenv("fastboot.board_rev", board_rev); +} + +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +static u32 omap_mmc_get_part_size(const char *part) +{ + int res; + struct blk_desc *dev_desc; + disk_partition_t info; + u64 sz = 0; + + dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); + if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { + error("invalid mmc device\n"); + return 0; + } + + res = part_get_info_by_name(dev_desc, part, &info); + if (res < 0) { + error("cannot find partition: '%s'\n", part); + return 0; + } + + /* Calculate size in bytes */ + sz = (info.size * (u64)info.blksz); + /* to KiB */ + sz >>= 10; + + return (u32)sz; +} + +static void omap_set_fastboot_userdata_size(void) +{ + char buf[16]; + u32 sz_kb; + + sz_kb = omap_mmc_get_part_size("userdata"); + if (sz_kb == 0) { + buf[0] = '\0'; + printf("Warning: fastboot.userdata_size: unable to calc\n"); + } else { + sprintf(buf, "%u", sz_kb); + } + + setenv("fastboot.userdata_size", buf); +} +#else +static inline void omap_set_fastboot_userdata_size(void) +{ +} +#endif /* CONFIG_FASTBOOT_FLASH_MMC_DEV */ +void omap_set_fastboot_vars(void) +{ + omap_set_fastboot_cpu(); + omap_set_fastboot_secure(); + omap_set_fastboot_board_rev(); + omap_set_fastboot_userdata_size(); +} +#endif /* CONFIG_FASTBOOT_FLASH */ + /* * Cancel out the denominator and numerator of a fraction * to get smaller numerator and denominator.