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 <nios2-io.h> |
| 15 | #include <linux/time.h> |
| 16 | |
| 17 | void display_sysid (void) |
| 18 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 19 | struct nios_sysid_t *sysid = (struct nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE; |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 20 | struct tm t; |
| 21 | char asc[32]; |
Scott McNutt | c2ced00 | 2006-06-08 11:59:57 -0400 | [diff] [blame] | 22 | time_t stamp; |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 23 | |
Scott McNutt | c2ced00 | 2006-06-08 11:59:57 -0400 | [diff] [blame] | 24 | stamp = readl (&sysid->timestamp); |
| 25 | localtime_r (&stamp, &t); |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 26 | asctime_r (&t, asc); |
Stefan Roese | f2302d4 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 27 | printf ("SYSID : %08lx, %s", readl (&sysid->id), asc); |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 28 | |
| 29 | } |
| 30 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 31 | 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] | 32 | { |
| 33 | display_sysid (); |
| 34 | return (0); |
| 35 | } |
| 36 | |
| 37 | U_BOOT_CMD( |
| 38 | sysid, 1, 1, do_sysid, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 39 | "display Nios-II system id", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 40 | "" |
wdenk | 0c1c117c | 2005-03-30 23:28:18 +0000 | [diff] [blame] | 41 | ); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 42 | #endif /* CONFIG_SYS_NIOS_SYSID_BASE */ |