This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
iq80321 battery fix
- From: Mark Salter <msalter at redhat dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Wed, 12 Feb 2003 08:34:20 -0500 (EST)
- Subject: iq80321 battery fix
Index: hal/arm/xscale/iq80321/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/xscale/iq80321/current/ChangeLog,v
retrieving revision 1.11
diff -u -p -5 -r1.11 ChangeLog
--- hal/arm/xscale/iq80321/current/ChangeLog 30 Jan 2003 14:47:52 -0000 1.11
+++ hal/arm/xscale/iq80321/current/ChangeLog 12 Feb 2003 13:30:38 -0000
@@ -1,5 +1,10 @@
+2003-02-12 Mark Salter <msalter@redhat.com>
+
+ * include/iq80321.h: Fix battery defines.
+ * src/diag/battery.c: Fix battery tests to match updated docs.
+
2003-01-30 Mark Salter <msalter@redhat.com>
* include/pkgconf/mlt_*: Adjust RAM size to match max supported.
Actual size of installed RAM determined at runtime.
Index: hal/arm/xscale/iq80321/current/include/iq80321.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/xscale/iq80321/current/include/iq80321.h,v
retrieving revision 1.2
diff -u -p -5 -r1.2 iq80321.h
--- hal/arm/xscale/iq80321/current/include/iq80321.h 23 May 2002 23:02:32 -0000 1.2
+++ hal/arm/xscale/iq80321/current/include/iq80321.h 12 Feb 2003 13:31:02 -0000
@@ -9,11 +9,11 @@
//
//=============================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -94,16 +94,20 @@
#define I2C_TIMOUT 0x1000000
// ------------------------------------------------------------------------
// Battery Status
//
-#define IQ80321_BATTERY_DISCHARGE 0x10
-#define IQ80321_BATTERY_CHARGE 0x04
-#define IQ80321_BATTERY_PRESENT 0x02
+#define IQ80321_BATTERY_NOT_PRESENT 0x01
+#define IQ80321_BATTERY_CHARGE 0x02
+#define IQ80321_BATTERY_ENABLE 0x04
+#define IQ80321_BATTERY_DISCHARGE 0x08
+
+#define IQ80321_BATTERY_STATUS ((volatile unsigned short *)IQ80321_BATTERY_STATUS_ADDR)
// Address used for battery backup test
#define SDRAM_BATTERY_TEST_ADDR (SDRAM_UNCACHED_BASE + 0x100000)
+
// ------------------------------------------------------------------------
// 7 Segment Display
#define DISPLAY_LEFT IQ80321_DISPLAY_LEFT_ADDR
#define DISPLAY_RIGHT IQ80321_DISPLAY_RIGHT_ADDR
Index: hal/arm/xscale/iq80321/current/src/diag/battery.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/xscale/iq80321/current/src/diag/battery.c,v
retrieving revision 1.2
diff -u -p -5 -r1.2 battery.c
--- hal/arm/xscale/iq80321/current/src/diag/battery.c 23 May 2002 23:02:33 -0000 1.2
+++ hal/arm/xscale/iq80321/current/src/diag/battery.c 12 Feb 2003 13:31:02 -0000
@@ -4,11 +4,11 @@
//
//=============================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -58,23 +58,22 @@ extern void diag_wait(void);
// test battery status
void
battery_status(MENU_ARG arg)
{
- unsigned char status;
+ unsigned short status;
// read battery status port
- status = *(unsigned char *)IQ80321_BATTERY_STATUS_ADDR;
+ status = *IQ80321_BATTERY_STATUS;
// examine bit b0 BATT_PRES#
- if (status & IQ80321_BATTERY_PRESENT)
- diag_printf("A battery is installed.\n");
- else {
+ if (status & IQ80321_BATTERY_NOT_PRESENT) {
diag_printf("No battery installed.\n");
diag_wait();
return;
}
+ diag_printf("A battery is installed.\n");
if (status & IQ80321_BATTERY_CHARGE)
diag_printf("Battery is fully charged.\n");
else
diag_printf("Battery is charging.\n");
@@ -82,10 +81,15 @@ battery_status(MENU_ARG arg)
if (status & IQ80321_BATTERY_DISCHARGE)
diag_printf("Battery is fully discharged.\n");
else
diag_printf("Battery voltage measures within normal operating range.\n");
+ if (status & IQ80321_BATTERY_ENABLE)
+ diag_printf("Battery Backup is enabled.\n");
+ else
+ diag_printf("Battery Backup is disabled.\n");
+
diag_wait();
}
#ifdef CYGSEM_HAL_ARM_IQ80321_BATTERY_TEST
@@ -93,10 +97,16 @@ battery_status(MENU_ARG arg)
// been powered off and powered back on
static void
battery_test_write (MENU_ARG arg)
{
+ *IQ80321_BATTERY_STATUS |= IQ80321_BATTERY_ENABLE;
+ if (*IQ80321_BATTERY_STATUS & IQ80321_BATTERY_ENABLE)
+ diag_printf("The battery backup has now been enabled.\n");
+ else
+ diag_printf("Unable to enable battery backup.\n");
+
*(volatile unsigned *)SDRAM_BATTERY_TEST_ADDR = TEST_PATTERN;
diag_printf("The value '%p' is now written to DRAM at address %p.\n",
TEST_PATTERN, SDRAM_BATTERY_TEST_ADDR);
diag_printf("\nYou may now power the board off, wait 60 seconds and power it back on.\n");
@@ -107,10 +117,16 @@ battery_test_write (MENU_ARG arg)
static void
battery_test_read (MENU_ARG arg)
{
cyg_uint32 value;
+
+ *IQ80321_BATTERY_STATUS &= ~IQ80321_BATTERY_ENABLE;
+ if (*IQ80321_BATTERY_STATUS & IQ80321_BATTERY_ENABLE)
+ diag_printf("Unable to disable battery backup.\n");
+ else
+ diag_printf("The battery backup has now been disabled.\n");
value = *(volatile unsigned *)SDRAM_BATTERY_TEST_ADDR;
diag_printf ("Value written at address %p: %p\n",
SDRAM_BATTERY_TEST_ADDR, TEST_PATTERN);