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