blob: 943bff8d290ab20da4401024309bde795ed36137 [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 <nios2-io.h>
15#include <linux/time.h>
16
17void display_sysid (void)
18{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020019 struct nios_sysid_t *sysid = (struct nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
wdenk0c1c117c2005-03-30 23:28:18 +000020 struct tm t;
21 char asc[32];
Scott McNuttc2ced002006-06-08 11:59:57 -040022 time_t stamp;
wdenk0c1c117c2005-03-30 23:28:18 +000023
Scott McNuttc2ced002006-06-08 11:59:57 -040024 stamp = readl (&sysid->timestamp);
25 localtime_r (&stamp, &t);
wdenk0c1c117c2005-03-30 23:28:18 +000026 asctime_r (&t, asc);
Stefan Roesef2302d42008-08-06 14:05:38 +020027 printf ("SYSID : %08lx, %s", readl (&sysid->id), asc);
wdenk0c1c117c2005-03-30 23:28:18 +000028
29}
30
Wolfgang Denk54841ab2010-06-28 22:00:46 +020031int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk0c1c117c2005-03-30 23:28:18 +000032{
33 display_sysid ();
34 return (0);
35}
36
37U_BOOT_CMD(
38 sysid, 1, 1, do_sysid,
Peter Tyser2fb26042009-01-27 18:03:12 -060039 "display Nios-II system id",
Wolfgang Denka89c33d2009-05-24 17:06:54 +020040 ""
wdenk0c1c117c2005-03-30 23:28:18 +000041);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020042#endif /* CONFIG_SYS_NIOS_SYSID_BASE */