card.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #define MMC_STATE_SDCARD (1<<3) /* is an SD card */
  46. u32 raw_cid[4]; /* raw card CID */
  47. u32 raw_csd[4]; /* raw card CSD */
  48. struct mmc_cid cid; /* card identification */
  49. struct mmc_csd csd; /* card specific */
  50. };
  51. #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
  52. #define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD)
  53. #define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
  54. #define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD)
  55. #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
  56. #define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
  57. #define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
  58. #define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD)
  59. #define mmc_card_name(c) ((c)->cid.prod_name)
  60. #define mmc_card_id(c) ((c)->dev.bus_id)
  61. #define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
  62. #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
  63. #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
  64. /*
  65. * MMC device driver (e.g., Flash card, I/O card...)
  66. */
  67. struct mmc_driver {
  68. struct device_driver drv;
  69. int (*probe)(struct mmc_card *);
  70. void (*remove)(struct mmc_card *);
  71. int (*suspend)(struct mmc_card *, pm_message_t);
  72. int (*resume)(struct mmc_card *);
  73. };
  74. extern int mmc_register_driver(struct mmc_driver *);
  75. extern void mmc_unregister_driver(struct mmc_driver *);
  76. static inline int mmc_card_claim_host(struct mmc_card *card)
  77. {
  78. return __mmc_claim_host(card->host, card);
  79. }
  80. #define mmc_card_release_host(c) mmc_release_host((c)->host)
  81. #endif