3 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com
5 * SPDX-License-Identifier: GPL-2.0+
16 #if defined CONFIG_DTT_SENSORS
17 static unsigned long sensor_initialized;
19 static void _initialize_dtt(void)
22 unsigned char sensors[] = CONFIG_DTT_SENSORS;
24 for (i = 0; i < sizeof(sensors); i++) {
25 if ((sensor_initialized & (1 << i)) == 0) {
26 if (dtt_init_one(sensors[i]) != 0) {
27 printf("DTT%d: Failed init!\n", i);
30 sensor_initialized |= (1 << i);
39 /* switch to correct I2C bus */
40 old_bus = I2C_GET_BUS();
41 I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
45 /* switch back to original I2C bus */
52 #if defined CONFIG_DTT_SENSORS
54 unsigned char sensors[] = CONFIG_DTT_SENSORS;
57 /* Force a compilation error, if there are more then 32 sensors */
58 BUILD_BUG_ON(sizeof(sensors) > 32);
59 /* switch to correct I2C bus */
61 old_bus = i2c_get_bus_num();
62 i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
64 old_bus = I2C_GET_BUS();
65 I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
71 * Loop through sensors, read
72 * temperature, and output it.
74 for (i = 0; i < sizeof(sensors); i++)
75 printf("DTT%d: %i C\n", i + 1, dtt_get_temp(sensors[i]));
77 /* switch back to original I2C bus */
79 i2c_set_bus_num(old_bus);
90 #if defined CONFIG_TMU_CMD_DTT
93 /* Sense and return latest thermal info */
94 if (tmu_monitor(&cur_temp) == TMU_STATUS_INIT) {
95 puts("TMU is in unknown state, temperature is invalid\n");
98 printf("Current temperature: %u degrees Celsius\n", cur_temp);
103 int do_dtt(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
113 /***************************************************/
117 "Read temperature from Digital Thermometer and Thermostat",