mmc.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * MMC definitions for OMAP2
  3. *
  4. * Copyright (C) 2006 Nokia Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __OMAP2_MMC_H
  11. #define __OMAP2_MMC_H
  12. #include <linux/types.h>
  13. #include <linux/device.h>
  14. #include <linux/mmc/host.h>
  15. #include <plat/board.h>
  16. #define OMAP15XX_NR_MMC 1
  17. #define OMAP16XX_NR_MMC 2
  18. #define OMAP1_MMC_SIZE 0x080
  19. #define OMAP1_MMC1_BASE 0xfffb7800
  20. #define OMAP1_MMC2_BASE 0xfffb7c00 /* omap16xx only */
  21. #define OMAP24XX_NR_MMC 2
  22. #define OMAP2420_MMC_SIZE OMAP1_MMC_SIZE
  23. #define OMAP2_MMC1_BASE 0x4809c000
  24. #define OMAP4_MMC_REG_OFFSET 0x100
  25. #define OMAP_MMC_MAX_SLOTS 2
  26. /*
  27. * struct omap_mmc_dev_attr.flags possibilities
  28. *
  29. * OMAP_HSMMC_SUPPORTS_DUAL_VOLT: Some HSMMC controller instances can
  30. * operate with either 1.8Vdc or 3.0Vdc card voltages; this flag
  31. * should be set if this is the case. See for example Section 22.5.3
  32. * "MMC/SD/SDIO1 Bus Voltage Selection" of the OMAP34xx Multimedia
  33. * Device Silicon Revision 3.1.x Revision ZR (July 2011) (SWPU223R).
  34. *
  35. * OMAP_HSMMC_BROKEN_MULTIBLOCK_READ: Multiple-block read transfers
  36. * don't work correctly on some MMC controller instances on some
  37. * OMAP3 SoCs; this flag should be set if this is the case. See
  38. * for example Advisory 2.1.1.128 "MMC: Multiple Block Read
  39. * Operation Issue" in _OMAP3530/3525/3515/3503 Silicon Errata_
  40. * Revision F (October 2010) (SPRZ278F).
  41. */
  42. #define OMAP_HSMMC_SUPPORTS_DUAL_VOLT BIT(0)
  43. #define OMAP_HSMMC_BROKEN_MULTIBLOCK_READ BIT(1)
  44. struct omap_mmc_dev_attr {
  45. u8 flags;
  46. };
  47. struct omap_mmc_platform_data {
  48. /* back-link to device */
  49. struct device *dev;
  50. /* number of slots per controller */
  51. unsigned nr_slots:2;
  52. /* set if your board has components or wiring that limits the
  53. * maximum frequency on the MMC bus */
  54. unsigned int max_freq;
  55. /* switch the bus to a new slot */
  56. int (*switch_slot)(struct device *dev, int slot);
  57. /* initialize board-specific MMC functionality, can be NULL if
  58. * not supported */
  59. int (*init)(struct device *dev);
  60. void (*cleanup)(struct device *dev);
  61. void (*shutdown)(struct device *dev);
  62. /* To handle board related suspend/resume functionality for MMC */
  63. int (*suspend)(struct device *dev, int slot);
  64. int (*resume)(struct device *dev, int slot);
  65. /* Return context loss count due to PM states changing */
  66. int (*get_context_loss_count)(struct device *dev);
  67. u64 dma_mask;
  68. /* Integrating attributes from the omap_hwmod layer */
  69. u8 controller_flags;
  70. /* Register offset deviation */
  71. u16 reg_offset;
  72. struct omap_mmc_slot_data {
  73. /*
  74. * 4/8 wires and any additional host capabilities
  75. * need to OR'd all capabilities (ref. linux/mmc/host.h)
  76. */
  77. u8 wires; /* Used for the MMC driver on omap1 and 2420 */
  78. u32 caps; /* Used for the MMC driver on 2430 and later */
  79. u32 pm_caps; /* PM capabilities of the mmc */
  80. /*
  81. * nomux means "standard" muxing is wrong on this board, and
  82. * that board-specific code handled it before common init logic.
  83. */
  84. unsigned nomux:1;
  85. /* switch pin can be for card detect (default) or card cover */
  86. unsigned cover:1;
  87. /* use the internal clock */
  88. unsigned internal_clock:1;
  89. /* nonremovable e.g. eMMC */
  90. unsigned nonremovable:1;
  91. /* Try to sleep or power off when possible */
  92. unsigned power_saving:1;
  93. /* If using power_saving and the MMC power is not to go off */
  94. unsigned no_off:1;
  95. /* eMMC does not handle power off when not in sleep state */
  96. unsigned no_regulator_off_init:1;
  97. /* Regulator off remapped to sleep */
  98. unsigned vcc_aux_disable_is_sleep:1;
  99. /* we can put the features above into this variable */
  100. #define HSMMC_HAS_PBIAS (1 << 0)
  101. #define HSMMC_HAS_UPDATED_RESET (1 << 1)
  102. unsigned features;
  103. int switch_pin; /* gpio (card detect) */
  104. int gpio_wp; /* gpio (write protect) */
  105. int (*set_bus_mode)(struct device *dev, int slot, int bus_mode);
  106. int (*set_power)(struct device *dev, int slot,
  107. int power_on, int vdd);
  108. int (*get_ro)(struct device *dev, int slot);
  109. void (*remux)(struct device *dev, int slot, int power_on);
  110. /* Call back before enabling / disabling regulators */
  111. void (*before_set_reg)(struct device *dev, int slot,
  112. int power_on, int vdd);
  113. /* Call back after enabling / disabling regulators */
  114. void (*after_set_reg)(struct device *dev, int slot,
  115. int power_on, int vdd);
  116. /* if we have special card, init it using this callback */
  117. void (*init_card)(struct mmc_card *card);
  118. /* return MMC cover switch state, can be NULL if not supported.
  119. *
  120. * possible return values:
  121. * 0 - closed
  122. * 1 - open
  123. */
  124. int (*get_cover_state)(struct device *dev, int slot);
  125. const char *name;
  126. u32 ocr_mask;
  127. /* Card detection IRQs */
  128. int card_detect_irq;
  129. int (*card_detect)(struct device *dev, int slot);
  130. unsigned int ban_openended:1;
  131. } slots[OMAP_MMC_MAX_SLOTS];
  132. };
  133. /* called from board-specific card detection service routine */
  134. extern void omap_mmc_notify_cover_event(struct device *dev, int slot,
  135. int is_closed);
  136. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  137. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  138. void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
  139. int nr_controllers);
  140. void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data);
  141. int omap_mmc_add(const char *name, int id, unsigned long base,
  142. unsigned long size, unsigned int irq,
  143. struct omap_mmc_platform_data *data);
  144. #else
  145. static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
  146. int nr_controllers)
  147. {
  148. }
  149. static inline void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
  150. {
  151. }
  152. static inline int omap_mmc_add(const char *name, int id, unsigned long base,
  153. unsigned long size, unsigned int irq,
  154. struct omap_mmc_platform_data *data)
  155. {
  156. return 0;
  157. }
  158. #endif
  159. #endif