summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-11-23 10:06:33 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-11-23 10:06:33 -0600
commitae4ce591e813ea5387805961c9fd7c226ef6f247 (patch)
treeb75ee4900fd2b2d6f094ebd1cdf68ec3a3fc8e8f
parent82713fbd51f277b714e1b89db9da9e1a4974567a (diff)
downloadnuttx-ae4ce591e813ea5387805961c9fd7c226ef6f247.tar.gz
nuttx-ae4ce591e813ea5387805961c9fd7c226ef6f247.tar.bz2
nuttx-ae4ce591e813ea5387805961c9fd7c226ef6f247.zip
SAMA5 PMECC: Some ROM-related interface updates
-rw-r--r--nuttx/arch/arm/src/sama5/Kconfig46
-rw-r--r--nuttx/arch/arm/src/sama5/sam_pmecc.c35
-rw-r--r--nuttx/arch/arm/src/sama5/sam_pmecc.h66
-rw-r--r--nuttx/tools/README.txt3
4 files changed, 135 insertions, 15 deletions
diff --git a/nuttx/arch/arm/src/sama5/Kconfig b/nuttx/arch/arm/src/sama5/Kconfig
index 21040e72a..94ebbb7f3 100644
--- a/nuttx/arch/arm/src/sama5/Kconfig
+++ b/nuttx/arch/arm/src/sama5/Kconfig
@@ -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
diff --git a/nuttx/arch/arm/src/sama5/sam_pmecc.c b/nuttx/arch/arm/src/sama5/sam_pmecc.c
index ec30dbd3b..f95cac958 100644
--- a/nuttx/arch/arm/src/sama5/sam_pmecc.c
+++ b/nuttx/arch/arm/src/sama5/sam_pmecc.c
@@ -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);
}
}
}
diff --git a/nuttx/arch/arm/src/sama5/sam_pmecc.h b/nuttx/arch/arm/src/sama5/sam_pmecc.h
index 6a26080f1..2e2b5ec6e 100644
--- a/nuttx/arch/arm/src/sama5/sam_pmecc.h
+++ b/nuttx/arch/arm/src/sama5/sam_pmecc.h
@@ -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
diff --git a/nuttx/tools/README.txt b/nuttx/tools/README.txt
index 5a26de25e..a1bf40b60 100644
--- a/nuttx/tools/README.txt
+++ b/nuttx/tools/README.txt
@@ -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
-------