public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250
@ 2013-02-06 13:18 Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit Akshay Saraswat
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

This patch series adds support for TMU driver using device tree for Exynos5250
based SMDK5250 board.

Changes since v8:
        - Patch-1: None.
        - Patch-2: None.
        - Patch-3: None.
        - Patch-4: None.
        - Patch-5: None.
        - Patch-6: Kept old code same and added dtt_i2c.
        - Patch-7: None.
        - Patch-8: None.
        - Patch-9: None.

Akshay Saraswat (9):
  EXYNOS5: TMU: Add driver for Thermal Management Unit
  EXYNOS5: Implement board_poweroff 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             |   25 ++
 arch/arm/dts/exynos5250.dtsi                  |    5 +
 arch/arm/include/asm/arch-exynos/exynos-tmu.h |   58 +++++
 arch/arm/include/asm/arch-exynos/power.h      |    6 +
 board/samsung/dts/exynos5250-smdk5250.dts     |   13 +
 board/samsung/smdk5250/smdk5250.c             |   35 +++
 common/cmd_dtt.c                              |   32 ++-
 doc/device-tree-bindings/exynos/tmu.txt       |   49 ++++
 drivers/power/Makefile                        |    1 +
 drivers/power/exynos-tmu.c                    |  317 +++++++++++++++++++++++++
 include/configs/exynos5250-dt.h               |    5 +
 include/fdtdec.h                              |    1 +
 include/tmu.h                                 |   46 ++++
 lib/fdtdec.c                                  |    1 +
 14 files changed, 593 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/include/asm/arch-exynos/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

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-20  8:36   ` Minkyu Kang
  2013-02-06 13:18 ` [U-Boot] [PATCH 2/9 v9] EXYNOS5: Implement board_poweroff " Akshay Saraswat
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

Adding Exynos Thermal Management Unit driver to monitor SOC
temperature and take actions corresponding to states of TMU.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 arch/arm/include/asm/arch-exynos/exynos-tmu.h |   58 +++++
 drivers/power/Makefile                        |    1 +
 drivers/power/exynos-tmu.c                    |  302 +++++++++++++++++++++++++
 include/tmu.h                                 |   46 ++++
 4 files changed, 407 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-exynos/exynos-tmu.h
 create mode 100644 drivers/power/exynos-tmu.c
 create mode 100644 include/tmu.h

diff --git a/arch/arm/include/asm/arch-exynos/exynos-tmu.h b/arch/arm/include/asm/arch-exynos/exynos-tmu.h
new file mode 100644
index 0000000..c79a520
--- /dev/null
+++ b/arch/arm/include/asm/arch-exynos/exynos-tmu.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *      http://www.samsung.com
+ * Akshay Saraswat <akshay.s@samsung.com>
+ *
+ * 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 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_THERMAL_H */
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 8c71901..1dac16a 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -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
diff --git a/drivers/power/exynos-tmu.c b/drivers/power/exynos-tmu.c
new file mode 100644
index 0000000..b010883
--- /dev/null
+++ b/drivers/power/exynos-tmu.c
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *      http://www.samsung.com
+ * Akshay Saraswat <akshay.s@samsung.com>
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <tmu.h>
+#include <asm/arch/exynos-tmu.h>
+
+#define TRIMINFO_RELOAD		1
+#define CORE_EN			1
+
+#define INTEN_RISE0		1
+#define INTEN_RISE1		(1 << 4)
+#define INTEN_RISE2		(1 << 8)
+#define INTEN_FALL0		(1 << 16)
+#define INTEN_FALL1		(1 << 20)
+#define INTEN_FALL2		(1 << 24)
+
+#define TRIM_INFO_MASK		0xff
+
+#define INTCLEAR_RISE0		1
+#define INTCLEAR_RISE1		(1 << 4)
+#define INTCLEAR_RISE2		(1 << 8)
+#define INTCLEAR_FALL0		(1 << 16)
+#define INTCLEAR_FALL1		(1 << 20)
+#define INTCLEAR_FALL2		(1 << 24)
+#define INTCLEARALL		(INTCLEAR_RISE0 | INTCLEAR_RISE1 | \
+				 INTCLEAR_RISE2 | INTCLEAR_FALL0 | \
+				 INTCLEAR_FALL1 | INTCLEAR_FALL2)
+
+/* Tmeperature threshold values for various thermal events */
+struct temperature_params {
+	/* minimum value in temperature code range */
+	unsigned int min_val;
+	/* maximum value in temperature code range */
+	unsigned int max_val;
+	/* temperature threshold to start warning */
+	unsigned int start_warning;
+	/* temperature threshold CPU tripping */
+	unsigned int start_tripping;
+};
+
+/* Pre-defined values and thresholds for calibration of current temperature */
+struct tmu_data {
+	/* pre-defined temperature thresholds */
+	struct temperature_params ts;
+	/* pre-defined efuse range minimum value */
+	unsigned int efuse_min_value;
+	/* pre-defined efuse value for temperature calibration */
+	unsigned int efuse_value;
+	/* pre-defined efuse range maximum value */
+	unsigned int efuse_max_value;
+	/* current temperature sensing slope */
+	unsigned int slope;
+};
+
+/* TMU device specific details and status */
+struct tmu_info {
+	/* base Address for the TMU */
+	unsigned tmu_base;
+	/* pre-defined values for calibration and thresholds */
+	struct tmu_data data;
+	/* value required for triminfo_25 calibration */
+	unsigned int te1;
+	/* value required for triminfo_85 calibration */
+	unsigned int te2;
+	/* Value for measured data calibration */
+	int dc_value;
+	/* enum value indicating status of the TMU */
+	int tmu_state;
+};
+
+/* Global struct tmu_info variable to store init values */
+static struct tmu_info gbl_info;
+
+/*
+ * Get current temperature code from register,
+ * then calculate and calibrate it's value
+ * in degree celsius.
+ *
+ * @return	current temperature of the chip as sensed by TMU
+ */
+int get_cur_temp(struct tmu_info *info)
+{
+	int cur_temp;
+	struct tmu_reg *reg = (struct tmu_reg *)info->tmu_base;
+
+	/*
+	 * Temperature code range between min 25 and max 125.
+	 * May run more than once for first call as initial sensing
+	 * has not yet happened.
+	 */
+	do {
+		cur_temp = readl(&reg->current_temp) & 0xff;
+	} while (cur_temp == 0 && info->tmu_state == TMU_STATUS_NORMAL);
+
+	/* Calibrate current temperature */
+	cur_temp = cur_temp - info->te1 + info->dc_value;
+
+	return cur_temp;
+}
+
+/*
+ * Monitors status of the TMU device and exynos temperature
+ *
+ * @param temp	pointer to the current temperature value
+ * @return	enum tmu_status_t value, code indicating event to execute
+ */
+enum tmu_status_t tmu_monitor(int *temp)
+{
+	if (gbl_info.tmu_state == TMU_STATUS_INIT)
+		return TMU_STATUS_INIT;
+
+	int cur_temp;
+	struct tmu_data *data = &gbl_info.data;
+
+	/* Read current temperature of the SOC */
+	cur_temp = get_cur_temp(&gbl_info);
+	*temp = cur_temp;
+
+	/* Temperature code lies between min 25 and max 125 */
+	if (cur_temp >= data->ts.start_tripping &&
+			cur_temp <= data->ts.max_val) {
+		return TMU_STATUS_TRIPPED;
+	} else if (cur_temp >= data->ts.start_warning) {
+		return TMU_STATUS_WARNING;
+	} else if (cur_temp < data->ts.start_warning &&
+			cur_temp >= data->ts.min_val) {
+		return TMU_STATUS_NORMAL;
+	/* Temperature code does not lie between min 25 and max 125 */
+	} else {
+		gbl_info.tmu_state = TMU_STATUS_INIT;
+		debug("EXYNOS_TMU: Thermal reading failed\n");
+		return TMU_STATUS_INIT;
+	}
+}
+
+/*
+ * Get TMU specific pre-defined values from FDT
+ *
+ * @param info	pointer to the tmu_info struct
+ * @param blob  FDT blob
+ * @return	int value, 0 for success
+ */
+int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
+{
+	int node;
+	int error = 0;
+
+	/* Get the node from FDT for TMU */
+	node = fdtdec_next_compatible(blob, 0,
+				      COMPAT_SAMSUNG_EXYNOS_TMU);
+	if (node < 0) {
+		debug("EXYNOS_TMU: No node for tmu in device tree\n");
+		return -1;
+	}
+
+	/*
+	 * Get the pre-defined TMU specific values from FDT.
+	 * All of these are expected to be correct otherwise
+	 * miscalculation of register values in tmu_setup_parameters
+	 * may result in misleading current temperature.
+	 */
+	info->tmu_base = fdtdec_get_addr(blob, node, "reg");
+	if (info->tmu_base == FDT_ADDR_T_NONE) {
+		debug("%s: Missing tmu-base\n", __func__);
+		return -1;
+	}
+	info->data.ts.min_val = fdtdec_get_int(blob,
+				node, "samsung,min-temp", -1);
+	error |= info->data.ts.min_val;
+	info->data.ts.max_val = fdtdec_get_int(blob,
+				node, "samsung,max-temp", -1);
+	error |= info->data.ts.max_val;
+	info->data.ts.start_warning = fdtdec_get_int(blob,
+				node, "samsung,start-warning", -1);
+	error |= info->data.ts.start_warning;
+	info->data.ts.start_tripping = fdtdec_get_int(blob,
+				node, "samsung,start-tripping", -1);
+	error |= info->data.ts.start_tripping;
+	info->data.efuse_min_value = fdtdec_get_int(blob,
+				node, "samsung,efuse-min-value", -1);
+	error |= info->data.efuse_min_value;
+	info->data.efuse_value = fdtdec_get_int(blob,
+				node, "samsung,efuse-value", -1);
+	error |= info->data.efuse_value;
+	info->data.efuse_max_value = fdtdec_get_int(blob,
+				node, "samsung,efuse-max-value", -1);
+	error |= info->data.efuse_max_value;
+	info->data.slope = fdtdec_get_int(blob,
+				node, "samsung,slope", -1);
+	error |= info->data.slope;
+	info->dc_value = fdtdec_get_int(blob,
+				node, "samsung,dc-value", -1);
+	error |= info->dc_value;
+
+	if (error == -1) {
+		debug("fail to get tmu node properties\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+/*
+ * Calibrate and calculate threshold values and
+ * enable interrupt levels
+ *
+ * @param	info pointer to the tmu_info struct
+ */
+void tmu_setup_parameters(struct tmu_info *info)
+{
+	unsigned int te_code, con;
+	unsigned int warning_code, trip_code;
+	unsigned int cooling_temp;
+	unsigned int rising_value;
+	struct tmu_data *data = &info->data;
+	struct tmu_reg *reg = (struct tmu_reg *)info->tmu_base;
+
+	/* Must reload for reading efuse value from triminfo register */
+	writel(TRIMINFO_RELOAD, &reg->triminfo_control);
+
+	/* Get the compensation parameter */
+	te_code = readl(&reg->triminfo);
+	info->te1 = te_code & TRIM_INFO_MASK;
+	info->te2 = ((te_code >> 8) & TRIM_INFO_MASK);
+
+	if ((data->efuse_min_value > info->te1) ||
+			(info->te1 > data->efuse_max_value)
+			||  (info->te2 != 0))
+		info->te1 = data->efuse_value;
+
+	/* Get RISING & FALLING Threshold value */
+	warning_code = data->ts.start_warning
+			+ info->te1 - info->dc_value;
+	trip_code = data->ts.start_tripping
+			+ info->te1 - info->dc_value;
+	cooling_temp = 0;
+
+	rising_value = ((warning_code << 8) | (trip_code << 16));
+
+	/* Set interrupt level */
+	writel(rising_value, &reg->threshold_temp_rise);
+	writel(cooling_temp, &reg->threshold_temp_fall);
+
+	/*
+	 * Init TMU control tuning parameters
+	 * [28:24] VREF - Voltage reference
+	 * [15:13] THERM_TRIP_MODE - Tripping mode
+	 * [12] THERM_TRIP_EN - Thermal tripping enable
+	 * [11:8] BUF_SLOPE_SEL - Gain of amplifier
+	 * [6] THERM_TRIP_BY_TQ_EN - Tripping by TQ pin
+	 */
+	writel(data->slope, &reg->tmu_control);
+
+	writel(INTCLEARALL, &reg->intclear);
+
+	/* TMU core enable */
+	con = readl(&reg->tmu_control);
+	con |= CORE_EN;
+
+	writel(con, &reg->tmu_control);
+
+	/* LEV0 LEV1 LEV2 interrupt enable */
+	writel(INTEN_RISE0 | INTEN_RISE1 | INTEN_RISE2,	&reg->inten);
+}
+
+/*
+ * Initialize TMU device
+ *
+ * @param blob  FDT blob
+ * @return	int value, 0 for success
+ */
+int tmu_init(const void *blob)
+{
+	gbl_info.tmu_state = TMU_STATUS_INIT;
+	if (get_tmu_fdt_values(&gbl_info, blob) < 0)
+		return -1;
+
+	tmu_setup_parameters(&gbl_info);
+	gbl_info.tmu_state = TMU_STATUS_NORMAL;
+	debug("EXYNOS_TMU: Available\n");
+
+	return 0;
+}
diff --git a/include/tmu.h b/include/tmu.h
new file mode 100644
index 0000000..17e9a85
--- /dev/null
+++ b/include/tmu.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *      http://www.samsung.com
+ * Akshay Saraswat <akshay.s@samsung.com>
+ *
+ * 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 _TMU_H
+#define _TMU_H
+
+enum tmu_status_t {
+	TMU_STATUS_INIT = 0,
+	TMU_STATUS_NORMAL,
+	TMU_STATUS_WARNING,
+	TMU_STATUS_TRIPPED,
+};
+
+/*
+ * Monitors status of the TMU device and exynos temperature
+ *
+ * @param temp	pointer to the current temperature value
+ * @return	enum tmu_status_t value, code indicating event to execute
+ *		and -1 on error
+ */
+enum tmu_status_t tmu_monitor(int *temp);
+
+/*
+ * Initialize TMU device
+ *
+ * @param blob  FDT blob
+ * @return	int value, 0 for success
+ */
+int tmu_init(const void *blob);
+#endif	/* _THERMAL_H_ */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 2/9 v9] EXYNOS5: Implement board_poweroff for Thermal Management Unit
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-20  8:38   ` Minkyu Kang
  2013-02-06 13:18 ` [U-Boot] [PATCH 3/9 v9] EXYNOS5: FDT: Add TMU device node values Akshay Saraswat
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

Adding API in power for system shutdown when tripping value is reached
in Exynos Thermal Management Unit.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 arch/arm/cpu/armv7/exynos/power.c        |   15 +++++++++++++++
 arch/arm/include/asm/arch-exynos/power.h |    1 +
 2 files changed, 16 insertions(+)

diff --git a/arch/arm/cpu/armv7/exynos/power.c b/arch/arm/cpu/armv7/exynos/power.c
index d4bce6d..73f764e 100644
--- a/arch/arm/cpu/armv7/exynos/power.c
+++ b/arch/arm/cpu/armv7/exynos/power.c
@@ -95,3 +95,18 @@ void set_dp_phy_ctrl(unsigned int enable)
 	if (cpu_is_exynos5())
 		exynos5_dp_phy_control(enable);
 }
+
+/*
+ * This function never returns.
+ * When called this function makes system hang and PAD driving value high
+ * which in turn makes system power down.
+ */
+void board_poweroff(void)
+{
+	struct exynos5_power *power =
+		(struct exynos5_power *)samsung_get_base_power();
+
+	clrbits_le32(&power->ps_hold_control, POWER_PS_HOLD_CONTROL_DATA_HIGH);
+
+	hang();
+}
diff --git a/arch/arm/include/asm/arch-exynos/power.h b/arch/arm/include/asm/arch-exynos/power.h
index d2fdb59..7463036 100644
--- a/arch/arm/include/asm/arch-exynos/power.h
+++ b/arch/arm/include/asm/arch-exynos/power.h
@@ -863,5 +863,6 @@ void set_usbhost_phy_ctrl(unsigned int enable);
 void set_dp_phy_ctrl(unsigned int enable);
 
 #define EXYNOS_DP_PHY_ENABLE		(1 << 0)
+#define POWER_PS_HOLD_CONTROL_DATA_HIGH         (1 << 8)
 
 #endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 3/9 v9] EXYNOS5: FDT: Add TMU device node values
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 2/9 v9] EXYNOS5: Implement board_poweroff " Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 4/9 v9] EXYNOS5: TMU: Add TMU init and status check Akshay Saraswat
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

Fdt entry for Exynos TMU driver specific pre-defined values used for
calibration of current temperature and defining threshold values.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 arch/arm/dts/exynos5250.dtsi              |    5 ++++
 board/samsung/dts/exynos5250-smdk5250.dts |   12 ++++++++
 doc/device-tree-bindings/exynos/tmu.txt   |   46 +++++++++++++++++++++++++++++
 include/fdtdec.h                          |    1 +
 lib/fdtdec.c                              |    1 +
 5 files changed, 65 insertions(+)
 create mode 100644 doc/device-tree-bindings/exynos/tmu.txt

diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi
index ed8c8dd..61d35a8 100644
--- a/arch/arm/dts/exynos5250.dtsi
+++ b/arch/arm/dts/exynos5250.dtsi
@@ -151,4 +151,9 @@
 		};
 	};
 
+	tmu at 10060000 {
+		compatible = "samsung,exynos-tmu";
+		reg = <0x10060000 0x10000>;
+	};
+
 };
diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts
index cbfab6f..00dac40 100644
--- a/board/samsung/dts/exynos5250-smdk5250.dts
+++ b/board/samsung/dts/exynos5250-smdk5250.dts
@@ -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>;
+	};
 };
diff --git a/doc/device-tree-bindings/exynos/tmu.txt b/doc/device-tree-bindings/exynos/tmu.txt
new file mode 100644
index 0000000..b911a52
--- /dev/null
+++ b/doc/device-tree-bindings/exynos/tmu.txt
@@ -0,0 +1,46 @@
+Exynos Thermal management Unit
+
+The device node for TMU that is a part of Exynos5250
+SOC is as described in the document "Open Firmware Recommended
+Practice : Universal Serial Bus" with the following modifications
+and additions:
+
+Required properties:
+
+ - compatible : Should be "samsung,exynos-tmu" for TMU
+ - samsung,min-temp : Minimum temperature value (25 degree celsius)
+	- Current temperature of SoC should be more than this value.
+ - 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,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)
+	- This is the data trimming info.
+	- This value is used to calculate measuring error.
+ - samsung,efuse-max-value : SoC max efuse value (Constant 100)
+	- efuse-value should be less than this value.
+ - samsung,slope : Default value 274761730 (Constant 0x1060_8802).
+	- This is the default value for TMU_CONTROL register.
+	- It sets the gain of amplifier to the positive-tc generator block.
+	- It selects thermal tripping mode and enables thermal tripping.
+ - samsung,dc-value : Measured data calibration value (Constant 25)
+	- Used for tempearture calculation.
+	- This is 25 because temperature measured is always above 25 degrees.
+
+
+Example:
+
+tmu at 10060000 {
+	compatible = "samsung,exynos-tmu"
+	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>;
+};
diff --git a/include/fdtdec.h b/include/fdtdec.h
index f77d195..058fb51 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -79,6 +79,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,
 };
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 16921e1..4613fcd 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -54,6 +54,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)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 4/9 v9] EXYNOS5: TMU: Add TMU init and status check
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
                   ` (2 preceding siblings ...)
  2013-02-06 13:18 ` [U-Boot] [PATCH 3/9 v9] EXYNOS5: FDT: Add TMU device node values Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-20  8:41   ` Minkyu Kang
  2013-02-06 13:18 ` [U-Boot] [PATCH 5/9 v9] EXYNOS5: Config: Enable support for Exynos TMU driver Akshay Saraswat
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

This adds call to tmu_init() and TMU boot time analysis
for the SoC temperature threshold breach.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 board/samsung/smdk5250/smdk5250.c |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
index 7a5f132..7b9a8c5 100644
--- a/board/samsung/smdk5250/smdk5250.c
+++ b/board/samsung/smdk5250/smdk5250.c
@@ -35,9 +35,35 @@
 #include <asm/arch/sromc.h>
 #include <asm/arch/dp_info.h>
 #include <power/pmic.h>
+#include <tmu.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined CONFIG_EXYNOS_TMU
+/*
+ * Boot Time Thermal Analysis for SoC temperature threshold breach
+ */
+void boot_temp_check(void)
+{
+	int temp;
+
+	switch (tmu_monitor(&temp)) {
+	case TMU_STATUS_TRIPPED:
+		puts("EXYNOS_TMU: TRIPPING! Device power going down ...\n");
+		board_poweroff();
+		break;
+	case TMU_STATUS_WARNING:
+		puts("EXYNOS_TMU: WARNING! Temperature very high\n");
+		break;
+	case TMU_STATUS_NORMAL:
+		break;
+	case TMU_STATUS_INIT:
+	default:
+		debug("Unknown TMU state\n");
+	}
+}
+#endif
+
 #ifdef CONFIG_USB_EHCI_EXYNOS
 int board_usb_vbus_init(void)
 {
@@ -57,6 +83,15 @@ int board_usb_vbus_init(void)
 int board_init(void)
 {
 	gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
+
+#if defined CONFIG_EXYNOS_TMU
+	if (tmu_init(gd->fdt_blob)) {
+		debug("%s: Failed to init TMU\n", __func__);
+		return -1;
+	}
+	boot_temp_check();
+#endif
+
 #ifdef CONFIG_EXYNOS_SPI
 	spi_init();
 #endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 5/9 v9] EXYNOS5: Config: Enable support for Exynos TMU driver
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
                   ` (3 preceding siblings ...)
  2013-02-06 13:18 ` [U-Boot] [PATCH 4/9 v9] EXYNOS5: TMU: Add TMU init and status check Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 6/9 v9] TMU: Add TMU support in dtt command Akshay Saraswat
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

Enables TMU driver support for exynos5250

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 include/configs/exynos5250-dt.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index cabd2f2..53ca41f 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -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
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 6/9 v9] TMU: Add TMU support in dtt command
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
                   ` (4 preceding siblings ...)
  2013-02-06 13:18 ` [U-Boot] [PATCH 5/9 v9] EXYNOS5: Config: Enable support for Exynos TMU driver Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-06 16:36   ` Simon Glass
  2013-02-06 13:18 ` [U-Boot] [PATCH 7/9 v9] EXYNOS5: Config: Enable dtt command for TMU Akshay Saraswat
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

Add 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.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
---
Changes since v8:
	- Kept old code same and added dtt_i2c.

 common/cmd_dtt.c |   32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index cd94423..0c1cfdb 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -27,7 +27,9 @@
 
 #include <dtt.h>
 #include <i2c.h>
+#include <tmu.h>
 
+#if defined CONFIG_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 defined CONFIG_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 defined CONFIG_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() */
 
 /***************************************************/
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 7/9 v9] EXYNOS5: Config: Enable dtt command for TMU
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
                   ` (5 preceding siblings ...)
  2013-02-06 13:18 ` [U-Boot] [PATCH 6/9 v9] TMU: Add TMU support in dtt command Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 8/9 v9] EXYNOS5: TMU: Add hardware tripping Akshay Saraswat
  2013-02-06 13:18 ` [U-Boot] [PATCH 9/9 v9] EXYNOS5: FDT: Add a H/W-trip member to TMU node Akshay Saraswat
  8 siblings, 0 replies; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

This enables the dtt command to read the current SOC
temperature with the help of TMU

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 include/configs/exynos5250-dt.h |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 53ca41f..8a8e9fe 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -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
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 8/9 v9] EXYNOS5: TMU: Add hardware tripping
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
                   ` (6 preceding siblings ...)
  2013-02-06 13:18 ` [U-Boot] [PATCH 7/9 v9] EXYNOS5: Config: Enable dtt command for TMU Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  2013-02-20  8:46   ` Minkyu Kang
  2013-02-06 13:18 ` [U-Boot] [PATCH 9/9 v9] EXYNOS5: FDT: Add a H/W-trip member to TMU node Akshay Saraswat
  8 siblings, 1 reply; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

This adds hardware tripping at 110 degrees celsius which must enable
forced system shutdown in case TMU fails to power off.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 arch/arm/cpu/armv7/exynos/power.c        |   10 ++++++++++
 arch/arm/include/asm/arch-exynos/power.h |    5 +++++
 drivers/power/exynos-tmu.c               |   25 ++++++++++++++++++++-----
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/armv7/exynos/power.c b/arch/arm/cpu/armv7/exynos/power.c
index 73f764e..234c9f4 100644
--- a/arch/arm/cpu/armv7/exynos/power.c
+++ b/arch/arm/cpu/armv7/exynos/power.c
@@ -96,6 +96,16 @@ void set_dp_phy_ctrl(unsigned int enable)
 		exynos5_dp_phy_control(enable);
 }
 
+/* Enables hardware tripping to power off the system when TMU fails */
+void power_enable_hw_thermal_trip(void)
+{
+	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);
+}
+
 /*
  * This function never returns.
  * When called this function makes system hang and PAD driving value high
diff --git a/arch/arm/include/asm/arch-exynos/power.h b/arch/arm/include/asm/arch-exynos/power.h
index 7463036..034774f 100644
--- a/arch/arm/include/asm/arch-exynos/power.h
+++ b/arch/arm/include/asm/arch-exynos/power.h
@@ -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 power_enable_hw_thermal_trip(void);
+
 #define POWER_USB_HOST_PHY_CTRL_EN		(1 << 0)
 #define POWER_USB_HOST_PHY_CTRL_DISABLE		(0 << 0)
 
@@ -864,5 +867,7 @@ void set_dp_phy_ctrl(unsigned int enable);
 
 #define EXYNOS_DP_PHY_ENABLE		(1 << 0)
 #define POWER_PS_HOLD_CONTROL_DATA_HIGH         (1 << 8)
+#define POWER_ENABLE_HW_TRIP			(1UL << 31)
+
 
 #endif
diff --git a/drivers/power/exynos-tmu.c b/drivers/power/exynos-tmu.c
index b010883..5885ce7 100644
--- a/drivers/power/exynos-tmu.c
+++ b/drivers/power/exynos-tmu.c
@@ -22,9 +22,11 @@
 #include <fdtdec.h>
 #include <tmu.h>
 #include <asm/arch/exynos-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 */
@@ -195,6 +199,9 @@ 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;
@@ -228,7 +235,7 @@ int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
 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;
@@ -252,9 +259,14 @@ 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, &reg->threshold_temp_rise);
@@ -274,12 +286,15 @@ void tmu_setup_parameters(struct tmu_info *info)
 
 	/* TMU core enable */
 	con = readl(&reg->tmu_control);
-	con |= CORE_EN;
+	con |= THERM_TRIP_EN | CORE_EN;
 
 	writel(con, &reg->tmu_control);
 
-	/* LEV0 LEV1 LEV2 interrupt enable */
-	writel(INTEN_RISE0 | INTEN_RISE1 | INTEN_RISE2,	&reg->inten);
+	/* Enable HW thermal trip */
+	power_enable_hw_thermal_trip();
+
+	/* LEV1 LEV2 interrupt enable */
+	writel(INTEN_RISE1 | INTEN_RISE2, &reg->inten);
 }
 
 /*
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 9/9 v9] EXYNOS5: FDT: Add a H/W-trip member to TMU node
  2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
                   ` (7 preceding siblings ...)
  2013-02-06 13:18 ` [U-Boot] [PATCH 8/9 v9] EXYNOS5: TMU: Add hardware tripping Akshay Saraswat
@ 2013-02-06 13:18 ` Akshay Saraswat
  8 siblings, 0 replies; 15+ messages in thread
From: Akshay Saraswat @ 2013-02-06 13:18 UTC (permalink / raw)
  To: u-boot

This adds a member to TMU FDT node for providing hardware
tripping temperature threshold.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes since v8:
	- None.

 board/samsung/dts/exynos5250-smdk5250.dts |    1 +
 doc/device-tree-bindings/exynos/tmu.txt   |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts
index 00dac40..1c2d52d 100644
--- a/board/samsung/dts/exynos5250-smdk5250.dts
+++ b/board/samsung/dts/exynos5250-smdk5250.dts
@@ -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>;
diff --git a/doc/device-tree-bindings/exynos/tmu.txt b/doc/device-tree-bindings/exynos/tmu.txt
index b911a52..a7492f9 100644
--- a/doc/device-tree-bindings/exynos/tmu.txt
+++ b/doc/device-tree-bindings/exynos/tmu.txt
@@ -13,7 +13,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)
@@ -38,6 +40,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>;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 6/9 v9] TMU: Add TMU support in dtt command
  2013-02-06 13:18 ` [U-Boot] [PATCH 6/9 v9] TMU: Add TMU support in dtt command Akshay Saraswat
@ 2013-02-06 16:36   ` Simon Glass
  0 siblings, 0 replies; 15+ messages in thread
From: Simon Glass @ 2013-02-06 16:36 UTC (permalink / raw)
  To: u-boot

Hi Akshay,

On Wed, Feb 6, 2013 at 5:18 AM, Akshay Saraswat <akshay.s@samsung.com> wrote:
> Add 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.
>
> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>

Yes that looks right, thanks.

Acked-by: Simon Glass <sjg@chromium.org>

> ---
> Changes since v8:
>         - Kept old code same and added dtt_i2c.
>
>  common/cmd_dtt.c |   32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
> index cd94423..0c1cfdb 100644
> --- a/common/cmd_dtt.c
> +++ b/common/cmd_dtt.c
> @@ -27,7 +27,9 @@
>
>  #include <dtt.h>
>  #include <i2c.h>
> +#include <tmu.h>
>
> +#if defined CONFIG_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 defined CONFIG_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 defined CONFIG_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() */
>
>  /***************************************************/
> --
> 1.7.9.5
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit
  2013-02-06 13:18 ` [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit Akshay Saraswat
@ 2013-02-20  8:36   ` Minkyu Kang
  0 siblings, 0 replies; 15+ messages in thread
From: Minkyu Kang @ 2013-02-20  8:36 UTC (permalink / raw)
  To: u-boot

Dear Akshay,

On 06/02/13 22:18, Akshay Saraswat wrote:
> Adding Exynos Thermal Management Unit driver to monitor SOC
> temperature and take actions corresponding to states of TMU.
> 
> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes since v8:
> 	- None.
> 
>  arch/arm/include/asm/arch-exynos/exynos-tmu.h |   58 +++++
>  drivers/power/Makefile                        |    1 +
>  drivers/power/exynos-tmu.c                    |  302 +++++++++++++++++++++++++
>  include/tmu.h                                 |   46 ++++
>  4 files changed, 407 insertions(+)
>  create mode 100644 arch/arm/include/asm/arch-exynos/exynos-tmu.h
>  create mode 100644 drivers/power/exynos-tmu.c
>  create mode 100644 include/tmu.h
> 
> diff --git a/arch/arm/include/asm/arch-exynos/exynos-tmu.h b/arch/arm/include/asm/arch-exynos/exynos-tmu.h
> new file mode 100644
> index 0000000..c79a520
> --- /dev/null
> +++ b/arch/arm/include/asm/arch-exynos/exynos-tmu.h

just tmu.h please.

> @@ -0,0 +1,58 @@
> +/*
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *      http://www.samsung.com
> + * Akshay Saraswat <akshay.s@samsung.com>
> + *
> + * 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 tmu_reg {

is it for exynos5? or exynos4? or both?

> +	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_THERMAL_H */
> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
> index 8c71901..1dac16a 100644
> --- a/drivers/power/Makefile
> +++ b/drivers/power/Makefile
> @@ -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
> diff --git a/drivers/power/exynos-tmu.c b/drivers/power/exynos-tmu.c
> new file mode 100644
> index 0000000..b010883
> --- /dev/null
> +++ b/drivers/power/exynos-tmu.c
> @@ -0,0 +1,302 @@
> +/*
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *      http://www.samsung.com
> + * Akshay Saraswat <akshay.s@samsung.com>
> + *
> + * 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
> + */
> +
> +#include <common.h>
> +#include <errno.h>
> +#include <fdtdec.h>
> +#include <tmu.h>
> +#include <asm/arch/exynos-tmu.h>
> +
> +#define TRIMINFO_RELOAD		1
> +#define CORE_EN			1
> +
> +#define INTEN_RISE0		1
> +#define INTEN_RISE1		(1 << 4)
> +#define INTEN_RISE2		(1 << 8)
> +#define INTEN_FALL0		(1 << 16)
> +#define INTEN_FALL1		(1 << 20)
> +#define INTEN_FALL2		(1 << 24)
> +
> +#define TRIM_INFO_MASK		0xff
> +
> +#define INTCLEAR_RISE0		1
> +#define INTCLEAR_RISE1		(1 << 4)
> +#define INTCLEAR_RISE2		(1 << 8)
> +#define INTCLEAR_FALL0		(1 << 16)
> +#define INTCLEAR_FALL1		(1 << 20)
> +#define INTCLEAR_FALL2		(1 << 24)
> +#define INTCLEARALL		(INTCLEAR_RISE0 | INTCLEAR_RISE1 | \
> +				 INTCLEAR_RISE2 | INTCLEAR_FALL0 | \
> +				 INTCLEAR_FALL1 | INTCLEAR_FALL2)
> +
> +/* Tmeperature threshold values for various thermal events */
> +struct temperature_params {
> +	/* minimum value in temperature code range */
> +	unsigned int min_val;
> +	/* maximum value in temperature code range */
> +	unsigned int max_val;
> +	/* temperature threshold to start warning */
> +	unsigned int start_warning;
> +	/* temperature threshold CPU tripping */
> +	unsigned int start_tripping;
> +};
> +
> +/* Pre-defined values and thresholds for calibration of current temperature */
> +struct tmu_data {
> +	/* pre-defined temperature thresholds */
> +	struct temperature_params ts;
> +	/* pre-defined efuse range minimum value */
> +	unsigned int efuse_min_value;
> +	/* pre-defined efuse value for temperature calibration */
> +	unsigned int efuse_value;
> +	/* pre-defined efuse range maximum value */
> +	unsigned int efuse_max_value;
> +	/* current temperature sensing slope */
> +	unsigned int slope;
> +};
> +
> +/* TMU device specific details and status */
> +struct tmu_info {
> +	/* base Address for the TMU */
> +	unsigned tmu_base;
> +	/* pre-defined values for calibration and thresholds */
> +	struct tmu_data data;
> +	/* value required for triminfo_25 calibration */
> +	unsigned int te1;
> +	/* value required for triminfo_85 calibration */
> +	unsigned int te2;
> +	/* Value for measured data calibration */
> +	int dc_value;
> +	/* enum value indicating status of the TMU */
> +	int tmu_state;
> +};
> +
> +/* Global struct tmu_info variable to store init values */
> +static struct tmu_info gbl_info;
> +
> +/*
> + * Get current temperature code from register,
> + * then calculate and calibrate it's value
> + * in degree celsius.
> + *
> + * @return	current temperature of the chip as sensed by TMU
> + */
> +int get_cur_temp(struct tmu_info *info)

static?

> +{
> +	int cur_temp;
> +	struct tmu_reg *reg = (struct tmu_reg *)info->tmu_base;
> +
> +	/*
> +	 * Temperature code range between min 25 and max 125.
> +	 * May run more than once for first call as initial sensing
> +	 * has not yet happened.
> +	 */
> +	do {
> +		cur_temp = readl(&reg->current_temp) & 0xff;
> +	} while (cur_temp == 0 && info->tmu_state == TMU_STATUS_NORMAL);
> +
> +	/* Calibrate current temperature */
> +	cur_temp = cur_temp - info->te1 + info->dc_value;
> +
> +	return cur_temp;
> +}
> +
> +/*
> + * Monitors status of the TMU device and exynos temperature
> + *
> + * @param temp	pointer to the current temperature value
> + * @return	enum tmu_status_t value, code indicating event to execute
> + */
> +enum tmu_status_t tmu_monitor(int *temp)
> +{
> +	if (gbl_info.tmu_state == TMU_STATUS_INIT)
> +		return TMU_STATUS_INIT;
> +
> +	int cur_temp;
> +	struct tmu_data *data = &gbl_info.data;

please move this declaration to start of function.

> +
> +	/* Read current temperature of the SOC */
> +	cur_temp = get_cur_temp(&gbl_info);
> +	*temp = cur_temp;
> +
> +	/* Temperature code lies between min 25 and max 125 */
> +	if (cur_temp >= data->ts.start_tripping &&
> +			cur_temp <= data->ts.max_val) {
> +		return TMU_STATUS_TRIPPED;
> +	} else if (cur_temp >= data->ts.start_warning) {
> +		return TMU_STATUS_WARNING;
> +	} else if (cur_temp < data->ts.start_warning &&
> +			cur_temp >= data->ts.min_val) {
> +		return TMU_STATUS_NORMAL;
> +	/* Temperature code does not lie between min 25 and max 125 */

is this comment for what?
please move this comment to correct position.

> +	} else {
> +		gbl_info.tmu_state = TMU_STATUS_INIT;
> +		debug("EXYNOS_TMU: Thermal reading failed\n");
> +		return TMU_STATUS_INIT;
> +	}
> +}
> +
> +/*
> + * Get TMU specific pre-defined values from FDT
> + *
> + * @param info	pointer to the tmu_info struct
> + * @param blob  FDT blob
> + * @return	int value, 0 for success
> + */
> +int get_tmu_fdt_values(struct tmu_info *info, const void *blob)

static?

> +{

#ifdef CONFIG_OF_CONTROL?

> +	int node;
> +	int error = 0;
> +
> +	/* Get the node from FDT for TMU */
> +	node = fdtdec_next_compatible(blob, 0,
> +				      COMPAT_SAMSUNG_EXYNOS_TMU);
> +	if (node < 0) {
> +		debug("EXYNOS_TMU: No node for tmu in device tree\n");
> +		return -1;
> +	}
> +
> +	/*
> +	 * Get the pre-defined TMU specific values from FDT.
> +	 * All of these are expected to be correct otherwise
> +	 * miscalculation of register values in tmu_setup_parameters
> +	 * may result in misleading current temperature.
> +	 */
> +	info->tmu_base = fdtdec_get_addr(blob, node, "reg");
> +	if (info->tmu_base == FDT_ADDR_T_NONE) {
> +		debug("%s: Missing tmu-base\n", __func__);
> +		return -1;
> +	}
> +	info->data.ts.min_val = fdtdec_get_int(blob,
> +				node, "samsung,min-temp", -1);
> +	error |= info->data.ts.min_val;
> +	info->data.ts.max_val = fdtdec_get_int(blob,
> +				node, "samsung,max-temp", -1);
> +	error |= info->data.ts.max_val;
> +	info->data.ts.start_warning = fdtdec_get_int(blob,
> +				node, "samsung,start-warning", -1);
> +	error |= info->data.ts.start_warning;
> +	info->data.ts.start_tripping = fdtdec_get_int(blob,
> +				node, "samsung,start-tripping", -1);
> +	error |= info->data.ts.start_tripping;
> +	info->data.efuse_min_value = fdtdec_get_int(blob,
> +				node, "samsung,efuse-min-value", -1);
> +	error |= info->data.efuse_min_value;
> +	info->data.efuse_value = fdtdec_get_int(blob,
> +				node, "samsung,efuse-value", -1);
> +	error |= info->data.efuse_value;
> +	info->data.efuse_max_value = fdtdec_get_int(blob,
> +				node, "samsung,efuse-max-value", -1);
> +	error |= info->data.efuse_max_value;
> +	info->data.slope = fdtdec_get_int(blob,
> +				node, "samsung,slope", -1);
> +	error |= info->data.slope;
> +	info->dc_value = fdtdec_get_int(blob,
> +				node, "samsung,dc-value", -1);
> +	error |= info->dc_value;
> +
> +	if (error == -1) {
> +		debug("fail to get tmu node properties\n");
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +/*
> + * Calibrate and calculate threshold values and
> + * enable interrupt levels
> + *
> + * @param	info pointer to the tmu_info struct
> + */
> +void tmu_setup_parameters(struct tmu_info *info)

static?

> +{
> +	unsigned int te_code, con;
> +	unsigned int warning_code, trip_code;
> +	unsigned int cooling_temp;
> +	unsigned int rising_value;
> +	struct tmu_data *data = &info->data;
> +	struct tmu_reg *reg = (struct tmu_reg *)info->tmu_base;
> +
> +	/* Must reload for reading efuse value from triminfo register */
> +	writel(TRIMINFO_RELOAD, &reg->triminfo_control);
> +
> +	/* Get the compensation parameter */
> +	te_code = readl(&reg->triminfo);
> +	info->te1 = te_code & TRIM_INFO_MASK;
> +	info->te2 = ((te_code >> 8) & TRIM_INFO_MASK);
> +
> +	if ((data->efuse_min_value > info->te1) ||
> +			(info->te1 > data->efuse_max_value)
> +			||  (info->te2 != 0))
> +		info->te1 = data->efuse_value;
> +
> +	/* Get RISING & FALLING Threshold value */
> +	warning_code = data->ts.start_warning
> +			+ info->te1 - info->dc_value;
> +	trip_code = data->ts.start_tripping
> +			+ info->te1 - info->dc_value;
> +	cooling_temp = 0;
> +
> +	rising_value = ((warning_code << 8) | (trip_code << 16));
> +
> +	/* Set interrupt level */
> +	writel(rising_value, &reg->threshold_temp_rise);
> +	writel(cooling_temp, &reg->threshold_temp_fall);
> +
> +	/*
> +	 * Init TMU control tuning parameters
> +	 * [28:24] VREF - Voltage reference
> +	 * [15:13] THERM_TRIP_MODE - Tripping mode
> +	 * [12] THERM_TRIP_EN - Thermal tripping enable
> +	 * [11:8] BUF_SLOPE_SEL - Gain of amplifier
> +	 * [6] THERM_TRIP_BY_TQ_EN - Tripping by TQ pin
> +	 */
> +	writel(data->slope, &reg->tmu_control);
> +
> +	writel(INTCLEARALL, &reg->intclear);
> +
> +	/* TMU core enable */
> +	con = readl(&reg->tmu_control);
> +	con |= CORE_EN;
> +
> +	writel(con, &reg->tmu_control);
> +
> +	/* LEV0 LEV1 LEV2 interrupt enable */
> +	writel(INTEN_RISE0 | INTEN_RISE1 | INTEN_RISE2,	&reg->inten);
> +}
> +
> +/*
> + * Initialize TMU device
> + *
> + * @param blob  FDT blob
> + * @return	int value, 0 for success
> + */
> +int tmu_init(const void *blob)
> +{
> +	gbl_info.tmu_state = TMU_STATUS_INIT;
> +	if (get_tmu_fdt_values(&gbl_info, blob) < 0)
> +		return -1;
> +
> +	tmu_setup_parameters(&gbl_info);
> +	gbl_info.tmu_state = TMU_STATUS_NORMAL;
> +	debug("EXYNOS_TMU: Available\n");
> +
> +	return 0;
> +}

Thanks,
Minkyu Kang.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 2/9 v9] EXYNOS5: Implement board_poweroff for Thermal Management Unit
  2013-02-06 13:18 ` [U-Boot] [PATCH 2/9 v9] EXYNOS5: Implement board_poweroff " Akshay Saraswat
@ 2013-02-20  8:38   ` Minkyu Kang
  0 siblings, 0 replies; 15+ messages in thread
From: Minkyu Kang @ 2013-02-20  8:38 UTC (permalink / raw)
  To: u-boot

Dear Akshay,

On 06/02/13 22:18, Akshay Saraswat wrote:
> Adding API in power for system shutdown when tripping value is reached
> in Exynos Thermal Management Unit.
> 
> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes since v8:
> 	- None.
> 
>  arch/arm/cpu/armv7/exynos/power.c        |   15 +++++++++++++++
>  arch/arm/include/asm/arch-exynos/power.h |    1 +
>  2 files changed, 16 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv7/exynos/power.c b/arch/arm/cpu/armv7/exynos/power.c
> index d4bce6d..73f764e 100644
> --- a/arch/arm/cpu/armv7/exynos/power.c
> +++ b/arch/arm/cpu/armv7/exynos/power.c
> @@ -95,3 +95,18 @@ void set_dp_phy_ctrl(unsigned int enable)
>  	if (cpu_is_exynos5())
>  		exynos5_dp_phy_control(enable);
>  }
> +
> +/*
> + * This function never returns.
> + * When called this function makes system hang and PAD driving value high
> + * which in turn makes system power down.
> + */
> +void board_poweroff(void)
> +{
> +	struct exynos5_power *power =
> +		(struct exynos5_power *)samsung_get_base_power();
> +
> +	clrbits_le32(&power->ps_hold_control, POWER_PS_HOLD_CONTROL_DATA_HIGH);
> +
> +	hang();
> +}

We can use set_ps_hold_ctrl function with little modification.
Could you please check this?

Thanks,
Minkyu Kang.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 4/9 v9] EXYNOS5: TMU: Add TMU init and status check
  2013-02-06 13:18 ` [U-Boot] [PATCH 4/9 v9] EXYNOS5: TMU: Add TMU init and status check Akshay Saraswat
@ 2013-02-20  8:41   ` Minkyu Kang
  0 siblings, 0 replies; 15+ messages in thread
From: Minkyu Kang @ 2013-02-20  8:41 UTC (permalink / raw)
  To: u-boot

On 06/02/13 22:18, Akshay Saraswat wrote:
> This adds call to tmu_init() and TMU boot time analysis
> for the SoC temperature threshold breach.
> 
> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes since v8:
> 	- None.
> 
>  board/samsung/smdk5250/smdk5250.c |   35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
> index 7a5f132..7b9a8c5 100644
> --- a/board/samsung/smdk5250/smdk5250.c
> +++ b/board/samsung/smdk5250/smdk5250.c
> @@ -35,9 +35,35 @@
>  #include <asm/arch/sromc.h>
>  #include <asm/arch/dp_info.h>
>  #include <power/pmic.h>
> +#include <tmu.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> +#if defined CONFIG_EXYNOS_TMU
> +/*
> + * Boot Time Thermal Analysis for SoC temperature threshold breach
> + */
> +void boot_temp_check(void)

static?

> +{
> +	int temp;
> +
> +	switch (tmu_monitor(&temp)) {
> +	case TMU_STATUS_TRIPPED:
> +		puts("EXYNOS_TMU: TRIPPING! Device power going down ...\n");
> +		board_poweroff();
> +		break;
> +	case TMU_STATUS_WARNING:
> +		puts("EXYNOS_TMU: WARNING! Temperature very high\n");
> +		break;
> +	case TMU_STATUS_NORMAL:
> +		break;

no action? then please remove it.

> +	case TMU_STATUS_INIT:

is it unknown state?

> +	default:
> +		debug("Unknown TMU state\n");
> +	}
> +}
> +#endif
> +
>  #ifdef CONFIG_USB_EHCI_EXYNOS
>  int board_usb_vbus_init(void)
>  {
> @@ -57,6 +83,15 @@ int board_usb_vbus_init(void)
>  int board_init(void)
>  {
>  	gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
> +
> +#if defined CONFIG_EXYNOS_TMU
> +	if (tmu_init(gd->fdt_blob)) {
> +		debug("%s: Failed to init TMU\n", __func__);
> +		return -1;
> +	}
> +	boot_temp_check();
> +#endif
> +
>  #ifdef CONFIG_EXYNOS_SPI
>  	spi_init();
>  #endif
> 

Thanks,
Minkyu Kang.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] [PATCH 8/9 v9] EXYNOS5: TMU: Add hardware tripping
  2013-02-06 13:18 ` [U-Boot] [PATCH 8/9 v9] EXYNOS5: TMU: Add hardware tripping Akshay Saraswat
@ 2013-02-20  8:46   ` Minkyu Kang
  0 siblings, 0 replies; 15+ messages in thread
From: Minkyu Kang @ 2013-02-20  8:46 UTC (permalink / raw)
  To: u-boot

Dear Akshay,

On 06/02/13 22:18, Akshay Saraswat wrote:
> This adds hardware tripping at 110 degrees celsius which must enable
> forced system shutdown in case TMU fails to power off.
> 
> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes since v8:
> 	- None.
> 
>  arch/arm/cpu/armv7/exynos/power.c        |   10 ++++++++++
>  arch/arm/include/asm/arch-exynos/power.h |    5 +++++
>  drivers/power/exynos-tmu.c               |   25 ++++++++++++++++++++-----
>  3 files changed, 35 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv7/exynos/power.c b/arch/arm/cpu/armv7/exynos/power.c
> index 73f764e..234c9f4 100644
> --- a/arch/arm/cpu/armv7/exynos/power.c
> +++ b/arch/arm/cpu/armv7/exynos/power.c
> @@ -96,6 +96,16 @@ void set_dp_phy_ctrl(unsigned int enable)
>  		exynos5_dp_phy_control(enable);
>  }
>  
> +/* Enables hardware tripping to power off the system when TMU fails */
> +void power_enable_hw_thermal_trip(void)

please change function name to set_hw_thermal_trip.
and this function should consider exynos4 also.
please refer other functions.

> +{
> +	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);
> +}
> +
>  /*
>   * This function never returns.
>   * When called this function makes system hang and PAD driving value high
> diff --git a/arch/arm/include/asm/arch-exynos/power.h b/arch/arm/include/asm/arch-exynos/power.h
> index 7463036..034774f 100644
> --- a/arch/arm/include/asm/arch-exynos/power.h
> +++ b/arch/arm/include/asm/arch-exynos/power.h
> @@ -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 power_enable_hw_thermal_trip(void);
> +
>  #define POWER_USB_HOST_PHY_CTRL_EN		(1 << 0)
>  #define POWER_USB_HOST_PHY_CTRL_DISABLE		(0 << 0)
>  
> @@ -864,5 +867,7 @@ void set_dp_phy_ctrl(unsigned int enable);
>  
>  #define EXYNOS_DP_PHY_ENABLE		(1 << 0)
>  #define POWER_PS_HOLD_CONTROL_DATA_HIGH         (1 << 8)
> +#define POWER_ENABLE_HW_TRIP			(1UL << 31)
> +

please remove extra space.

>  
>  #endif
> diff --git a/drivers/power/exynos-tmu.c b/drivers/power/exynos-tmu.c
> index b010883..5885ce7 100644
> --- a/drivers/power/exynos-tmu.c
> +++ b/drivers/power/exynos-tmu.c
> @@ -22,9 +22,11 @@
>  #include <fdtdec.h>
>  #include <tmu.h>
>  #include <asm/arch/exynos-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 */
> @@ -195,6 +199,9 @@ 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;
> @@ -228,7 +235,7 @@ int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
>  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;
> @@ -252,9 +259,14 @@ 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, &reg->threshold_temp_rise);
> @@ -274,12 +286,15 @@ void tmu_setup_parameters(struct tmu_info *info)
>  
>  	/* TMU core enable */
>  	con = readl(&reg->tmu_control);
> -	con |= CORE_EN;
> +	con |= THERM_TRIP_EN | CORE_EN;
>  
>  	writel(con, &reg->tmu_control);
>  
> -	/* LEV0 LEV1 LEV2 interrupt enable */
> -	writel(INTEN_RISE0 | INTEN_RISE1 | INTEN_RISE2,	&reg->inten);
> +	/* Enable HW thermal trip */
> +	power_enable_hw_thermal_trip();
> +
> +	/* LEV1 LEV2 interrupt enable */
> +	writel(INTEN_RISE1 | INTEN_RISE2, &reg->inten);
>  }
>  
>  /*
> 

Thanks,
Minkyu Kang.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-02-20  8:46 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-06 13:18 [U-Boot] [PATCH 0/9 v9] Add TMU support for Exynos5250 based SMDK5250 Akshay Saraswat
2013-02-06 13:18 ` [U-Boot] [PATCH 1/9 v9] EXYNOS5: TMU: Add driver for Thermal Management Unit Akshay Saraswat
2013-02-20  8:36   ` Minkyu Kang
2013-02-06 13:18 ` [U-Boot] [PATCH 2/9 v9] EXYNOS5: Implement board_poweroff " Akshay Saraswat
2013-02-20  8:38   ` Minkyu Kang
2013-02-06 13:18 ` [U-Boot] [PATCH 3/9 v9] EXYNOS5: FDT: Add TMU device node values Akshay Saraswat
2013-02-06 13:18 ` [U-Boot] [PATCH 4/9 v9] EXYNOS5: TMU: Add TMU init and status check Akshay Saraswat
2013-02-20  8:41   ` Minkyu Kang
2013-02-06 13:18 ` [U-Boot] [PATCH 5/9 v9] EXYNOS5: Config: Enable support for Exynos TMU driver Akshay Saraswat
2013-02-06 13:18 ` [U-Boot] [PATCH 6/9 v9] TMU: Add TMU support in dtt command Akshay Saraswat
2013-02-06 16:36   ` Simon Glass
2013-02-06 13:18 ` [U-Boot] [PATCH 7/9 v9] EXYNOS5: Config: Enable dtt command for TMU Akshay Saraswat
2013-02-06 13:18 ` [U-Boot] [PATCH 8/9 v9] EXYNOS5: TMU: Add hardware tripping Akshay Saraswat
2013-02-20  8:46   ` Minkyu Kang
2013-02-06 13:18 ` [U-Boot] [PATCH 9/9 v9] EXYNOS5: FDT: Add a H/W-trip member to TMU node Akshay Saraswat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox