Mercurial > ecos
changeset 591:3e913eba92cc
iq80321 battery fix
| author | msalter |
|---|---|
| date | Wed, 12 Feb 2003 13:34:02 +0000 |
| parents | 8cd2a5dfbb00 |
| children | 52b1b868a0ef |
| files | packages/hal/arm/xscale/iq80321/current/ChangeLog packages/hal/arm/xscale/iq80321/current/include/iq80321.h packages/hal/arm/xscale/iq80321/current/src/diag/battery.c |
| diffstat | 3 files changed, 35 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/hal/arm/xscale/iq80321/current/ChangeLog +++ b/packages/hal/arm/xscale/iq80321/current/ChangeLog @@ -1,3 +1,8 @@ +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.
--- a/packages/hal/arm/xscale/iq80321/current/include/iq80321.h +++ b/packages/hal/arm/xscale/iq80321/current/include/iq80321.h @@ -11,7 +11,7 @@ //####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 @@ -96,13 +96,17 @@ // ------------------------------------------------------------------------ // 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
--- a/packages/hal/arm/xscale/iq80321/current/src/diag/battery.c +++ b/packages/hal/arm/xscale/iq80321/current/src/diag/battery.c @@ -6,7 +6,7 @@ //####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 @@ -60,19 +60,18 @@ extern void diag_wait(void); 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"); @@ -84,6 +83,11 @@ battery_status(MENU_ARG arg) 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(); } @@ -95,6 +99,12 @@ battery_status(MENU_ARG arg) 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", @@ -110,6 +120,12 @@ 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",
