1 /* 2 * $Id: flash.h,v 1.5 2003/11/02 22:30:46 telka Exp $ 3 * 4 * Copyright (C) 2003 ETC s.r.o. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the ETC s.r.o. nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Written by Marcel Telka <marcel@telka.sk>, 2003. 31 * 32 */ 33 34 #ifndef BRUX_FLASH_H 35 #define BRUX_FLASH_H 36 37 #include <stdio.h> 38 #include <stdint.h> 39 40 #include <brux/bus.h> 41 #include <brux/cfi.h> 42 43 typedef struct { 44 unsigned int bus_width; /* 1 for 8 bits, 2 for 16 bits, 4 for 32 bits, etc. */ 45 const char *name; 46 const char *description; 47 int (*autodetect)( cfi_array_t *cfi_array ); 48 void (*print_info)( cfi_array_t *cfi_array ); 49 int (*erase_block)( cfi_array_t *cfi_array, uint32_t adr ); 50 int (*unlock_block)( cfi_array_t *cfi_array, uint32_t adr ); 51 int (*program)( cfi_array_t *cfi_array, uint32_t adr, uint32_t data ); 52 void (*readarray)( cfi_array_t *cfi_array ); 53 } flash_driver_t; 54 55 #define FLASH_ERROR_NOERROR 0 56 #define FLASH_ERROR_INVALID_COMMAND_SEQUENCE 1 57 #define FLASH_ERROR_LOW_VPEN 2 58 #define FLASH_ERROR_BLOCK_LOCKED 3 59 #define FLASH_ERROR_UNKNOWN 99 60 61 void detectflash( bus_t *bus, uint32_t adr ); 62 63 void flashmem( bus_t *bus, FILE *f, uint32_t addr ); 64 void flashmsbin( bus_t *bus, FILE *f ); 65 66 #endif /* BRUX_FLASH_H */ 67