sdhci.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /* linux/arch/arm/plat-s3c/include/plat/sdhci.h
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * http://armlinux.simtec.co.uk/
  6. * Ben Dooks <ben@simtec.co.uk>
  7. *
  8. * S3C Platform - SDHCI (HSMMC) platform data definitions
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __PLAT_S3C_SDHCI_H
  15. #define __PLAT_S3C_SDHCI_H __FILE__
  16. struct platform_device;
  17. struct mmc_host;
  18. struct mmc_card;
  19. struct mmc_ios;
  20. enum cd_types {
  21. S3C_SDHCI_CD_INTERNAL, /* use mmc internal CD line */
  22. S3C_SDHCI_CD_EXTERNAL, /* use external callback */
  23. S3C_SDHCI_CD_GPIO, /* use external gpio pin for CD line */
  24. S3C_SDHCI_CD_NONE, /* no CD line, use polling to detect card */
  25. S3C_SDHCI_CD_PERMANENT, /* no CD line, card permanently wired to host */
  26. };
  27. /**
  28. * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
  29. * @max_width: The maximum number of data bits supported.
  30. * @host_caps: Standard MMC host capabilities bit field.
  31. * @cd_type: Type of Card Detection method (see cd_types enum above)
  32. * @ext_cd_init: Initialize external card detect subsystem. Called on
  33. * sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
  34. * notify_func argument is a callback to the sdhci-s3c driver
  35. * that triggers the card detection event. Callback arguments:
  36. * dev is pointer to platform device of the host controller,
  37. * state is new state of the card (0 - removed, 1 - inserted).
  38. * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
  39. * sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
  40. * notify_func argument is the same callback as for ext_cd_init.
  41. * @ext_cd_gpio: gpio pin used for external CD line, valid only if
  42. * cd_type == S3C_SDHCI_CD_GPIO
  43. * @ext_cd_gpio_invert: invert values for external CD gpio line
  44. * @cfg_gpio: Configure the GPIO for a specific card bit-width
  45. * @cfg_card: Configure the interface for a specific card and speed. This
  46. * is necessary the controllers and/or GPIO blocks require the
  47. * changing of driver-strength and other controls dependant on
  48. * the card and speed of operation.
  49. *
  50. * Initialisation data specific to either the machine or the platform
  51. * for the device driver to use or call-back when configuring gpio or
  52. * card speed information.
  53. */
  54. struct s3c_sdhci_platdata {
  55. unsigned int max_width;
  56. unsigned int host_caps;
  57. enum cd_types cd_type;
  58. char **clocks; /* set of clock sources */
  59. int ext_cd_gpio;
  60. bool ext_cd_gpio_invert;
  61. int (*ext_cd_init)(void (*notify_func)(struct platform_device *,
  62. int state));
  63. int (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
  64. int state));
  65. void (*cfg_gpio)(struct platform_device *dev, int width);
  66. void (*cfg_card)(struct platform_device *dev,
  67. void __iomem *regbase,
  68. struct mmc_ios *ios,
  69. struct mmc_card *card);
  70. };
  71. /**
  72. * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
  73. * @pd: Platform data to register to device.
  74. *
  75. * Register the given platform data for use withe S3C SDHCI device.
  76. * The call will copy the platform data, so the board definitions can
  77. * make the structure itself __initdata.
  78. */
  79. extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
  80. extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
  81. extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
  82. extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
  83. /* Default platform data, exported so that per-cpu initialisation can
  84. * set the correct one when there are more than one cpu type selected.
  85. */
  86. extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
  87. extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
  88. extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
  89. extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
  90. /* Helper function availablity */
  91. extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  92. extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  93. extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  94. extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  95. extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  96. extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  97. extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  98. extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  99. extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  100. extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  101. /* S3C64XX SDHCI setup */
  102. #ifdef CONFIG_S3C64XX_SETUP_SDHCI
  103. extern char *s3c64xx_hsmmc_clksrcs[4];
  104. extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
  105. void __iomem *r,
  106. struct mmc_ios *ios,
  107. struct mmc_card *card);
  108. static inline void s3c6400_default_sdhci0(void)
  109. {
  110. #ifdef CONFIG_S3C_DEV_HSMMC
  111. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  112. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  113. s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  114. #endif
  115. }
  116. static inline void s3c6400_default_sdhci1(void)
  117. {
  118. #ifdef CONFIG_S3C_DEV_HSMMC1
  119. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  120. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  121. s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  122. #endif
  123. }
  124. static inline void s3c6400_default_sdhci2(void)
  125. {
  126. #ifdef CONFIG_S3C_DEV_HSMMC2
  127. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  128. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  129. s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  130. #endif
  131. }
  132. extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
  133. void __iomem *r,
  134. struct mmc_ios *ios,
  135. struct mmc_card *card);
  136. static inline void s3c6410_default_sdhci0(void)
  137. {
  138. #ifdef CONFIG_S3C_DEV_HSMMC
  139. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  140. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  141. s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  142. #endif
  143. }
  144. static inline void s3c6410_default_sdhci1(void)
  145. {
  146. #ifdef CONFIG_S3C_DEV_HSMMC1
  147. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  148. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  149. s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  150. #endif
  151. }
  152. static inline void s3c6410_default_sdhci2(void)
  153. {
  154. #ifdef CONFIG_S3C_DEV_HSMMC2
  155. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  156. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  157. s3c_hsmmc2_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  158. #endif
  159. }
  160. #else
  161. static inline void s3c6410_default_sdhci0(void) { }
  162. static inline void s3c6410_default_sdhci1(void) { }
  163. static inline void s3c6410_default_sdhci2(void) { }
  164. static inline void s3c6400_default_sdhci0(void) { }
  165. static inline void s3c6400_default_sdhci1(void) { }
  166. static inline void s3c6400_default_sdhci2(void) { }
  167. #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
  168. /* S5PC100 SDHCI setup */
  169. #ifdef CONFIG_S5PC100_SETUP_SDHCI
  170. extern char *s5pc100_hsmmc_clksrcs[4];
  171. extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
  172. void __iomem *r,
  173. struct mmc_ios *ios,
  174. struct mmc_card *card);
  175. static inline void s5pc100_default_sdhci0(void)
  176. {
  177. #ifdef CONFIG_S3C_DEV_HSMMC
  178. s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  179. s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
  180. s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  181. #endif
  182. }
  183. static inline void s5pc100_default_sdhci1(void)
  184. {
  185. #ifdef CONFIG_S3C_DEV_HSMMC1
  186. s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  187. s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
  188. s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  189. #endif
  190. }
  191. static inline void s5pc100_default_sdhci2(void)
  192. {
  193. #ifdef CONFIG_S3C_DEV_HSMMC2
  194. s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  195. s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
  196. s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  197. #endif
  198. }
  199. #else
  200. static inline void s5pc100_default_sdhci0(void) { }
  201. static inline void s5pc100_default_sdhci1(void) { }
  202. static inline void s5pc100_default_sdhci2(void) { }
  203. #endif /* CONFIG_S5PC100_SETUP_SDHCI */
  204. /* S5PV210 SDHCI setup */
  205. #ifdef CONFIG_S5PV210_SETUP_SDHCI
  206. extern char *s5pv210_hsmmc_clksrcs[4];
  207. extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
  208. void __iomem *r,
  209. struct mmc_ios *ios,
  210. struct mmc_card *card);
  211. static inline void s5pv210_default_sdhci0(void)
  212. {
  213. #ifdef CONFIG_S3C_DEV_HSMMC
  214. s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  215. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
  216. s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  217. #endif
  218. }
  219. static inline void s5pv210_default_sdhci1(void)
  220. {
  221. #ifdef CONFIG_S3C_DEV_HSMMC1
  222. s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  223. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
  224. s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  225. #endif
  226. }
  227. static inline void s5pv210_default_sdhci2(void)
  228. {
  229. #ifdef CONFIG_S3C_DEV_HSMMC2
  230. s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  231. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
  232. s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  233. #endif
  234. }
  235. static inline void s5pv210_default_sdhci3(void)
  236. {
  237. #ifdef CONFIG_S3C_DEV_HSMMC3
  238. s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  239. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
  240. s3c_hsmmc3_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  241. #endif
  242. }
  243. #else
  244. static inline void s5pv210_default_sdhci0(void) { }
  245. static inline void s5pv210_default_sdhci1(void) { }
  246. static inline void s5pv210_default_sdhci2(void) { }
  247. static inline void s5pv210_default_sdhci3(void) { }
  248. #endif /* CONFIG_S5PV210_SETUP_SDHCI */
  249. #endif /* __PLAT_S3C_SDHCI_H */