Add TMU support for Exynos5250 based SMDK5250
Subsystems (3)
v11 cover Add TMU support for Exynos5250 based SMDK5250
This patch series adds support for TMU driver using device tree for Exynos5250 based SMDK5250 board.
Changes since v10:
- Patch-1: Renamed asm/arch/exynos-tmu.h to asm/arch/tmu.h.
- Patch-2: None.
- Patch-3: None.
- Patch-4: None.
- Patch-5: None.
- Patch-6: None.
- Patch-7: None.
- Patch-8: None.
Akshay Saraswat (8):
Exynos5: TMU: Add driver for Thermal Management Unit
Exynos5: FDT: Add TMU device node values
Exynos5: TMU: Add TMU init and status check
Exynos5: Config: Enable support for Exynos TMU driver
TMU: Add TMU support in dtt command
Exynos5: Config: Enable dtt command for TMU
Exynos5: TMU: Add hardware tripping
Exynos5: FDT: Add a H/W-trip member to TMU node
arch/arm/cpu/armv7/exynos/power.c | 12 ++ arch/arm/dts/exynos5250.dtsi | 5 + arch/arm/include/asm/arch-exynos/power.h | 4 + arch/arm/include/asm/arch-exynos/tmu.h | 58 ++++++ board/samsung/dts/exynos5250-smdk5250.dts | 13 ++ board/samsung/smdk5250/smdk5250.c | 39 ++++ common/cmd_dtt.c | 32 ++- doc/device-tree-bindings/exynos/tmu.txt | 44 +++++ drivers/power/Makefile | 1 + drivers/power/exynos-tmu.c | 319 ++++++++++++++++++++++++++++++ include/configs/exynos5250-dt.h | 5 + include/fdtdec.h | 1 + include/tmu.h | 46 +++++ lib/fdtdec.c | 1 + 14 files changed, 579 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/arch-exynos/tmu.h create mode 100644 doc/device-tree-bindings/exynos/tmu.txt create mode 100644 drivers/power/exynos-tmu.c create mode 100644 include/tmu.h
Signature · 1 line
1.8.0
PATCH v11 1/8 Exynos5: TMU: Add driver for Thermal Management Unit
Adding Exynos Thermal Management Unit driver to monitor SOC temperature and take actions corresponding to states of TMU.
---
Changes since v10:
- Renamed as/asch/exynos-tmu.h to asm/arch/tmu.h.
arch/arm/include/asm/arch-exynos/tmu.h | 58 +++++++ drivers/power/Makefile | 1 + drivers/power/exynos-tmu.c | 304 +++++++++++++++++++++++++++++++++ include/tmu.h | 46 +++++ 4 files changed, 409 insertions(+) create mode 100644 arch/arm/include/asm/arch-exynos/tmu.h create mode 100644 drivers/power/exynos-tmu.c create mode 100644 include/tmu.h
arch/arm/include/asm/arch-exynos/tmu.h new file +58 -0
@@ -0,0 +1,58 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd. +* http://www.samsung.com +* Akshay Saraswat <[email protected]> +* +* EXYNOS - Thermal Management Unit +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#ifndef __ASM_ARCH_TMU_H +#define __ASM_ARCH_TMU_H + +struct exynos5_tmu_reg { +unsigned triminfo; +unsigned rsvd1; +unsigned rsvd2; +unsigned rsvd3; +unsigned rsvd4; +unsigned triminfo_control; +unsigned rsvd5; +unsigned rsvd6; +unsigned tmu_control; +unsigned rsvd7; +unsigned tmu_status; +unsigned sampling_internal; +unsigned counter_value0; +unsigned counter_value1; +unsigned rsvd8; +unsigned rsvd9; +unsigned current_temp; +unsigned rsvd10; +unsigned rsvd11; +unsigned rsvd12; +unsigned threshold_temp_rise; +unsigned threshold_temp_fall; +unsigned rsvd13; +unsigned rsvd14; +unsigned past_temp3_0; +unsigned past_temp7_4; +unsigned past_temp11_8; +unsigned past_temp15_12; +unsigned inten; +unsigned intstat; +unsigned intclear; +unsigned rsvd15; +unsigned emul_con; +}; +#endif /* __ASM_ARCH_TMU_H */
drivers/power/Makefile +1 -0
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libpower.o +COBJS-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o COBJS-$(CONFIG_FTPMU010_POWER) += ftpmu010.o COBJS-$(CONFIG_TPS6586X_POWER) += tps6586x.o COBJS-$(CONFIG_TWL4030_POWER) += twl4030.o
drivers/power/exynos-tmu.c new file +304 -0
304 lines not on this page · raw message
include/tmu.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.8.0
PATCH v11 2/8 Exynos5: FDT: Add TMU device node values
In reply to Akshay SaraswatFdt entry for Exynos TMU driver specific pre-defined values used for calibration of current temperature and defining threshold values.
---
Changes since v10:
- None.
arch/arm/dts/exynos5250.dtsi | 5 ++++ board/samsung/dts/exynos5250-smdk5250.dts | 12 +++++++++ doc/device-tree-bindings/exynos/tmu.txt | 41 +++++++++++++++++++++++++++++++ include/fdtdec.h | 1 + lib/fdtdec.c | 1 + 5 files changed, 60 insertions(+) create mode 100644 doc/device-tree-bindings/exynos/tmu.txt
arch/arm/dts/exynos5250.dtsi +5 -0
@@ -151,4 +151,9 @@ }; }; + tmu at 10060000 { + compatible = "samsung,exynos-tmu"; + reg = <0x10060000 0x10000>; + }; + };
board/samsung/dts/exynos5250-smdk5250.dts +12 -0
@@ -66,4 +66,16 @@ compatible = "maxim,max77686_pmic"; }; }; + + tmu at 10060000 { + samsung,min-temp = <25>; + samsung,max-temp = <125>; + samsung,start-warning = <95>; + samsung,start-tripping = <105>; + samsung,efuse-min-value = <40>; + samsung,efuse-value = <55>; + samsung,efuse-max-value = <100>; + samsung,slope = <274761730>; + samsung,dc-value = <25>; + }; };
doc/device-tree-bindings/exynos/tmu.txt new file +41 -0
41 lines not on this page · raw message
include/fdtdec.h +1 -0
@@ -81,6 +81,7 @@ enum fdt_compat_id {COMPAT_SAMSUNG_EXYNOS_EHCI ,/* Exynos EHCI controller */ COMPAT_SAMSUNG_EXYNOS_USB_PHY ,/* Exynos phy controller for usb2.0 */ COMPAT_MAXIM_MAX77686_PMIC ,/* MAX77686 PMIC */ +COMPAT_SAMSUNG_EXYNOS_TMU ,/* Exynos TMU */ COMPAT_COUNT, };
lib/fdtdec.c +1 -0
@@ -56,6 +56,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (SAMSUNG_EXYNOS_EHCI ,"samsung,exynos-ehci" ),COMPAT (SAMSUNG_EXYNOS_USB_PHY ,"samsung,exynos-usb-phy" ),COMPAT (MAXIM_MAX77686_PMIC ,"maxim,max77686_pmic" ), + COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"), };const char *fdtdec_get_compatible (enum fdt_compat_id id)
Signature · 1 line
1.8.0
PATCH v11 3/8 Exynos5: TMU: Add TMU init and status check
In reply to Akshay SaraswatThis adds call to tmu_init() and TMU boot time analysis for the SoC temperature threshold breach.
---
Changes since v10:
- None.
board/samsung/smdk5250/smdk5250.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
board/samsung/smdk5250/smdk5250.c +39 -0
@@ -37,9 +37,39 @@#include <asm/arch/dp_info.h> #include <power/pmic.h> #include <power/max77686_pmic.h> +#include <tmu.h> DECLARE_GLOBAL_DATA_PTR ; +#if definedCONFIG_EXYNOS_TMU +/* +* Boot Time Thermal Analysis for SoC temperature threshold breach +*/ +static void boot_temp_check (void ) +{ +int temp; + +switch (tmu_monitor (&temp)) { +/* Status TRIPPED ans WARNING means corresponding threshold breach */ +case TMU_STATUS_TRIPPED : +puts ("EXYNOS_TMU: TRIPPING! Device power going down ...\n" ); +set_ps_hold_ctrl (); +hang (); +break ; +case TMU_STATUS_WARNING : +puts ("EXYNOS_TMU: WARNING! Temperature very high\n" ); +break ; +/* +* TMU_STATUS_INIT means something is wrong with temperature sensing +* and TMU status was changed back from NORMAL to INIT. +*/ +case TMU_STATUS_INIT : +default : +debug ("EXYNOS_TMU: Unknown TMU state\n" ); + } +} +#endif +#ifdef CONFIG_USB_EHCI_EXYNOS int board_usb_vbus_init (void ) {
@@ -59,6 +89,15 @@ int board_usb_vbus_init(void)int board_init (void ) { gd->bd->bi_boot_params = (PHYS_SDRAM_1 +0x100UL ); + +#if definedCONFIG_EXYNOS_TMU +if (tmu_init (gd->fdt_blob) !=TMU_STATUS_NORMAL ) { +debug ("%s: Failed to init TMU\n" , __func__); +return -1 ; + } +boot_temp_check (); +#endif +#ifdef CONFIG_EXYNOS_SPI spi_init ();#endif
Signature · 1 line
1.8.0
PATCH v11 4/8 Exynos5: Config: Enable support for Exynos TMU driver
In reply to Akshay SaraswatEnables TMU driver support for exynos5250
---
Changes since v10:
- None.
include/configs/exynos5250-dt.h | 3 +++ 1 file changed, 3 insertions(+)
include/configs/exynos5250-dt.h +3 -0
@@ -117,6 +117,9 @@#define CONFIG_BOOTDELAY 3#define CONFIG_ZERO_BOOTDELAY_CHECK +/* Thermal Management Unit */ +#define CONFIG_EXYNOS_TMU +/* USB */ #define CONFIG_CMD_USB #define CONFIG_USB_EHCI
Signature · 1 line
1.8.0
PATCH v11 5/8 TMU: Add TMU support in dtt command
In reply to Akshay SaraswatAdd generic TMU support alongwith i2c sensors in dtt command to enable temperature reading in cases where TMU is present along-with/instead-of i2c sensors.
---
Changes since v10:
- None.
common/cmd_dtt.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
common/cmd_dtt.c +31 -1
@@ -27,7 +27,9 @@#include <dtt.h> #include <i2c.h> +#include <tmu.h> +#if definedCONFIG_DTT_SENSORS static unsigned long sensor_initialized;static void _initialize_dtt (void )
@@ -59,9 +61,11 @@ void dtt_init(void)/* switch back to original I2C bus */ I2C_SET_BUS(old_bus); } +#endif -int do_dtt (cmd_tbl_t * cmdtp,int flag,int argc,char *const argv[]) +int dtt_i2c (void ) { +#if definedCONFIG_DTT_SENSORS int i;unsigned char sensors[] =CONFIG_DTT_SENSORS ;int old_bus;
@@ -83,8 +87,34 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])/* switch back to original I2C bus */ I2C_SET_BUS (old_bus); +#endif return 0 ; +} + +int dtt_tmu (void ) +{ +#if definedCONFIG_TMU_CMD_DTT +int cur_temp; + +/* Sense and return latest thermal info */ +if (tmu_monitor (&cur_temp) ==TMU_STATUS_INIT ) { +puts ("TMU is in unknown state, temperature is invalid\n" ); +return -1 ; + } +printf ("Current temperature: %u degrees Celsius\n" , cur_temp); +#endif +return 0 ; +} + +int do_dtt (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +int err =0 ; + + err |=dtt_i2c (); + err |=dtt_tmu (); + +return err; }/* do_dtt() */ /***************************************************/
Signature · 1 line
1.8.0
PATCH v11 6/8 Exynos5: Config: Enable dtt command for TMU
In reply to Akshay SaraswatThis enables the dtt command to read the current SOC temperature with the help of TMU
---
Changes since v10:
- None.
include/configs/exynos5250-dt.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/exynos5250-dt.h +2 -0
@@ -119,6 +119,8 @@/* Thermal Management Unit */ #define CONFIG_EXYNOS_TMU +#define CONFIG_CMD_DTT +#define CONFIG_TMU_CMD_DTT /* USB */ #define CONFIG_CMD_USB
Signature · 1 line
1.8.0
PATCH v11 7/8 Exynos5: TMU: Add hardware tripping
In reply to Akshay SaraswatThis adds hardware tripping at 110 degrees celsius which must enable forced system shutdown in case TMU fails to power off.
---
Changes since v10:
- None.
arch/arm/cpu/armv7/exynos/power.c | 12 ++++++++++++ arch/arm/include/asm/arch-exynos/power.h | 4 ++++ drivers/power/exynos-tmu.c | 25 ++++++++++++++++++++----- 3 files changed, 36 insertions(+), 5 deletions(-)
arch/arm/cpu/armv7/exynos/power.c +12 -0
@@ -111,3 +111,15 @@ void set_ps_hold_ctrl(void)if (cpu_is_exynos5 ())exynos5_set_ps_hold_ctrl (); } + +/* Enables hardware tripping to power off the system when TMU fails */ +void set_hw_thermal_trip (void ) +{ +if (cpu_is_exynos5 ()) { +struct exynos5_power *power = + (struct exynos5_power *)samsung_get_base_power (); + +/* PS_HOLD_CONTROL register ENABLE_HW_TRIP bit*/ +setbits_le32 (&power->ps_hold_control,POWER_ENABLE_HW_TRIP ); + } +}
arch/arm/include/asm/arch-exynos/power.h +4 -0
@@ -857,6 +857,9 @@ void set_mipi_phy_ctrl(unsigned int dev_index, unsigned int enable);void set_usbhost_phy_ctrl (unsigned int enable); +/* Enables hardware tripping to power off the system when TMU fails */ +void set_hw_thermal_trip (void ); +#define POWER_USB_HOST_PHY_CTRL_EN (1 << 0)#define POWER_USB_HOST_PHY_CTRL_DISABLE (0 << 0)
@@ -865,6 +868,7 @@ void set_dp_phy_ctrl(unsigned int enable);#define EXYNOS_DP_PHY_ENABLE (1 << 0)#define EXYNOS_PS_HOLD_CONTROL_DATA_HIGH (1 << 8) +#define POWER_ENABLE_HW_TRIP (1UL << 31)/* * Set ps_hold data driving value high
drivers/power/exynos-tmu.c +20 -5
@@ -22,9 +22,11 @@#include <fdtdec.h> #include <tmu.h> #include <asm/arch/tmu.h> +#include <asm/arch/power.h> #define TRIMINFO_RELOAD 1#define CORE_EN 1 +#define THERM_TRIP_EN (1 << 12)#define INTEN_RISE0 1#define INTEN_RISE1 (1 << 4)
@@ -55,6 +57,8 @@ struct temperature_params {unsigned int start_warning;/* temperature threshold CPU tripping */ unsigned int start_tripping; +/* temperature threshold for HW tripping */ +unsigned int hardware_tripping; };/* Pre-defined values and thresholds for calibration of current temperature */
@@ -196,6 +200,9 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob) info->data.ts.start_tripping =fdtdec_get_int (blob, node,"samsung,start-tripping" ,-1 ); error |= info->data.ts.start_tripping; + info->data.ts.hardware_tripping =fdtdec_get_int (blob, + node,"samsung,hw-tripping" ,-1 ); + error |= info->data.ts.hardware_tripping; info->data.efuse_min_value =fdtdec_get_int (blob, node,"samsung,efuse-min-value" ,-1 ); error |= info->data.efuse_min_value;
@@ -230,7 +237,7 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob)static void tmu_setup_parameters (struct tmu_info *info) {unsigned int te_code, con; -unsigned int warning_code, trip_code; +unsigned int warning_code, trip_code, hwtrip_code;unsigned int cooling_temp;unsigned int rising_value;struct tmu_data *data = &info->data;
@@ -254,9 +261,14 @@ static void tmu_setup_parameters(struct tmu_info *info) + info->te1 - info->dc_value; trip_code = data->ts.start_tripping + info->te1 - info->dc_value; + hwtrip_code = data->ts.hardware_tripping + + info->te1 - info->dc_value; + cooling_temp =0 ; - rising_value = ((warning_code <<8 ) | (trip_code <<16 )); + rising_value = ((warning_code <<8 ) | + (trip_code <<16 ) | + (hwtrip_code <<24 ));/* Set interrupt level */ writel (rising_value, ®->threshold_temp_rise);
@@ -276,12 +288,15 @@ static void tmu_setup_parameters(struct tmu_info *info)/* TMU core enable */ con =readl (®->tmu_control); - con |=CORE_EN ; + con |=THERM_TRIP_EN |CORE_EN ;writel (con, ®->tmu_control); -/* LEV0 LEV1 LEV2 interrupt enable */ -writel (INTEN_RISE0 |INTEN_RISE1 |INTEN_RISE2 , ®->inten); +/* Enable HW thermal trip */ +set_hw_thermal_trip (); + +/* LEV1 LEV2 interrupt enable */ +writel (INTEN_RISE1 |INTEN_RISE2 , ®->inten); }/*
Signature · 1 line
1.8.0
PATCH v11 8/8 Exynos5: FDT: Add a H/W-trip member to TMU node
In reply to Akshay SaraswatThis adds a member to TMU FDT node for providing hardware tripping temperature threshold.
---
Changes since v10:
- None.
board/samsung/dts/exynos5250-smdk5250.dts | 1 + doc/device-tree-bindings/exynos/tmu.txt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
board/samsung/dts/exynos5250-smdk5250.dts +1 -0
@@ -72,6 +72,7 @@ samsung,max-temp = <125>; samsung,start-warning = <95>; samsung,start-tripping = <105>; + samsung,hw-tripping = <110>; samsung,efuse-min-value = <40>; samsung,efuse-value = <55>; samsung,efuse-max-value = <100>;
doc/device-tree-bindings/exynos/tmu.txt +4 -1
@@ -8,7 +8,9 @@ Required properties: - samsung,max-temp : Maximum temperature value (125 degree celsius) - Current temperature of SoC should be less than this value. - samsung,start-warning : Temperature at which TMU starts giving warning (degree celsius) - - samsung,start-tripping : Temperature at which system will trip and shutdown (degree celsius) + - samsung,start-tripping : Temperature at which TMU shuts down the system (degree celsius) + - samsung,hw-tripping : Temperature at which hardware tripping should happen + in case TMU fails to power off (degree celsius) - samsung,efuse-min-value : SOC efuse min value (Constant 40) - efuse-value should be more than this value. - samsung,efuse-value : SOC actual efuse value (Literal value)
@@ -33,6 +35,7 @@ tmu at 10060000 { samsung,max-temp = <125>; samsung,start-warning = <95>; samsung,start-tripping = <105>; + samsung,hw-tripping = <110>; samsung,efuse-min-value = <40>; samsung,efuse-value = <55>; samsung,efuse-max-value = <100>;
Signature · 1 line
1.8.0
v11 cover Add TMU support for Exynos5250 based SMDK5250
In reply to Akshay SaraswatQuoted 34 lines · Akshay Saraswat
This patch series adds support for TMU driver using device tree for Exynos5250 based SMDK5250 board.
Changes since v10:
- Patch-1: Renamedasm/arch/exynos-tmu.htoasm/arch/tmu.h.
- Patch-2: None.
- Patch-3: None.
- Patch-4: None.
- Patch-5: None.
- Patch-6: None.
- Patch-7: None.
- Patch-8: None.Akshay Saraswat (8):
Exynos5: TMU: Add driver for Thermal Management Unit
Exynos5: FDT: Add TMU device node values
Exynos5: TMU: Add TMU init and status check
Exynos5: Config: Enable support for Exynos TMU driver
TMU: Add TMU support in dtt command
Exynos5: Config: Enable dtt command for TMU
Exynos5: TMU: Add hardware tripping
Exynos5: FDT: Add a H/W-trip member to TMU nodearch/arm/cpu/armv7/exynos/power.c | 12 ++ arch/arm/dts/exynos5250.dtsi | 5 + arch/arm/include/asm/arch-exynos/power.h | 4 + arch/arm/include/asm/arch-exynos/tmu.h | 58 ++++++ board/samsung/dts/exynos5250-smdk5250.dts | 13 ++ board/samsung/smdk5250/smdk5250.c | 39 ++++ common/cmd_dtt.c | 32 ++- doc/device-tree-bindings/exynos/tmu.txt | 44 +++++ drivers/power/Makefile | 1 + drivers/power/exynos-tmu.c | 319 ++++++++++++++++++++++++++++++ include/configs/exynos5250-dt.h | 5 +
Quoted 9 lines
include/fdtdec.h | 1 + include/tmu.h | 46 +++++ lib/fdtdec.c | 1 + 14 files changed, 579 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/arch-exynos/tmu.h create mode 100644 doc/device-tree-bindings/exynos/tmu.txt create mode 100644 drivers/power/exynos-tmu.c create mode 100644 include/tmu.h
applied to u-boot-samsung.
Thanks,
Minkyu Kang.