-
Notifications
You must be signed in to change notification settings - Fork 45
/
mss_envm.h
183 lines (160 loc) · 5.31 KB
/
mss_envm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*******************************************************************************
* Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
*
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* PolarFire SoC MSS eNVM bare metal software driver public APIs.
*
*/
#ifndef MSS_ENVM_H
#define MSS_ENVM_H
#include "stdint.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Base address for C_BUS set by Microsemi. All other REG_IF registers are
* offset from this address - C_Bus address base
*/
#define FM_SYS_START_ADDR 0x20200000
#define MSS_ENVM_DATA_BASE ((uint64_t) 0x0020220000llu)
#define MSS_ENVM_DATA_SECTOR2 (MSS_ENVM_DATA_BASE + 0x00000)
#define MSS_ENVM_DATA_SECTOR0 (MSS_ENVM_DATA_BASE + 0x02000)
#define MSS_ENVM_DATA_SECTOR1 (MSS_ENVM_DATA_BASE + 0x10000)
#define MSS_ENVM_DATA_SECTOR3 (MSS_ENVM_DATA_BASE + 0x1E000)
#define NUM_FM_PAGES 224u
#define NUM_SM_PAGES 32u
typedef struct {
uint8_t sector;
uint8_t page;
} envm_addr_t;
/**
* envm_set_clock function which setups the clock and timing for the eNVM
*
* Must be called after envm_init()
*
* \param[in] mss_frequency is the frequency the MSS is running at in MHz
*/
void envm_set_clock(uint32_t mss_frequency);
/**
* envm_init function which sets up the programming and read parameters.
*
* Must be called first in order to use eNVM
*
* \pre eNVM powered up by controller
*
* \param[in] p_envm_params specifies a pointer to an array containing the eNVM
* parameters retrieved through system services.
*
* \retval 0 passed
* \retval 1 failed
*
*/
uint8_t envm_init(const uint8_t * p_envm_params);
/**
* Top level envm_program_page function which takes in absolute address
* performs a full program and verify cycle of the eNVM
* performs a preprogram - erase - write cycle and then a verify
*
* Erased is 0 and Program is 1
*
* \pre pageLatchData.pageData correctly setup with data to be programmed
*
* \param[in] absolute_address specifies the absolute address
*
* \retval 0 eNVM was programmed successfully
* \retval 1 eNVM verify error occurred during programming
* \retval 2 page is outside boundary error
* \retval 3 page latch load error
* \retval 4 startup previously failed
*/
uint_fast8_t envm_program_page_address(uint64_t absolute_address);
/**
* Top level envm_erase_sector function which takes in absolute address
* performs a preprogram - erase cycle of a sector
*
* \param[in] absolute_address specifies the absolute address
*
* \retval 0 eNVM was erased successfully
* \retval 2 page is outside boundary error
* \retval 4 startup previously failed
*/
uint_fast8_t envm_erase_sector_address(uint64_t absolute_address);
/**
* performs a full program and verify cycle of the eNVM
* performs a preprogram - erase - write cycle and then a verify
*
* Erased is 0 and Program is 1
*
* \pre pageLatchData.pageData correctly setup with data to be programmed
*
* \param[in] sector specifies one of the four sectors
* \param[in] page specifies one of the pages within a sector
*
* \retval 0 eNVM was programmed successfully
* \retval 1 eNVM verify error occurred during programming
* \retval 2 page is outside boundary error
* \retval 3 page latch load error
* \retval 4 startup previously failed
* \retval 5 sector outside bounds error
*/
uint_fast8_t envm_program_page(uint_fast8_t sector, uint_fast8_t page);
/**
* performs an erase of a full sector of the eNVM
* performs a preprogram - erase cycle
*
* \param[in] sector specifies one of the four sectors
*
* \retval 0 eNVM was programmed successfully
* \retval 4 startup previously failed
* \retval 5 sector outside bounds error
*/
uint_fast8_t envm_erase_sector(uint_fast8_t sector);
/**
* Top level envm_erase_bulk function
* performs a preprogram - erase cycle of all sectors
*
* \param[in] absolute_address specifies the absolute address
*
* \retval 0 eNVM was erased successfully
* \retval 4 startup previously failed
*/
uint_fast8_t envm_erase_bulk(void);
/**
* Returns the eNVM Sector & Page information derived from eNVM absolute address
* Returns 0 if Sector & Page are valid
*
*/
uint_fast8_t envm_address(uint64_t absolute_address, envm_addr_t * envm_address);
/**
* load block of data into pageData
*
*/
void envm_set_page_data(uint32_t *source);
/**
* clears pageData contents to 0
*
*/
void envm_clear_page_data(void);
#ifdef __cplusplus
}
#endif
#endif