mmc.h 5.0 KB

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