ARM: mx31: Print the silicon version
Subsystems (2)
Fabio Estevam
reviewerPATCH v2 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 at 531 MHz
MX31 silicon rev 2.0
---
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 | 18 ++++++++++++ arch/arm/include/asm/arch-mx31/imx-regs.h | 20 +++++++++++++ arch/arm/include/asm/imx_soc_revision.h | 42 +++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/imx_soc_revision.h
arch/arm/cpu/arm1136/mx31/generic.c +18 -0
@@ -24,6 +24,7 @@#include <common.h> #include <asm/arch/imx-regs.h> #include <asm/io.h> +#include <asm/imx_soc_revision.h> static u32 mx31_decode_pll (u32 reg,u32 infreq) {
@@ -106,11 +107,28 @@ void mx31_set_pad(enum iomux_pins pin, u32 config) } +void 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) { +printf ("MX31 silicon rev %s\n" , mx31_cpu_type[i].v); +return ; + } +printf ("Unknown CPU identifier. srev = %02x\n" , srev); +} +#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void ) {printf ("CPU: Freescale i.MX31 at %d MHz\n" ,mx31_get_mcu_main_clk () /1000000 ); +get_cpu_rev ();return 0 ; }#endif
arch/arm/include/asm/arch-mx31/imx-regs.h +20 -0
@@ -84,6 +84,24 @@ 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; +};#define IOMUX_PADNUM_MASK 0x1ff#define IOMUX_PIN (gpionum, padnum) ((padnum) & IOMUX_PADNUM_MASK)
@@ -480,6 +498,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)
arch/arm/include/asm/imx_soc_revision.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.6.0.4
PATCH v2 1/1 ARM: mx31: Print the silicon version
Dear Fabio Estevam,
Quoted 6 lines · In message <[email protected]> you wrote:
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 at 531 MHz
...
arch/arm/include/asm/imx_soc_revision.h line 22
Quoted 12 lines
arch/arm/include/asm/imx_soc_revision.h new file +12
-0+#define IMX_CHIP_REVISION_1_0 0x10 +#define IMX_CHIP_REVISION_1_1 0x11 +#define IMX_CHIP_REVISION_1_2 0x12 +#define IMX_CHIP_REVISION_1_3 0x13 +#define IMX_CHIP_REVISION_2_0 0x20 +#define IMX_CHIP_REVISION_2_1 0x21 +#define IMX_CHIP_REVISION_2_2 0x22 +#define IMX_CHIP_REVISION_2_3 0x23 +#define IMX_CHIP_REVISION_3_0 0x30 +#define IMX_CHIP_REVISION_3_1 0x31 +#define IMX_CHIP_REVISION_3_2 0x32 +#define IMX_CHIP_REVISION_3_3 0x33
What a nightmare. Does this not give the creeps to any of you who add to this code?
I'm finally fed up with this, and say NAK here.
Please use something like this instead:
#define IMX_CHIP_REVISION(maj, min) ((maj) * 16 + (min))
Feel free to add appropriate range checking on the parameters, probably using BUILD_BUG_ON() so it gets caught at compile time.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Common sense and a sense of humor are the same thing, moving at
different speeds. A sense of humor is just common sense, dancing.
- Clive James