v2m_flash.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef V2M_FLASH_H
  7. #define V2M_FLASH_H
  8. #include <stdint.h>
  9. /* First bus cycle */
  10. #define NOR_CMD_READ_ARRAY 0xFF
  11. #define NOR_CMD_READ_ID_CODE 0x90
  12. #define NOR_CMD_READ_QUERY 0x98
  13. #define NOR_CMD_READ_STATUS_REG 0x70
  14. #define NOR_CMD_CLEAR_STATUS_REG 0x50
  15. #define NOR_CMD_WRITE_TO_BUFFER 0xE8
  16. #define NOR_CMD_WORD_PROGRAM 0x40
  17. #define NOR_CMD_BLOCK_ERASE 0x20
  18. #define NOR_CMD_LOCK_UNLOCK 0x60
  19. #define NOR_CMD_BLOCK_ERASE_ACK 0xD0
  20. /* Second bus cycle */
  21. #define NOR_LOCK_BLOCK 0x01
  22. #define NOR_UNLOCK_BLOCK 0xD0
  23. /* Status register bits */
  24. #define NOR_DWS (1 << 7)
  25. #define NOR_ESS (1 << 6)
  26. #define NOR_ES (1 << 5)
  27. #define NOR_PS (1 << 4)
  28. #define NOR_VPPS (1 << 3)
  29. #define NOR_PSS (1 << 2)
  30. #define NOR_BLS (1 << 1)
  31. #define NOR_BWS (1 << 0)
  32. /* Public API */
  33. void nor_send_cmd(uintptr_t base_addr, unsigned long cmd);
  34. int nor_word_program(uintptr_t base_addr, unsigned long data);
  35. int nor_lock(uintptr_t base_addr);
  36. int nor_unlock(uintptr_t base_addr);
  37. int nor_erase(uintptr_t base_addr);
  38. #endif /* V2M_FLASH_H*/