sysid.c 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #if defined (CONFIG_SYS_NIOS_SYSID_BASE)
  9. #include <command.h>
  10. #include <asm/io.h>
  11. #include <linux/time.h>
  12. typedef volatile struct {
  13. unsigned id; /* The system build id */
  14. unsigned timestamp; /* Timestamp */
  15. } nios_sysid_t;
  16. void display_sysid (void)
  17. {
  18. nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
  19. struct tm t;
  20. char asc[32];
  21. time_t stamp;
  22. stamp = readl (&sysid->timestamp);
  23. localtime_r (&stamp, &t);
  24. asctime_r (&t, asc);
  25. printf ("SYSID : %08lx, %s", readl (&sysid->id), asc);
  26. }
  27. int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  28. {
  29. display_sysid ();
  30. return (0);
  31. }
  32. U_BOOT_CMD(
  33. sysid, 1, 1, do_sysid,
  34. "display Nios-II system id",
  35. ""
  36. );
  37. #endif /* CONFIG_SYS_NIOS_SYSID_BASE */