source: svn/trunk/newcon3bcm2_21bu/dta/src/bspi_flash.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 5.3 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2010, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: $
11 * $brcm_Revision: $
12 * $brcm_Date: $
13 *
14 * Module Description: flash data store abstraction
15 *
16 * Revision History:
17 *
18 * $brcm_Log: $
19 *
20 *
21 ***************************************************************************/
22#ifndef __BSPI_FLASH_H__
23#define __BSPI_FLASH_H__
24
25#include "bsettop_types.h"
26
27/***************************************************************************
28Summary:
29        The SPI flash interface handle.
30
31Description:
32        An opaque handle SPI device control.
33
34See Also:
35        bspi_open()
36
37****************************************************************************/
38typedef struct bspi *bspi_t;
39
40/***************************************************************************
41Summary:
42        SPI flash settings structure.
43
44Description:
45        SPI Flash configuration parameters for the attached flash type.
46
47See Also:
48        bspi_identify()
49
50****************************************************************************/
51typedef struct bspi_settings_t
52{
53        unsigned char   se_cmd;      /* Flash sector erase command */
54        unsigned int    sector_size; /* Flash sector size */
55        unsigned int    page_size;   /* Flash page size (usually 0x100) */
56        unsigned int    total_size;   /* Flash size */
57}bspi_settings_t;
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63/***************************************************************************
64Summary:
65        Use RDID command to determine flash settings.
66
67Description:
68        Uses RDID command to determine flash type and configure the settings structure.
69
70Returns:
71        non-zero on failure.
72
73See Also:
74        bspi_open(),
75
76****************************************************************************/
77bresult bspi_identify(
78                                          bspi_settings_t *p_settings   /* [out] SPI flash settings structure */
79                                          );
80/***************************************************************************
81Summary:
82        Initialize and return SPI interface handle.
83
84Description:
85        Initialize and return a SPI interface handle.  This function
86        expects the bspi_settings_t structure to be initialized.
87
88Returns:
89        SPI interface handle, non-zero on failure.
90
91See Also:
92        bspi_close(), bspi_identify(),
93
94****************************************************************************/
95bresult bspi_open(
96                                        bspi_t *h_spi,  /* [out] Return SPI handle */
97                                        bspi_settings_t *p_settings  /* [in] SPI flash settings */
98                                        );
99/***************************************************************************
100Summary:
101        Release SPI interface handle.
102
103Description:
104        Release SPI interface handle and any other SPI flash resources.
105
106Returns:
107        non-zero on failure.
108
109See Also:
110        bspi_open(),
111
112****************************************************************************/
113bresult bspi_close(
114                                        bspi_t h_spi    /* [in] SPI handle */
115                                        );
116
117/***************************************************************************
118Summary:
119        Reads a single byte from flash using the SPI interface, not memory mapped spi.
120
121Description:
122        Reads a single byte from flash using the SPI interface, not the memory mapped SPI
123        interface.  It will disable the BSP (memory mapped SPI interface) temporarily.
124
125Returns:
126        non-zero on failure.
127
128See Also:
129        bspi_open(),
130
131****************************************************************************/
132bresult bspi_read(
133                                        bspi_t h_spi,        /* [in] SPI handle */
134                                        unsigned int offset, /* [in] Offset in bytes */
135                                        unsigned char *data  /* [out] buffer to receive data */
136                                        );
137
138/***************************************************************************
139Summary:
140        Erase flash sector at offset.
141
142Description:
143        Erase flash sector at offset.  It will disable the BSP (memory mapped
144        SPI interface) temporarily.
145
146Returns:
147        non-zero on failure.
148
149See Also:
150        bspi_open(),bspi_page_program()
151
152****************************************************************************/
153bresult bspi_sector_erase(
154                                        bspi_t h_spi,        /* [in] SPI handle */
155                                        unsigned int offset  /* [in] Offset in bytes */
156                                        );
157
158/***************************************************************************
159Summary:
160        Program the flash page at offset with the data provided in the buffer.
161
162Description:
163        Program the flash page at offset with the data provided in the buffer. 
164        It will disable the BSP (memory mapped SPI interface) temporarily.
165
166Returns:
167        non-zero on failure.
168
169See Also:
170        bspi_open(), bspi_sector_erase()
171
172****************************************************************************/
173bresult bspi_page_program(
174                                        bspi_t h_spi,        /* [in] SPI handle */
175                                        unsigned int offset, /* [in] Offset in bytes */
176                                        unsigned char *buf,  /* [in] Data buffer to program */
177                                        int len              /* [in] Size in bytes of data buffer */
178                                        );
179/***************************************************************************
180Summary:
181        Flush BSPI interface.
182****************************************************************************/
183void bspi_flush(void);
184
185void mspi_enable_bspi(void);
186void mspi_disable_bspi(void);
187
188#ifdef __cplusplus
189}
190#endif
191
192#endif /* __BSPI_FLASH_H__ */
193
Note: See TracBrowser for help on using the repository browser.