: imx: mx6: use OTP for temperature grade info
Subsystems (3)
v2 cover : imx: mx6: use OTP for temperature grade info
This is a second take on my last series to obtain and use CPU temperature grade in print_cpuinfo().
--
v2:
- split into two series: 1 for CPU frequency, other for Temperature grade
Tim Harvey (4):
mx6: add OTP bank1 registers
imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP
imx: mx6: add display of CPU temperature grade in print_cpuinfo()
thermal: imx_thermal: use CPU temperature grade for trip points
arch/arm/cpu/armv7/mx6/soc.c | 38 +++++++++++++++++++++++++++++++ arch/arm/imx-common/cpu.c | 27 ++++++++++++++++++---- arch/arm/include/asm/arch-mx6/imx-regs.h | 19 ++++++++++++++++ arch/arm/include/asm/arch-mx6/sys_proto.h | 1 + drivers/thermal/imx_thermal.c | 29 +++++++++++++++-------- include/imx_thermal.h | 6 +++++ 6 files changed, 106 insertions(+), 14 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/4 mx6: add OTP bank1 registers
--- arch/arm/include/asm/arch-mx6/imx-regs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +19 -0
@@ -640,6 +640,25 @@ struct fuse_bank0_regs {u32 rsvd7[3 ]; }; +struct fuse_bank1_regs { +u32 mem0; +u32 rsvd0[3 ]; +u32 mem1; +u32 rsvd1[3 ]; +u32 mem2; +u32 rsvd2[3 ]; +u32 mem3; +u32 rsvd3[3 ]; +u32 mem4; +u32 rsvd4[3 ]; +u32 ana0; +u32 rsvd5[3 ]; +u32 ana1; +u32 rsvd6[3 ]; +u32 ana2; +u32 rsvd7[3 ]; +}; + #ifdef CONFIG_MX6SX struct fuse_bank4_regs { u32 sjc_resp_low;
Signature · 1 line
1.9.1
PATCH v2 1/4 mx6: add OTP bank1 registers
2015-05-14 7:11 GMT+02:00 Tim Harvey <[email protected]>:
Quoted 36 lines
Signed-off-by Tim Harvey <[email protected]>--- arch/arm/include/asm/arch-mx6/imx-regs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)arch/arm/include/asm/arch-mx6/imx-regs.h +19
-1@@ -640,6 +640,25 @@ struct fuse_bank0_regs {u32 rsvd7[3 ]; }; +struct fuse_bank1_regs { +u32 mem0; +u32 rsvd0[3 ]; +u32 mem1; +u32 rsvd1[3 ]; +u32 mem2; +u32 rsvd2[3 ]; +u32 mem3; +u32 rsvd3[3 ]; +u32 mem4; +u32 rsvd4[3 ]; +u32 ana0; +u32 rsvd5[3 ]; +u32 ana1; +u32 rsvd6[3 ]; +u32 ana2; +u32 rsvd7[3 ]; +}; + #ifdef CONFIG_MX6SX struct fuse_bank4_regs { u32 sjc_resp_low; --
Quoted 2 lines
1.9.1
greets
--
Christian Gmeiner, MSc
PATCH v2 1/4 mx6: add OTP bank1 registers
In reply to Tim HarveyHi Tim,
Quoted 26 lines · Tim Harvey
Signed-off-by Tim Harvey <[email protected]>--- arch/arm/include/asm/arch-mx6/imx-regs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)arch/arm/include/asm/arch-mx6/imx-regs.h +12
-0@@ -640,6 +640,25 @@ struct fuse_bank0_regs {u32 rsvd7[3 ]; }; +struct fuse_bank1_regs { +u32 mem0; +u32 rsvd0[3 ]; +u32 mem1; +u32 rsvd1[3 ]; +u32 mem2; +u32 rsvd2[3 ]; +u32 mem3; +u32 rsvd3[3 ]; +u32 mem4; +u32 rsvd4[3 ]; +u32 ana0;
arch/arm/include/asm/arch-mx6/imx-regs.h struct fuse_bank0_regs { · line 664
Quoted 10 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +7
-0+u32 rsvd5[3 ]; +u32 ana1; +u32 rsvd6[3 ]; +u32 ana2; +u32 rsvd7[3 ]; +}; + #ifdef CONFIG_MX6SX struct fuse_bank4_regs { u32 sjc_resp_low;
U-Boot 2015.07-rc1-21804-gaf1db4a-dirty (May 18 2015 - 01:26:05)
CPU: Freescale i.MX6SOLO rev1.1 996 MHz (running at 792 MHz) CPU: Commercial temperature grade (0C to 95C) at 59C Reset cause: POR Board: RIoTboard
Regards,
Nikolay
PATCH v2 2/4 imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP
In reply to Tim HarveyThe MX6 has a temperature grade defined by OCOTP_MEM0[7:6] which is at 0x480 in the Fusemap Description Table in the reference manual. Return this value as well as min/max temperature based on the value.
Note that the IMX6SDLRM and the IMX6SXRM do not indicate this in the their Fusemap Description Table however Freescale has confirmed that these eFUSE bits match the description within the IMX6DQRM and that they will be added to the next revision of the respective reference manuals.
This has been tested with IMX6 Automative and Industrial parts.
---
v2:
- split out adding get_cpu_temp_grade to its own patch
- added note about support of MX6SDL and MX6SX
--- arch/arm/cpu/armv7/mx6/soc.c | 38 +++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx6/sys_proto.h | 1 + include/imx_thermal.h | 6 +++++ 3 files changed, 45 insertions(+)
arch/arm/cpu/armv7/mx6/soc.c +38 -0
@@ -124,6 +124,44 @@ u32 get_cpu_speed_grade_hz(void)return 0 ; } +/* +* OCOTP_MEM0[7:6] (see Fusemap Description Table offset 0x480) +* defines a 2-bit Temperature Grade +* +* return temperature grade and min/max temperature in celcius +*/ +#define OCOTP_MEM0_TEMP_SHIFT 6 + +u32 get_cpu_temp_grade (int *minc,int *maxc) +{ +struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR ; +struct fuse_bank *bank = &ocotp->bank[1 ]; +struct fuse_bank1_regs *fuse = + (struct fuse_bank1_regs *)bank->fuse_regs; +uint32_t val; + + val =readl (&fuse->mem0); + val >>=OCOTP_MEM0_TEMP_SHIFT ; + val &=0x3 ; + +if (minc && maxc) { +if (val ==TEMP_AUTOMOTIVE ) { + *minc =-40 ; + *maxc =125 ; + }else if (val ==TEMP_INDUSTRIAL ) { + *minc =-40 ; + *maxc =105 ; + }else if (val ==TEMP_EXTCOMMERCIAL ) { + *minc =-20 ; + *maxc =105 ; + }else { + *minc =0 ; + *maxc =95 ; + } + } +return val; +} +#ifdef CONFIG_REVISION_TAG u32 __weak get_board_rev (void ) {
arch/arm/include/asm/arch-mx6/sys_proto.h +1 -0
@@ -17,6 +17,7 @@u32 get_nr_cpus (void );u32 get_cpu_rev (void );u32 get_cpu_speed_grade_hz (void ); +u32 get_cpu_temp_grade (int *minc,int *maxc);/* returns MXC_CPU_ value */ #define cpu_type (rev) (((rev) >> 12)&0xff)
include/imx_thermal.h +6 -0
@@ -8,6 +8,12 @@ #ifndef _IMX_THERMAL_H_ #define _IMX_THERMAL_H_ +/* CPU Temperature Grades */ +#define TEMP_COMMERCIAL 0 +#define TEMP_EXTCOMMERCIAL 1 +#define TEMP_INDUSTRIAL 2 +#define TEMP_AUTOMOTIVE 3 + struct imx_thermal_plat { void *regs; int fuse_bank;
Signature · 1 line
1.9.1
PATCH v2 2/4 imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP
2015-05-14 7:11 GMT+02:00 Tim Harvey <[email protected]>:
Quoted 103 lines
The MX6 has a temperature grade defined by OCOTP_MEM0[7:6] which is at
0x480in the Fusemap Description Table in the reference manual. Return this value as well as min/max temperature based on the value.Note that the IMX6SDLRM and the IMX6SXRM do not indicate this in the their Fusemap Description Table however Freescale has confirmed that these eFUSE bits match the description within the IMX6DQRM and that they will be added to the next revision of the respective reference manuals.
This has been tested with IMX6 Automative and Industrial parts.
Signed-off-by Tim Harvey <[email protected]>---
v2:
- split out addingget_cpu_temp_gradeto its own patch
- added note about support of MX6SDL and MX6SXSigned-off-by Tim Harvey <[email protected]>--- arch/arm/cpu/armv7/mx6/soc.c | 38 +++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx6/sys_proto.h | 1 + include/imx_thermal.h | 6 +++++ 3 files changed, 45 insertions(+)arch/arm/cpu/armv7/mx6/soc.c +38
-0@@ -124,6 +124,44 @@ u32 get_cpu_speed_grade_hz(void)return 0 ; } +/* +* OCOTP_MEM0[7:6] (see Fusemap Description Table offset 0x480) +* defines a 2-bit Temperature Grade +* +* return temperature grade and min/max temperature in celcius +*/ +#define OCOTP_MEM0_TEMP_SHIFT 6 + +u32 get_cpu_temp_grade (int *minc,int *maxc) +{ +struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR ; +struct fuse_bank *bank = &ocotp->bank[1 ]; +struct fuse_bank1_regs *fuse = + (struct fuse_bank1_regs *)bank->fuse_regs; +uint32_t val; + + val =readl (&fuse->mem0); + val >>=OCOTP_MEM0_TEMP_SHIFT ; + val &=0x3 ; + +if (minc && maxc) { +if (val ==TEMP_AUTOMOTIVE ) { + *minc =-40 ; + *maxc =125 ; + }else if (val ==TEMP_INDUSTRIAL ) { + *minc =-40 ; + *maxc =105 ; + }else if (val ==TEMP_EXTCOMMERCIAL ) { + *minc =-20 ; + *maxc =105 ; + }else { + *minc =0 ; + *maxc =95 ; + } + } +return val; +} +#ifdef CONFIG_REVISION_TAG u32 __weak get_board_rev (void ) {arch/arm/include/asm/arch-mx6/sys_proto.h +1
-0@@ -17,6 +17,7 @@u32 get_nr_cpus (void );u32 get_cpu_rev (void );u32 get_cpu_speed_grade_hz (void ); +u32 get_cpu_temp_grade (int *minc,int *maxc);/* returns MXC_CPU_ value */ #define cpu_type (rev) (((rev) >> 12)&0xff)include/imx_thermal.h +6
-1@@ -8,6 +8,12 @@ #ifndef _IMX_THERMAL_H_ #define _IMX_THERMAL_H_ +/* CPU Temperature Grades */ +#define TEMP_COMMERCIAL 0 +#define TEMP_EXTCOMMERCIAL 1 +#define TEMP_INDUSTRIAL 2 +#define TEMP_AUTOMOTIVE 3 + struct imx_thermal_plat { void *regs; int fuse_bank; --
Quoted 2 lines
1.9.1
greets
--
Christian Gmeiner, MSc
PATCH v2 2/4 imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP
In reply to Tim HarveyQuoted 93 lines · Tim Harvey
The MX6 has a temperature grade defined by OCOTP_MEM0[7:6] which is at
0x480in the Fusemap Description Table in the reference manual. Return this value as well as min/max temperature based on the value.Note that the IMX6SDLRM and the IMX6SXRM do not indicate this in the their Fusemap Description Table however Freescale has confirmed that these eFUSE bits match the description within the IMX6DQRM and that they will be added to the next revision of the respective reference manuals.
This has been tested with IMX6 Automative and Industrial parts.
Signed-off-by Tim Harvey <[email protected]>---
v2:
- split out addingget_cpu_temp_gradeto its own patch
- added note about support of MX6SDL and MX6SXSigned-off-by Tim Harvey <[email protected]>--- arch/arm/cpu/armv7/mx6/soc.c | 38 +++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx6/sys_proto.h | 1 + include/imx_thermal.h | 6 +++++ 3 files changed, 45 insertions(+)arch/arm/cpu/armv7/mx6/soc.c +38
-0@@ -124,6 +124,44 @@ u32 get_cpu_speed_grade_hz(void)return 0 ; } +/* +* OCOTP_MEM0[7:6] (see Fusemap Description Table offset 0x480) +* defines a 2-bit Temperature Grade +* +* return temperature grade and min/max temperature in celcius +*/ +#define OCOTP_MEM0_TEMP_SHIFT 6 + +u32 get_cpu_temp_grade (int *minc,int *maxc) +{ +struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR ; +struct fuse_bank *bank = &ocotp->bank[1 ]; +struct fuse_bank1_regs *fuse = + (struct fuse_bank1_regs *)bank->fuse_regs; +uint32_t val; + + val =readl (&fuse->mem0); + val >>=OCOTP_MEM0_TEMP_SHIFT ; + val &=0x3 ; + +if (minc && maxc) { +if (val ==TEMP_AUTOMOTIVE ) { + *minc =-40 ; + *maxc =125 ; + }else if (val ==TEMP_INDUSTRIAL ) { + *minc =-40 ; + *maxc =105 ; + }else if (val ==TEMP_EXTCOMMERCIAL ) { + *minc =-20 ; + *maxc =105 ; + }else { + *minc =0 ; + *maxc =95 ; + } + } +return val; +} +#ifdef CONFIG_REVISION_TAG u32 __weak get_board_rev (void ) {arch/arm/include/asm/arch-mx6/sys_proto.h +1
-0@@ -17,6 +17,7 @@u32 get_nr_cpus (void );u32 get_cpu_rev (void );u32 get_cpu_speed_grade_hz (void ); +u32 get_cpu_temp_grade (int *minc,int *maxc);/* returns MXC_CPU_ value */ #define cpu_type (rev) (((rev) >> 12)&0xff)include/imx_thermal.h +0
-0@@ -8,6 +8,12 @@#ifndef _IMX_THERMAL_H_#define _IMX_THERMAL_H_
include/imx_thermal.h line 19
Quoted 10 lines
include/imx_thermal.h +6
-0+/* CPU Temperature Grades */ +#define TEMP_COMMERCIAL 0 +#define TEMP_EXTCOMMERCIAL 1 +#define TEMP_INDUSTRIAL 2 +#define TEMP_AUTOMOTIVE 3 +struct imx_thermal_plat {void *regs;int fuse_bank;
Regards,
Nikolay
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
In reply to Tim HarveyWhen CONFIG_IMX6_THERMAL is defined print the CPU temperature grade info along with the current temperature.
Before:
CPU: Temperature 42 C
After:
CPU: Automotive temperature grade (-40C to 125C) at 42C CPU: Industiral temperature grade (-40C to 105C) at 42C CPU: Extended Commercial temperature grade (-20C to 105C) at 42C
---
v2:
- moved display of CPU temperature grade to own patch and combined with the current temperature from the thermal sensor driver
- add example output to description
--- arch/arm/imx-common/cpu.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
arch/arm/imx-common/cpu.c +23 -4
@@ -16,6 +16,7 @@#include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> +#include <imx_thermal.h> #include <ipu_pixfmt.h> #include <thermal.h> #include <sata.h>
@@ -146,7 +147,7 @@ int print_cpuinfo(void)#if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL )struct udevice *thermal_dev; -int cpu_tmp, ret; +int cpu_tmp, minc, maxc, ret;#endif cpurev =get_cpu_rev ();
@@ -172,16 +173,34 @@ int print_cpuinfo(void)#endif #if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL ) +puts ("CPU: " ); +if (!is_cpu_type (MXC_CPU_MX6SX )) { +switch (get_cpu_temp_grade (&minc, &maxc)) { +case TEMP_AUTOMOTIVE : +puts ("Automotive temperature grade " ); +break ; +case TEMP_INDUSTRIAL : +puts ("Industrial temperature grade " ); +break ; +case TEMP_EXTCOMMERCIAL : +puts ("Extended Commercial temperature grade " ); +break ; +default : +puts ("Commercial temperature grade " ); +break ; + } +printf ("(%dC to %dC)" , minc, maxc); + } ret =uclass_get_device (UCLASS_THERMAL ,0 , &thermal_dev);if (!ret) { ret =thermal_get_temp (thermal_dev, &cpu_tmp);if (!ret) -printf ("CPU: Temperature %d C\n" , cpu_tmp); +printf (" at %dC\n" , cpu_tmp);else -printf ("CPU: Temperature: invalid sensor data\n" ); +puts (" - invalid sensor data\n" ); }else { -printf ("CPU: Temperature: Can't find sensor device\n" ); +puts (" - invalid sensor device\n" ); }#endif
Signature · 1 line
1.9.1
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
2015-05-14 7:11 GMT+02:00 Tim Harvey <[email protected]>:
Quoted 56 lines
When
CONFIG_IMX6_THERMALis defined print the CPU temperature grade info along with the current temperature.Before:
CPU: Temperature 42 CAfter:
CPU: Automotive temperature grade (-40C to 125C) at 42C CPU: Industiral temperature grade (-40C to 105C) at 42C CPU: Extended Commercial temperature grade (-20C to 105C) at 42CSigned-off-by Tim Harvey <[email protected]>---
v2:
- moved display of CPU temperature grade to own patch and combined with the current temperature from the thermal sensor driver
- add example output to descriptionSigned-off-by Tim Harvey <[email protected]>--- arch/arm/imx-common/cpu.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)arch/arm/imx-common/cpu.c +10
-1@@ -16,6 +16,7 @@#include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> +#include <imx_thermal.h> #include <ipu_pixfmt.h> #include <thermal.h> #include <sata.h> @@ -146,7 +147,7 @@ int print_cpuinfo(void)#if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL )struct udevice *thermal_dev; -int cpu_tmp, ret; +int cpu_tmp, minc, maxc, ret;#endif cpurev =get_cpu_rev ();@@ -172,16 +173,34 @@ int print_cpuinfo(void)#endif #if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL ) +puts ("CPU: " ); +if (!is_cpu_type (MXC_CPU_MX6SX )) { +switch (get_cpu_temp_grade (&minc, &maxc)) { +case TEMP_AUTOMOTIVE : +puts ("Automotive temperature grade " ); +break ; +case TEMP_INDUSTRIAL : +puts ("Industrial temperature grade " );
arch/arm/imx-common/cpu.c int print_cpuinfo(void) · line 193
Quoted 10 lines
arch/arm/imx-common/cpu.c +10
-0+break ; +case TEMP_EXTCOMMERCIAL : +puts ("Extended Commercial temperature grade " ); +break ; +default : +puts ("Commercial temperature grade " ); +break ; + } +printf ("(%dC to %dC)" , minc, maxc); + }
For the additions above we do not need CONFIG_IMX6_THERMAL.
Quoted 17 lines
arch/arm/imx-common/cpu.c +3
-4ret =uclass_get_device (UCLASS_THERMAL ,0 , &thermal_dev);if (!ret) { ret =thermal_get_temp (thermal_dev, &cpu_tmp);if (!ret) -printf ("CPU: Temperature %d C\n" , cpu_tmp); +printf (" at %dC\n" , cpu_tmp);else -printf ("CPU: Temperature: invalid sensor data\n" ); +puts (" - invalid sensor data\n" ); }else { -printf ("CPU: Temperature: Can't find sensor device\n" ); +puts (" - invalid sensor device\n" ); }#endif --
Quoted 2 lines
1.9.1
greets
--
Christian Gmeiner, MSc
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
Quoted 61 lines · Christian Gmeiner
2015-05-14 7:11 GMT+02:00 Tim Harvey <[email protected]>:
Quoted 60 lines
When
CONFIG_IMX6_THERMALis defined print the CPU temperature grade info along with the current temperature.Before:
CPU: Temperature 42 CAfter:
CPU: Automotive temperature grade (-40C to 125C) at 42C CPU: Industiral temperature grade (-40C to 105C) at 42C CPU: Extended Commercial temperature grade (-20C to 105C) at 42CSigned-off-by Tim Harvey <[email protected]>---
v2:
- moved display of CPU temperature grade to own patch and combined with the current temperature from the thermal sensor driver
- add example output to descriptionSigned-off-by Tim Harvey <[email protected]>--- arch/arm/imx-common/cpu.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)arch/arm/imx-common/cpu.c +14
-1@@ -16,6 +16,7 @@#include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> +#include <imx_thermal.h> #include <ipu_pixfmt.h> #include <thermal.h> #include <sata.h> @@ -146,7 +147,7 @@ int print_cpuinfo(void)#if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL )struct udevice *thermal_dev; -int cpu_tmp, ret; +int cpu_tmp, minc, maxc, ret;#endif cpurev =get_cpu_rev ();@@ -172,16 +173,34 @@ int print_cpuinfo(void)#endif #if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL ) +puts ("CPU: " ); +if (!is_cpu_type (MXC_CPU_MX6SX )) { +switch (get_cpu_temp_grade (&minc, &maxc)) { +case TEMP_AUTOMOTIVE : +puts ("Automotive temperature grade " ); +break ; +case TEMP_INDUSTRIAL : +puts ("Industrial temperature grade " ); +break ; +case TEMP_EXTCOMMERCIAL : +puts ("Extended Commercial temperature grade " ); +break ;
Quoted 8 lines
arch/arm/imx-common/cpu.c int print_cpuinfo(void) · line 193
Quoted 6 lines
arch/arm/imx-common/cpu.c +6
-0+default : +puts ("Commercial temperature grade " ); +break ; + } +printf ("(%dC to %dC)" , minc, maxc); + }For the additions above we do not need
CONFIG_IMX6_THERMAL.
Hi Christian,
Thanks for the review.
Its true that CONFIG_IMX6_THERMAL is not needed for cpu temperature grade but I felt that there would be resistance in general to adding additional lines in print_cpuinfo without allowing them to be easily disabled. I felt that temperature grade and current temperature made sense to go together in this fasion.
Looking over this though did remind me that now that Freescale has told me that the IMX6SX has the same OTP registers/definitions for temperature grade programmed I can remove the skip for MX6SX. I would however sure like to have someone with an actual MX6SX enable that code and give us some testing feedback.
Regards,
Tim
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
Hi Tim,
Quoted 72 lines · Tim Harvey
Quoted 61 lines · Christian Gmeiner
2015-05-14 7:11 GMT+02:00 Tim Harvey <[email protected]>:
Quoted 60 lines
When
CONFIG_IMX6_THERMALis defined print the CPU temperature grade info along with the current temperature.Before:
CPU: Temperature 42 CAfter:
CPU: Automotive temperature grade (-40C to 125C) at 42C CPU: Industiral temperature grade (-40C to 105C) at 42C CPU: Extended Commercial temperature grade (-20C to 105C) at 42CSigned-off-by Tim Harvey <[email protected]>---
v2:
- moved display of CPU temperature grade to own patch and combined with the current temperature from the thermal sensor driver
- add example output to descriptionSigned-off-by Tim Harvey <[email protected]>--- arch/arm/imx-common/cpu.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)arch/arm/imx-common/cpu.c +14
-1@@ -16,6 +16,7 @@#include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> +#include <imx_thermal.h> #include <ipu_pixfmt.h> #include <thermal.h> #include <sata.h> @@ -146,7 +147,7 @@ int print_cpuinfo(void)#if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL )struct udevice *thermal_dev; -int cpu_tmp, ret; +int cpu_tmp, minc, maxc, ret;#endif cpurev =get_cpu_rev ();@@ -172,16 +173,34 @@ int print_cpuinfo(void)#endif #if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL ) +puts ("CPU: " ); +if (!is_cpu_type (MXC_CPU_MX6SX )) { +switch (get_cpu_temp_grade (&minc, &maxc)) { +case TEMP_AUTOMOTIVE : +puts ("Automotive temperature grade " ); +break ; +case TEMP_INDUSTRIAL : +puts ("Industrial temperature grade " ); +break ; +case TEMP_EXTCOMMERCIAL : +puts ("Extended Commercial temperature grade " ); +break ;Quoted 8 lines
arch/arm/imx-common/cpu.c int print_cpuinfo(void) · line 193
Quoted 6 lines
arch/arm/imx-common/cpu.c +6
-0+default : +puts ("Commercial temperature grade " ); +break ; + } +printf ("(%dC to %dC)" , minc, maxc); + }For the additions above we do not need
CONFIG_IMX6_THERMAL.
Quoted 8 lines
Hi Christian,
Thanks for the review.
Its true that
CONFIG_IMX6_THERMALis not needed for cpu temperature grade but I felt that there would be resistance in general to adding additional lines inprint_cpuinfowithout allowing them to be easily disabled.
Agree on this point.
Quoted 9 lines
I felt that temperature grade and current temperature made sense to go together in this fasion.
Looking over this though did remind me that now that Freescale has told me that the IMX6SX has the same OTP registers/definitions for temperature grade programmed I can remove the skip for MX6SX. I would however sure like to have someone with an actual MX6SX enable that code and give us some testing feedback.
Right. My proposal is to merge the currrent patchset, enabling for IMX6SX again when someone will test it.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
Quoted 96 lines · Stefano Babic
Hi Tim,
Quoted 72 lines · Tim Harvey
Quoted 61 lines · Christian Gmeiner
2015-05-14 7:11 GMT+02:00 Tim Harvey <[email protected]>:
Quoted 60 lines
When
CONFIG_IMX6_THERMALis defined print the CPU temperature grade info along with the current temperature.Before:
CPU: Temperature 42 CAfter:
CPU: Automotive temperature grade (-40C to 125C) at 42C CPU: Industiral temperature grade (-40C to 105C) at 42C CPU: Extended Commercial temperature grade (-20C to 105C) at 42CSigned-off-by Tim Harvey <[email protected]>---
v2:
- moved display of CPU temperature grade to own patch and combined with the current temperature from the thermal sensor driver
- add example output to descriptionSigned-off-by Tim Harvey <[email protected]>--- arch/arm/imx-common/cpu.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)arch/arm/imx-common/cpu.c +14
-1@@ -16,6 +16,7 @@#include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> +#include <imx_thermal.h> #include <ipu_pixfmt.h> #include <thermal.h> #include <sata.h> @@ -146,7 +147,7 @@ int print_cpuinfo(void)#if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL )struct udevice *thermal_dev; -int cpu_tmp, ret; +int cpu_tmp, minc, maxc, ret;#endif cpurev =get_cpu_rev ();@@ -172,16 +173,34 @@ int print_cpuinfo(void)#endif #if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL ) +puts ("CPU: " ); +if (!is_cpu_type (MXC_CPU_MX6SX )) { +switch (get_cpu_temp_grade (&minc, &maxc)) { +case TEMP_AUTOMOTIVE : +puts ("Automotive temperature grade " ); +break ; +case TEMP_INDUSTRIAL : +puts ("Industrial temperature grade " ); +break ; +case TEMP_EXTCOMMERCIAL : +puts ("Extended Commercial temperature grade " ); +break ;Quoted 8 lines
arch/arm/imx-common/cpu.c int print_cpuinfo(void) · line 193
Quoted 6 lines
arch/arm/imx-common/cpu.c +6
-0+default : +puts ("Commercial temperature grade " ); +break ; + } +printf ("(%dC to %dC)" , minc, maxc); + }For the additions above we do not need
CONFIG_IMX6_THERMAL.Quoted 8 lines
Hi Christian,
Thanks for the review.
Its true that
CONFIG_IMX6_THERMALis not needed for cpu temperature grade but I felt that there would be resistance in general to adding additional lines inprint_cpuinfowithout allowing them to be easily disabled.Agree on this point.
Quoted 9 lines
I felt that temperature grade and current temperature made sense to go together in this fasion.
Looking over this though did remind me that now that Freescale has told me that the IMX6SX has the same OTP registers/definitions for temperature grade programmed I can remove the skip for MX6SX. I would however sure like to have someone with an actual MX6SX enable that code and give us some testing feedback.
Quoted 6 lines
Right. My proposal is to merge the currrent patchset, enabling for IMX6SX again when someone will test it.
Best regards,
Stefano Babic
Stefano,
Yes, that sounds like the best approach. What were your thoughts on enabling the second CPU: line just to display the temperature grade if CONFIG_IMX6_THERMAL was not enabled?
I'm surprised someone on this list hasn't already tested this on IMX6SX.
Fabio - certainly you must have a reference board with an IMX6SX and could enable/test that the CPU markings agree with what is detected/displayed via OTP?
Tim
Fabio Estevam
reviewerPATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
Hi Tim,
Quoted 9 lines · Tim Harvey
Yes, that sounds like the best approach. What were your thoughts on enabling the second CPU: line just to display the temperature grade if
CONFIG_IMX6_THERMALwas not enabled?I'm surprised someone on this list hasn't already tested this on IMX6SX.
Fabio - certainly you must have a reference board with an IMX6SX and could enable/test that the CPU markings agree with what is detected/displayed via OTP?
Yes, I do have a mx6sx sdb board, but the one I have is from the old silicon and I had issues event with the temperature reading, so I prefer not to rely on my testing.
Ye Li / Peng / Nitin,
Could some of you please test Tim's series on a mx6sx sdb and let us know what it displays on the CPU lines?
Thanks,
Fabio Estevam
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
Hi Fabio,
Quoted 14 lines · Fabio Estevam
Hi Tim,
Quoted 9 lines · Tim Harvey
Yes, that sounds like the best approach. What were your thoughts on enabling the second CPU: line just to display the temperature grade if
CONFIG_IMX6_THERMALwas not enabled?I'm surprised someone on this list hasn't already tested this on IMX6SX.
Fabio - certainly you must have a reference board with an IMX6SX and could enable/test that the CPU markings agree with what is detected/displayed via OTP?
Quoted 9 lines
Yes, I do have a mx6sx sdb board, but the one I have is from the old silicon and I had issues event with the temperature reading, so I prefer not to rely on my testing.
Ye Li / Peng / Nitin,
Could some of you please test Tim's series on a mx6sx sdb and let us know what it displays on the CPU lines?
Tested on mx6sx sdb Revb board. I applied the following patches for this test:
mx6: add OTP bank1 registers
thermal: imx_thermal: use CPU temperature grade for trip points
imx: mx6: add display of CPU temperature grade in print_cpuinfo()
imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP
mx: mx6: display max cpu frequency in print_cpuinfo()
imx: mx6: add get_cpu_speed_grade_hz func to return MHz speed grade from OTP
The log info: "
U-Boot 2015.07-rc1-00256-gec154cc (May 18 2015 - 09:00:57)
CPU: Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz) CPU: at 39C Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB PMIC: PFUZE100 ID=0x11 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 In: serial Out: serial Err: serial Net: FEC [PRIME] Hit any key to stop autoboot: 0
"
Quoted 3 lines
Thanks,
Fabio Estevam
Regards,
Peng.
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
Quoted 52 lines · Peng Fan
Hi Fabio,
Quoted 14 lines · Fabio Estevam
Hi Tim,
Quoted 9 lines · Tim Harvey
Yes, that sounds like the best approach. What were your thoughts on enabling the second CPU: line just to display the temperature grade if
CONFIG_IMX6_THERMALwas not enabled?I'm surprised someone on this list hasn't already tested this on IMX6SX.
Fabio - certainly you must have a reference board with an IMX6SX and could enable/test that the CPU markings agree with what is detected/displayed via OTP?
Quoted 9 lines
Yes, I do have a mx6sx sdb board, but the one I have is from the old silicon and I had issues event with the temperature reading, so I prefer not to rely on my testing.
Ye Li / Peng / Nitin,
Could some of you please test Tim's series on a mx6sx sdb and let us know what it displays on the CPU lines?
Tested on mx6sx sdb Revb board. I applied the following patches for this test:
mx6: add OTP bank1 registers
thermal:imx_thermal: use CPU temperature grade for trip points
imx: mx6: add display of CPU temperature grade inprint_cpuinfo()
imx: mx6: addget_cpu_temp_gradeto obtain cpu temperature grade from OTP
mx: mx6: display max cpu frequency inprint_cpuinfo()
imx: mx6: addget_cpu_speed_grade_hzfunc to return MHz speed grade from OTPThe log info: "
U-Boot 2015.07-rc1-00256-gec154cc (May 18 2015 - 09:00:57)CPU: Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz) CPU: at 39C Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB PMIC: PFUZE100 ID=0x11 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 In: serial Out: serial Err: serial Net: FEC [PRIME] Hit any key to stop autoboot: 0"
Quoted 8 lines
Quoted 3 lines
Thanks,
Fabio Estevam
Regards,
Peng.--
Peng,
I'll send a v3 of the patch that removes disabling of showing the temperature grade info for imx6sx and please test again with this version as well as let us know the part markings for your chip so I can verify the fuses are set properly.
Thanks!
Tim
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
In reply to Tim HarveyHi Tim,
Quoted 7 lines · Tim Harvey
Quoted 6 lines
Right. My proposal is to merge the currrent patchset, enabling for IMX6SX again when someone will test it.
Best regards,
Stefano Babic
Quoted 5 lines
Stefano,
Yes, that sounds like the best approach. What were your thoughts on enabling the second CPU: line just to display the temperature grade if
CONFIG_IMX6_THERMALwas not enabled?
As you said, printing a lot can be disturbing for someone, and letting the possibility to turn out prints is not bad. I will let the board maintainer to decide it.
Quoted 3 lines
I'm surprised someone on this list hasn't already tested this on IMX6SX.
I am quite convinced that patches are tested by a few until they are merged. If there is a ready-to-use tree, people are more motivated to test it.
Quoted 4 lines
Fabio - certainly you must have a reference board with an IMX6SX and could enable/test that the CPU markings agree with what is detected/displayed via OTP?
Of course, I could delay for applying this patchset if Fabio / someone has the possibility to test it with 6X. Anyway, running on 6X is protected by the check on the cpu, and I do not see problems to merge it.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 3/4 imx: mx6: add display of CPU temperature grade in print_cpuinfo()
In reply to Tim HarveyQuoted 73 lines · Tim Harvey
When
CONFIG_IMX6_THERMALis defined print the CPU temperature grade info along with the current temperature.Before:
CPU: Temperature 42 CAfter:
CPU: Automotive temperature grade (-40C to 125C) at 42C CPU: Industiral temperature grade (-40C to 105C) at 42C CPU: Extended Commercial temperature grade (-20C to 105C) at 42CSigned-off-by Tim Harvey <[email protected]>---
v2:
- moved display of CPU temperature grade to own patch and combined with the current temperature from the thermal sensor driver
- add example output to descriptionSigned-off-by Tim Harvey <[email protected]>--- arch/arm/imx-common/cpu.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)arch/arm/imx-common/cpu.c +20
-2@@ -16,6 +16,7 @@#include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> +#include <imx_thermal.h> #include <ipu_pixfmt.h> #include <thermal.h> #include <sata.h> @@ -146,7 +147,7 @@ int print_cpuinfo(void)#if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL )struct udevice *thermal_dev; -int cpu_tmp, ret; +int cpu_tmp, minc, maxc, ret;#endif cpurev =get_cpu_rev ();@@ -172,16 +173,34 @@ int print_cpuinfo(void)#endif #if defined(CONFIG_MX6 ) && defined(CONFIG_IMX6_THERMAL ) +puts ("CPU: " ); +if (!is_cpu_type (MXC_CPU_MX6SX )) { +switch (get_cpu_temp_grade (&minc, &maxc)) { +case TEMP_AUTOMOTIVE : +puts ("Automotive temperature grade " ); +break ; +case TEMP_INDUSTRIAL : +puts ("Industrial temperature grade " ); +break ; +case TEMP_EXTCOMMERCIAL : +puts ("Extended Commercial temperature grade " ); +break ; +default : +puts ("Commercial temperature grade " ); +break ; + } +printf ("(%dC to %dC)" , minc, maxc); + } ret =uclass_get_device (UCLASS_THERMAL ,0 , &thermal_dev);if (!ret) { ret =thermal_get_temp (thermal_dev, &cpu_tmp);if (!ret) -printf ("CPU: Temperature %d C\n" , cpu_tmp);
arch/arm/imx-common/cpu.c int print_cpuinfo(void) · line 206
Quoted 10 lines
arch/arm/imx-common/cpu.c +3
-2+printf (" at %dC\n" , cpu_tmp); else - printf("CPU: Temperature: invalid sensor data\n"); + puts(" - invalid sensor data\n"); }else { -printf ("CPU: Temperature: Can't find sensor device\n" ); +puts (" - invalid sensor device\n" ); }#endif
Regards,
Nikolay
PATCH v2 4/4 thermal: imx_thermal: use CPU temperature grade for trip points
In reply to Tim HarveyReplace the hard-coded values for min/max/passive with values derived from the CPU temperature grade.
--- drivers/thermal/imx_thermal.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/thermal/imx_thermal.c +19 -10
@@ -12,15 +12,13 @@#include <fuse.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/sys_proto.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <thermal.h> #include <imx_thermal.h> -#define TEMPERATURE_MIN -40 -#define TEMPERATURE_HOT 80 -#define TEMPERATURE_MAX 125#define FACTOR0 10000000#define FACTOR1 15976#define FACTOR2 4297157
@@ -34,14 +32,21 @@#define MISC0_REFTOP_SELBIASOFF (1 << 3)#define TEMPSENSE1_MEASURE_FREQ 0xffff +struct thermal_data { +unsigned int fuse; +int passive; +int minc; +int maxc; +}; +static int read_cpu_temperature (struct udevice *dev) {int temperature;unsigned int reg, n_meas;const struct imx_thermal_plat *pdata =dev_get_platdata (dev);struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; -unsigned int *priv =dev_get_priv (dev); -u32 fuse = *priv; +struct thermal_data *priv =dev_get_priv (dev); +u32 fuse = priv->fuse;int t1, n1;u32 c1, c2;u64 temp64;
@@ -119,11 +124,12 @@ static int read_cpu_temperature(struct udevice *dev)int imx_thermal_get_temp (struct udevice *dev,int *temp) { +struct thermal_data *priv =dev_get_priv (dev);int cpu_tmp =0 ; cpu_tmp =read_cpu_temperature (dev); -while (cpu_tmp >TEMPERATURE_MIN && cpu_tmp <TEMPERATURE_MAX ) { -if (cpu_tmp >=TEMPERATURE_HOT ) { +while (cpu_tmp > priv->minc && cpu_tmp < priv->maxc) { +if (cpu_tmp >= priv->passive) {printf ("CPU Temperature is %d C, too hot to boot, waiting...\n" , cpu_tmp);udelay (5000000 );
@@ -147,7 +153,7 @@ static int imx_thermal_probe(struct udevice *dev)unsigned int fuse = ~0 ;const struct imx_thermal_plat *pdata =dev_get_platdata (dev); -unsigned int *priv =dev_get_priv (dev); +struct thermal_data *priv =dev_get_priv (dev);/* Read Temperature calibration data fuse */ fuse_read (pdata->fuse_bank, pdata->fuse_word, &fuse);
@@ -158,7 +164,10 @@ static int imx_thermal_probe(struct udevice *dev)return -EPERM ; } - *priv = fuse; +/* set passive cooling temp to max - 20C */ +get_cpu_temp_grade (&priv->minc, &priv->maxc); + priv->passive = priv->maxc -20 ; + priv->fuse = fuse;enable_thermal_clk ();
@@ -170,6 +179,6 @@ U_BOOT_DRIVER(imx_thermal) = { .id = UCLASS_THERMAL, .ops = &imx_thermal_ops, .probe = imx_thermal_probe, - .priv_auto_alloc_size = sizeof(unsigned int), + .priv_auto_alloc_size = sizeof(struct thermal_data), .flags = DM_FLAG_PRE_RELOC, };
Signature · 1 line
1.9.1
PATCH v2 4/4 thermal: imx_thermal: use CPU temperature grade for trip points
Quoted 91 lines · Tim Harvey
Replace the hard-coded values for min/max/passive with values derived from the CPU temperature grade.
Signed-off-by Tim Harvey <[email protected]>--- drivers/thermal/imx_thermal.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)drivers/thermal/imx_thermal.c +18
-9@@ -12,15 +12,13 @@#include <fuse.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/sys_proto.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <thermal.h> #include <imx_thermal.h> -#define TEMPERATURE_MIN -40 -#define TEMPERATURE_HOT 80 -#define TEMPERATURE_MAX 125#define FACTOR0 10000000#define FACTOR1 15976#define FACTOR2 4297157@@ -34,14 +32,21 @@#define MISC0_REFTOP_SELBIASOFF (1 << 3)#define TEMPSENSE1_MEASURE_FREQ 0xffff +struct thermal_data { +unsigned int fuse; +int passive; +int minc; +int maxc; +}; +static int read_cpu_temperature (struct udevice *dev) {int temperature;unsigned int reg, n_meas;const struct imx_thermal_plat *pdata =dev_get_platdata (dev);struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; -unsigned int *priv =dev_get_priv (dev); -u32 fuse = *priv; +struct thermal_data *priv =dev_get_priv (dev); +u32 fuse = priv->fuse;int t1, n1;u32 c1, c2;u64 temp64;@@ -119,11 +124,12 @@ static int read_cpu_temperature(struct udevice *dev)int imx_thermal_get_temp (struct udevice *dev,int *temp) { +struct thermal_data *priv =dev_get_priv (dev);int cpu_tmp =0 ; cpu_tmp =read_cpu_temperature (dev); -while (cpu_tmp >TEMPERATURE_MIN && cpu_tmp <TEMPERATURE_MAX ) { -if (cpu_tmp >=TEMPERATURE_HOT ) { +while (cpu_tmp > priv->minc && cpu_tmp < priv->maxc) { +if (cpu_tmp >= priv->passive) {printf ("CPU Temperature is %d C, too hot to boot, waiting...\n" , cpu_tmp);udelay (5000000 );@@ -147,7 +153,7 @@ static int imx_thermal_probe(struct udevice *dev)unsigned int fuse = ~0 ;const struct imx_thermal_plat *pdata =dev_get_platdata (dev); -unsigned int *priv =dev_get_priv (dev); +struct thermal_data *priv =dev_get_priv (dev);/* Read Temperature calibration data fuse */ fuse_read (pdata->fuse_bank, pdata->fuse_word, &fuse);@@ -158,7 +164,10 @@ static int imx_thermal_probe(struct udevice *dev)return -EPERM ; } - *priv = fuse; +/* set passive cooling temp to max - 20C */ +get_cpu_temp_grade (&priv->minc, &priv->maxc); + priv->passive = priv->maxc -20 ; + priv->fuse = fuse;enable_thermal_clk ();
drivers/thermal/imx_thermal.c U_BOOT_DRIVER(imx_thermal) = { · line 184
Quoted 7 lines
drivers/thermal/imx_thermal.c +1
-1@@ -170,6 +179,6 @@ U_BOOT_DRIVER(imx_thermal) = { .id = UCLASS_THERMAL, .ops = &imx_thermal_ops, .probe = imx_thermal_probe, - .priv_auto_alloc_size = sizeof(unsigned int), + .priv_auto_alloc_size = sizeof(struct thermal_data), .flags = DM_FLAG_PRE_RELOC, };
Regards,
Nikolay