card.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 capacity;
  31. };
  32. struct mmc_host;
  33. /*
  34. * MMC device
  35. */
  36. struct mmc_card {
  37. struct list_head node; /* node in hosts devices list */
  38. struct mmc_host *host; /* the host this device belongs to */
  39. struct device dev; /* the device */
  40. unsigned int rca; /* relative card address of device */
  41. unsigned int state; /* (our) card state */
  42. #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
  43. #define MMC_STATE_DEAD (1<<1) /* device no longer in stack */
  44. #define MMC_STATE_BAD (1<<2) /* unrecognised device */
  45. u32 raw_cid[4]; /* raw card CID */
  46. u32 raw_csd[4]; /* raw card CSD */
  47. struct mmc_cid cid; /* card identification */
  48. struct mmc_csd csd; /* card specific */
  49. };
  50. #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
  51. #define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD)
  52. #define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
  53. #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
  54. #define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
  55. #define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
  56. #define mmc_card_name(c) ((c)->cid.prod_name)
  57. #define mmc_card_id(c) ((c)->dev.bus_id)
  58. #define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
  59. #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
  60. #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
  61. /*
  62. * MMC device driver (e.g., Flash card, I/O card...)
  63. */
  64. struct mmc_driver {
  65. struct device_driver drv;
  66. int (*probe)(struct mmc_card *);
  67. void (*remove)(struct mmc_card *);
  68. int (*suspend)(struct mmc_card *, pm_message_t);
  69. int (*resume)(struct mmc_card *);
  70. };
  71. extern int mmc_register_driver(struct mmc_driver *);
  72. extern void mmc_unregister_driver(struct mmc_driver *);
  73. static inline int mmc_card_claim_host(struct mmc_card *card)
  74. {
  75. return __mmc_claim_host(card->host, card);
  76. }
  77. #define mmc_card_release_host(c) mmc_release_host((c)->host)
  78. #endif