sdhci.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. * @host_caps2: The second standard MMC host capabilities bit field.
  39. * @cd_type: Type of Card Detection method (see cd_types enum above)
  40. * @clk_type: Type of clock divider method (see clk_types enum above)
  41. * @ext_cd_init: Initialize external card detect subsystem. Called on
  42. * sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
  43. * notify_func argument is a callback to the sdhci-s3c driver
  44. * that triggers the card detection event. Callback arguments:
  45. * dev is pointer to platform device of the host controller,
  46. * state is new state of the card (0 - removed, 1 - inserted).
  47. * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
  48. * sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
  49. * notify_func argument is the same callback as for ext_cd_init.
  50. * @ext_cd_gpio: gpio pin used for external CD line, valid only if
  51. * cd_type == S3C_SDHCI_CD_GPIO
  52. * @ext_cd_gpio_invert: invert values for external CD gpio line
  53. * @cfg_gpio: Configure the GPIO for a specific card bit-width
  54. *
  55. * Initialisation data specific to either the machine or the platform
  56. * for the device driver to use or call-back when configuring gpio or
  57. * card speed information.
  58. */
  59. struct s3c_sdhci_platdata {
  60. unsigned int max_width;
  61. unsigned int host_caps;
  62. unsigned int host_caps2;
  63. unsigned int pm_caps;
  64. enum cd_types cd_type;
  65. enum clk_types clk_type;
  66. int ext_cd_gpio;
  67. bool ext_cd_gpio_invert;
  68. int (*ext_cd_init)(void (*notify_func)(struct platform_device *,
  69. int state));
  70. int (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
  71. int state));
  72. void (*cfg_gpio)(struct platform_device *dev, int width);
  73. };
  74. /* s3c_sdhci_set_platdata() - common helper for setting SDHCI platform data
  75. * @pd: The default platform data for this device.
  76. * @set: Pointer to the platform data to fill in.
  77. */
  78. extern void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
  79. struct s3c_sdhci_platdata *set);
  80. /**
  81. * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
  82. * @pd: Platform data to register to device.
  83. *
  84. * Register the given platform data for use withe S3C SDHCI device.
  85. * The call will copy the platform data, so the board definitions can
  86. * make the structure itself __initdata.
  87. */
  88. extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
  89. extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
  90. extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
  91. extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
  92. /* Default platform data, exported so that per-cpu initialisation can
  93. * set the correct one when there are more than one cpu type selected.
  94. */
  95. extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
  96. extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
  97. extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
  98. extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
  99. /* Helper function availability */
  100. extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  101. extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  102. extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  103. extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  104. extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  105. extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  106. extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  107. extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  108. extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  109. extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  110. extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  111. extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  112. extern void exynos4_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  113. extern void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  114. extern void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  115. extern void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  116. extern void s5p64x0_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  117. extern void s5p64x0_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  118. extern void s5p6440_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  119. extern void s5p6450_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  120. /* S3C2416 SDHCI setup */
  121. #ifdef CONFIG_S3C2416_SETUP_SDHCI
  122. static inline void s3c2416_default_sdhci0(void)
  123. {
  124. #ifdef CONFIG_S3C_DEV_HSMMC
  125. s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
  126. #endif /* CONFIG_S3C_DEV_HSMMC */
  127. }
  128. static inline void s3c2416_default_sdhci1(void)
  129. {
  130. #ifdef CONFIG_S3C_DEV_HSMMC1
  131. s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
  132. #endif /* CONFIG_S3C_DEV_HSMMC1 */
  133. }
  134. #else
  135. static inline void s3c2416_default_sdhci0(void) { }
  136. static inline void s3c2416_default_sdhci1(void) { }
  137. #endif /* CONFIG_S3C2416_SETUP_SDHCI */
  138. /* S3C64XX SDHCI setup */
  139. #ifdef CONFIG_S3C64XX_SETUP_SDHCI
  140. static inline void s3c6400_default_sdhci0(void)
  141. {
  142. #ifdef CONFIG_S3C_DEV_HSMMC
  143. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  144. #endif
  145. }
  146. static inline void s3c6400_default_sdhci1(void)
  147. {
  148. #ifdef CONFIG_S3C_DEV_HSMMC1
  149. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  150. #endif
  151. }
  152. static inline void s3c6400_default_sdhci2(void)
  153. {
  154. #ifdef CONFIG_S3C_DEV_HSMMC2
  155. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  156. #endif
  157. }
  158. static inline void s3c6410_default_sdhci0(void)
  159. {
  160. #ifdef CONFIG_S3C_DEV_HSMMC
  161. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  162. #endif
  163. }
  164. static inline void s3c6410_default_sdhci1(void)
  165. {
  166. #ifdef CONFIG_S3C_DEV_HSMMC1
  167. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  168. #endif
  169. }
  170. static inline void s3c6410_default_sdhci2(void)
  171. {
  172. #ifdef CONFIG_S3C_DEV_HSMMC2
  173. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  174. #endif
  175. }
  176. #else
  177. static inline void s3c6410_default_sdhci0(void) { }
  178. static inline void s3c6410_default_sdhci1(void) { }
  179. static inline void s3c6410_default_sdhci2(void) { }
  180. static inline void s3c6400_default_sdhci0(void) { }
  181. static inline void s3c6400_default_sdhci1(void) { }
  182. static inline void s3c6400_default_sdhci2(void) { }
  183. #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
  184. /* S5P64X0 SDHCI setup */
  185. #ifdef CONFIG_S5P64X0_SETUP_SDHCI
  186. static inline void s5p64x0_default_sdhci0(void)
  187. {
  188. #ifdef CONFIG_S3C_DEV_HSMMC
  189. s3c_hsmmc0_def_platdata.cfg_gpio = s5p64x0_setup_sdhci0_cfg_gpio;
  190. #endif
  191. }
  192. static inline void s5p64x0_default_sdhci1(void)
  193. {
  194. #ifdef CONFIG_S3C_DEV_HSMMC1
  195. s3c_hsmmc1_def_platdata.cfg_gpio = s5p64x0_setup_sdhci1_cfg_gpio;
  196. #endif
  197. }
  198. static inline void s5p6440_default_sdhci2(void)
  199. {
  200. #ifdef CONFIG_S3C_DEV_HSMMC2
  201. s3c_hsmmc2_def_platdata.cfg_gpio = s5p6440_setup_sdhci2_cfg_gpio;
  202. #endif
  203. }
  204. static inline void s5p6450_default_sdhci2(void)
  205. {
  206. #ifdef CONFIG_S3C_DEV_HSMMC2
  207. s3c_hsmmc2_def_platdata.cfg_gpio = s5p6450_setup_sdhci2_cfg_gpio;
  208. #endif
  209. }
  210. #else
  211. static inline void s5p64x0_default_sdhci0(void) { }
  212. static inline void s5p64x0_default_sdhci1(void) { }
  213. static inline void s5p6440_default_sdhci2(void) { }
  214. static inline void s5p6450_default_sdhci2(void) { }
  215. #endif /* CONFIG_S5P64X0_SETUP_SDHCI */
  216. /* S5PC100 SDHCI setup */
  217. #ifdef CONFIG_S5PC100_SETUP_SDHCI
  218. static inline void s5pc100_default_sdhci0(void)
  219. {
  220. #ifdef CONFIG_S3C_DEV_HSMMC
  221. s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
  222. #endif
  223. }
  224. static inline void s5pc100_default_sdhci1(void)
  225. {
  226. #ifdef CONFIG_S3C_DEV_HSMMC1
  227. s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
  228. #endif
  229. }
  230. static inline void s5pc100_default_sdhci2(void)
  231. {
  232. #ifdef CONFIG_S3C_DEV_HSMMC2
  233. s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
  234. #endif
  235. }
  236. #else
  237. static inline void s5pc100_default_sdhci0(void) { }
  238. static inline void s5pc100_default_sdhci1(void) { }
  239. static inline void s5pc100_default_sdhci2(void) { }
  240. #endif /* CONFIG_S5PC100_SETUP_SDHCI */
  241. /* S5PV210 SDHCI setup */
  242. #ifdef CONFIG_S5PV210_SETUP_SDHCI
  243. static inline void s5pv210_default_sdhci0(void)
  244. {
  245. #ifdef CONFIG_S3C_DEV_HSMMC
  246. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
  247. #endif
  248. }
  249. static inline void s5pv210_default_sdhci1(void)
  250. {
  251. #ifdef CONFIG_S3C_DEV_HSMMC1
  252. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
  253. #endif
  254. }
  255. static inline void s5pv210_default_sdhci2(void)
  256. {
  257. #ifdef CONFIG_S3C_DEV_HSMMC2
  258. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
  259. #endif
  260. }
  261. static inline void s5pv210_default_sdhci3(void)
  262. {
  263. #ifdef CONFIG_S3C_DEV_HSMMC3
  264. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
  265. #endif
  266. }
  267. #else
  268. static inline void s5pv210_default_sdhci0(void) { }
  269. static inline void s5pv210_default_sdhci1(void) { }
  270. static inline void s5pv210_default_sdhci2(void) { }
  271. static inline void s5pv210_default_sdhci3(void) { }
  272. #endif /* CONFIG_S5PV210_SETUP_SDHCI */
  273. /* EXYNOS4 SDHCI setup */
  274. #ifdef CONFIG_EXYNOS4_SETUP_SDHCI
  275. static inline void exynos4_default_sdhci0(void)
  276. {
  277. #ifdef CONFIG_S3C_DEV_HSMMC
  278. s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
  279. #endif
  280. }
  281. static inline void exynos4_default_sdhci1(void)
  282. {
  283. #ifdef CONFIG_S3C_DEV_HSMMC1
  284. s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
  285. #endif
  286. }
  287. static inline void exynos4_default_sdhci2(void)
  288. {
  289. #ifdef CONFIG_S3C_DEV_HSMMC2
  290. s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
  291. #endif
  292. }
  293. static inline void exynos4_default_sdhci3(void)
  294. {
  295. #ifdef CONFIG_S3C_DEV_HSMMC3
  296. s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
  297. #endif
  298. }
  299. #else
  300. static inline void exynos4_default_sdhci0(void) { }
  301. static inline void exynos4_default_sdhci1(void) { }
  302. static inline void exynos4_default_sdhci2(void) { }
  303. static inline void exynos4_default_sdhci3(void) { }
  304. #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
  305. #endif /* __PLAT_S3C_SDHCI_H */