flashchip.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * struct flchip definition
  3. *
  4. * Contains information about the location and state of a given flash device
  5. *
  6. * (C) 2000 Red Hat. GPLd.
  7. *
  8. * $Id: flashchip.h,v 1.1.1.1 2007/06/12 07:27:16 eyryu Exp $
  9. *
  10. */
  11. #ifndef __MTD_FLASHCHIP_H__
  12. #define __MTD_FLASHCHIP_H__
  13. /* For spinlocks. sched.h includes spinlock.h from whichever directory it
  14. * happens to be in - so we don't have to care whether we're on 2.2, which
  15. * has asm/spinlock.h, or 2.4, which has linux/spinlock.h
  16. */
  17. #include <linux/sched.h>
  18. typedef enum {
  19. FL_READY,
  20. FL_STATUS,
  21. FL_CFI_QUERY,
  22. FL_JEDEC_QUERY,
  23. FL_ERASING,
  24. FL_ERASE_SUSPENDING,
  25. FL_ERASE_SUSPENDED,
  26. FL_WRITING,
  27. FL_WRITING_TO_BUFFER,
  28. FL_OTP_WRITE,
  29. FL_WRITE_SUSPENDING,
  30. FL_WRITE_SUSPENDED,
  31. FL_PM_SUSPENDED,
  32. FL_SYNCING,
  33. FL_UNLOADING,
  34. FL_LOCKING,
  35. FL_UNLOCKING,
  36. FL_POINT,
  37. FL_XIP_WHILE_ERASING,
  38. FL_XIP_WHILE_WRITING,
  39. FL_UNKNOWN
  40. } flstate_t;
  41. /* NOTE: confusingly, this can be used to refer to more than one chip at a time,
  42. if they're interleaved. This can even refer to individual partitions on
  43. the same physical chip when present. */
  44. struct flchip {
  45. unsigned long start; /* Offset within the map */
  46. // unsigned long len;
  47. /* We omit len for now, because when we group them together
  48. we insist that they're all of the same size, and the chip size
  49. is held in the next level up. If we get more versatile later,
  50. it'll make it a damn sight harder to find which chip we want from
  51. a given offset, and we'll want to add the per-chip length field
  52. back in.
  53. */
  54. int ref_point_counter;
  55. flstate_t state;
  56. flstate_t oldstate;
  57. unsigned int write_suspended:1;
  58. unsigned int erase_suspended:1;
  59. unsigned long in_progress_block_addr;
  60. spinlock_t *mutex;
  61. spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */
  62. wait_queue_head_t wq; /* Wait on here when we're waiting for the chip
  63. to be ready */
  64. int word_write_time;
  65. int buffer_write_time;
  66. int erase_time;
  67. void *priv;
  68. };
  69. /* This is used to handle contention on write/erase operations
  70. between partitions of the same physical chip. */
  71. struct flchip_shared {
  72. spinlock_t lock;
  73. struct flchip *writing;
  74. struct flchip *erasing;
  75. };
  76. #endif /* __MTD_FLASHCHIP_H__ */