spi_flash_internal.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * SPI flash internal definitions
  3. *
  4. * Copyright (C) 2008 Atmel Corporation
  5. */
  6. /* Common parameters */
  7. #define SPI_FLASH_PROG_TIMEOUT ((10 * CFG_HZ) / 1000)
  8. #define SPI_FLASH_PAGE_ERASE_TIMEOUT ((50 * CFG_HZ) / 1000)
  9. #define SPI_FLASH_SECTOR_ERASE_TIMEOUT (10 * CFG_HZ)
  10. /* Common commands */
  11. #define CMD_READ_ID 0x9f
  12. #define CMD_READ_ARRAY_SLOW 0x03
  13. #define CMD_READ_ARRAY_FAST 0x0b
  14. #define CMD_READ_ARRAY_LEGACY 0xe8
  15. /* Send a single-byte command to the device and read the response */
  16. int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len);
  17. /*
  18. * Send a multi-byte command to the device and read the response. Used
  19. * for flash array reads, etc.
  20. */
  21. int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
  22. size_t cmd_len, void *data, size_t data_len);
  23. /*
  24. * Send a multi-byte command to the device followed by (optional)
  25. * data. Used for programming the flash array, etc.
  26. */
  27. int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
  28. const void *data, size_t data_len);
  29. /*
  30. * Same as spi_flash_cmd_read() except it also claims/releases the SPI
  31. * bus. Used as common part of the ->read() operation.
  32. */
  33. int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
  34. size_t cmd_len, void *data, size_t data_len);
  35. /* Manufacturer-specific probe functions */
  36. struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode);
  37. struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);