spi.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef __SPI_H__
  2. #define __SPI_H__
  3. #include "update.h"
  4. #define MAX_WAIT_LOOP_COUNT 100000
  5. #define SPI_WRITE_ENABLE 0x06
  6. #define SPI_WRITE_DISABLE 0x04
  7. #define SPI_READ_STATUS 0x05
  8. #define SPI_READ_STATUS2 0x35
  9. #define SPI_READ_STATUS3 0x15
  10. #define SPI_WRITE_STATUS 0x01
  11. #define SPI_WRITE_STATUS2 0x31
  12. #define SPI_READ_DATA 0x03
  13. #define SPI_4BYTEADDR_READ_DATA 0x13
  14. #define SPI_FAST_READ 0x0B
  15. #define SPI_PAGE_PROGRAM 0x02
  16. #define SPI_4BYTEADD_PAGE_PROGRAM 0x12
  17. #define SPI_SECTOR_ERASE 0x20
  18. #define SPI_4BYTEADD_SECTOR_ERASE 0x21
  19. #define SPI_SECTOR_ERASE_1 0xD7
  20. #define SPI_BLOCK_ERASE 0xD8
  21. #define SPI_4BYTEADD_BLOCK_ERASE 0xDC
  22. #define SPI_BLOCK_ERASE_1 0x52
  23. #define SPI_CHIP_ERASE 0xC7
  24. #define SPI_CHIP_ERASE_1 0x60
  25. #define SPI_POWER_DOWN 0xB9
  26. #define SPI_READ_JEDEC_ID 0x9F
  27. #define SPI_READ_ID_1 0xAB
  28. #define SPI_MF_DEVICE_ID 0x90
  29. #define SPI_MF_DEVICE_ID_1 0x15
  30. #define SPI_READ_ELECTRON_SIGN 0xAB
  31. #define SPI_MF_WINBOND 0xEF
  32. #define SPI_MF_EON 0x1C
  33. #define SPI_MF_AMIC 0x37
  34. #define SPI_MF_ATMEL 0x1F
  35. #define SPI_MF_SST 0xBF
  36. #define SPI_MF_MXIC 0xC2
  37. #define SPI_ENABLE_4BYTE_MODE 0xB7
  38. #define SPI_DISABLE_4BYTE_MODE 0xE9
  39. #define SPI_QUAD_IO_READ_DATA 0xEB
  40. #define SPI_BUSY (1<<0)
  41. #define SPIFLASH_WRITEENABLE (1<<1)
  42. #define SPI_QE (1 << 1)
  43. #define SPI_QE2 (1 << 6)
  44. #define SPI_WRITE_DMA
  45. #define SPI_READ_DMA
  46. #define WORDSPERPAGE 64
  47. #define BYTESPERPAGE 256
  48. #define PAGESPERSECTORS 16
  49. #define SECTORSPERBLOCK 16
  50. #define BLOCKSPERFLASH 64
  51. #define BYTESPERBLOCK (BYTESPERPAGE*PAGESPERSECTORS*SECTORSPERBLOCK)
  52. #define BYTESPERSECTOR (BYTESPERPAGE*PAGESPERSECTORS)
  53. #define PAGES_PER_BLOCK 64
  54. #define BYTES_PER_PAGE 2048
  55. void SpiSelectPad(void);
  56. void SpiInit(void);
  57. void SpiBurnLoad(void);
  58. void SpiReadId(void);
  59. int SpiNorBurn(void *buf, unsigned int offset, unsigned int size, int show_progress);
  60. unsigned int SpiGetUpfileOffset(int type);
  61. #endif