summaryrefslogtreecommitdiff
path: root/post/board/lwmon5/dspic.c
diff options
context:
space:
mode:
authorYuri Tikhonov <yur@emcraft.com>2008-03-24 11:29:14 +0100
committerWolfgang Denk <wd@denx.de>2008-03-25 00:14:46 +0100
commitff2bdfb2c1e073f65c065011f1e18d0a130bd3d8 (patch)
treea5dff9815dbd9d9881655d01fb6bd176342cefce /post/board/lwmon5/dspic.c
parentb38d7fc2f1d27957a810950f07c27f2be353f50f (diff)
downloadu-boot-imx-ff2bdfb2c1e073f65c065011f1e18d0a130bd3d8.zip
u-boot-imx-ff2bdfb2c1e073f65c065011f1e18d0a130bd3d8.tar.gz
u-boot-imx-ff2bdfb2c1e073f65c065011f1e18d0a130bd3d8.tar.bz2
lwmon5 SYSMON POST: fix handling of negative temperatures
Fix errors in the LWMON5 Sysmon POST for negative temperatures. Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
Diffstat (limited to 'post/board/lwmon5/dspic.c')
-rw-r--r--post/board/lwmon5/dspic.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/post/board/lwmon5/dspic.c b/post/board/lwmon5/dspic.c
index dbaa074..fcbbc60 100644
--- a/post/board/lwmon5/dspic.c
+++ b/post/board/lwmon5/dspic.c
@@ -59,25 +59,27 @@ int dspic_init_post_test(int flags)
#if CONFIG_POST & CFG_POST_BSPEC2
/* Read a register from the dsPIC. */
-int dspic_read(ushort reg)
+int dspic_read(ushort reg, ushort *data)
{
- uchar buf[2];
+ uchar buf[sizeof(*data)];
+ int rval;
- if (i2c_read(CFG_I2C_DSPIC_IO_ADDR, reg, 2, buf, 2))
- return -1;
+ rval = i2c_read(CFG_I2C_DSPIC_IO_ADDR, reg, sizeof(reg),
+ buf, sizeof(*data));
- return (uint)((buf[0] << 8) | buf[1]);
+ *data = (buf[0] << 8) | buf[1];
+
+ return rval;
}
/* Verify error codes regs, display version */
int dspic_post_test(int flags)
{
- int data;
+ ushort data;
int ret = 0;
post_log("\n");
- data = dspic_read(DSPIC_VERSION_REG);
- if (data == -1) {
+ if (dspic_read(DSPIC_VERSION_REG, &data)) {
post_log("dsPIC : failed read version\n");
ret = 1;
} else {
@@ -85,16 +87,15 @@ int dspic_post_test(int flags)
(data >> 8) & 0xFF, data & 0xFF);
}
- data = dspic_read(DSPIC_POST_ERROR_REG);
- if (data != 0) ret = 1;
- if (data == -1) {
+ if (dspic_read(DSPIC_POST_ERROR_REG, &data)) {
post_log("dsPIC : failed read POST code\n");
} else {
post_log("dsPIC POST code 0x%04X\n", data);
}
+ if (data != 0)
+ ret = 1;
- data = dspic_read(DSPIC_SYS_ERROR_REG);
- if (data == -1) {
+ if (dspic_read(DSPIC_SYS_ERROR_REG, &data)) {
post_log("dsPIC : failed read system error\n");
ret = 1;
} else if (data != 0) {