SAMA5 PMECC: Some ROM-related interface updates
This commit is contained in:
parent
b6da35e12c
commit
f4c6a16c3d
4 changed files with 135 additions and 15 deletions
|
|
@ -3336,7 +3336,51 @@ config SAMA5_NAND_CE
|
|||
|
||||
void board_nand_ce(int cs, bool enable);
|
||||
|
||||
endif # SAMA5_EBICS0_NAND
|
||||
if SAMA5_EBICS0_NAND || SAMA5_EBICS1_NAND || SAMA5_EBICS2_NAND || SAMA5_EBICS3_NAND
|
||||
|
||||
config SAMA5_PMECC_EMBEDDEDALGO
|
||||
bool "ROM ECC detection/correction"
|
||||
default y
|
||||
---help---
|
||||
The SAMA5D3 ROM code embeds the software used in the process of ECC
|
||||
detection/correction: function pmecc_correctionalgo(). If this
|
||||
option is selected, the ROM code will be used. If not, then the an
|
||||
implementation pmecc_correctionalgo() will be built into the NuttX
|
||||
image.
|
||||
|
||||
config SAMA5_PMECC_EMBEDDEDALGO_ADDR
|
||||
hex "Address of ROM ECC detection/correction"
|
||||
default 0x00104510
|
||||
---help---
|
||||
The ROM code embeds the software used in the process of ECC
|
||||
detection/correction at this address. Don't change this address
|
||||
unless you know what you are doing.
|
||||
|
||||
config SAMA5_PMECC_GALOIS_ROMTABLES
|
||||
bool "ROM Galois Tables"
|
||||
default y
|
||||
---help---
|
||||
Support the PMECC algorithm using Galois tables in ROM.
|
||||
|
||||
if SAMA5_PMECC_GALOIS_ROMTABLES
|
||||
|
||||
config SAMA5_PMECC_GALOIS_TABLE512_ROMADDR
|
||||
hex "Address of Galois Table 512"
|
||||
default 0x00110000
|
||||
---help---
|
||||
Address of Galois Field Table 512 mapping in ROM. Don't change this
|
||||
address unless you know what you are doing.
|
||||
|
||||
config SAMA5_PMECC_GALOIS_TABLE1024_ROMADDR
|
||||
hex "Address of Galois Table 1024"
|
||||
default 0x00118000
|
||||
---help---
|
||||
Address of Galois Field Table 1024 mapping in ROM. Don't change this
|
||||
address unless you know what you are doing.
|
||||
|
||||
endif # SAMA5_PMECC_GALOIS_ROMTABLES
|
||||
endif # SAMA5_EBICS*_PMECC
|
||||
endif # SAMA5_EBICS*_NAND
|
||||
|
||||
endmenu # External Memory Configuration
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,15 @@
|
|||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Number of bits of correction. These much match the (unshifted) values
|
||||
* in the SMC_PMECCFG register BCH_ERR field.
|
||||
*/
|
||||
|
||||
#define BCH_ERR2 0 /* 2 errors */
|
||||
#define BCH_ERR4 1 /* 4 errors */
|
||||
#define BCH_ERR8 2 /* 8 errors */
|
||||
#define BCH_ERR12 3 /* 12 errors */
|
||||
#define BCH_ERR24 4 /* 24 errors */
|
||||
#define BCH_ERR2 0 /* 2 bit errors */
|
||||
#define BCH_ERR4 1 /* 4 bit errors */
|
||||
#define BCH_ERR8 2 /* 8 bit errors */
|
||||
#define BCH_ERR12 3 /* 12 bit errors */
|
||||
#define BCH_ERR24 4 /* 24 bit errors */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
|
|
@ -73,8 +76,8 @@
|
|||
|
||||
struct sam_pmecc_s
|
||||
{
|
||||
uint8_t nsectors : 4; /* Number of sectors in data */
|
||||
uint8_t bcherr : 3; /* BCH_ERR correctability code */
|
||||
uint8_t nsectors; /* Number of sectors in data */
|
||||
struct pmecc_desc_s desc; /* Atmel PMECC descriptor */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -211,6 +214,12 @@ static void pmecc_pagelayout(uint16_t datasize, uint16_t sparesize,
|
|||
uint8_t bcherr512;
|
||||
uint8_t bcherr1k;
|
||||
|
||||
/* ECC must not start at address zero, since bad block tags are at offset
|
||||
* zero.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(offset > 0);
|
||||
|
||||
/* Decrease the spare size by the offset */
|
||||
|
||||
sparesize -= offset;
|
||||
|
|
@ -240,8 +249,8 @@ static void pmecc_pagelayout(uint16_t datasize, uint16_t sparesize,
|
|||
DEBUGASSERT(bcherr512 > 0 || bcherr1k > 0);
|
||||
if (bcherr1k == 0)
|
||||
{
|
||||
g_pmecc.nsectors = nsectors512;
|
||||
g_pmecc.bcherr = bcherr512;
|
||||
g_pmecc.nsectors = nsectors512;
|
||||
g_pmecc.desc.bcherr = bcherr512;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -249,13 +258,13 @@ static void pmecc_pagelayout(uint16_t datasize, uint16_t sparesize,
|
|||
correctability1K = nsectors1k * g_correctability[bcherr1k];
|
||||
if (correctability512 >= correctability1K)
|
||||
{
|
||||
g_pmecc.nsectors = nsectors512;
|
||||
g_pmecc.bcherr = bcherr512;
|
||||
g_pmecc.nsectors = nsectors512;
|
||||
g_pmecc.desc.bcherr = ((uint32_t)bcherr512 << HSMC_PMECCFG_BCHERR_SHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pmecc.nsectors = nsectors1k;
|
||||
g_pmecc.bcherr = bcherr1k;
|
||||
g_pmecc.nsectors = nsectors1k;
|
||||
g_pmecc.desc.bcherr = ((uint32_t)bcherr1k << HSMC_PMECCFG_BCHERR_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,9 +129,75 @@
|
|||
|
||||
#ifdef NAND_HAVE_PMECC
|
||||
|
||||
/* The ROM code embeds the software used in the process of ECC
|
||||
* detection/correction
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SAMA5_PMECC_EMBEDDEDALGO_ADDR
|
||||
# ifndef CONFIG_SAMA5_PMECC_EMBEDDEDALGO_ADDR
|
||||
# define CONFIG_SAMA5_PMECC_EMBEDDEDALGO_ADDR 0x00104510
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMA5_PMECC_GALOIS_ROMTABLES
|
||||
# ifndef CONFIG_SAMA5_PMECC_GALOIS_TABLE512_ROMADDR
|
||||
# define CONFIG_SAMA5_PMECC_GALOIS_TABLE512_ROMADDR 0x00110000
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_SAMA5_PMECC_GALOIS_TABLE1024_ROMADDR
|
||||
# define CONFIG_SAMA5_PMECC_GALOIS_TABLE1024_ROMADDR 0x00118000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Other PMECC Definitions **************************************************/
|
||||
/* Defines the maximum value of the error correcting capability */
|
||||
|
||||
#define PMECC_MAX_CORRECTABILITY 25
|
||||
|
||||
/* Start address of ECC cvalue in spare zone, this must not be 0 since bad
|
||||
* block tags are at address 0.
|
||||
*/
|
||||
|
||||
#define PMECC_ECC_STARTOFFSET 2
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
/* This is the form of the PMECC descriptor that is passed to the ECC
|
||||
* detection correction algorithm in ROM. The binary for of this structure
|
||||
* cannot be altered!
|
||||
*/
|
||||
|
||||
struct pmecc_desc_s
|
||||
{
|
||||
uint32_t pagesize; /* 0-3: See HSMC_PMECCFG_PAGESIZE_* definitions */
|
||||
uint32_t sparesize; /* 4-7: The spare area size is equal to (SPARESIZE+1) bytes */
|
||||
uint32_t sectorsz; /* 8-11: See HSMC_PMECCFG_SECTORSZ_* definitions*/
|
||||
uint32_t bcherr; /* 12-15: See HSMC_PMECCFG_BCHERR_* definitions */
|
||||
uint32_t eccsize; /* 16-19: Real size in bytes of ECC in spare */
|
||||
uint32_t eccstart; /* 20-23: The first byte address of the ECC area */
|
||||
uint32_t eccend; /* 24-27: The last byte address of the ECC area */
|
||||
uint32_t nandwr; /* 28-31: NAND Write Access */
|
||||
uint32_t sparena; /* 32-35: Spare Enable */
|
||||
uint32_t automode; /* 36-39: Automatic Mode */
|
||||
uint32_t clkctrl; /* 40-43: PMECC Module data path Setup Time is CLKCTRL+1. */
|
||||
uint32_t interrupt; /* 44-47: */
|
||||
int32_t tt; /* 48-51: Error correcting capability */
|
||||
int32_t mm; /* 52-55: Degree of the remainders, GF(2**mm) */
|
||||
int32_t nn; /* 56-59: Length of codeword = nn=2**mm -1 */
|
||||
int16_t *alphato; /* 60-63: Gallois field table */
|
||||
int16_t *indexof; /* 64-67: Index of Gallois field table */
|
||||
int16_t partsyn[100]; /* 68-267: */
|
||||
int16_t si[100]; /* 268-467: Current syndrome value */
|
||||
|
||||
/* 468-: Sigma table */
|
||||
|
||||
int16_t smu[PMECC_MAX_CORRECTABILITY + 2][2 * PMECC_MAX_CORRECTABILITY + 1];
|
||||
|
||||
/* Polynomial order */
|
||||
|
||||
int16_t lmu[PMECC_MAX_CORRECTABILITY + 1];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
|
|
|||
|
|
@ -207,7 +207,8 @@ mksymtab.c, cvsparser.c, and cvsparser.h
|
|||
mkctags.sh
|
||||
----------
|
||||
|
||||
A script for creating ctags from Ken Pettit. See http://ctags.sourceforge.net/
|
||||
A script for creating ctags from Ken Pettit. See http://en.wikipedia.org/wiki/Ctags
|
||||
and http://ctags.sourceforge.net/
|
||||
|
||||
pic32mx
|
||||
-------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue