You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
2.7 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2012 by George Harris *
  3. * george@luminairecoffee.com *
  4. * *
  5. * Copyright (C) 2010 by Antonio Borneo *
  6. * borneo.antonio@gmail.com *
  7. * *
  8. * This program is free software; you can redistribute it and/or modify *
  9. * it under the terms of the GNU General Public License as published by *
  10. * the Free Software Foundation; either version 2 of the License, or *
  11. * (at your option) any later version. *
  12. * *
  13. * This program is distributed in the hope that it will be useful, *
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU General Public License for more details. *
  17. * *
  18. * You should have received a copy of the GNU General Public License *
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  20. ***************************************************************************/
  21. #ifndef OPENOCD_FLASH_NOR_SPI_H
  22. #define OPENOCD_FLASH_NOR_SPI_H
  23. /* data structure to maintain flash ids from different vendors */
  24. struct flash_device {
  25. char *name;
  26. uint8_t erase_cmd;
  27. uint8_t chip_erase_cmd;
  28. uint32_t device_id;
  29. uint32_t pagesize;
  30. unsigned long sectorsize;
  31. unsigned long size_in_bytes;
  32. };
  33. #define FLASH_ID(n, es, ces, id, psize, ssize, size) \
  34. { \
  35. .name = n, \
  36. .erase_cmd = es, \
  37. .chip_erase_cmd = ces, \
  38. .device_id = id, \
  39. .pagesize = psize, \
  40. .sectorsize = ssize, \
  41. .size_in_bytes = size \
  42. }
  43. extern const struct flash_device flash_devices[];
  44. /* fields in SPI flash status register */
  45. #define SPIFLASH_BSY_BIT 0x00000001 /* WIP Bit of SPI SR on SMI SR */
  46. #define SPIFLASH_WE_BIT 0x00000002 /* WEL Bit of SPI SR on SMI SR */
  47. /* SPI Flash Commands */
  48. #define SPIFLASH_READ_ID 0x9F /* Read Flash Identification */
  49. #define SPIFLASH_READ_STATUS 0x05 /* Read Status Register */
  50. #define SPIFLASH_WRITE_ENABLE 0x06 /* Write Enable */
  51. #define SPIFLASH_PAGE_PROGRAM 0x02 /* Page Program */
  52. #define SPIFLASH_FAST_READ 0x0B /* Fast Read */
  53. #define SPIFLASH_READ 0x03 /* Normal Read */
  54. #endif /* OPENOCD_FLASH_NOR_SPI_H */