2 * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include "Driver_Flash.h"
21 #define ARM_FLASH_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
23 /* Sector Information */
25 static ARM_FLASH_SECTOR FLASH_SECTOR_INFO[FLASH_SECTOR_COUNT] = {
29 #define FLASH_SECTOR_INFO NULL
32 /* Flash Information */
33 static ARM_FLASH_INFO FlashInfo = {
34 0, /* FLASH_SECTOR_INFO */
35 0, /* FLASH_SECTOR_COUNT */
36 0, /* FLASH_SECTOR_SIZE */
37 0, /* FLASH_PAGE_SIZE */
38 0, /* FLASH_PROGRAM_UNIT */
39 0, /* FLASH_ERASED_VALUE */
40 { 0, 0, 0 } /* Reserved (must be zero) */
44 static ARM_FLASH_STATUS FlashStatus;
47 static const ARM_DRIVER_VERSION DriverVersion = {
48 ARM_FLASH_API_VERSION,
52 /* Driver Capabilities */
53 static const ARM_FLASH_CAPABILITIES DriverCapabilities = {
55 0, /* data_width = 0:8-bit, 1:16-bit, 2:32-bit */
57 0 /* reserved (must be zero) */
64 static ARM_DRIVER_VERSION ARM_Flash_GetVersion(void)
69 static ARM_FLASH_CAPABILITIES ARM_Flash_GetCapabilities(void)
71 return DriverCapabilities;
74 static int32_t ARM_Flash_Initialize(ARM_Flash_SignalEvent_t cb_event)
78 static int32_t ARM_Flash_Uninitialize(void)
82 static int32_t ARM_Flash_PowerControl(ARM_POWER_STATE state)
98 static int32_t ARM_Flash_ReadData(uint32_t addr, void *data, uint32_t cnt)
102 static int32_t ARM_Flash_ProgramData(uint32_t addr, const void *data, uint32_t cnt)
106 static int32_t ARM_Flash_EraseSector(uint32_t addr)
110 static int32_t ARM_Flash_EraseChip(void)
114 static ARM_FLASH_STATUS ARM_Flash_GetStatus(void)
119 static ARM_FLASH_INFO * ARM_Flash_GetInfo(void)
124 static void ARM_Flash_SignalEvent(uint32_t event)
128 // End Flash Interface
131 ARM_DRIVER_FLASH Driver_Flash0;
132 ARM_DRIVER_FLASH Driver_Flash0 = {
133 ARM_Flash_GetVersion,
134 ARM_Flash_GetCapabilities,
135 ARM_Flash_Initialize,
136 ARM_Flash_Uninitialize,
137 ARM_Flash_PowerControl,
139 ARM_Flash_ProgramData,
140 ARM_Flash_EraseSector,