spi_nor.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2019, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef DRIVERS_SPI_NOR_H
  7. #define DRIVERS_SPI_NOR_H
  8. #include <drivers/spi_mem.h>
  9. /* OPCODE */
  10. #define SPI_NOR_OP_WREN 0x06U /* Write enable */
  11. #define SPI_NOR_OP_WRSR 0x01U /* Write status register 1 byte */
  12. #define SPI_NOR_OP_READ_ID 0x9FU /* Read JEDEC ID */
  13. #define SPI_NOR_OP_READ_CR 0x35U /* Read configuration register */
  14. #define SPI_NOR_OP_READ_SR 0x05U /* Read status register */
  15. #define SPI_NOR_OP_READ_FSR 0x70U /* Read flag status register */
  16. #define SPINOR_OP_RDEAR 0xC8U /* Read Extended Address Register */
  17. #define SPINOR_OP_WREAR 0xC5U /* Write Extended Address Register */
  18. /* Used for Spansion flashes only. */
  19. #define SPINOR_OP_BRWR 0x17U /* Bank register write */
  20. #define SPINOR_OP_BRRD 0x16U /* Bank register read */
  21. #define SPI_NOR_OP_READ 0x03U /* Read data bytes (low frequency) */
  22. #define SPI_NOR_OP_READ_FAST 0x0BU /* Read data bytes (high frequency) */
  23. #define SPI_NOR_OP_READ_1_1_2 0x3BU /* Read data bytes (Dual Output SPI) */
  24. #define SPI_NOR_OP_READ_1_2_2 0xBBU /* Read data bytes (Dual I/O SPI) */
  25. #define SPI_NOR_OP_READ_1_1_4 0x6BU /* Read data bytes (Quad Output SPI) */
  26. #define SPI_NOR_OP_READ_1_4_4 0xEBU /* Read data bytes (Quad I/O SPI) */
  27. /* Flags for NOR specific configuration */
  28. #define SPI_NOR_USE_FSR BIT(0)
  29. #define SPI_NOR_USE_BANK BIT(1)
  30. struct nor_device {
  31. struct spi_mem_op read_op;
  32. uint32_t size;
  33. uint32_t flags;
  34. uint8_t selected_bank;
  35. uint8_t bank_write_cmd;
  36. uint8_t bank_read_cmd;
  37. };
  38. int spi_nor_read(unsigned int offset, uintptr_t buffer, size_t length,
  39. size_t *length_read);
  40. int spi_nor_init(unsigned long long *device_size, unsigned int *erase_size);
  41. /*
  42. * Platform can implement this to override default NOR instance configuration.
  43. *
  44. * @device: target NOR instance.
  45. * Return 0 on success, negative value otherwise.
  46. */
  47. int plat_get_nor_data(struct nor_device *device);
  48. #endif /* DRIVERS_SPI_NOR_H */