mmc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 OMAP34XX_NR_MMC 3
  23. #define OMAP44XX_NR_MMC 5
  24. #define OMAP2420_MMC_SIZE OMAP1_MMC_SIZE
  25. #define OMAP3_HSMMC_SIZE 0x200
  26. #define OMAP4_HSMMC_SIZE 0x1000
  27. #define OMAP2_MMC1_BASE 0x4809c000
  28. #define OMAP2_MMC2_BASE 0x480b4000
  29. #define OMAP3_MMC3_BASE 0x480ad000
  30. #define OMAP4_MMC4_BASE 0x480d1000
  31. #define OMAP4_MMC5_BASE 0x480d5000
  32. #define OMAP4_MMC_REG_OFFSET 0x100
  33. #define HSMMC5 (1 << 4)
  34. #define HSMMC4 (1 << 3)
  35. #define HSMMC3 (1 << 2)
  36. #define HSMMC2 (1 << 1)
  37. #define HSMMC1 (1 << 0)
  38. #define OMAP_MMC_MAX_SLOTS 2
  39. struct omap_mmc_platform_data {
  40. /* back-link to device */
  41. struct device *dev;
  42. /* number of slots per controller */
  43. unsigned nr_slots:2;
  44. /* set if your board has components or wiring that limits the
  45. * maximum frequency on the MMC bus */
  46. unsigned int max_freq;
  47. /* switch the bus to a new slot */
  48. int (*switch_slot)(struct device *dev, int slot);
  49. /* initialize board-specific MMC functionality, can be NULL if
  50. * not supported */
  51. int (*init)(struct device *dev);
  52. void (*cleanup)(struct device *dev);
  53. void (*shutdown)(struct device *dev);
  54. /* To handle board related suspend/resume functionality for MMC */
  55. int (*suspend)(struct device *dev, int slot);
  56. int (*resume)(struct device *dev, int slot);
  57. /* Return context loss count due to PM states changing */
  58. int (*get_context_loss_count)(struct device *dev);
  59. u64 dma_mask;
  60. /* Register offset deviation */
  61. u16 reg_offset;
  62. struct omap_mmc_slot_data {
  63. /*
  64. * 4/8 wires and any additional host capabilities
  65. * need to OR'd all capabilities (ref. linux/mmc/host.h)
  66. */
  67. u8 wires; /* Used for the MMC driver on omap1 and 2420 */
  68. u32 caps; /* Used for the MMC driver on 2430 and later */
  69. /*
  70. * nomux means "standard" muxing is wrong on this board, and
  71. * that board-specific code handled it before common init logic.
  72. */
  73. unsigned nomux:1;
  74. /* switch pin can be for card detect (default) or card cover */
  75. unsigned cover:1;
  76. /* use the internal clock */
  77. unsigned internal_clock:1;
  78. /* nonremovable e.g. eMMC */
  79. unsigned nonremovable:1;
  80. /* Try to sleep or power off when possible */
  81. unsigned power_saving:1;
  82. /* If using power_saving and the MMC power is not to go off */
  83. unsigned no_off:1;
  84. /* Regulator off remapped to sleep */
  85. unsigned vcc_aux_disable_is_sleep:1;
  86. /* we can put the features above into this variable */
  87. #define HSMMC_HAS_PBIAS (1 << 0)
  88. #define HSMMC_HAS_UPDATED_RESET (1 << 1)
  89. unsigned features;
  90. int switch_pin; /* gpio (card detect) */
  91. int gpio_wp; /* gpio (write protect) */
  92. int (*set_bus_mode)(struct device *dev, int slot, int bus_mode);
  93. int (*set_power)(struct device *dev, int slot,
  94. int power_on, int vdd);
  95. int (*get_ro)(struct device *dev, int slot);
  96. int (*set_sleep)(struct device *dev, int slot, int sleep,
  97. int vdd, int cardsleep);
  98. void (*remux)(struct device *dev, int slot, int power_on);
  99. /* Call back before enabling / disabling regulators */
  100. void (*before_set_reg)(struct device *dev, int slot,
  101. int power_on, int vdd);
  102. /* Call back after enabling / disabling regulators */
  103. void (*after_set_reg)(struct device *dev, int slot,
  104. int power_on, int vdd);
  105. /* if we have special card, init it using this callback */
  106. void (*init_card)(struct mmc_card *card);
  107. /* return MMC cover switch state, can be NULL if not supported.
  108. *
  109. * possible return values:
  110. * 0 - closed
  111. * 1 - open
  112. */
  113. int (*get_cover_state)(struct device *dev, int slot);
  114. const char *name;
  115. u32 ocr_mask;
  116. /* Card detection IRQs */
  117. int card_detect_irq;
  118. int (*card_detect)(struct device *dev, int slot);
  119. unsigned int ban_openended:1;
  120. } slots[OMAP_MMC_MAX_SLOTS];
  121. };
  122. /* called from board-specific card detection service routine */
  123. extern void omap_mmc_notify_cover_event(struct device *dev, int slot,
  124. int is_closed);
  125. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  126. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  127. void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
  128. int nr_controllers);
  129. void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  130. int nr_controllers);
  131. int omap_mmc_add(const char *name, int id, unsigned long base,
  132. unsigned long size, unsigned int irq,
  133. struct omap_mmc_platform_data *data);
  134. #else
  135. static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
  136. int nr_controllers)
  137. {
  138. }
  139. static inline void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  140. int nr_controllers)
  141. {
  142. }
  143. static inline int omap_mmc_add(const char *name, int id, unsigned long base,
  144. unsigned long size, unsigned int irq,
  145. struct omap_mmc_platform_data *data)
  146. {
  147. return 0;
  148. }
  149. #endif
  150. #endif