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.
143 lines
1.8 KiB
143 lines
1.8 KiB
22 years ago
|
|
||
|
#include <common.h>
|
||
|
|
||
|
#ifdef CONFIG_DS1722
|
||
|
|
||
17 years ago
|
#include <ssi.h>
|
||
|
|
||
22 years ago
|
static void ds1722_select(int dev)
|
||
|
{
|
||
|
ssi_set_interface(4096, 0, 0, 0);
|
||
|
ssi_chip_select(0);
|
||
|
udelay(1);
|
||
|
ssi_chip_select(dev);
|
||
|
udelay(1);
|
||
|
}
|
||
|
|
||
|
|
||
|
u8 ds1722_read(int dev, int addr)
|
||
|
{
|
||
|
u8 res;
|
||
22 years ago
|
|
||
22 years ago
|
ds1722_select(dev);
|
||
22 years ago
|
|
||
|
ssi_tx_byte(addr);
|
||
|
res = ssi_rx_byte();
|
||
|
|
||
22 years ago
|
ssi_chip_select(0);
|
||
22 years ago
|
|
||
22 years ago
|
return res;
|
||
|
}
|
||
|
|
||
|
void ds1722_write(int dev, int addr, u8 data)
|
||
|
{
|
||
|
ds1722_select(dev);
|
||
22 years ago
|
|
||
|
ssi_tx_byte(0x80|addr);
|
||
|
ssi_tx_byte(data);
|
||
|
|
||
22 years ago
|
ssi_chip_select(0);
|
||
|
}
|
||
|
|
||
|
|
||
|
u16 ds1722_temp(int dev, int resolution)
|
||
|
{
|
||
|
static int useconds[] = {
|
||
22 years ago
|
75000, 150000, 300000, 600000, 1200000
|
||
22 years ago
|
};
|
||
|
char temp;
|
||
|
u16 res;
|
||
22 years ago
|
|
||
|
|
||
22 years ago
|
/* set up the desired resulotion ... */
|
||
|
ds1722_write(dev, 0, 0xe0 | (resolution << 1));
|
||
22 years ago
|
|
||
22 years ago
|
/* wait while the chip measures the tremperature */
|
||
22 years ago
|
udelay(useconds[resolution]);
|
||
|
|
||
22 years ago
|
res = (temp = ds1722_read(dev, 2)) << 8;
|
||
22 years ago
|
|
||
|
if (temp < 0) {
|
||
22 years ago
|
temp = (16 - (ds1722_read(dev, 1) >> 4)) & 0x0f;
|
||
|
} else {
|
||
|
temp = (ds1722_read(dev, 1) >> 4);
|
||
|
}
|
||
22 years ago
|
|
||
22 years ago
|
switch (temp) {
|
||
|
case 0:
|
||
|
/* .0000 */
|
||
|
break;
|
||
|
case 1:
|
||
|
/* .0625 */
|
||
|
res |=1;
|
||
|
break;
|
||
|
case 2:
|
||
|
/* .1250 */
|
||
|
res |=1;
|
||
|
break;
|
||
|
case 3:
|
||
|
/* .1875 */
|
||
|
res |=2;
|
||
|
break;
|
||
|
case 4:
|
||
|
/* .2500 */
|
||
|
res |=3;
|
||
|
break;
|
||
|
case 5:
|
||
|
/* .3125 */
|
||
|
res |=3;
|
||
|
break;
|
||
|
case 6:
|
||
|
/* .3750 */
|
||
|
res |=4;
|
||
|
break;
|
||
|
case 7:
|
||
|
/* .4375 */
|
||
|
res |=4;
|
||
|
break;
|
||
|
case 8:
|
||
|
/* .5000 */
|
||
|
res |=5;
|
||
|
break;
|
||
|
case 9:
|
||
|
/* .5625 */
|
||
|
res |=6;
|
||
|
break;
|
||
|
case 10:
|
||
|
/* .6250 */
|
||
|
res |=6;
|
||
|
break;
|
||
|
case 11:
|
||
|
/* .6875 */
|
||
|
res |=7;
|
||
|
break;
|
||
|
case 12:
|
||
|
/* .7500 */
|
||
|
res |=8;
|
||
|
break;
|
||
|
case 13:
|
||
|
/* .8125 */
|
||
|
res |=8;
|
||
|
break;
|
||
|
case 14:
|
||
|
/* .8750 */
|
||
|
res |=9;
|
||
|
break;
|
||
|
case 15:
|
||
|
/* .9375 */
|
||
|
res |=9;
|
||
|
break;
|
||
|
}
|
||
|
return res;
|
||
22 years ago
|
|
||
22 years ago
|
}
|
||
|
|
||
|
int ds1722_probe(int dev)
|
||
|
{
|
||
|
u16 temp = ds1722_temp(dev, DS1722_RESOLUTION_12BIT);
|
||
|
printf("%d.%d deg C\n\n", (char)(temp >> 8), temp & 0xff);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
#endif
|