Mercurial > ecos
changeset 221:6a3479d240be
Update for 320D. Support cache flush/disable
| author | gthomas |
|---|---|
| date | Thu, 20 Jun 2002 23:08:04 +0000 |
| parents | e3ee4b61fbea |
| children | 34c1f81105e9 |
| files | packages/devs/flash/amd/am29xxxxx/current/ChangeLog packages/devs/flash/amd/am29xxxxx/current/cdl/flash_amd_am29xxxxx.cdl packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx.inl packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx_parts.inl packages/devs/flash/powerpc/viper/current/ChangeLog packages/devs/flash/powerpc/viper/current/cdl/flash_viper.cdl packages/devs/flash/powerpc/viper/current/src/flash.h packages/devs/flash/powerpc/viper/current/src/flash_erase_block.c packages/devs/flash/powerpc/viper/current/src/flash_program_buf.c packages/devs/flash/powerpc/viper/current/src/flash_query.c packages/devs/flash/powerpc/viper/current/src/viper_flash.c |
| diffstat | 11 files changed, 198 insertions(+), 517 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/devs/flash/amd/am29xxxxx/current/ChangeLog +++ b/packages/devs/flash/amd/am29xxxxx/current/ChangeLog @@ -1,3 +1,11 @@ +2002-06-20 Gary Thomas <gary@chez-thomas.org> + + * include/flash_am29xxxxx.inl: Add cache disable/enable code + since this is required on most platforms. + + * include/flash_am29xxxxx_parts.inl: + * cdl/flash_amd_am29xxxxx.cdl: Add support for AM29LV320D{T|B} + 2002-04-24 Bob Koninckx <bob.koninckx@mech.kuleuven.ac.be> * cdl/flash_amd_am29xxxxx.cdl: Support AM29LV200 and ST M29W200B.
--- a/packages/devs/flash/amd/am29xxxxx/current/cdl/flash_amd_am29xxxxx.cdl +++ b/packages/devs/flash/amd/am29xxxxx/current/cdl/flash_amd_am29xxxxx.cdl @@ -86,6 +86,16 @@ cdl_package CYGPKG_DEVS_FLASH_AMD_AM29XX part in the family." } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV320D { + display "AMD AM29LV320 flash memory support" + default_value 0 + implements CYGINT_DEVS_FLASH_AMD_VARIANTS + description " + When this option is enabled, the AMD flash driver will be + able to recognize and handle the AMD29LV320 + part in the family." + } + cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV200 { display "AMD AM29LV200 flash memory support" default_value 0
--- a/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx.inl +++ b/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx.inl @@ -162,13 +162,14 @@ int flash_program_buf(void* addr, void* // device(s) in series. It is assumed that any devices in series // will be of the same type. -void -flash_query(void* data) +static void +_flash_query(void* data) { volatile flash_data_t *ROM; volatile flash_data_t *f_s1, *f_s2; flash_data_t* id = (flash_data_t*) data; flash_data_t w; + long timeout = 500000; ROM = (flash_data_t*) CYGNUM_FLASH_BASE; f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1); @@ -192,7 +193,23 @@ flash_query(void* data) *(FLASH_P2V(ROM)) = FLASH_Reset; // Stall, waiting for flash to return to read mode. - while (w != *(FLASH_P2V(ROM))); + while ((--timeout != 0) && (w != *(FLASH_P2V(ROM)))) ; +} + +void +flash_query(void* data) +{ + int cache_on; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + _flash_query(data); + if (cache_on) { + HAL_DCACHE_ENABLE(); + } } //---------------------------------------------------------------------------- @@ -252,8 +269,8 @@ flash_code_overlaps(void *start, void *e //---------------------------------------------------------------------------- // Erase Block -int -flash_erase_block(void* block, unsigned int size) +static int +_flash_erase_block(void* block, unsigned int size) { volatile flash_data_t* ROM, *BANK; volatile flash_data_t* b_p = (flash_data_t*) block; @@ -372,10 +389,26 @@ flash_erase_block(void* block, unsigned return res; } +int +flash_erase_block(void* block, unsigned int size) +{ + int ret, cache_on; + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + ret = _flash_erase_block(block, size); + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + return ret; +} + //---------------------------------------------------------------------------- // Program Buffer -int -flash_program_buf(void* addr, void* data, int len) +static int +_flash_program_buf(void* addr, void* data, int len) { volatile flash_data_t* ROM; volatile flash_data_t* BANK; @@ -454,4 +487,20 @@ flash_program_buf(void* addr, void* data // the address/device that reported the error. return res; } + +int +flash_program_buf(void* addr, void* data, int len) +{ + int ret, cache_on; + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + ret = _flash_program_buf(addr, data, len); + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + return ret; +} #endif // CYGONCE_DEVS_FLASH_AMD_AM29XXXXX_INL
--- a/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx_parts.inl +++ b/packages/devs/flash/amd/am29xxxxx/current/include/flash_am29xxxxx_parts.inl @@ -135,6 +135,48 @@ banked : false }, #endif +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV320D + { // AM29LV320DT + device_id : FLASHWORD(0xF6), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 64, + device_size: 0x400000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x400000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x3f0000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0 + }, + banked : false + }, + { // AM29LV320D + device_id : FLASHWORD(0xF9), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 64, + device_size: 0x400000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x400000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x000000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0 + }, + banked : false + }, +#endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL324D { // AM29DL324D-T device_id : FLASHWORD(0x5c), @@ -374,6 +416,49 @@ banked : false }, #endif +#ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV320D +#warning *** Untested *** + { // AM29LV320DT + device_id : FLASHWORD(0x01F6), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 64, + device_size: 0x400000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x400000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x3f0000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0 + }, + banked : false + }, + { // AM29LV320D + device_id : FLASHWORD(0x01F9), + block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE, + block_count: 64, + device_size: 0x400000 * CYGNUM_FLASH_INTERLEAVE, + base_mask : ~(0x400000 * CYGNUM_FLASH_INTERLEAVE - 1), + bootblock : true, + bootblocks : { 0x000000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0x002000 * CYGNUM_FLASH_INTERLEAVE, + 0 + }, + banked : false + }, +#endif #ifdef CYGHWR_DEVS_FLASH_AMD_AM29DL324D { // AM29DL324D-T device_id : FLASHWORD(0x225c),
--- a/packages/devs/flash/powerpc/viper/current/ChangeLog +++ b/packages/devs/flash/powerpc/viper/current/ChangeLog @@ -1,3 +1,13 @@ +2002-06-20 Gary Thomas <gary@chez-thomas.org> + + * src/flash_query.c: + * src/flash_program_buf.c: + * src/flash_erase_block.c: + * src/flash.h: Removed file(s). + + * src/viper_flash.c: + * cdl/flash_viper.cdl: Update to use generic AMD FLASH drivers. + 2001-06-11 Gary Thomas <gthomas@redhat.com> * src/viper_flash.c: Remove dependency on printf() via user functions.
--- a/packages/devs/flash/powerpc/viper/current/cdl/flash_viper.cdl +++ b/packages/devs/flash/powerpc/viper/current/cdl/flash_viper.cdl @@ -1,6 +1,6 @@ # ==================================================================== # -# flash_mbx.cdl +# flash_viper.cdl # # FLASH memory - Hardware support on A&M PowerPC/8xx Viper # @@ -50,45 +50,25 @@ # ==================================================================== cdl_package CYGPKG_DEVS_FLASH_VIPER { - display "Motorola PowerPC/860 FLASH memory support" + display "A&M Viper (PowerPC/860) FLASH memory support" parent CYGPKG_IO_FLASH active_if CYGPKG_IO_FLASH requires CYGPKG_HAL_POWERPC_VIPER implements CYGHWR_IO_FLASH_DEVICE - implements CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM - include_dir . - include_files ; # none _exported_ whatsoever - description "FLASH memory device support for A&M PowerPC/8xx VIPER boards" compile viper_flash.c - make -priority 1 { - flash_query.o: $(REPOSITORY)/$(PACKAGE)/src/flash_query.c - $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -msoft-float -mcpu=860 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_query.c - echo " .globl flash_query_end" >>flash_query.s - echo "flash_query_end:" >>flash_query.s - $(CC) -c -o flash_query.o flash_query.s - $(AR) rcs $(PREFIX)/lib/libtarget.a flash_query.o + # Arguably this should do in the generic package + # but then there is a logic loop so you can never enable it. + cdl_interface CYGINT_DEVS_FLASH_AMD_AM29XXXXX_REQUIRED { + display "Generic AMD flash driver required" } - make -priority 1 { - flash_erase_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c - $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -msoft-float -mcpu=860 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c - echo " .globl flash_erase_block_end" >>flash_erase_block.s - echo "flash_erase_block_end:" >>flash_erase_block.s - $(CC) -c -o flash_erase_block.o flash_erase_block.s - $(AR) rcs $(PREFIX)/lib/libtarget.a flash_erase_block.o - } + implements CYGINT_DEVS_FLASH_AMD_AM29XXXXX_REQUIRED + requires CYGHWR_DEVS_FLASH_AMD_AM29LV320D + requires CYGHWR_DEVS_FLASH_AMD_AM29F800 - make -priority 1 { - flash_program_buf.o: $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c - $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -msoft-float -mcpu=860 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c - echo " .globl flash_program_buf_end" >>flash_program_buf.s - echo "flash_program_buf_end:" >>flash_program_buf.s - $(CC) -c -o flash_program_buf.o flash_program_buf.s - $(AR) rcs $(PREFIX)/lib/libtarget.a flash_program_buf.o - } }
deleted file mode 100644 --- a/packages/devs/flash/powerpc/viper/current/src/flash.h +++ /dev/null @@ -1,72 +0,0 @@ -//========================================================================== -// -// flash.h -// -// Flash programming - device constants, etc. -// -//========================================================================== -//####ECOSGPLCOPYRIGHTBEGIN#### -// ------------------------------------------- -// This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 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. -// -// eCos is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with eCos; if not, write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -// -// As a special exception, if other files instantiate templates or use macros -// or inline functions from this file, or you compile this file and link it -// with other works to produce a work based on this file, this file does not -// by itself cause the resulting work to be covered by the GNU General Public -// License. However the source code for this file must still be made available -// in accordance with section (3) of the GNU General Public License. -// -// This exception does not invalidate any other reasons why a work based on -// this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ -// ------------------------------------------- -//####ECOSGPLCOPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): gthomas -// Contributors: gthomas -// Date: 2000-10-20 -// Purpose: -// Description: -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#ifndef _FLASH_HWR_H_ -#define _FLASH_HWR_H_ - -#define FLASH_Read_ID 0x90 -#define FLASH_Reset 0xFF -#define FLASH_Program 0xA0 -#define FLASH_Block_Erase 0x30 - -#define FLASH_Busy 0x40 // "Toggle" bit -#define FLASH_Err 0x20 - -#define FLASH_Setup_Addr1 0xAAA -#define FLASH_Setup_Addr2 0x555 -#define FLASH_Setup_Code1 0xAA -#define FLASH_Setup_Code2 0x55 -#define FLASH_Setup_Erase 0x80 - -#define FLASH_BLOCK_SIZE 0x10000 - -#endif // _FLASH_HWR_H_
deleted file mode 100644 --- a/packages/devs/flash/powerpc/viper/current/src/flash_erase_block.c +++ /dev/null @@ -1,135 +0,0 @@ -//========================================================================== -// -// flash_erase_block.c -// -// Flash programming -// -//========================================================================== -//####ECOSGPLCOPYRIGHTBEGIN#### -// ------------------------------------------- -// This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 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. -// -// eCos is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with eCos; if not, write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -// -// As a special exception, if other files instantiate templates or use macros -// or inline functions from this file, or you compile this file and link it -// with other works to produce a work based on this file, this file does not -// by itself cause the resulting work to be covered by the GNU General Public -// License. However the source code for this file must still be made available -// in accordance with section (3) of the GNU General Public License. -// -// This exception does not invalidate any other reasons why a work based on -// this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ -// ------------------------------------------- -//####ECOSGPLCOPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): gthomas -// Contributors: gthomas -// Date: 2000-07-14 -// Purpose: -// Description: -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include "flash.h" - -#include <pkgconf/hal.h> -#include <cyg/hal/hal_arch.h> -#include <cyg/hal/hal_cache.h> - -// -// CAUTION! This code must be copied to RAM before execution. Therefore, -// it must not contain any code which might be position dependent! -// - -int flash_erase_block(volatile unsigned char *block) -{ - volatile unsigned char *ROM; - volatile unsigned char *sector = block; - int timeout = 50000; - int cache_on; - int len, sector_size; - int erase_state, new_state; - long offset; - - HAL_DCACHE_IS_ENABLED(cache_on); - if (cache_on) { - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - } - - ROM = (volatile unsigned char *)((unsigned long)block & 0xFF800000); - - // We treat the low 4 sectors like a single block - // These sectors are 0x4000, 0x2000, 0x2000, 0x8000 long - offset = ((unsigned long)block - (unsigned long)ROM); - if (offset < FLASH_BLOCK_SIZE) { - sector_size = 0x4000; - } else { - sector_size = FLASH_BLOCK_SIZE; - } - - len = 0; - while (len < FLASH_BLOCK_SIZE) { - // Erase block - six step sequence - ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1; - ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2; - ROM[FLASH_Setup_Addr1] = FLASH_Setup_Erase; - ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1; - ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2; - *sector = FLASH_Block_Erase; - for (timeout = 50; timeout--; timeout > 0) ; - erase_state = *sector & FLASH_Busy; - timeout = 5000000; - while (true) { - new_state = *sector; - if ((new_state & FLASH_Busy) == erase_state) break; // "toggle" stopped - erase_state = new_state & FLASH_Busy; - if (new_state & FLASH_Err) break; - if (--timeout == 0) break; - } - sector += sector_size; - len += sector_size; - offset += sector_size; - if (offset == 0x4000) { - sector_size = 0x2000; - } else if (offset == 0x8000) { - sector_size = 0x8000; - } - } - - // Restore ROM to "normal" mode - ROM[0] = FLASH_Reset; - - len = FLASH_BLOCK_SIZE; - while (len > 0) { - if (*block++ != 0xFF) break; - len -= sizeof(*block); - } - if (len == 0) new_state = 0; - - if (cache_on) { - HAL_DCACHE_ENABLE(); - } - - return new_state; -}
deleted file mode 100644 --- a/packages/devs/flash/powerpc/viper/current/src/flash_program_buf.c +++ /dev/null @@ -1,112 +0,0 @@ -//========================================================================== -// -// flash_program_buf.c -// -// Flash programming -// -//========================================================================== -//####ECOSGPLCOPYRIGHTBEGIN#### -// ------------------------------------------- -// This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 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. -// -// eCos is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with eCos; if not, write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -// -// As a special exception, if other files instantiate templates or use macros -// or inline functions from this file, or you compile this file and link it -// with other works to produce a work based on this file, this file does not -// by itself cause the resulting work to be covered by the GNU General Public -// License. However the source code for this file must still be made available -// in accordance with section (3) of the GNU General Public License. -// -// This exception does not invalidate any other reasons why a work based on -// this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ -// ------------------------------------------- -//####ECOSGPLCOPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): gthomas -// Contributors: gthomas -// Date: 2000-07-14 -// Purpose: -// Description: -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include "flash.h" - -#include <pkgconf/hal.h> -#include <cyg/hal/hal_arch.h> -#include <cyg/hal/hal_cache.h> - -// -// CAUTION! This code must be copied to RAM before execution. Therefore, -// it must not contain any code which might be position dependent! -// - -int -flash_program_buf(volatile unsigned char *addr, unsigned char *data, int len) -{ - volatile unsigned char *ROM; - int timeout = 50000; - int cache_on; - int erase_state, new_state; - - HAL_DCACHE_IS_ENABLED(cache_on); - if (cache_on) { - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - } - - ROM = (volatile unsigned long *)((unsigned long)addr & 0xFF800000); - - while (len > 0) { - // Program data [byte] - 4 step sequence - ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1; - ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2; - ROM[FLASH_Setup_Addr1] = FLASH_Program; - *addr = *data; - for (timeout = 50; timeout--; timeout > 0) ; - erase_state = *addr & FLASH_Busy; - while (true) { - new_state = *addr; - if ((new_state & FLASH_Busy) == erase_state) break; // "toggle" stopped - erase_state = new_state & FLASH_Busy; - if (new_state & FLASH_Err) break; - if (--timeout == 0) break; - } - ROM[0] = FLASH_Reset; - if (*addr++ != *data++) { - new_state = 0xFF; - break; - } - len -= sizeof(*data); - } - if (len == 0) new_state = 0; // Success - - // Restore ROM to "normal" mode - bad: - ROM[0] = FLASH_Reset; - - if (cache_on) { - HAL_DCACHE_ENABLE(); - } - return new_state; -}
deleted file mode 100644 --- a/packages/devs/flash/powerpc/viper/current/src/flash_query.c +++ /dev/null @@ -1,96 +0,0 @@ -//========================================================================== -// -// flash_query.c -// -// Flash programming - query device -// -//========================================================================== -//####ECOSGPLCOPYRIGHTBEGIN#### -// ------------------------------------------- -// This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 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. -// -// eCos is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with eCos; if not, write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -// -// As a special exception, if other files instantiate templates or use macros -// or inline functions from this file, or you compile this file and link it -// with other works to produce a work based on this file, this file does not -// by itself cause the resulting work to be covered by the GNU General Public -// License. However the source code for this file must still be made available -// in accordance with section (3) of the GNU General Public License. -// -// This exception does not invalidate any other reasons why a work based on -// this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ -// ------------------------------------------- -//####ECOSGPLCOPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): gthomas -// Contributors: gthomas -// Date: 2000-10-20 -// Purpose: -// Description: -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include "flash.h" - -#include <pkgconf/hal.h> -#include <cyg/hal/hal_arch.h> -#include <cyg/hal/hal_cache.h> -#include CYGHWR_MEMORY_LAYOUT_H - -// -// CAUTION! This code must be copied to RAM before execution. Therefore, -// it must not contain any code which might be position dependent! -// - -int -flash_query(unsigned char *data) -{ - volatile unsigned char *ROM; - int cnt; - int cache_on; - - HAL_DCACHE_IS_ENABLED(cache_on); - if (cache_on) { - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - } - - ROM = (volatile unsigned char *)0xFE000000; - - ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1; - ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2; - ROM[FLASH_Setup_Addr1] = FLASH_Read_ID; - - // Manufacturers' code - *data++ = ROM[0x00]; - // Part number - *data++ = ROM[0x02]; - - ROM[0] = FLASH_Reset; - - if (cache_on) { - HAL_DCACHE_ENABLE(); - } - - return 0; -}
--- a/packages/devs/flash/powerpc/viper/current/src/viper_flash.c +++ b/packages/devs/flash/powerpc/viper/current/src/viper_flash.c @@ -1,8 +1,8 @@ //========================================================================== // -// mbx_flash.c +// viper_flash.c // -// Flash programming +// Flash programming support // //========================================================================== //####ECOSGPLCOPYRIGHTBEGIN#### @@ -50,72 +50,26 @@ // //========================================================================== -#include <pkgconf/hal.h> -#include <cyg/hal/hal_arch.h> -#include <cyg/hal/hal_cache.h> +#include <cyg/infra/cyg_type.h> -#define _FLASH_PRIVATE_ -#include <cyg/io/flash.h> - -#include "flash.h" +//-------------------------------------------------------------------------- +// Device properties -int -flash_hwr_init(void) -{ - int region_size = 0x10000; - int num_regions = 16; - extern char flash_query, flash_query_end; - typedef int code_fun(unsigned char *); - code_fun *_flash_query; - int code_len, stat; - unsigned char info[4]; - - // Copy 'program' code to RAM for execution - code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query; - _flash_query = (code_fun *)flash_info.work_space; - memcpy(_flash_query, &flash_query, code_len); - HAL_DCACHE_SYNC(); // Should guarantee this code will run - - stat = (*_flash_query)(info); -#if 0 - (*flash_info.pf)("stat = %x\n", stat); - dump_buf(info, sizeof(info)); -#endif +#define CYGNUM_FLASH_INTERLEAVE (1) +#define CYGNUM_FLASH_SERIES (1) +#define CYGNUM_FLASH_WIDTH (8) +#define CYGNUM_FLASH_BASE (0xFE000000) +#define CYGNUM_FLASH_16AS8 (1) - // Hard wired for now - flash_info.block_size = region_size; - flash_info.blocks = num_regions; - flash_info.start = (void *)0xFE000000; - flash_info.end = (void *)(0xFE000000+(num_regions*region_size)); - return FLASH_ERR_OK; -} +//static cyg_uint32 plf_flash_base; + +//-------------------------------------------------------------------------- +// Platform specific extras +#define CYGHWR_FLASH_AM29XXXXX_NO_WRITE_PROTECT // This feature fails :-( -// Map a hardware status to a package error -int -flash_hwr_map_error(int err) -{ - if (err & 0x007E007E) { - (*flash_info.pf)("Err = %x\n", err); - if (err & 0x00100010) { - return FLASH_ERR_PROGRAM; - } else - if (err & 0x00200020) { - return FLASH_ERR_ERASE; - } else - return FLASH_ERR_HWR; // FIXME - } else { - return FLASH_ERR_OK; - } -} +//-------------------------------------------------------------------------- +// Now include the driver code. +#include "cyg/io/flash_am29xxxxx.inl" -// See if a range of FLASH addresses overlaps currently running code -bool -flash_code_overlaps(void *start, void *end) -{ - extern char _stext[], _etext[]; - - return ((((unsigned long)&_stext >= (unsigned long)start) && - ((unsigned long)&_stext < (unsigned long)end)) || - (((unsigned long)&_etext >= (unsigned long)start) && - ((unsigned long)&_etext < (unsigned long)end))); -} +// ------------------------------------------------------------------------ +// EOF viper_flash.c
