Skip to contentSkip to conversation

ARM: mx31: Print the silicon version

PATCH New Fabio Estevam 5 participants 11 messages Apr 12, 2011 – Apr 27, 2011

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Use the same method of the Linux kernel to print the MX31 silicon version on boot.

Tested on a MX31PDK with a 2.0 silicon, where it shows:

CPU: Freescale i.MX31 rev 2.0 at 531 MHz

---
Changes since v4:
- Get rid of imx_soc_revision.h and its macro
Changes since v3:
- Keep consistency with other i.MX processors and print the silicon version in the same line as the CPU name
- Remove unneeded blank line in imx_soc_revision.h
Changes since v2:
- Use macro instead of defines for IMX_CHIP_REVISION
Changes since v1:
- rename the CPU detect function name to get_cpu_rev
- Use struct to access iim register

 arch/arm/cpu/arm1136/mx31/generic.c       |   30 +++++++++++++++++++++++++++-
 arch/arm/include/asm/arch-mx31/imx-regs.h |   25 ++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
arch/arm/cpu/arm1136/mx31/generic.c +28 -2
index fa07fec..9b7a7a2 100644
@@ -106,11 +106,37 @@ void mx31_set_pad(enum iomux_pins pin, u32 config)
 
 }
 
+struct mx3_cpu_type mx31_cpu_type[] = {
+	{ .srev = 0x00,	.v = "1.0"  },
+	{ .srev = 0x10,	.v = "1.1"  },
+	{ .srev = 0x11,	.v = "1.1"  },
+	{ .srev = 0x12,	.v = "1.15" },
+	{ .srev = 0x13,	.v = "1.15" },
+	{ .srev = 0x14,	.v = "1.2"  },
+	{ .srev = 0x15,	.v = "1.2"  },
+	{ .srev = 0x28,	.v = "2.0"  },
+	{ .srev = 0x29,	.v = "2.0"  },
+};
+
+char *get_cpu_rev(void)
+{
+	u32 i, srev;
+
+	/* read SREV register from IIM module */
+	struct iim_regs *iim = (struct iim_regs *)MX31_IIM_BASE_ADDR;
+	srev = readl(&iim->iim_srev);
+
+	for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++)
+		if (srev == mx31_cpu_type[i].srev)
+			return mx31_cpu_type[i].v;
+		return "unknown";
+}
+
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo (void)
 {
-	printf("CPU:   Freescale i.MX31 at %d MHz\n",
-		mx31_get_mcu_main_clk() / 1000000);
+	printf("CPU:   Freescale i.MX31 rev %s@%d MHz\n",
+			get_cpu_rev(), mx31_get_mcu_main_clk() / 1000000);
 	return 0;
 }
 #endif
arch/arm/include/asm/arch-mx31/imx-regs.h +25 -0
index 37337f2..0eeaf39 100644
@@ -84,6 +84,29 @@ struct wdog_regs {
 	u16 wrsr;	/* Reset Status */
 };
 
+/* IIM Control Registers */
+struct iim_regs {
+	u32 iim_stat;
+	u32 iim_statm;
+	u32 iim_err;
+	u32 iim_emask;
+	u32 iim_fctl;
+	u32 iim_ua;
+	u32 iim_la;
+	u32 iim_sdat;
+	u32 iim_prev;
+	u32 iim_srev;
+	u32 iim_prog_p;
+	u32 iim_scs0;
+	u32 iim_scs1;
+	u32 iim_scs2;
+	u32 iim_scs3;
+};
+
+struct mx3_cpu_type {
+	u8 srev;
+	const char *v;
+};
 
 #define IOMUX_PADNUM_MASK	0x1ff
 #define IOMUX_PIN(gpionum, padnum) ((padnum) & IOMUX_PADNUM_MASK)
@@ -480,6 +503,8 @@ enum iomux_pins {
 #define CCMR_FPM	(1 << 1)
 #define CCMR_CKIH	(2 << 1)
 
+#define MX31_IIM_BASE_ADDR	0x5001C000
+
 #define PDR0_CSI_PODF(x)	(((x) & 0x1ff) << 23)
 #define PDR0_PER_PODF(x)	(((x) & 0x1f) << 16)
 #define PDR0_HSP_PODF(x)	(((x) & 0x7) << 11)
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Le 12/04/2011 04:18, Fabio Estevam a ?crit :

Quoted 21 lines

Use the same method of the Linux kernel to print the MX31 silicon version on boot.

Tested on a MX31PDK with a 2.0 silicon, where it shows:

CPU: Freescale i.MX31 rev 2.0 at 531 MHz

---
Changes since v4:
- Get rid of imx_soc_revision.h and its macro
Changes since v3:
- Keep consistency with other i.MX processors and print the silicon version in the same line as the CPU name
- Remove unneeded blank line in imx_soc_revision.h
Changes since v2:
- Use macro instead of defines for IMX_CHIP_REVISION
Changes since v1:
- rename the CPU detect function name to get_cpu_rev
- Use struct to access iim register

Quoted 3 lines
  arch/arm/cpu/arm1136/mx31/generic.c       |   30 +++++++++++++++++++++++++++-
  arch/arm/include/asm/arch-mx31/imx-regs.h |   25 ++++++++++++++++++++++++
  2 files changed, 53 insertions(+), 2 deletions(-)

Seems this is ok.

Stefano, will you take this patch in and send a pull request, or do you want me to pick it?

Amicalement,

Signature · 1 line
Albert.
#2 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Am 14/04/2011 13:14, schrieb Albert ARIBAUD:

Quoted 2 lines

Seems this is ok.

It is for me ok, too.

Quoted 3 lines

Stefano, will you take this patch in and send a pull request, or do you want me to pick it?

I will take this patch and I wiil send you a pull request.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#3 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

In reply to Fabio Estevam
Quoted 9 lines · Fabio Estevam

Use the same method of the Linux kernel to print the MX31 silicon version on boot.

Tested on a MX31PDK with a 2.0 silicon, where it shows:

CPU: Freescale i.MX31 rev 2.0 at 531 MHz

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#4 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Quoted 4 lines · Stefano Babic
Quoted 3 lines · Fabio Estevam

Use the same method of the Linux kernel to print the MX31 silicon version on boot.

Quoted 9 lines
Quoted 6 lines

Tested on a MX31PDK with a 2.0 silicon, where it shows:

CPU: Freescale i.MX31 rev 2.0 at 531 MHz

Applied to u-boot-imx, thanks.

Fabio,

I have not noted before that your patch introduce a warning:

generic.c: In function 'get_cpu_rev':
generic.c:131: warning: return discards qualifiers from pointer target type

This is due to the usage of the const in the mx3_cpu_type:

struct mx3_cpu_type {
        u8 srev;
       const char *v;

Do you agree if I drop myself the const attribute on u-boot-imx before pulling your patch to the arm tree ?

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#5 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Hi Stefano,

Quoted 22 lines · Stefano Babic
Quoted 13 lines · Fabio Estevam
Quoted 9 lines

Use the same method of the Linux kernel to print the MX31 silicon version on boot.

Tested on a MX31PDK with a 2.0 silicon, where it shows:

CPU: Freescale i.MX31 rev 2.0 at 531 MHz

Applied to u-boot-imx, thanks.

Fabio,

I have not noted before that your patch introduce a warning:

generic.c: In function 'get_cpu_rev':
generic.c:131: warning: return discards qualifiers from pointer target type

Quoted 8 lines

This is due to the usage of the const in the mx3_cpu_type:

struct mx3_cpu_type {
        u8 srev;
       const char *v;

Do you agree if I drop myself the const attribute on u-boot-imx before pulling your patch to the arm tree ?

Sorry to jump in late, but why not change get_cpu_rev to 'const char *' which it actually is?

Cheers
Detlev

Signature · 5 lines
Emacs is the way to purify your soul using garbage collection.
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#6 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Quoted 10 lines · Detlev Zundel
Quoted 8 lines
Quoted 1 line
Quoted 1 line

This is due to the usage of the const in the mx3_cpu_type:

struct mx3_cpu_type {
        u8 srev;
       const char *v;

Do you agree if I drop myself the const attribute on u-boot-imx before pulling your patch to the arm tree ?

Sorry to jump in late,

.. not so late, we can change it...

Quoted 2 lines

but why not change get_cpu_rev to 'const char *'
which it actually is?

This is correct. However, I have not noted before that the last introduced get_cpu_rev() in MX31 is an exception in u-boot. For all other processors, it returns a u32 and it is defined as u32 get_cpu_rev(void).

Fabio's patch introduces a variant, because it is defined as const char *get_cpu_rev(void). I propose to change its name (get_cpu_rev_string ?) and add the static attribute, to make clear it is different as the get_cpu_rev() already implemented in u-boot.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#7 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Hi Stefano,

On 4/27/2011 6:40 AM, Stefano Babic wrote:
...

Quoted 8 lines
Quoted 2 lines

but why not change get_cpu_rev to 'const char *'
which it actually is?

This is correct. However, I have not noted before that the last introduced get_cpu_rev() in MX31 is an exception in u-boot. For all other processors, it returns a u32 and it is defined as u32 get_cpu_rev(void).

Quoted 4 lines

Fabio's patch introduces a variant, because it is defined as const char *get_cpu_rev(void). I propose to change its name (get_cpu_rev_string ?) and add the static attribute, to make clear it is different as the get_cpu_rev() already implemented in u-boot.

Ok, I can change it as per your suggestion.

Will send a patch soon.

Regards,

Fabio Estevam

#8 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

On 04/27/2011 03:16 PM, Fabio Estevam wrote:

Hi Fabio,

Quoted 1 line

Will send a patch soon.

Ok, thanks.

Regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#9 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

In reply to Stefano Babic

Hi Stefano,

Quoted 23 lines · Detlev Zundel
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

This is due to the usage of the const in the mx3_cpu_type:

struct mx3_cpu_type {
        u8 srev;
       const char *v;

Do you agree if I drop myself the const attribute on u-boot-imx before pulling your patch to the arm tree ?

Sorry to jump in late,

.. not so late, we can change it...

Quoted 2 lines

but why not change get_cpu_rev to 'const char *'
which it actually is?

This is correct. However, I have not noted before that the last introduced get_cpu_rev() in MX31 is an exception in u-boot. For all other processors, it returns a u32 and it is defined as u32 get_cpu_rev(void).

Quoted 4 lines

Fabio's patch introduces a variant, because it is defined as const char *get_cpu_rev(void). I propose to change its name (get_cpu_rev_string ?) and add the static attribute, to make clear it is different as the get_cpu_rev() already implemented in u-boot.

I see. Can't we consolidate all those functions into more general functions higher up in the specialization graph? I.e. why have static non-conforming functions when we could have one generic function to handle all users?

Cheers
Detlev

Signature · 5 lines
System going down at 1:45 this afternoon for disk crashing.
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#10 lore raw

PATCH v5 1/1 ARM: mx31: Print the silicon version

Quoted 2 lines · Detlev Zundel

I see. Can't we consolidate all those functions into more general functions higher up in the specialization graph?

As I can see, the get_cpu_rev() is already a generalized function, used in more processors. IMHO we should switch back to the usual prototype u32 get_cpu_rev(), and print_cpuinfo() should transform the revision number in a human readable way.

Quoted 3 lines

I.e. why have static
non-conforming functions when we could have one generic function to handle all users?

Yes, agree. Really I have not seen that get_cpu_rev() changed returning a string, instead of u32 as usual. This must be fixed.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================