Hardware Libraries  20.1
Arria 10 SoC Hardware Manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
alt_nand.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright 2013-2016 Altera Corporation. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************/
32 
33 /*
34  * $Id: //acds/rel/20.1/embedded/ip/hps/altera_hps/hwlib/include/alt_nand.h#1 $
35  */
36 
41 #ifndef __ALT_NAND_FLASH_H__
42 #define __ALT_NAND_FLASH_H__
43 
44 #include "hwlib.h"
45 #include "socal/alt_nand.h"
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif /* __cplusplus */
51 
52 #define ALT_NAND_BOOTSTRAP_INHIBIT_INIT_ENABLE (1)
53 #define ALT_NAND_BOOTSTRAP_INHIBIT_INIT_DISABLE (0)
54 #define ALT_NAND_BOOTSTRAP_INHIBIT_B0P0_LOAD_ENABLE (1)
55 #define ALT_NAND_BOOTSTRAP_INHIBIT_B0P0_LOAD_DISABLE (0)
56 #define ALT_NAND_BOOTSTRAP_512B_DEVICE_ENABLE (1)
57 #define ALT_NAND_BOOTSTRAP_512B_DEVICE_DISABLE (0)
58 
59 /******************************************************************************/
148 typedef void (*alt_nand_callback_t)(ALT_STATUS_CODE status, void *callback_arg);
149 
171 typedef ALT_STATUS_CODE (*alt_nand_flash_custom_init_t)(void *user_arg);
172 
255 ALT_STATUS_CODE alt_nand_init(const bool load_block0_page0,
256  const bool page_size_512,
257  alt_nand_flash_custom_init_t custom_init,
258  void *user_arg);
259 
272 ALT_STATUS_CODE alt_nand_uninit(void);
273 
277 #define ALT_NAND_INVALID_FLASH_ADDR 0xffffffff
278 
291 uint32_t alt_nand_block_address_get(const uint32_t addr);
292 
305 uint32_t alt_nand_page_address_get(const uint32_t addr);
306 
325 uint32_t alt_nand_addr_compose(const uint32_t block_num,
326  const uint32_t page_num);
327 
364 ALT_STATUS_CODE alt_nand_block_erase(const uint32_t block_addr,
365  alt_nand_callback_t completion_callback,
366  void *completion_arg);
367 
421 ALT_STATUS_CODE alt_nand_page_read(const uint32_t page_addr,
422  const uint32_t num_pages,
423  void *dest,
424  const uint32_t dest_size);
425 
458 ALT_STATUS_CODE alt_nand_read_page(uint32_t block, uint32_t page, uint32_t * buf);
459 
494 ALT_STATUS_CODE alt_nand_read_page_and_spare(uint32_t block, uint32_t page, uint32_t * buf);
495 
531 ALT_STATUS_CODE alt_nand_read_page_and_spare_byte(uint32_t block, uint32_t page, uint8_t * buf);
532 
563 ALT_STATUS_CODE alt_nand_page_write(const uint32_t page_addr,
564  const uint32_t num_pages,
565  const void *src,
566  const uint32_t src_size);
567 
600 ALT_STATUS_CODE alt_nand_write_page(uint32_t block, uint32_t page, uint32_t * buf);
601 
636 ALT_STATUS_CODE alt_nand_write_page_and_spare(uint32_t block, uint32_t page, uint32_t * buf);
637 
638 
687 ALT_STATUS_CODE alt_nand_page_dma_read(const uint32_t page_addr,
688  const uint32_t num_pages,
689  void *dest,
690  const uint32_t dest_size,
691  alt_nand_callback_t completion_callback,
692  void *completion_arg);
739 ALT_STATUS_CODE alt_nand_page_dma_write(const uint32_t page_addr,
740  const uint32_t num_pages,
741  const void *src,
742  const uint32_t src_size,
743  alt_nand_callback_t completion_callback,
744  void *completion_arg);
745 
751 {
752  ALT_NAND_ECC_4_BIT_CORRECTION = 4, /* Performs 4 bit correction over a 512 byte sector */
753  ALT_NAND_ECC_8_BIT_CORRECTION = 8, /* Performs 8 bit correction over a 512 byte sector */
754  ALT_NAND_ECC_16_BIT_CORRECTION = 16, /* Performs 16 bit correction over a 512 byte sector */
755  ALT_NAND_ECC_24_BIT_CORRECTION = 24 /* Performs 24 bit correction over a 1024 byte sector */
757 
774 ALT_STATUS_CODE alt_nand_ecc_enable(const ALT_NAND_ECC_CORRECTION_t ecc_correction);
775 
786 ALT_STATUS_CODE alt_nand_ecc_disable(void);
787 
788 
794 {
795  uint32_t corrected_errors[4];
812 
829 ALT_STATUS_CODE alt_nand_ecc_status_get(ALT_NAND_FLASH_ECC_STATUS_t *ecc_status);
830 
869 {
966 
980 uint32_t alt_nand_int_status_get(void);
981 
997 ALT_STATUS_CODE alt_nand_int_clear(const uint32_t mask);
998 
1020 ALT_STATUS_CODE alt_nand_int_disable(const uint32_t mask);
1021 
1043 ALT_STATUS_CODE alt_nand_int_enable(const uint32_t mask);
1044 
1058 uint32_t alt_nand_num_planes_get(void);
1059 
1073 uint32_t alt_nand_num_blocks_get(void);
1074 
1088 uint32_t alt_nand_num_pages_per_block_get(void);
1089 
1103 uint32_t alt_nand_page_size_get(void);
1104 
1115 uint32_t alt_nand_page_size_32_get(void);
1116 
1130 uint32_t alt_nand_spare_size_get(void);
1131 
1150 bool alt_nand_block_is_bad(const uint32_t block_addr);
1151 
1158 #define ALT_NAND_BAD_BLOCK_MARKER 0
1159 
1160 #define ALT_NAND_GOOD_BLOCK_FLAG 0
1161 #define ALT_NAND_BAD_BLOCK_FLAG 1
1162 
1191 typedef uint32_t * alt_nand_bad_block_table_t;
1192 
1215 ALT_STATUS_CODE alt_nand_bad_block_table_get(alt_nand_bad_block_table_t bad_block_table,
1216  const uint32_t bad_block_table_len);
1217 
1218 
1219 
1220 
1223 #ifdef __cplusplus
1224 }
1225 #endif /* __cplusplus */
1226 #endif /* __ALT_NAND_FLASH_H__ */