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

login
register
mail settings
Submitter Akshay Saraswat
Date Feb. 6, 2013, 1:18 p.m.
Message ID <1360156726-13315-7-git-send-email-akshay.s@samsung.com>
Download mbox | patch
Permalink /patch/218594/
State Superseded
Delegated to: Minkyu Kang
Headers show

Comments

Akshay Saraswat - Feb. 6, 2013, 1:18 p.m.
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(-)
Simon Glass - Feb. 6, 2013, 4:36 p.m.
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
>

Patch

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() */
 
 /***************************************************/