card.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * linux/include/linux/mmc/card.h
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Card driver specific definitions.
  9. */
  10. #ifndef LINUX_MMC_CARD_H
  11. #define LINUX_MMC_CARD_H
  12. #include <linux/mmc/mmc.h>
  13. struct mmc_cid {
  14. unsigned int manfid;
  15. char prod_name[8];
  16. unsigned int serial;
  17. unsigned short oemid;
  18. unsigned short year;
  19. unsigned char hwrev;
  20. unsigned char fwrev;
  21. unsigned char month;
  22. };
  23. struct mmc_csd {
  24. unsigned char mmca_vsn;
  25. unsigned short cmdclass;
  26. unsigned short tacc_clks;
  27. unsigned int tacc_ns;
  28. unsigned int max_dtr;
  29. unsigned int read_blkbits;
  30. unsigned int write_blkbits;
  31. unsigned int capacity;
  32. unsigned int read_partial:1,
  33. read_misalign:1,
  34. write_partial:1,
  35. write_misalign:1;
  36. };
  37. struct sd_scr {
  38. unsigned char sda_vsn;
  39. unsigned char bus_widths;
  40. #define SD_SCR_BUS_WIDTH_1 (1<<0)
  41. #define SD_SCR_BUS_WIDTH_4 (1<<2)
  42. };
  43. struct mmc_host;
  44. /*
  45. * MMC device
  46. */
  47. struct mmc_card {
  48. struct list_head node; /* node in hosts devices list */
  49. struct mmc_host *host; /* the host this device belongs to */
  50. struct device dev; /* the device */
  51. unsigned int rca; /* relative card address of device */
  52. unsigned int state; /* (our) card state */
  53. #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
  54. #define MMC_STATE_DEAD (1<<1) /* device no longer in stack */
  55. #define MMC_STATE_BAD (1<<2) /* unrecognised device */
  56. #define MMC_STATE_SDCARD (1<<3) /* is an SD card */
  57. #define MMC_STATE_READONLY (1<<4) /* card is read-only */
  58. u32 raw_cid[4]; /* raw card CID */
  59. u32 raw_csd[4]; /* raw card CSD */
  60. u32 raw_scr[2]; /* raw card SCR */
  61. struct mmc_cid cid; /* card identification */
  62. struct mmc_csd csd; /* card specific */
  63. struct sd_scr scr; /* extra SD information */
  64. };
  65. #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
  66. #define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD)
  67. #define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
  68. #define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD)
  69. #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
  70. #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
  71. #define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
  72. #define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
  73. #define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD)
  74. #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
  75. #define mmc_card_name(c) ((c)->cid.prod_name)
  76. #define mmc_card_id(c) ((c)->dev.bus_id)
  77. #define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
  78. #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
  79. #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
  80. /*
  81. * MMC device driver (e.g., Flash card, I/O card...)
  82. */
  83. struct mmc_driver {
  84. struct device_driver drv;
  85. int (*probe)(struct mmc_card *);
  86. void (*remove)(struct mmc_card *);
  87. int (*suspend)(struct mmc_card *, pm_message_t);
  88. int (*resume)(struct mmc_card *);
  89. };
  90. extern int mmc_register_driver(struct mmc_driver *);
  91. extern void mmc_unregister_driver(struct mmc_driver *);
  92. static inline int mmc_card_claim_host(struct mmc_card *card)
  93. {
  94. return __mmc_claim_host(card->host, card);
  95. }
  96. #define mmc_card_release_host(c) mmc_release_host((c)->host)
  97. #endif