[U-Boot] [PATCH 6/9 v8] TMU: Add TMU support in dtt command
Akshay Saraswat
akshay.s at samsung.com
Tue Feb 5 12:57:14 CET 2013
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 v7:
- Made sensor_initialized static again.
- Changed return type to int in dtt_init declaration.
common/cmd_dtt.c | 63 ++++++++++++++++++++++++++++++++----------------------
include/dtt.h | 2 +-
2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index cd94423..799e1c7 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -27,52 +27,52 @@
#include <dtt.h>
#include <i2c.h>
+#include <tmu.h>
+#if defined CONFIG_DTT_SENSORS
static unsigned long sensor_initialized;
+#endif
-static void _initialize_dtt(void)
+int dtt_tmu(void)
{
- int i;
- unsigned char sensors[] = CONFIG_DTT_SENSORS;
+#if defined CONFIG_TMU_CMD_DTT
+ int cur_temp;
- for (i = 0; i < sizeof(sensors); i++) {
- if ((sensor_initialized & (1 << i)) == 0) {
- if (dtt_init_one(sensors[i]) != 0) {
- printf("DTT%d: Failed init!\n", i);
- continue;
- }
- sensor_initialized |= (1 << i);
- }
+ /* 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;
}
-}
-
-void dtt_init(void)
-{
- int old_bus;
-
- /* switch to correct I2C bus */
- old_bus = I2C_GET_BUS();
- I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
-
- _initialize_dtt();
+ printf("Current temperature: %u degrees Celsius\n", cur_temp);
+#endif
- /* switch back to original I2C bus */
- I2C_SET_BUS(old_bus);
+ return 0;
}
-int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+int dtt_init(void)
{
+#if defined CONFIG_DTT_SENSORS
int i;
unsigned char sensors[] = CONFIG_DTT_SENSORS;
int old_bus;
/* Force a compilation error, if there are more then 32 sensors */
BUILD_BUG_ON(sizeof(sensors) > 32);
+
/* switch to correct I2C bus */
old_bus = I2C_GET_BUS();
I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
- _initialize_dtt();
+ /* Initialize dtt sensors */
+ for (i = 0; i < sizeof(sensors); i++) {
+ if ((sensor_initialized & (1 << i)) == 0) {
+ if (dtt_init_one(sensors[i]) != 0) {
+ printf("DTT%d: Failed init!\n", i);
+ continue;
+ }
+ sensor_initialized |= (1 << i);
+ }
+ }
/*
* Loop through sensors, read
@@ -83,8 +83,19 @@ 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 do_dtt(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ int err = 0;
+
+ err |= dtt_init();
+ err |= dtt_tmu();
+
+ return err;
} /* do_dtt() */
/***************************************************/
diff --git a/include/dtt.h b/include/dtt.h
index 6d5534d..94fbce3 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -52,7 +52,7 @@
#endif
#endif /* CONFIG_DTT_ADM1021 */
-extern void dtt_init(void);
+extern int dtt_init(void);
extern int dtt_init_one(int);
extern int dtt_read(int sensor, int reg);
extern int dtt_write(int sensor, int reg, int val);
--
1.7.9.5
More information about the U-Boot
mailing list