Juan Castillo | facdd1c | 2015-08-12 12:53:02 +0100 | [diff] [blame] | 1 | /* |
Roberto Vargas | 86a610e | 2017-07-26 14:37:56 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | facdd1c | 2015-08-12 12:53:02 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | facdd1c | 2015-08-12 12:53:02 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef V2M_FLASH_H |
| 8 | #define V2M_FLASH_H |
Juan Castillo | facdd1c | 2015-08-12 12:53:02 +0100 | [diff] [blame] | 9 | |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | /* First bus cycle */ |
| 13 | #define NOR_CMD_READ_ARRAY 0xFF |
| 14 | #define NOR_CMD_READ_ID_CODE 0x90 |
| 15 | #define NOR_CMD_READ_QUERY 0x98 |
| 16 | #define NOR_CMD_READ_STATUS_REG 0x70 |
| 17 | #define NOR_CMD_CLEAR_STATUS_REG 0x50 |
| 18 | #define NOR_CMD_WRITE_TO_BUFFER 0xE8 |
| 19 | #define NOR_CMD_WORD_PROGRAM 0x40 |
| 20 | #define NOR_CMD_BLOCK_ERASE 0x20 |
| 21 | #define NOR_CMD_LOCK_UNLOCK 0x60 |
Roberto Vargas | ea21edc | 2017-07-28 10:38:24 +0100 | [diff] [blame] | 22 | #define NOR_CMD_BLOCK_ERASE_ACK 0xD0 |
Juan Castillo | facdd1c | 2015-08-12 12:53:02 +0100 | [diff] [blame] | 23 | |
| 24 | /* Second bus cycle */ |
| 25 | #define NOR_LOCK_BLOCK 0x01 |
| 26 | #define NOR_UNLOCK_BLOCK 0xD0 |
| 27 | |
| 28 | /* Status register bits */ |
| 29 | #define NOR_DWS (1 << 7) |
| 30 | #define NOR_ESS (1 << 6) |
| 31 | #define NOR_ES (1 << 5) |
| 32 | #define NOR_PS (1 << 4) |
| 33 | #define NOR_VPPS (1 << 3) |
| 34 | #define NOR_PSS (1 << 2) |
| 35 | #define NOR_BLS (1 << 1) |
| 36 | #define NOR_BWS (1 << 0) |
| 37 | |
| 38 | /* Public API */ |
| 39 | void nor_send_cmd(uintptr_t base_addr, unsigned long cmd); |
| 40 | int nor_word_program(uintptr_t base_addr, unsigned long data); |
Roberto Vargas | 86a610e | 2017-07-26 14:37:56 +0100 | [diff] [blame] | 41 | int nor_lock(uintptr_t base_addr); |
| 42 | int nor_unlock(uintptr_t base_addr); |
Roberto Vargas | ea21edc | 2017-07-28 10:38:24 +0100 | [diff] [blame] | 43 | int nor_erase(uintptr_t base_addr); |
Juan Castillo | facdd1c | 2015-08-12 12:53:02 +0100 | [diff] [blame] | 44 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 45 | #endif /* V2M_FLASH_H*/ |