blob: 50819b24249d475cc4668a4d90fa5a8621161458 [file] [log] [blame]
wdenk194b8392005-03-30 23:28:18 +00001/*
2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk194b8392005-03-30 23:28:18 +00006 */
7
8#include <common.h>
9
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020010#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
wdenk194b8392005-03-30 23:28:18 +000011
12#include <command.h>
Scott McNutta5721a32006-06-08 11:59:57 -040013#include <asm/io.h>
wdenk194b8392005-03-30 23:28:18 +000014#include <linux/time.h>
15
Thomas Chou769cb5c2014-08-25 16:50:14 +080016typedef volatile struct {
17 unsigned id; /* The system build id */
18 unsigned timestamp; /* Timestamp */
19} nios_sysid_t;
20
wdenk194b8392005-03-30 23:28:18 +000021void display_sysid (void)
22{
Thomas Chou769cb5c2014-08-25 16:50:14 +080023 nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
wdenk194b8392005-03-30 23:28:18 +000024 struct tm t;
25 char asc[32];
Scott McNutta5721a32006-06-08 11:59:57 -040026 time_t stamp;
wdenk194b8392005-03-30 23:28:18 +000027
Scott McNutta5721a32006-06-08 11:59:57 -040028 stamp = readl (&sysid->timestamp);
29 localtime_r (&stamp, &t);
wdenk194b8392005-03-30 23:28:18 +000030 asctime_r (&t, asc);
Stefan Roese37628252008-08-06 14:05:38 +020031 printf ("SYSID : %08lx, %s", readl (&sysid->id), asc);
wdenk194b8392005-03-30 23:28:18 +000032
33}
34
Wolfgang Denk6262d0212010-06-28 22:00:46 +020035int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk194b8392005-03-30 23:28:18 +000036{
37 display_sysid ();
38 return (0);
39}
40
41U_BOOT_CMD(
42 sysid, 1, 1, do_sysid,
Peter Tyserdfb72b82009-01-27 18:03:12 -060043 "display Nios-II system id",
Wolfgang Denkc54781c2009-05-24 17:06:54 +020044 ""
wdenk194b8392005-03-30 23:28:18 +000045);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020046#endif /* CONFIG_SYS_NIOS_SYSID_BASE */