]> git.sur5r.net Git - u-boot/blobdiff - post/board/lwmon5/sysmon.c
lwmon5: fix offset error in sysmon0 POST
[u-boot] / post / board / lwmon5 / sysmon.c
index f7e51a3cfe6aa18ef2dcd8f3876308d37d14031c..e9c9624907ecc36a08767a1924f40bd14cd70506 100644 (file)
@@ -25,8 +25,6 @@
 #include <post.h>
 #include <common.h>
 
-#ifdef CONFIG_POST
-
 /*
  * SYSMON test
  *
@@ -34,9 +32,9 @@
  * The test passes when all the following voltages and temperatures
  * are within allowed ranges:
  *
- * Temperature                -40 .. +85 C
- * +5V                      +4.75 .. +5.25 V
- * +5V standby              +4.75 .. +5.25 V
+ * Temperature           -40 .. +90 C
+ * +5V                 +4.50 .. +5.50 V
+ * +5V standby         +3.50 .. +5.50 V
  *
  * LCD backlight is not enabled if temperature values are not within
  * allowed ranges (-30 .. + 80). The brightness of backlite can be
@@ -62,6 +60,21 @@ extern int dspic_read(ushort reg);
 
 #define        RELOC(x) if (x != NULL) x = (void *) ((ulong) (x) + gd->reloc_off)
 
+#define REG_TEMPERATURE                        0x12BC
+#define REG_VOLTAGE_5V                 0x12CA
+#define REG_VOLTAGE_5V_STANDBY         0x12C6
+
+#define TEMPERATURE_MIN                        (-40)   /* degr. C */
+#define TEMPERATURE_MAX                        (+90)   /* degr. C */
+#define TEMPERATURE_DISPLAY_MIN                (-35)   /* degr. C */
+#define TEMPERATURE_DISPLAY_MAX                (+85)   /* degr. C */  
+
+#define VOLTAGE_5V_MIN                 (+4500) /* mV */
+#define VOLTAGE_5V_MAX                 (+5500) /* mV */
+
+#define VOLTAGE_5V_STANDBY_MIN         (+3500) /* mV */
+#define VOLTAGE_5V_STANDBY_MAX         (+5500) /* mV */
+
 typedef struct sysmon_s sysmon_t;
 typedef struct sysmon_table_s sysmon_table_t;
 
@@ -109,17 +122,29 @@ struct sysmon_table_s
 
 static sysmon_table_t sysmon_table[] =
 {
-    {"Temperature", " C", &sysmon_dspic, NULL, sysmon_backlight_disable,
-     1, 1, -32768, 32767, 0xFFFF, 0x8000-40, 0x8000+85, 0,
-                                  0x8000-30, 0x8000+80, 0, 0x12BC},
-
-    {"+ 5 V", "V", &sysmon_dspic, NULL, NULL,
-     100, 1000, -0x8000, 0x7FFF, 0xFFFF, 0x8000+4750, 0x8000+5250, 0,
-                                         0x8000+4750, 0x8000+5250, 0, 0x12CA},
-
-    {"+ 5 V standby", "V", &sysmon_dspic, NULL, NULL,
-     100, 1000, -0x8000, 0x7FFF, 0xFFFF, 0x8000+4750, 0x8000+5250, 0,
-                                         0x8000+4750, 0x8000+5250, 0, 0x12C6},
+       {
+       "Temperature", " C", &sysmon_dspic, NULL, sysmon_backlight_disable,
+       1, 1, -32768, 32767, 0xFFFF,
+       0x8000 + TEMPERATURE_MIN,         0x8000 + TEMPERATURE_MAX,         0,
+       0x8000 + TEMPERATURE_DISPLAY_MIN, 0x8000 + TEMPERATURE_DISPLAY_MAX, 0,
+       REG_TEMPERATURE,
+       },
+
+       {
+       "+ 5 V", "V", &sysmon_dspic, NULL, NULL,
+       100, 1000, -0x8000, 0x7FFF, 0xFFFF,
+       0x8000 + VOLTAGE_5V_MIN, 0x8000 + VOLTAGE_5V_MAX, 0,
+       0x8000 + VOLTAGE_5V_MIN, 0x8000 + VOLTAGE_5V_MAX, 0,
+       REG_VOLTAGE_5V,
+       },
+
+       {
+       "+ 5 V standby", "V", &sysmon_dspic, NULL, NULL,
+       100, 1000, -0x8000, 0x7FFF, 0xFFFF,
+       0x8000 + VOLTAGE_5V_STANDBY_MIN, 0x8000 + VOLTAGE_5V_STANDBY_MAX, 0,
+       0x8000 + VOLTAGE_5V_STANDBY_MIN, 0x8000 + VOLTAGE_5V_STANDBY_MAX, 0,
+       REG_VOLTAGE_5V_STANDBY,
+       },
 };
 static int sysmon_table_size = sizeof(sysmon_table) / sizeof(sysmon_table[0]);
 
@@ -158,8 +183,7 @@ static char *sysmon_unit_value (sysmon_table_t *s, uint val)
        int decimal, frac;
        int unit_val;
 
-       unit_val =
-           s->unit_min + (s->unit_max - s->unit_min) * val / s->val_mask;
+       unit_val = s->unit_min + (s->unit_max - s->unit_min) * val / s->val_mask;
 
        if (val == -1)
                return "I/O ERROR";
@@ -243,6 +267,4 @@ int sysmon_post_test (int flags)
 
        return res;
 }
-
 #endif /* CONFIG_POST & CFG_POST_SYSMON */
-#endif /* CONFIG_POST */