norflash.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _NORFLASH_H
  2. #define _NORFLASH_H
  3. #include "device/device.h"
  4. #include "ioctl_cmds.h"
  5. #include "asm/spi.h"
  6. #include "printf.h"
  7. #include "gpio.h"
  8. #include "device_drive.h"
  9. #include "malloc.h"
  10. /*************************************************/
  11. /*
  12. COMMAND LIST - WinBond FLASH WX25X
  13. */
  14. /***************************************************************/
  15. #define WINBOND_WRITE_ENABLE 0x06
  16. #define WINBOND_READ_SR1 0x05
  17. #define WINBOND_READ_SR2 0x35
  18. #define WINBOND_WRITE_SR1 0x01
  19. #define WINBOND_WRITE_SR2 0x31
  20. #define WINBOND_READ_DATA 0x03
  21. #define WINBOND_FAST_READ_DATA 0x0b
  22. #define WINBOND_FAST_READ_DUAL_OUTPUT 0x3b
  23. #define WINBOND_PAGE_PROGRAM 0x02
  24. #define WINBOND_PAGE_ERASE 0x81
  25. #define WINBOND_SECTOR_ERASE 0x20
  26. #define WINBOND_BLOCK_ERASE 0xD8
  27. #define WINBOND_CHIP_ERASE 0xC7
  28. #define WINBOND_JEDEC_ID 0x9F
  29. enum {
  30. FLASH_PAGE_ERASER,
  31. FLASH_SECTOR_ERASER,
  32. FLASH_BLOCK_ERASER,
  33. FLASH_CHIP_ERASER,
  34. };
  35. struct norflash_dev_platform_data {
  36. int spi_hw_num; //只支持SPI1或SPI2
  37. u32 spi_cs_port; //cs的引脚
  38. u32 spi_read_width; //flash读数据的线宽
  39. const struct spi_platform_data *spi_pdata;
  40. u32 start_addr; //分区起始地址
  41. u32 size; //分区大小,若只有1个分区,则这个参数可以忽略
  42. };
  43. #define NORFLASH_DEV_PLATFORM_DATA_BEGIN(data) \
  44. const struct norflash_dev_platform_data data = {
  45. #define NORFLASH_DEV_PLATFORM_DATA_END() \
  46. };
  47. extern const struct device_operations norflash_dev_ops;
  48. extern const struct device_operations norfs_dev_ops;
  49. #endif