flash.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef FLASH_LIB_H
  2. #define FLASH_LIB_H
  3. #include <common.h>
  4. /* PIO operations max */
  5. #define FLASH_PROGRAM_POLLS 100000
  6. /* 10 Seconds default */
  7. #define FLASH_ERASE_SECTOR_TIMEOUT (10*1000 /*SEC*/ )
  8. /* Flash device info structure */
  9. typedef struct flash_dev_s {
  10. char name[24]; /* Bank Name */
  11. int bank; /* Bank 0 or 1 */
  12. unsigned int base; /* Base address */
  13. int sectors; /* Sector count */
  14. int lgSectorSize; /* Log2(usable bytes/sector) */
  15. int vendorID; /* Expected vendor ID */
  16. int deviceID; /* Expected device ID */
  17. int found; /* Set if found by flashLibInit */
  18. int swap; /* Set for bank 1 if byte swap req'd */
  19. } flash_dev_t;
  20. #define FLASH_MAX_POS(dev) \
  21. ((dev)->sectors << (dev)->lgSectorSize)
  22. #define FLASH_SECTOR_POS(dev, sector) \
  23. ((sector) << (dev)->lgSectorSize)
  24. /* AMD 29F040 */
  25. #define FLASH0_BANK 0
  26. #define FLASH0_VENDOR_ID 0x01
  27. #define FLASH0_DEVICE_ID 0x49
  28. /* AMD29LV160DB */
  29. #define FLASH1_BANK 1
  30. #define FLASH1_VENDOR_ID 0x0001
  31. #define FLASH1_DEVICE_ID 0x2249
  32. extern flash_dev_t flashDev[];
  33. extern int flashDevCount;
  34. /*
  35. * Device pointers
  36. *
  37. * These must be kept in sync with the table in flashLib.c.
  38. */
  39. #define FLASH_DEV_BANK0_SA0 (&flashDev[0])
  40. #define FLASH_DEV_BANK0_SA1 (&flashDev[1])
  41. #define FLASH_DEV_BANK0_SA2 (&flashDev[2])
  42. #define FLASH_DEV_BANK0_LOW (&flashDev[3]) /* 960K */
  43. #define FLASH_DEV_BANK0_BOOT (&flashDev[4]) /* PLCC */
  44. #define FLASH_DEV_BANK0_HIGH (&flashDev[5]) /* 512K PLCC shadow */
  45. unsigned long flash_init(void);
  46. int flashEraseSector(flash_dev_t *dev, int sector);
  47. int flashErase(flash_dev_t *dev);
  48. int flashRead(flash_dev_t *dev, int pos, char *buf, int len);
  49. int flashWrite(flash_dev_t *dev, int pos, char *buf, int len);
  50. int flashWritable(flash_dev_t *dev, int pos, int len);
  51. int flashDiag(flash_dev_t *dev);
  52. int flashDiagAll(void);
  53. ulong flash_get_size (vu_long *addr, flash_info_t *info);
  54. void flash_print_info (flash_info_t *info);
  55. int flash_erase (flash_info_t *info, int s_first, int s_last);
  56. int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
  57. /*
  58. * Flash info indices.
  59. */
  60. #define FLASH_BANK_KERNEL 0
  61. #define FLASH_BANK_BOOT 1
  62. #define FLASH_BANK_AUX 2
  63. #define FIRST_SECTOR 0
  64. #endif /* !FLASH_LIB_H */