Altera HWLIB  16.0
The Altera HW Manager API Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
alt_nand_flash.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright 2013 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: //depot/embedded/rel/15.0/ip/hps/altera_hps/hwlib/include/alt_nand_flash.h#1 $
35  */
36 
41 #ifndef __ALT_NAND_FLASH_H__
42 #define __ALT_NAND_FLASH_H__
43 
44 #include "hwlib.h"
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif /* __cplusplus */
50 
51 /******************************************************************************/
140 typedef void (*alt_nand_callback_t)(ALT_STATUS_CODE status, void *callback_arg);
141 
163 typedef ALT_STATUS_CODE (*alt_nand_flash_custom_init_t)(void *user_arg);
164 
247 ALT_STATUS_CODE alt_nand_flash_init(const bool load_block0_page0,
248  const bool page_size_512,
249  alt_nand_flash_custom_init_t custom_init,
250  void *user_arg);
251 
264 ALT_STATUS_CODE alt_nand_flash_uninit(void);
265 
269 #define ALT_NAND_INVALID_FLASH_ADDR 0xffffffff
270 
283 uint32_t alt_nand_block_address_get(const uint32_t addr);
284 
297 uint32_t alt_nand_page_address_get(const uint32_t addr);
298 
317 uint32_t alt_nand_flash_addr_compose(const uint32_t block_num,
318  const uint32_t page_num);
319 
356 ALT_STATUS_CODE alt_nand_flash_block_erase(const uint32_t block_addr,
357  alt_nand_callback_t completion_callback,
358  void *completion_arg);
359 
413 ALT_STATUS_CODE alt_nand_flash_page_read(const uint32_t page_addr,
414  const uint32_t num_pages,
415  void *dest,
416  const uint32_t dest_size);
417 
448 ALT_STATUS_CODE alt_nand_flash_page_write(const uint32_t page_addr,
449  const uint32_t num_pages,
450  const void *src,
451  const uint32_t src_size);
452 
501 ALT_STATUS_CODE alt_nand_flash_page_dma_read(const uint32_t page_addr,
502  const uint32_t num_pages,
503  void *dest,
504  const uint32_t dest_size,
505  alt_nand_callback_t completion_callback,
506  void *completion_arg);
553 ALT_STATUS_CODE alt_nand_flash_page_dma_write(const uint32_t page_addr,
554  const uint32_t num_pages,
555  const void *src,
556  const uint32_t src_size,
557  alt_nand_callback_t completion_callback,
558  void *completion_arg);
559 
565 {
571 
588 ALT_STATUS_CODE alt_nand_flash_ecc_enable(const ALT_NAND_ECC_CORRECTION_t ecc_correction);
589 
600 ALT_STATUS_CODE alt_nand_flash_ecc_disable(void);
601 
602 
608 {
609  uint32_t corrected_errors[4];
626 
644 
683 {
780 
794 uint32_t alt_nand_int_status_get(void);
795 
811 ALT_STATUS_CODE alt_nand_int_clear(const uint32_t mask);
812 
834 ALT_STATUS_CODE alt_nand_int_disable(const uint32_t mask);
835 
857 ALT_STATUS_CODE alt_nand_int_enable(const uint32_t mask);
858 
872 uint32_t alt_nand_num_planes_get(void);
873 
887 uint32_t alt_nand_num_blocks_get(void);
888 
902 uint32_t alt_nand_num_pages_per_block_get(void);
903 
917 uint32_t alt_nand_sector_size_get(void);
918 
932 uint32_t alt_nand_spare_size_get(void);
933 
952 bool alt_nand_block_is_bad(const uint32_t block_addr);
953 
960 #define ALT_NAND_BAD_BLOCK_MARKER 0
961 
990 typedef uint32_t * alt_nand_bad_block_table_t;
991 
1014 ALT_STATUS_CODE alt_nand_bad_block_table_get(alt_nand_bad_block_table_t bad_block_table,
1015  const uint32_t bad_block_table_len);
1016 
1017 
1018 
1019 
1022 #ifdef __cplusplus
1023 }
1024 #endif /* __cplusplus */
1025 #endif /* __ALT_NAND_FLASH_H__ */