2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-10-15 07:39:08 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2008
|
|
|
|
* Heiko Schocher, DENX Software Engineering, hs@denx.de.
|
|
|
|
*
|
2011-06-05 22:22:18 +00:00
|
|
|
* (C) Copyright 2011
|
|
|
|
* Holger Brunck, Keymile GmbH Hannover, holger.brunck@keymile.com
|
2008-10-15 07:39:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2008-10-15 07:39:08 +00:00
|
|
|
#include <ioports.h>
|
2011-05-04 01:47:30 +00:00
|
|
|
#include <command.h>
|
2008-10-15 07:39:08 +00:00
|
|
|
#include <malloc.h>
|
2014-04-11 02:01:24 +00:00
|
|
|
#include <cli_hush.h>
|
2008-11-21 07:29:40 +00:00
|
|
|
#include <net.h>
|
2010-02-18 07:08:25 +00:00
|
|
|
#include <netdev.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2008-11-21 07:29:40 +00:00
|
|
|
#include <asm/io.h>
|
2011-05-12 19:59:22 +00:00
|
|
|
#include <linux/ctype.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2021-12-10 10:07:53 +00:00
|
|
|
#include <linux/bug.h>
|
|
|
|
#include <bootcount.h>
|
2008-10-15 07:39:08 +00:00
|
|
|
|
2012-05-04 08:55:58 +00:00
|
|
|
#if defined(CONFIG_POST)
|
|
|
|
#include "post.h"
|
|
|
|
#endif
|
2011-06-05 22:22:18 +00:00
|
|
|
#include "common.h"
|
2008-10-15 07:39:08 +00:00
|
|
|
#include <i2c.h>
|
|
|
|
|
2010-04-26 11:07:28 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
2011-03-08 09:51:15 +00:00
|
|
|
|
2010-04-26 11:07:28 +00:00
|
|
|
/*
|
|
|
|
* Set Keymile specific environment variables
|
|
|
|
* Currently only some memory layout variables are calculated here
|
|
|
|
* ... ------------------------------------------------
|
|
|
|
* ... |@rootfsaddr |@pnvramaddr |@varaddr |@reserved |@END_OF_RAM
|
|
|
|
* ... |<------------------- pram ------------------->|
|
|
|
|
* ... ------------------------------------------------
|
|
|
|
* @END_OF_RAM: denotes the RAM size
|
|
|
|
* @pnvramaddr: Startadress of pseudo non volatile RAM in hex
|
|
|
|
* @pram : preserved ram size in k
|
|
|
|
* @varaddr : startadress for /var mounted into RAM
|
|
|
|
*/
|
|
|
|
int set_km_env(void)
|
|
|
|
{
|
|
|
|
unsigned int pnvramaddr;
|
|
|
|
unsigned int pram;
|
|
|
|
unsigned int varaddr;
|
2011-09-13 23:06:11 +00:00
|
|
|
unsigned int kernelmem;
|
|
|
|
unsigned long rootfssize = 0;
|
2021-06-04 09:25:00 +00:00
|
|
|
char envval[16];
|
|
|
|
char *p;
|
2010-04-26 11:07:28 +00:00
|
|
|
|
2022-11-16 18:10:37 +00:00
|
|
|
pnvramaddr = CFG_SYS_SDRAM_BASE + gd->ram_size -
|
2021-01-19 10:41:00 +00:00
|
|
|
CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM - CONFIG_KM_PNVRAM;
|
2021-06-04 09:25:00 +00:00
|
|
|
sprintf(envval, "0x%x", pnvramaddr);
|
|
|
|
env_set("pnvramaddr", envval);
|
2010-04-26 11:07:28 +00:00
|
|
|
|
2016-07-15 17:44:45 +00:00
|
|
|
/* try to read rootfssize (ram image) from environment */
|
2017-08-03 18:22:12 +00:00
|
|
|
p = env_get("rootfssize");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (p)
|
2011-09-13 23:06:11 +00:00
|
|
|
strict_strtoul(p, 16, &rootfssize);
|
|
|
|
pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
|
|
|
|
CONFIG_KM_PNVRAM) / 0x400;
|
2021-01-21 12:19:19 +00:00
|
|
|
env_set_ulong("pram", pram);
|
2010-04-26 11:07:28 +00:00
|
|
|
|
2022-11-16 18:10:37 +00:00
|
|
|
varaddr = CFG_SYS_SDRAM_BASE + gd->ram_size -
|
2021-01-19 10:41:00 +00:00
|
|
|
CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
|
2021-01-21 12:19:19 +00:00
|
|
|
env_set_hex("varaddr", varaddr);
|
2021-06-04 09:25:00 +00:00
|
|
|
sprintf(envval, "0x%x", varaddr);
|
|
|
|
env_set("varaddr", envval);
|
2011-09-13 23:06:11 +00:00
|
|
|
|
|
|
|
kernelmem = gd->ram_size - 0x400 * pram;
|
2021-06-04 09:25:00 +00:00
|
|
|
sprintf(envval, "0x%x", kernelmem);
|
|
|
|
env_set("kernelmem", envval);
|
2011-09-13 23:06:11 +00:00
|
|
|
|
2010-04-26 11:07:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-10 10:07:53 +00:00
|
|
|
#if CONFIG_IS_ENABLED(PG_WCOM_UBOOT_UPDATE_SUPPORTED)
|
|
|
|
#if ((!CONFIG_IS_ENABLED(PG_WCOM_UBOOT_BOOTPACKAGE) && \
|
|
|
|
!CONFIG_IS_ENABLED(PG_WCOM_UBOOT_UPDATE)) || \
|
|
|
|
(CONFIG_IS_ENABLED(PG_WCOM_UBOOT_BOOTPACKAGE) && \
|
|
|
|
CONFIG_IS_ENABLED(PG_WCOM_UBOOT_UPDATE)))
|
|
|
|
#error "It has to be either bootpackage or update u-boot image!"
|
|
|
|
#endif
|
|
|
|
void check_for_uboot_update(void)
|
|
|
|
{
|
|
|
|
void (*uboot_update_entry)(void) =
|
|
|
|
(void (*)(void)) CONFIG_PG_WCOM_UBOOT_UPDATE_TEXT_BASE;
|
|
|
|
char *isupdated = env_get("updateduboot");
|
|
|
|
ulong bootcount = bootcount_load();
|
|
|
|
ulong ebootcount = 0;
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_PG_WCOM_UBOOT_BOOTPACKAGE)) {
|
|
|
|
/*
|
|
|
|
* When running in factory burned u-boot move to the updated
|
|
|
|
* u-boot version only if updateduboot envvar is set to 'yes'
|
|
|
|
* and bootcount limit is not exceeded.
|
|
|
|
* Board must be able to start in factory bootloader mode!
|
|
|
|
*/
|
|
|
|
if (isupdated && !strncmp(isupdated, "yes", 3) &&
|
|
|
|
bootcount <= CONFIG_BOOTCOUNT_BOOTLIMIT) {
|
|
|
|
printf("Check update: update detected, ");
|
|
|
|
printf("starting new image @%08x ...\n",
|
|
|
|
CONFIG_PG_WCOM_UBOOT_UPDATE_TEXT_BASE);
|
|
|
|
ebootcount = early_bootcount_load();
|
|
|
|
if (ebootcount <= CONFIG_BOOTCOUNT_BOOTLIMIT) {
|
|
|
|
early_bootcount_store(++ebootcount);
|
|
|
|
uboot_update_entry();
|
|
|
|
} else {
|
|
|
|
printf("Check update: warning: ");
|
|
|
|
printf("early bootcount exceeded (%lu)\n",
|
|
|
|
ebootcount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("Check update: starting factory image @%08x ...\n",
|
2022-10-21 00:22:39 +00:00
|
|
|
CONFIG_TEXT_BASE);
|
2021-12-10 10:07:53 +00:00
|
|
|
} else if (IS_ENABLED(CONFIG_PG_WCOM_UBOOT_UPDATE)) {
|
|
|
|
/*
|
|
|
|
* When running in field updated u-boot, make sure that
|
|
|
|
* bootcount limit is never exceeded. Must never happen!
|
|
|
|
*/
|
|
|
|
WARN_ON(bootcount > CONFIG_BOOTCOUNT_BOOTLIMIT);
|
|
|
|
printf("Check update: updated u-boot starting @%08x ...\n",
|
2022-10-21 00:22:39 +00:00
|
|
|
CONFIG_TEXT_BASE);
|
2021-12-10 10:07:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-14 08:54:12 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_INIT_BOARD)
|
2011-03-08 09:51:15 +00:00
|
|
|
static void i2c_write_start_seq(void)
|
2008-10-15 07:39:08 +00:00
|
|
|
{
|
2011-03-15 15:52:29 +00:00
|
|
|
set_sda(1);
|
|
|
|
udelay(DELAY_HALF_PERIOD);
|
|
|
|
set_scl(1);
|
|
|
|
udelay(DELAY_HALF_PERIOD);
|
|
|
|
set_sda(0);
|
|
|
|
udelay(DELAY_HALF_PERIOD);
|
|
|
|
set_scl(0);
|
|
|
|
udelay(DELAY_HALF_PERIOD);
|
2008-10-15 07:39:08 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 15:52:29 +00:00
|
|
|
/*
|
|
|
|
* I2C is a synchronous protocol and resets of the processor in the middle
|
|
|
|
* of an access can block the I2C Bus until a powerdown of the full unit is
|
|
|
|
* done. This function toggles the SCL until the SCL and SCA line are
|
|
|
|
* released, but max. 16 times, after this a I2C start-sequence is sent.
|
|
|
|
* This I2C Deblocking mechanism was developed by Keymile in association
|
|
|
|
* with Anatech and Atmel in 1998.
|
2008-10-15 07:39:08 +00:00
|
|
|
*/
|
2011-06-05 22:22:18 +00:00
|
|
|
int i2c_make_abort(void)
|
2008-10-15 07:39:08 +00:00
|
|
|
{
|
|
|
|
int scl_state = 0;
|
|
|
|
int sda_state = 0;
|
|
|
|
int i = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-03-15 15:52:29 +00:00
|
|
|
if (!get_sda()) {
|
2008-10-15 07:39:08 +00:00
|
|
|
ret = -1;
|
|
|
|
while (i < 16) {
|
|
|
|
i++;
|
2011-03-15 15:52:29 +00:00
|
|
|
set_scl(0);
|
|
|
|
udelay(DELAY_ABORT_SEQ);
|
|
|
|
set_scl(1);
|
|
|
|
udelay(DELAY_ABORT_SEQ);
|
|
|
|
scl_state = get_scl();
|
|
|
|
sda_state = get_sda();
|
2008-10-15 07:39:08 +00:00
|
|
|
if (scl_state && sda_state) {
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-15 15:52:29 +00:00
|
|
|
if (ret == 0)
|
|
|
|
for (i = 0; i < 5; i++)
|
2011-03-08 09:51:15 +00:00
|
|
|
i2c_write_start_seq();
|
2011-03-15 15:52:29 +00:00
|
|
|
|
2011-03-08 09:51:15 +00:00
|
|
|
/* respect stop setup time */
|
|
|
|
udelay(DELAY_ABORT_SEQ);
|
|
|
|
set_scl(1);
|
|
|
|
udelay(DELAY_ABORT_SEQ);
|
|
|
|
set_sda(1);
|
2011-03-15 15:52:29 +00:00
|
|
|
get_sda();
|
2011-03-08 09:51:15 +00:00
|
|
|
|
2008-10-15 07:39:08 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-03-08 09:51:15 +00:00
|
|
|
/**
|
|
|
|
* i2c_init_board - reset i2c bus. When the board is powercycled during a
|
|
|
|
* bus transfer it might hang; for details see doc/I2C_Edge_Conditions.
|
|
|
|
*/
|
|
|
|
void i2c_init_board(void)
|
|
|
|
{
|
2008-10-15 07:39:08 +00:00
|
|
|
/* Now run the AbortSequence() */
|
2011-03-15 15:52:29 +00:00
|
|
|
i2c_make_abort();
|
2008-10-15 07:39:08 +00:00
|
|
|
}
|
2011-09-14 08:54:12 +00:00
|
|
|
#endif
|
|
|
|
|
2013-10-18 09:47:18 +00:00
|
|
|
#if defined(CONFIG_KM_COMMON_ETH_INIT)
|
2020-06-26 06:13:33 +00:00
|
|
|
int board_eth_init(struct bd_info *bis)
|
2008-11-21 07:29:40 +00:00
|
|
|
{
|
2011-03-15 15:52:29 +00:00
|
|
|
if (ethernet_present())
|
2010-02-18 07:08:25 +00:00
|
|
|
return cpu_eth_init(bis);
|
|
|
|
|
|
|
|
return -1;
|
2008-11-21 07:29:40 +00:00
|
|
|
}
|
2013-10-18 09:47:18 +00:00
|
|
|
#endif
|
2011-05-04 01:47:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* do_setboardid command
|
|
|
|
* read out the board id and the hw key from the intventory EEPROM and set
|
|
|
|
* this values as environment variables.
|
|
|
|
*/
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_setboardid(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2011-05-04 01:47:30 +00:00
|
|
|
{
|
|
|
|
unsigned char buf[32];
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = get_local_var("IVM_BoardId");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (!p) {
|
2011-05-04 01:47:30 +00:00
|
|
|
printf("can't get the IVM_Boardid\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2015-12-30 13:05:58 +00:00
|
|
|
strcpy((char *)buf, p);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("boardid", (char *)buf);
|
2011-07-04 22:23:59 +00:00
|
|
|
printf("set boardid=%s\n", buf);
|
2011-05-04 01:47:30 +00:00
|
|
|
|
|
|
|
p = get_local_var("IVM_HWKey");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (!p) {
|
2011-05-04 01:47:30 +00:00
|
|
|
printf("can't get the IVM_HWKey\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2015-12-30 13:05:58 +00:00
|
|
|
strcpy((char *)buf, p);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("hwkey", (char *)buf);
|
2011-07-04 22:23:59 +00:00
|
|
|
printf("set hwkey=%s\n", buf);
|
|
|
|
printf("Execute manually saveenv for persistent storage.\n");
|
2011-05-04 01:47:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-30 11:45:49 +00:00
|
|
|
U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid",
|
|
|
|
"read out bid and hwkey from IVM and set in environment");
|
2011-05-12 19:59:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* command km_checkbidhwk
|
|
|
|
* if "boardid" and "hwkey" are not already set in the environment, do:
|
|
|
|
* if a "boardIdListHex" exists in the environment:
|
|
|
|
* - read ivm data for boardid and hwkey
|
|
|
|
* - compare each entry of the boardIdListHex with the
|
|
|
|
* IVM data:
|
|
|
|
* if match:
|
|
|
|
* set environment variables boardid, boardId,
|
|
|
|
* hwkey, hwKey to the found values
|
|
|
|
* both (boardid and boardId) are set because
|
|
|
|
* they might be used differently in the
|
|
|
|
* application and in the init scripts (?)
|
|
|
|
* return 0 in case of match, 1 if not match or error
|
|
|
|
*/
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2011-05-12 19:59:22 +00:00
|
|
|
{
|
|
|
|
unsigned long ivmbid = 0, ivmhwkey = 0;
|
|
|
|
unsigned long envbid = 0, envhwkey = 0;
|
|
|
|
char *p;
|
|
|
|
int verbose = argc > 1 && *argv[1] == 'v';
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* first read out the real inventory values, these values are
|
|
|
|
* already stored in the local hush variables
|
|
|
|
*/
|
|
|
|
p = get_local_var("IVM_BoardId");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (!p) {
|
2011-05-12 19:59:22 +00:00
|
|
|
printf("can't get the IVM_Boardid\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
rc = strict_strtoul(p, 16, &ivmbid);
|
|
|
|
|
|
|
|
p = get_local_var("IVM_HWKey");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (!p) {
|
2011-05-12 19:59:22 +00:00
|
|
|
printf("can't get the IVM_HWKey\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
rc = strict_strtoul(p, 16, &ivmhwkey);
|
|
|
|
|
|
|
|
if (!ivmbid || !ivmhwkey) {
|
|
|
|
printf("Error: IVM_BoardId and/or IVM_HWKey not set!\n");
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now try to read values from environment if available */
|
2017-08-03 18:22:12 +00:00
|
|
|
p = env_get("boardid");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (p)
|
2011-05-12 19:59:22 +00:00
|
|
|
rc = strict_strtoul(p, 16, &envbid);
|
2017-08-03 18:22:12 +00:00
|
|
|
p = env_get("hwkey");
|
2020-10-30 11:45:49 +00:00
|
|
|
if (p)
|
2011-05-12 19:59:22 +00:00
|
|
|
rc = strict_strtoul(p, 16, &envhwkey);
|
|
|
|
if (rc != 0) {
|
|
|
|
printf("strict_strtoul returns error: %d", rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!envbid || !envhwkey) {
|
|
|
|
/*
|
|
|
|
* BoardId/HWkey not available in the environment, so try the
|
|
|
|
* environment variable for BoardId/HWkey list
|
|
|
|
*/
|
2017-08-03 18:22:12 +00:00
|
|
|
char *bidhwklist = env_get("boardIdListHex");
|
2011-05-12 19:59:22 +00:00
|
|
|
|
|
|
|
if (bidhwklist) {
|
|
|
|
int found = 0;
|
|
|
|
char *rest = bidhwklist;
|
|
|
|
char *endp;
|
|
|
|
|
|
|
|
if (verbose) {
|
|
|
|
printf("IVM_BoardId: %ld, IVM_HWKey=%ld\n",
|
2020-10-30 11:45:49 +00:00
|
|
|
ivmbid, ivmhwkey);
|
|
|
|
printf("boardIdHwKeyList: %s\n", bidhwklist);
|
2011-05-12 19:59:22 +00:00
|
|
|
}
|
|
|
|
while (!found) {
|
|
|
|
/* loop over each bid/hwkey pair in the list */
|
|
|
|
unsigned long bid = 0;
|
|
|
|
unsigned long hwkey = 0;
|
|
|
|
|
|
|
|
while (*rest && !isxdigit(*rest))
|
|
|
|
rest++;
|
|
|
|
/*
|
|
|
|
* use simple_strtoul because we need &end and
|
|
|
|
* we know we got non numeric char at the end
|
|
|
|
*/
|
2021-07-24 15:03:29 +00:00
|
|
|
bid = hextoul(rest, &endp);
|
2011-05-12 19:59:22 +00:00
|
|
|
/* BoardId and HWkey are separated with a "_" */
|
|
|
|
if (*endp == '_') {
|
|
|
|
rest = endp + 1;
|
|
|
|
/*
|
|
|
|
* use simple_strtoul because we need
|
|
|
|
* &end
|
|
|
|
*/
|
2021-07-24 15:03:29 +00:00
|
|
|
hwkey = hextoul(rest, &endp);
|
2011-05-12 19:59:22 +00:00
|
|
|
rest = endp;
|
|
|
|
while (*rest && !isxdigit(*rest))
|
|
|
|
rest++;
|
|
|
|
}
|
2020-10-30 11:45:49 +00:00
|
|
|
if (!bid || !hwkey) {
|
2011-05-12 19:59:22 +00:00
|
|
|
/* end of list */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (verbose) {
|
|
|
|
printf("trying bid=0x%lX, hwkey=%ld\n",
|
2020-10-30 11:45:49 +00:00
|
|
|
bid, hwkey);
|
2011-05-12 19:59:22 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Compare the values of the found entry in the
|
|
|
|
* list with the valid values which are stored
|
|
|
|
* in the inventory eeprom. If they are equal
|
2011-06-05 22:22:17 +00:00
|
|
|
* set the values in environment variables.
|
2011-05-12 19:59:22 +00:00
|
|
|
*/
|
2020-10-30 11:45:49 +00:00
|
|
|
if (bid == ivmbid && hwkey == ivmhwkey) {
|
2011-05-12 19:59:22 +00:00
|
|
|
found = 1;
|
|
|
|
envbid = bid;
|
|
|
|
envhwkey = hwkey;
|
2021-01-21 12:19:19 +00:00
|
|
|
env_set_hex("boardid", bid);
|
|
|
|
env_set_hex("hwkey", hwkey);
|
2011-05-12 19:59:22 +00:00
|
|
|
}
|
|
|
|
} /* end while( ! found ) */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compare now the values */
|
2020-10-30 11:45:49 +00:00
|
|
|
if (ivmbid == envbid && ivmhwkey == envhwkey) {
|
2011-05-12 19:59:22 +00:00
|
|
|
printf("boardid=0x%3lX, hwkey=%ld\n", envbid, envhwkey);
|
|
|
|
rc = 0; /* match */
|
|
|
|
} else {
|
2011-07-04 22:23:59 +00:00
|
|
|
printf("Error: env boardid=0x%3lX, hwkey=%ld\n", envbid,
|
2020-10-30 11:45:49 +00:00
|
|
|
envhwkey);
|
2011-05-12 19:59:22 +00:00
|
|
|
printf(" IVM bId=0x%3lX, hwKey=%ld\n", ivmbid, ivmhwkey);
|
|
|
|
rc = 1; /* don't match */
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(km_checkbidhwk, 2, 0, do_checkboardidhwk,
|
2020-10-30 11:45:49 +00:00
|
|
|
"check boardid and hwkey",
|
|
|
|
"[v]\n - check environment parameter \"boardIdListHex\" against stored boardid and hwkey from the IVM\n v: verbose output"
|
2011-05-12 19:59:22 +00:00
|
|
|
);
|
2012-05-04 08:55:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* command km_checktestboot
|
|
|
|
* if the testpin of the board is asserted, return 1
|
|
|
|
* * else return 0
|
|
|
|
*/
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_checktestboot(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2012-05-04 08:55:58 +00:00
|
|
|
{
|
|
|
|
int testpin = 0;
|
|
|
|
char *s = NULL;
|
|
|
|
int testboot = 0;
|
|
|
|
int verbose = argc > 1 && *argv[1] == 'v';
|
|
|
|
|
|
|
|
#if defined(CONFIG_POST)
|
|
|
|
testpin = post_hotkeys_pressed();
|
2015-11-17 09:53:26 +00:00
|
|
|
#endif
|
2020-10-30 11:45:49 +00:00
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
s = env_get("test_bank");
|
2012-05-04 08:55:58 +00:00
|
|
|
/* when test_bank is not set, act as if testpin is not asserted */
|
|
|
|
testboot = (testpin != 0) && (s);
|
|
|
|
if (verbose) {
|
|
|
|
printf("testpin = %d\n", testpin);
|
2014-11-06 13:02:57 +00:00
|
|
|
/* cppcheck-suppress nullPointer */
|
2012-05-04 08:55:58 +00:00
|
|
|
printf("test_bank = %s\n", s ? s : "not set");
|
|
|
|
printf("boot test app : %s\n", (testboot) ? "yes" : "no");
|
|
|
|
}
|
|
|
|
/* return 0 means: testboot, therefore we need the inversion */
|
|
|
|
return !testboot;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(km_checktestboot, 2, 0, do_checktestboot,
|
2020-10-30 11:45:49 +00:00
|
|
|
"check if testpin is asserted",
|
|
|
|
"[v]\n v - verbose output"
|
2012-05-04 08:55:58 +00:00
|
|
|
);
|