Skip to contentSkip to conversation

ARM: at91: Print CPU serial number in cpuinfo

RFC PATCH New Alexander Dahl 2 participants 2 messages Nov 27, 2019 – Nov 29, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ARM: at91: Print CPU serial number in cpuinfo

The SAMA5D2 and SAMA5D4 series SoCs have a 64-bit Serial Number (unique ID) burned in, which is displayed with 'print_cpuinfo()' now (in the same format the SAM-BA applet prints it).

Example output:

CPU: SAMA5D27 1G bits DDR2 SDRAM
Serial number 0: 0x4630394b

              1: 0x190d2750
Crystal frequency:       24 MHz
CPU clock        :      492 MHz
Master clock     :      164 MHz

---

I looked over lots of other 'print_cpuinfo()' implementations for different SoCs and found none printing a unique ID at all. Is there another place for this? Is it just few SoCs have such a serial number at all? Or is it not desired to print those along with the other CPU info?

Greets
Alex

---
 arch/arm/mach-at91/armv7/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/mach-at91/armv7/cpu.c +8 -0
index 5da067cda1..6d50e1aea4 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/at91_pit.h>
 #include <asm/arch/at91_gpbr.h>
+#include <asm/arch/at91_sfr.h>
 #include <asm/arch/clk.h>
 
 #ifndef CONFIG_SYS_AT91_MAIN_CLOCK
@@ -42,9 +43,16 @@ void arch_preboot_os(void)
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
 {
+	struct atmel_sfr *sfr = (struct atmel_sfr *)ATMEL_BASE_SFR;
 	char buf[32];
 
 	printf("CPU: %s\n", get_cpu_name());
+
+#if defined(CONFIG_SAMA5D2) || defined(CONFIG_SAMA5D4)
+	printf("Serial number 0: 0x%08x\n", sfr->sn0);
+	printf("              1: 0x%08x\n", sfr->sn1);
+#endif
+
 	printf("Crystal frequency: %8s MHz\n",
 	       strmhz(buf, get_main_clk_rate()));
 	printf("CPU clock        : %8s MHz\n",
Signature · 1 line
2.20.1
#1 lore raw

RFC PATCH 1/1 ARM: at91: Print CPU serial number in cpuinfo

Quoted 13 lines · Alexander Dahl

The SAMA5D2 and SAMA5D4 series SoCs have a 64-bit Serial Number (unique ID) burned in, which is displayed with 'print_cpuinfo()' now (in the same format the SAM-BA applet prints it).

Example output:

CPU: SAMA5D27 1G bits DDR2 SDRAM
Serial number 0: 0x4630394b

               1: 0x190d2750
Crystal frequency:       24 MHz
CPU clock        :      492 MHz
Master clock     :      164 MHz
Quoted 9 lines

---

I looked over lots of other 'print_cpuinfo()' implementations for different SoCs and found none printing a unique ID at all. Is there another place for this? Is it just few SoCs have such a serial number at all? Or is it not desired to print those along with the other CPU info?

Hi Alex,

I do not have anything against it.
Nor do I have a strong opinion about which way to go. Is it better to just have a CMD that prints out this serial or print it at boot ? Maybe some other people have a different idea ?

Eugen

Quoted 40 lines

Greets
Alex

---
  arch/arm/mach-at91/armv7/cpu.c | 8 ++++++++
  1 file changed, 8 insertions(+)
arch/arm/mach-at91/armv7/cpu.c +8 -1
index 5da067cda1..6d50e1aea4 100644
@@ -13,6 +13,7 @@
  #include <asm/arch/hardware.h>
  #include <asm/arch/at91_pit.h>
  #include <asm/arch/at91_gpbr.h>
+#include <asm/arch/at91_sfr.h>
  #include <asm/arch/clk.h>
 
  #ifndef CONFIG_SYS_AT91_MAIN_CLOCK
@@ -42,9 +43,16 @@ void arch_preboot_os(void)
  #if defined(CONFIG_DISPLAY_CPUINFO)
  int print_cpuinfo(void)
  {
+       struct atmel_sfr *sfr = (struct atmel_sfr *)ATMEL_BASE_SFR;
         char buf[32];
 
         printf("CPU: %s\n", get_cpu_name());
+
+#if defined(CONFIG_SAMA5D2) || defined(CONFIG_SAMA5D4)
+       printf("Serial number 0: 0x%08x\n", sfr->sn0);
+       printf("              1: 0x%08x\n", sfr->sn1);
+#endif
+
         printf("Crystal frequency: %8s MHz\n",
                strmhz(buf, get_main_clk_rate()));
         printf("CPU clock        : %8s MHz\n",
--

2.20.1