[U-Boot] [PATCH 6/7 v5] TMU: Add TMU support in dtt command

Simon Glass sjg at chromium.org
Tue Jan 22 21:51:11 CET 2013


Hi Akshay,

On Mon, Jan 21, 2013 at 3:11 AM, Akshay Saraswat <akshay.s at 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 at samsung.com>
> ---
> Changes since v4:
>         - Removed tmu command and added to dtt.
>
>  common/cmd_dtt.c |   19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
> index cd94423..715f4ba 100644
> --- a/common/cmd_dtt.c
> +++ b/common/cmd_dtt.c
> @@ -28,6 +28,20 @@
>  #include <dtt.h>
>  #include <i2c.h>
>
> +#if defined CONFIG_TMU_CMD_DTT
> +#include <tmu.h>
> +
> +void dtt_get_temp(void)
> +{
> +       int cur_temp;
> +
> +       if (tmu_monitor(&cur_temp) == TMU_STATUS_INIT)
> +               printf("TMU is in unknown state, temperature is invalid \n");

puts()

Should return an error result here so that do_dtt() returns 1.

> +       else
> +               printf("Current temperature: %u degrees Celsius \n", cur_temp);
> +}
> +
> +#else
>  static unsigned long sensor_initialized;
>
>  static void _initialize_dtt(void)
> @@ -59,9 +73,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
> +       dtt_get_temp();
> +#else

How about creating two versions of the dtt_get_temp() function: one
with your code and one with the old code? Then you don't have an
#ifdef here.



>         int i;
>         unsigned char sensors[] = CONFIG_DTT_SENSORS;
>         int old_bus;
> @@ -83,6 +101,7 @@ 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;
>  }      /* do_dtt() */
> --
> 1.7.9.5
>

Regards,
Simon


More information about the U-Boot mailing list