X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fdataflash.h;h=84a56c30ce2608c0c60f9e177a86bab7796f35c4;hb=4f58002013ba1e89eb8fda015ff495bd37cd4016;hp=cc4badfd16b076b49e4678e9c9260db5d9c9f2b5;hpb=2abbe0754759f94c79125a2534fbc4be74f416bc;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/dataflash.h b/include/dataflash.h index cc4badf..84a56c3 100644 --- a/include/dataflash.h +++ b/include/dataflash.h @@ -3,23 +3,7 @@ * Data Flash Atmel Description File * Author : Hamid Ikdoumi (Atmel) * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program 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 of - * the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ */ /* File Name : dataflash.h */ @@ -34,19 +18,47 @@ #define _DataFlash_h -#include #include "config.h" +/*number of protected area*/ +#define NB_DATAFLASH_AREA 5 -typedef struct { - unsigned long base; /* logical base address for a bank */ - unsigned long size; /* total bank size */ - unsigned long page_count; - unsigned long page_size; - unsigned long id; /* device id */ - unsigned char protect[CFG_MAX_DATAFLASH_PAGES]; /* page protection status */ -} dataflash_info_t; +#ifndef CONFIG_MTD_NOR_FLASH +/*----------------------------------------------------------------------- + * return codes from flash_write(): + */ +# define ERR_OK 0 +# define ERR_TIMOUT 1 +# define ERR_NOT_ERASED 2 +# define ERR_PROTECTED 4 +# define ERR_INVAL 8 +# define ERR_ALIGN 16 +# define ERR_UNKNOWN_FLASH_VENDOR 32 +# define ERR_UNKNOWN_FLASH_TYPE 64 +# define ERR_PROG_ERROR 128 + +/*----------------------------------------------------------------------- + * Protection Flags for flash_protect(): + */ +# define FLAG_PROTECT_SET 0x01 +# define FLAG_PROTECT_CLEAR 0x02 +# define FLAG_PROTECT_INVALID 0x03 + +/*----------------------------------------------------------------------- + * Set Environment according to label: + */ +# define FLAG_SETENV 0x80 +#endif /* CONFIG_MTD_NOR_FLASH */ + +/*define the area structure*/ +typedef struct { + unsigned long start; + unsigned long end; + unsigned char protected; + unsigned char setenv; + unsigned char label[20]; +} dataflash_protect_t; typedef unsigned int AT91S_DataFlashStatus; @@ -80,6 +92,7 @@ typedef struct _AT91S_Dataflash { int page_offset; /* page offset in command */ int byte_mask; /* byte mask in command */ int cs; + dataflash_protect_t area_list[NB_DATAFLASH_AREA]; /* area protection status */ } AT91S_DataflashFeatures, *AT91PS_DataflashFeatures; /*---------------------------------------------*/ @@ -91,22 +104,27 @@ typedef struct _AT91S_DataFlash { } AT91S_DataFlash, *AT91PS_DataFlash; - typedef struct _AT91S_DATAFLASH_INFO { AT91S_DataflashDesc Desc; AT91S_DataflashFeatures Device; /* Pointer on a dataflash features array */ unsigned long logical_address; + unsigned long end_address; unsigned int id; /* device id */ - unsigned char protect[CFG_MAX_DATAFLASH_PAGES]; /* page protection status */ } AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO; - +struct dataflash_addr { + unsigned long addr; + int cs; +}; /*-------------------------------------------------------------------------------------------------*/ - #define AT45DB161 0x2c +#define AT45DB021 0x14 +#define AT45DB081 0x24 #define AT45DB321 0x34 #define AT45DB642 0x3c +#define AT45DB128 0x10 +#define PAGES_PER_BLOCK 8 #define AT91C_DATAFLASH_TIMEOUT 10000 /* For AT91F_DataFlashWaitReady */ @@ -167,10 +185,21 @@ typedef struct _AT91S_DATAFLASH_INFO { /*-------------------------------------------------------------------------------------------------*/ +extern int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, unsigned long size); +extern int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr); +extern int addr2ram(ulong addr); +extern int dataflash_real_protect (int flag, unsigned long start_addr, unsigned long end_addr); extern int addr_dataflash (unsigned long addr); extern int read_dataflash (unsigned long addr, unsigned long size, char *result); -extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size); +extern int write_dataflash(unsigned long addr_dest, unsigned long addr_src, + unsigned long size); +extern int AT91F_DataflashInit(void); + extern void dataflash_print_info (void); extern void dataflash_perror (int err); +extern void AT91F_DataflashSetEnv (void); +extern struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS]; +extern dataflash_protect_t area_list[NB_DATAFLASH_AREA]; +extern AT91S_DATAFLASH_INFO dataflash_info[]; #endif