upstream u-boot with additional patches for our devices/boards:
https://lists.denx.de/pipermail/u-boot/2017-March/282789.html (AXP crashes) ;
Gbit ethernet patch for some LIME2 revisions ;
with SPI flash support
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
2.2 KiB
120 lines
2.2 KiB
22 years ago
|
/*
|
||
|
* (C) Copyright 2001
|
||
|
* Erik Theisen, Wave 7 Optics, etheisen@mindspring.com
|
||
|
*
|
||
11 years ago
|
* SPDX-License-Identifier: GPL-2.0+
|
||
22 years ago
|
*/
|
||
|
|
||
|
#include <common.h>
|
||
|
#include <config.h>
|
||
|
#include <command.h>
|
||
|
|
||
|
#include <dtt.h>
|
||
17 years ago
|
#include <i2c.h>
|
||
11 years ago
|
#include <tmu.h>
|
||
22 years ago
|
|
||
11 years ago
|
#if defined CONFIG_DTT_SENSORS
|
||
13 years ago
|
static unsigned long sensor_initialized;
|
||
|
|
||
13 years ago
|
static void _initialize_dtt(void)
|
||
|
{
|
||
|
int i;
|
||
|
unsigned char sensors[] = CONFIG_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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
|
||
|
/* switch back to original I2C bus */
|
||
|
I2C_SET_BUS(old_bus);
|
||
|
}
|
||
11 years ago
|
#endif
|
||
13 years ago
|
|
||
11 years ago
|
int dtt_i2c(void)
|
||
22 years ago
|
{
|
||
11 years ago
|
#if defined CONFIG_DTT_SENSORS
|
||
22 years ago
|
int i;
|
||
|
unsigned char sensors[] = CONFIG_DTT_SENSORS;
|
||
17 years ago
|
int old_bus;
|
||
|
|
||
13 years ago
|
/* Force a compilation error, if there are more then 32 sensors */
|
||
|
BUILD_BUG_ON(sizeof(sensors) > 32);
|
||
17 years ago
|
/* switch to correct I2C bus */
|
||
12 years ago
|
#ifdef CONFIG_SYS_I2C
|
||
|
old_bus = i2c_get_bus_num();
|
||
|
i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
|
||
|
#else
|
||
17 years ago
|
old_bus = I2C_GET_BUS();
|
||
16 years ago
|
I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
|
||
12 years ago
|
#endif
|
||
22 years ago
|
|
||
13 years ago
|
_initialize_dtt();
|
||
|
|
||
22 years ago
|
/*
|
||
|
* Loop through sensors, read
|
||
|
* temperature, and output it.
|
||
|
*/
|
||
13 years ago
|
for (i = 0; i < sizeof(sensors); i++)
|
||
13 years ago
|
printf("DTT%d: %i C\n", i + 1, dtt_get_temp(sensors[i]));
|
||
17 years ago
|
|
||
|
/* switch back to original I2C bus */
|
||
12 years ago
|
#ifdef CONFIG_SYS_I2C
|
||
|
i2c_set_bus_num(old_bus);
|
||
|
#else
|
||
17 years ago
|
I2C_SET_BUS(old_bus);
|
||
11 years ago
|
#endif
|
||
12 years ago
|
#endif
|
||
22 years ago
|
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
|
|
||
|
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;
|
||
22 years ago
|
} /* do_dtt() */
|
||
|
|
||
21 years ago
|
/***************************************************/
|
||
|
|
||
21 years ago
|
U_BOOT_CMD(
|
||
|
dtt, 1, 1, do_dtt,
|
||
15 years ago
|
"Read temperature from Digital Thermometer and Thermostat",
|
||
|
""
|
||
21 years ago
|
);
|