Patchwork [U-Boot,6/9,v6] TMU: Add TMU support in dtt command

login
register
mail settings
Submitter Akshay Saraswat
Date Jan. 23, 2013, 3:24 p.m.
Message ID <1358954681-6217-7-git-send-email-akshay.s@samsung.com>
Download mbox | patch
Permalink /patch/214988/
State Superseded
Delegated to: Minkyu Kang
Headers show

Comments

Akshay Saraswat - Jan. 23, 2013, 3:24 p.m.
Add generic TMU support alongwith i2c sensors in dtt command
to enable temperature reading in cases where TMU is present
instead of i2c sensors.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
---
Changes since v5:
	- Changed 'pirntf' to 'puts'.
	- Added 'return -1' in case of erroneous tmu_state.

 common/cmd_dtt.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
Simon Glass - Jan. 25, 2013, 8:58 p.m.
On Thu, Jan 24, 2013 at 4:24 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
> instead of i2c sensors.
>
> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
> ---
> Changes since v5:
>         - Changed 'pirntf' to 'puts'.
>         - Added 'return -1' in case of erroneous tmu_state.

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

>
>  common/cmd_dtt.c |   22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
> index cd94423..493f643 100644
> --- a/common/cmd_dtt.c
> +++ b/common/cmd_dtt.c
> @@ -28,6 +28,23 @@
>  #include <dtt.h>
>  #include <i2c.h>
>
> +#if defined CONFIG_TMU_CMD_DTT
> +#include <tmu.h>
> +
> +int dtt_get_temp(void)
> +{
> +       int cur_temp;
> +
> +       if (tmu_monitor(&cur_temp) == TMU_STATUS_INIT) {
> +               puts("TMU is in unknown state, temperature is invalid\n");
> +               return -1;
> +       } else {
> +               printf("Current temperature: %u degrees Celsius\n", cur_temp);
> +               return 0;
> +       }
> +}
> +
> +#else
>  static unsigned long sensor_initialized;
>
>  static void _initialize_dtt(void)
> @@ -59,9 +76,13 @@ 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[])
>  {
> +#if defined CONFIG_TMU_CMD_DTT
> +       return dtt_get_temp();
> +#else
>         int i;
>         unsigned char sensors[] = CONFIG_DTT_SENSORS;
>         int old_bus;
> @@ -85,6 +106,7 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
>         I2C_SET_BUS(old_bus);
>
>         return 0;
> +#endif
>  }      /* do_dtt() */
>
>  /***************************************************/
> --
> 1.7.9.5
>

Patch

diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index cd94423..493f643 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -28,6 +28,23 @@ 
 #include <dtt.h>
 #include <i2c.h>
 
+#if defined CONFIG_TMU_CMD_DTT
+#include <tmu.h>
+
+int dtt_get_temp(void)
+{
+	int cur_temp;
+
+	if (tmu_monitor(&cur_temp) == TMU_STATUS_INIT) {
+		puts("TMU is in unknown state, temperature is invalid\n");
+		return -1;
+	} else {
+		printf("Current temperature: %u degrees Celsius\n", cur_temp);
+		return 0;
+	}
+}
+
+#else
 static unsigned long sensor_initialized;
 
 static void _initialize_dtt(void)
@@ -59,9 +76,13 @@  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[])
 {
+#if defined CONFIG_TMU_CMD_DTT
+	return dtt_get_temp();
+#else
 	int i;
 	unsigned char sensors[] = CONFIG_DTT_SENSORS;
 	int old_bus;
@@ -85,6 +106,7 @@  int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	I2C_SET_BUS(old_bus);
 
 	return 0;
+#endif
 }	/* do_dtt() */
 
 /***************************************************/