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