wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004, Psyent Corporation <www.psyent.com> |
| 3 | * Scott McNutt <smcnutt@psyent.com> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 10 | #if defined (CONFIG_SYS_NIOS_SYSID_BASE) |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 11 | |
| 12 | #include <command.h> |
Scott McNutt | c2ced00 | 2006-06-08 11:59:57 -0400 | [diff] [blame] | 13 | #include <asm/io.h> |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 14 | #include <linux/time.h> |
| 15 | |
Thomas Chou | 8645071 | 2014-08-25 16:50:14 +0800 | [diff] [blame] | 16 | typedef volatile struct { |
| 17 | unsigned id; /* The system build id */ |
| 18 | unsigned timestamp; /* Timestamp */ |
| 19 | } nios_sysid_t; |
| 20 | |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 21 | void display_sysid (void) |
| 22 | { |
Thomas Chou | 8645071 | 2014-08-25 16:50:14 +0800 | [diff] [blame] | 23 | nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE; |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 24 | struct tm t; |
| 25 | char asc[32]; |
Scott McNutt | c2ced00 | 2006-06-08 11:59:57 -0400 | [diff] [blame] | 26 | time_t stamp; |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 27 | |
Scott McNutt | c2ced00 | 2006-06-08 11:59:57 -0400 | [diff] [blame] | 28 | stamp = readl (&sysid->timestamp); |
| 29 | localtime_r (&stamp, &t); |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 30 | asctime_r (&t, asc); |
Stefan Roese | f2302d4 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 31 | printf ("SYSID : %08lx, %s", readl (&sysid->id), asc); |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 32 | |
| 33 | } |
| 34 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 35 | int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 36 | { |
| 37 | display_sysid (); |
| 38 | return (0); |
| 39 | } |
| 40 | |
| 41 | U_BOOT_CMD( |
| 42 | sysid, 1, 1, do_sysid, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 43 | "display Nios-II system id", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 44 | "" |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 45 | ); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | #endif /* CONFIG_SYS_NIOS_SYSID_BASE */ |