19#ifndef LIBBSP_ARM_LPC32XX_NAND_MLC_H
20#define LIBBSP_ARM_LPC32XX_NAND_MLC_H
68#define MLC_SMALL_PAGE_SIZE 528
69#define MLC_SMALL_DATA_SIZE 512
70#define MLC_SMALL_SPARE_SIZE 16
71#define MLC_SMALL_USER_SPARE_SIZE 6
72#define MLC_SMALL_ECC_SPARE_SIZE 10
73#define MLC_SMALL_DATA_WORD_COUNT (MLC_SMALL_DATA_SIZE / 4)
74#define MLC_SMALL_SPARE_WORD_COUNT (MLC_SMALL_SPARE_SIZE / 4)
75#define MLC_SMALL_PAGES_PER_LARGE_PAGE 4
76#define MLC_LARGE_PAGE_SIZE \
77 (MLC_SMALL_PAGES_PER_LARGE_PAGE * MLC_SMALL_PAGE_SIZE)
78#define MLC_LARGE_DATA_SIZE \
79 (MLC_SMALL_PAGES_PER_LARGE_PAGE * MLC_SMALL_DATA_SIZE)
80#define MLC_LARGE_SPARE_SIZE \
81 (MLC_SMALL_PAGES_PER_LARGE_PAGE * MLC_SMALL_SPARE_SIZE)
82#define MLC_LARGE_DATA_WORD_COUNT (MLC_LARGE_DATA_SIZE / 4)
83#define MLC_LARGE_SPARE_WORD_COUNT (MLC_LARGE_SPARE_SIZE / 4)
93#define FLASHCLK_IRQ_MLC BSP_BIT32(5)
94#define FLASHCLK_MLC_DMA_RNB BSP_BIT32(4)
95#define FLASHCLK_MLC_DMA_INT BSP_BIT32(3)
96#define FLASHCLK_SELECT_SLC BSP_BIT32(2)
97#define FLASHCLK_MLC_CLK_ENABLE BSP_BIT32(1)
98#define FLASHCLK_SLC_CLK_ENABLE BSP_BIT32(0)
108#define MLC_TIME_WR_LOW(val) BSP_FLD32(val, 0, 3)
109#define MLC_TIME_WR_HIGH(val) BSP_FLD32(val, 4, 7)
110#define MLC_TIME_RD_LOW(val) BSP_FLD32(val, 8, 11)
111#define MLC_TIME_RD_HIGH(val) BSP_FLD32(val, 12, 15)
112#define MLC_TIME_NAND_TA(val) BSP_FLD32(val, 16, 18)
113#define MLC_TIME_BUSY_DELAY(val) BSP_FLD32(val, 19, 23)
114#define MLC_TIME_TCEA_DELAY(val) BSP_FLD32(val, 24, 25)
124#define MLC_UNLOCK_PROT 0xa25e
134#define MLC_ISR_DECODER_FAILURE BSP_BIT32(6)
135#define MLC_ISR_SYMBOL_ERRORS(reg) BSP_FLD32GET(reg, 4, 5)
136#define MLC_ISR_ERRORS_DETECTED BSP_BIT32(3)
137#define MLC_ISR_ECC_READY BSP_BIT32(2)
138#define MLC_ISR_CONTROLLER_READY BSP_BIT32(1)
139#define MLC_ISR_NAND_READY BSP_BIT32(0)
149#define MLC_ICR_SOFT_WRITE_PROT BSP_BIT32(3)
150#define MLC_ICR_LARGE_PAGES BSP_BIT32(2)
151#define MLC_ICR_ADDR_WORD_COUNT_4_5 BSP_BIT32(1)
152#define MLC_ICR_IO_BUS_16 BSP_BIT32(0)
162#define MLC_ECC_AUTO_ENC_PROGRAM BSP_BIT32(8)
172#define NAND_STATUS_ERROR (1U << 0)
173#define NAND_STATUS_READY (1U << 6)
174#define NAND_STATUS_NOT_PROTECTED (1U << 7)
184 uint32_t block_count;
196#define MLC_SMALL_PAGES 0x1U
202#define MLC_MANY_ADDRESS_CYCLES 0x2U
209#define MLC_NORMAL_BLOCKS 0x4U
214#define MLC_IO_WIDTH_16_BIT 0x8U
221uint32_t lpc32xx_mlc_page_size(
void);
223uint32_t lpc32xx_mlc_pages_per_block(
void);
225uint32_t lpc32xx_mlc_block_count(
void);
227uint32_t lpc32xx_mlc_io_width(
void);
229void lpc32xx_mlc_write_protection(
230 uint32_t page_index_low,
231 uint32_t page_index_high
234void lpc32xx_mlc_read_id(uint8_t *
id,
size_t n);
253 uint32_t *symbol_error_count
307 uint32_t block_index,
347 uint32_t block_begin,
351 uint32_t page_buffer [MLC_LARGE_DATA_WORD_COUNT]
366 uint32_t page_data [MLC_LARGE_DATA_WORD_COUNT],
367 uint32_t page_spare [MLC_LARGE_SPARE_WORD_COUNT]
381 uint32_t block_begin,
385 uint32_t page_buffer_0 [MLC_LARGE_DATA_WORD_COUNT],
386 uint32_t page_buffer_1 [MLC_LARGE_DATA_WORD_COUNT]
401static inline bool lpc32xx_mlc_is_bad_page(
const uint32_t *spare)
403 uint32_t first_byte_mask = 0x000000ff;
404 uint32_t sixth_byte_mask = 0x0000ff00;
406 return (spare [0] & first_byte_mask) != first_byte_mask
407 || (spare [1] & sixth_byte_mask) != sixth_byte_mask;
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
void lpc32xx_mlc_init(const lpc32xx_mlc_config *cfg)
Initializes the MLC NAND controller according to cfg.
Definition: nand-mlc.c:178
rtems_status_code lpc32xx_mlc_write_page_with_ecc(uint32_t page_index, const void *data, const void *spare)
Writes the page with index page_index.
Definition: nand-mlc.c:352
rtems_status_code lpc32xx_mlc_erase_block(uint32_t block_index)
Erases the block with index block_index.
Definition: nand-mlc.c:332
rtems_status_code lpc32xx_mlc_write_blocks(uint32_t block_begin, uint32_t block_end, const void *src, size_t src_size, uint32_t page_buffer[MLC_LARGE_DATA_WORD_COUNT])
Writes src_size Bytes from src to the flash area specified by block_begin and block_end.
rtems_status_code lpc32xx_mlc_erase_block_safe(uint32_t block_index)
Erases the block with index block_index.
Definition: nand-mlc-erase-block-safe.c:124
rtems_status_code lpc32xx_mlc_erase_block_safe_3(uint32_t block_index, uint32_t page_begin, uint32_t page_end)
Erases the block with index block_index.
Definition: nand-mlc-erase-block-safe.c:105
rtems_status_code lpc32xx_mlc_is_valid_block(uint32_t block_index)
Checks if the block with index block_index is valid.
Definition: nand-mlc-erase-block-safe.c:97
rtems_status_code lpc32xx_mlc_read_page(uint32_t page_index, void *data, void *spare, uint32_t *symbol_error_count)
Reads the page with index page_index.
Definition: nand-mlc.c:224
void lpc32xx_mlc_zero_pages(uint32_t page_begin, uint32_t page_end)
Writes zero values to the pages specified by page_begin and page_end.
Definition: nand-mlc-erase-block-safe.c:43
bool(* lpc32xx_mlc_read_process)(void *process_arg, uint32_t page_index, uint32_t page_size, uint32_t page_data[MLC_LARGE_DATA_WORD_COUNT], uint32_t page_spare[MLC_LARGE_SPARE_WORD_COUNT])
Read blocks process function type.
Definition: nand-mlc.h:362
rtems_status_code lpc32xx_mlc_read_blocks(uint32_t block_begin, uint32_t block_end, lpc32xx_mlc_read_process process, void *process_arg, uint32_t page_buffer_0[MLC_LARGE_DATA_WORD_COUNT], uint32_t page_buffer_1[MLC_LARGE_DATA_WORD_COUNT])
Reads the pages of block block_begin up to and excluding block_end.
Definition: nand-mlc-read-blocks.c:65
This header file provides utility macros for BSPs.
This header file defines the RTEMS Classic API.
MLC NAND controller configuration.
Definition: nand-mlc.h:181
uint32_t time
Value for the MLC NAND Timing Register (MLC_TIME_REG).
Definition: nand-mlc.h:189