[U-Boot] [PATCH 2/2] mx6sxsabresd: Add thermal support

Add thermal support so that the temperature of the chip can be displayed on boot:
U-Boot 2015.01-rc1-18268-g1366c05-dirty (Nov 25 2014 - 13:02:42)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz CPU: Temperature 50 C
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com --- include/configs/mx6sxsabresd.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/include/configs/mx6sxsabresd.h b/include/configs/mx6sxsabresd.h index d8ab291..5e0edab 100644 --- a/include/configs/mx6sxsabresd.h +++ b/include/configs/mx6sxsabresd.h @@ -208,6 +208,16 @@ #define CONFIG_PCIE_IMX_POWER_GPIO IMX_GPIO_NR(2, 1) #endif
+#define CONFIG_DM +#define CONFIG_DM_THERMAL +#define CONFIG_SYS_MALLOC_F_LEN (1 << 10) +#define CONFIG_IMX6_THERMAL + +#define CONFIG_CMD_FUSE +#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL) +#define CONFIG_MXC_OCOTP +#endif + /* FLASH and environment organization */ #define CONFIG_SYS_NO_FLASH

Leave the OCOTP turned on, so that we subsequent access do not fail.
After enabling the thermal driver on a mx6sxsabresd board:
U-Boot 2015.01-rc1-18267-g99d4189-dirty (Nov 24 2014 - 12:59:01)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz CPU: Temperature 48 C Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB PMIC: PFUZE100 ID=0x10 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 00:01.0 - 16c3:abcd - Bridge device 01:00.0 - 8086:08b1 - Network controller In: serial Out: serial Err: serial Net: (hang)
As the thermal driver accesses the ocotp registers, its clock will be disabled afterwards.
Then when the MAC address is read (also from ocotp registers) it will cause a hang.
Do not disable the ocotp clock to prevent this problem.
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com --- drivers/misc/mxc_ocotp.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c index 3de1245..67f9429 100644 --- a/drivers/misc/mxc_ocotp.c +++ b/drivers/misc/mxc_ocotp.c @@ -81,8 +81,6 @@ static int finish_access(struct ocotp_regs *regs, const char *caller) err = !!(readl(®s->ctrl) & BM_CTRL_ERROR); clear_error(regs);
- enable_ocotp_clk(0); - if (err) { printf("mxc_ocotp %s(): Access protect error\n", caller); return -EIO;

Hi Fabio,
On Tue, Nov 25, 2014 at 4:11 PM, Fabio Estevam fabio.estevam@freescale.com wrote:
Leave the OCOTP turned on, so that we subsequent access do not fail.
After enabling the thermal driver on a mx6sxsabresd board:
U-Boot 2015.01-rc1-18267-g99d4189-dirty (Nov 24 2014 - 12:59:01)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz CPU: Temperature 48 C Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB PMIC: PFUZE100 ID=0x10 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 00:01.0 - 16c3:abcd - Bridge device 01:00.0 - 8086:08b1 - Network controller In: serial Out: serial Err: serial Net: (hang)
As the thermal driver accesses the ocotp registers, its clock will be disabled afterwards.
Then when the MAC address is read (also from ocotp registers) it will cause a hang.
Do not disable the ocotp clock to prevent this problem.
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
drivers/misc/mxc_ocotp.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c index 3de1245..67f9429 100644 --- a/drivers/misc/mxc_ocotp.c +++ b/drivers/misc/mxc_ocotp.c @@ -81,8 +81,6 @@ static int finish_access(struct ocotp_regs *regs, const char *caller) err = !!(readl(®s->ctrl) & BM_CTRL_ERROR); clear_error(regs);
enable_ocotp_clk(0);
if (err) { printf("mxc_ocotp %s(): Access protect error\n", caller); return -EIO;
That, or: - Make imx_get_mac_from_fuse() call enable_ocotp_clk(1) before reading the fuses, then call enable_ocotp_clk(0). - Make enable_ocotp_clk() return the clock initial state and store it in prepare_access(), then restore it in finish_access(). Same in imx_get_mac_from_fuse().
Which of these 3 choices do you think would be the best?
Regards, Benoît

Hi Benoît,
On Tue, Nov 25, 2014 at 5:48 PM, Benoît Thébaudeau benoit.thebaudeau.dev@gmail.com wrote:
That, or:
- Make imx_get_mac_from_fuse() call enable_ocotp_clk(1) before
reading the fuses, then call enable_ocotp_clk(0).
Yes, I started with this exact same approach as well. It works, but Nitin told me he also had similiar issues with hab.
Other issue I see with such approach is that if people would try to read the ocotp registers manually in the U-boot prompt (via md.l command), then they will also get a hang.
- Make enable_ocotp_clk() return the clock initial state and store it
in prepare_access(), then restore it in finish_access(). Same in imx_get_mac_from_fuse().
This would work as well, but with some more complexity. Still would cause the hang via manual readings.
Which of these 3 choices do you think would be the best?
I think the simplest one and the one that would be more general would be the one proposed by this patch.
Regards,
Fabio Estevam

Hi Fabio,
On Tue, Nov 25, 2014 at 8:56 PM, Fabio Estevam festevam@gmail.com wrote:
On Tue, Nov 25, 2014 at 5:48 PM, Benoît Thébaudeau benoit.thebaudeau.dev@gmail.com wrote:
That, or:
- Make imx_get_mac_from_fuse() call enable_ocotp_clk(1) before
reading the fuses, then call enable_ocotp_clk(0).
Yes, I started with this exact same approach as well. It works, but Nitin told me he also had similiar issues with hab.
Other issue I see with such approach is that if people would try to read the ocotp registers manually in the U-boot prompt (via md.l command), then they will also get a hang.
If users access the OCOTP registers manually, they can also enable the OCOTP clock in the corresponding register beforehand, even if this complicates things.
- Make enable_ocotp_clk() return the clock initial state and store it
in prepare_access(), then restore it in finish_access(). Same in imx_get_mac_from_fuse().
This would work as well, but with some more complexity. Still would cause the hang via manual readings.
Which of these 3 choices do you think would be the best?
I think the simplest one and the one that would be more general would be the one proposed by this patch.
The only possible issue that I see with leaving the OCOTP clock enabled is the risk of inadvertently writing the fuses, either in U-Boot or in the booted OS. That being said, Freescale advise against leaving the fuses powered for production boards, in which cases there is no such risk.
Reviewed-by: Benoît Thébaudeau benoit.thebaudeau.dev@gmail.com
Regards, Benoît

On 25/11/2014 16:11, Fabio Estevam wrote:
Leave the OCOTP turned on, so that we subsequent access do not fail.
After enabling the thermal driver on a mx6sxsabresd board:
U-Boot 2015.01-rc1-18267-g99d4189-dirty (Nov 24 2014 - 12:59:01)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz CPU: Temperature 48 C Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB PMIC: PFUZE100 ID=0x10 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 00:01.0 - 16c3:abcd - Bridge device 01:00.0 - 8086:08b1 - Network controller In: serial Out: serial Err: serial Net: (hang)
As the thermal driver accesses the ocotp registers, its clock will be disabled afterwards.
Then when the MAC address is read (also from ocotp registers) it will cause a hang.
Do not disable the ocotp clock to prevent this problem.
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
drivers/misc/mxc_ocotp.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c index 3de1245..67f9429 100644 --- a/drivers/misc/mxc_ocotp.c +++ b/drivers/misc/mxc_ocotp.c @@ -81,8 +81,6 @@ static int finish_access(struct ocotp_regs *regs, const char *caller) err = !!(readl(®s->ctrl) & BM_CTRL_ERROR); clear_error(regs);
- enable_ocotp_clk(0);
- if (err) { printf("mxc_ocotp %s(): Access protect error\n", caller); return -EIO;
Applied to u-boot-imx, thanks !
Best regards, Stefano Babic

On 25/11/2014 16:11, Fabio Estevam wrote:
Add thermal support so that the temperature of the chip can be displayed on boot:
U-Boot 2015.01-rc1-18268-g1366c05-dirty (Nov 25 2014 - 13:02:42)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz CPU: Temperature 50 C
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
include/configs/mx6sxsabresd.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/include/configs/mx6sxsabresd.h b/include/configs/mx6sxsabresd.h index d8ab291..5e0edab 100644 --- a/include/configs/mx6sxsabresd.h +++ b/include/configs/mx6sxsabresd.h @@ -208,6 +208,16 @@ #define CONFIG_PCIE_IMX_POWER_GPIO IMX_GPIO_NR(2, 1) #endif
+#define CONFIG_DM +#define CONFIG_DM_THERMAL +#define CONFIG_SYS_MALLOC_F_LEN (1 << 10) +#define CONFIG_IMX6_THERMAL
+#define CONFIG_CMD_FUSE +#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL) +#define CONFIG_MXC_OCOTP +#endif
/* FLASH and environment organization */ #define CONFIG_SYS_NO_FLASH
Applied to u-boot-imx, thanks !
Best regards, Stefano Babic
participants (4)
-
Benoît Thébaudeau
-
Fabio Estevam
-
Fabio Estevam
-
Stefano Babic