1 /*
2 *
3 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
38 #ifndef _NAND_HW_API_H
39 #define _NAND_HW_API_H
40 /****************************************************************************************
41 * FILE PURPOSE: Define the nand api which applies to all nand drivers
42 ****************************************************************************************
43 * FILE NAME: nandhwapi.h
44 *
45 * DESCRIPTION: Defines the API used by all the low level nand drivers
46 *
47 * @file nandhwapi.h
48 *
49 * @brief
50 * Defines the API used by all the low level nand drivers
51 *
52 ****************************************************************************************/
54 /* Return values */
55 #define NAND_INVALID_ADDR_SIZE -810
56 #define NAND_NULL_ARG -811
57 #define NAND_INVALID_ADDR -812
58 #define NAND_ECC_FAILURE -813
59 #define NAND_INVALID_CS -814
60 #define NAND_READ_FAILURE -815
63 /* Information used only for programming flash */
64 typedef struct nandProgramInfo_s
65 {
66 uint8 blockEraseCommandPre; /**< The command used to erase a block (sent before the address) */
67 uint8 blockEraseCommandPost; /**< The command used to erase a block (sent after the address) */
68 uint8 blockEraseNaddrBytes; /**< The number of address bytes sent */
69 bool blockErasePost; /**< If TRUE the post command is sent */
71 uint8 pageWriteCommandPre; /**< The command used to program a page (sent before the address) */
72 uint8 pageWriteCommandPost; /**< The command used to program a page (sent after the address) */
73 bool pageWritePost; /**< If TRUE the post command is sent */
75 } nandProgramInfo_t;
80 /* Driver functions, EMIF and GPIO interface */
81 Int32 nandHwGpioDriverInit (int32 cs, void *devInfo);
82 Int32 nandHwGpioDriverReadBytes (Uint32 block, Uint32 page, Uint32 byte, Uint32 nbytes, Uint8 *data);
83 Int32 nandHwGpioDriverReadPage(Uint32 block, Uint32 page, Uint8 *data);
84 Int32 nandHwGpioDriverClose (void);
86 Int32 nandHwDriverWritePage (Uint32 block, Uint32 page, Uint8 *data, nandProgramInfo_t *winfo);
87 Int32 nandHwDriverBlockErase (Uint32 uiBlockNumber, nandProgramInfo_t *winfo);
89 /* Driver functions, SPI interface */
90 Int32 nandHwSpiDriverInit (int32 cs, void *devInfo);
91 Int32 nandHwSpiDriverReadBytes (Uint32 block, Uint32 page, Uint32 byte, Uint32 nbytes, Uint8 *data);
92 Int32 nandHwSpiDriverReadPage(Uint32 block, Uint32 page, Uint8 *data);
93 Int32 nandHwSpiDriverClose (void);
98 #endif /* _NAND_HW_API_H */