summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-07-01 13:05:06 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-07-01 13:05:06 +0000
commit03d210895f393b6eba617ac945a729f70c7101a4 (patch)
tree78f31959961ce5cbd000d1a5640834589a527164 /c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h
parentFix. (diff)
downloadrtems-03d210895f393b6eba617ac945a729f70c7101a4.tar.bz2
2011-07-01 Stephan Hoffmann <sho@reLinux.de>
Sebastian Huber <sebastian.huber@embedded-brains.de> * misc/nand-mlc-erase-block-safe.c: New file * Makefile.am: Reflect change from above. * misc/nand-mlc-write-blocks.c: Use lpc32xx_mlc_erase_block_safe_3(). * include/nand-mlc.h: Bad block handling.
Diffstat (limited to '')
-rw-r--r--c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h66
1 files changed, 59 insertions, 7 deletions
diff --git a/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h b/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h
index 4e70345716..29ad8d04b4 100644
--- a/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h
+++ b/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h
@@ -7,12 +7,15 @@
*/
/*
- * Copyright (c) 2010
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
+ * Copyright (c) 2010-2011 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * Copyright (c) 2011 Stephan Hoffmann <sho@reLinux.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -166,6 +169,19 @@ extern "C" {
#define MLC_BAD_BLOCK_MASK ((uint32_t) 0xff00)
/**
+ * @brief Bad block mark.
+ *
+ * We define our own bad block mark to be able to recognize the blocks that
+ * have been marked bad during operation later.
+ */
+#define MLC_BAD_BLOCK_MARK ((uint32_t) 0xbadb)
+
+/**
+ * @brief The bytes 4 and 5 are reserved for bad block handling.
+ */
+#define MLC_RESERVED ((uint32_t) 0xffff)
+
+/**
* @name NAND Status Register
*
* @{
@@ -253,6 +269,32 @@ rtems_status_code lpc32xx_mlc_read_page(
rtems_status_code lpc32xx_mlc_erase_block(uint32_t block_index);
/**
+ * @brief Erases the block with index @a block_index.
+ *
+ * In case of an erase error all pages and the spare areas of this block are
+ * programmed with zero values. This will mark the first and second page as
+ * bad.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INCORRECT_STATE The first or second page of this block is bad.
+ * @retval RTEMS_INVALID_ID Invalid @a block_index value.
+ * @retval RTEMS_IO_ERROR Erase error.
+ */
+rtems_status_code lpc32xx_mlc_erase_block_safe(uint32_t block_index);
+
+/**
+ * @brief Erases the block with index @a block_index.
+ *
+ * Variant of lpc32xx_mlc_erase_block_safe() with more parameters for
+ * efficiency reasons.
+ */
+rtems_status_code lpc32xx_mlc_erase_block_safe_3(
+ uint32_t block_index,
+ uint32_t first_page_of_block,
+ uint32_t pages_per_block
+);
+
+/**
* @brief Writes the page with index @a page_index.
*
* 32-bit writes will be performed.
@@ -278,7 +320,7 @@ rtems_status_code lpc32xx_mlc_write_page_with_ecc(
*
* @retval RTEMS_SUCCESSFUL Successful operation.
* @retval RTEMS_INVALID_ID Invalid @a block_begin or @a block_end value.
- * @retval RTEMS_IO_ERROR To many bad blocks or source area to big.
+ * @retval RTEMS_IO_ERROR Too many bad blocks or source area too big.
*/
rtems_status_code lpc32xx_mlc_write_blocks(
uint32_t block_begin,
@@ -328,6 +370,16 @@ static inline bool lpc32xx_mlc_is_bad_page(const uint32_t *spare)
return (spare [1] & MLC_BAD_BLOCK_MASK) != MLC_BAD_BLOCK_MASK;
}
+static inline void lpc32xx_mlc_set_bad_page(uint32_t *spare)
+{
+ spare [1] = MLC_BAD_BLOCK_MARK;
+}
+
+static inline void lpc32xx_mlc_set_reserved(uint32_t *spare)
+{
+ spare [1] = MLC_RESERVED;
+}
+
/** @} */
#ifdef __cplusplus