sdhci.h 9.7 KB

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