sdhci.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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. extern void s5p64x0_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  114. extern void s5p64x0_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  115. extern void s5p6440_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  116. extern void s5p6450_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  117. /* S3C2416 SDHCI setup */
  118. #ifdef CONFIG_S3C2416_SETUP_SDHCI
  119. static inline void s3c2416_default_sdhci0(void)
  120. {
  121. #ifdef CONFIG_S3C_DEV_HSMMC
  122. s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
  123. #endif /* CONFIG_S3C_DEV_HSMMC */
  124. }
  125. static inline void s3c2416_default_sdhci1(void)
  126. {
  127. #ifdef CONFIG_S3C_DEV_HSMMC1
  128. s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
  129. #endif /* CONFIG_S3C_DEV_HSMMC1 */
  130. }
  131. #else
  132. static inline void s3c2416_default_sdhci0(void) { }
  133. static inline void s3c2416_default_sdhci1(void) { }
  134. #endif /* CONFIG_S3C2416_SETUP_SDHCI */
  135. /* S3C64XX SDHCI setup */
  136. #ifdef CONFIG_S3C64XX_SETUP_SDHCI
  137. static inline void s3c6400_default_sdhci0(void)
  138. {
  139. #ifdef CONFIG_S3C_DEV_HSMMC
  140. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  141. #endif
  142. }
  143. static inline void s3c6400_default_sdhci1(void)
  144. {
  145. #ifdef CONFIG_S3C_DEV_HSMMC1
  146. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  147. #endif
  148. }
  149. static inline void s3c6400_default_sdhci2(void)
  150. {
  151. #ifdef CONFIG_S3C_DEV_HSMMC2
  152. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  153. #endif
  154. }
  155. static inline void s3c6410_default_sdhci0(void)
  156. {
  157. #ifdef CONFIG_S3C_DEV_HSMMC
  158. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  159. #endif
  160. }
  161. static inline void s3c6410_default_sdhci1(void)
  162. {
  163. #ifdef CONFIG_S3C_DEV_HSMMC1
  164. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  165. #endif
  166. }
  167. static inline void s3c6410_default_sdhci2(void)
  168. {
  169. #ifdef CONFIG_S3C_DEV_HSMMC2
  170. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  171. #endif
  172. }
  173. #else
  174. static inline void s3c6410_default_sdhci0(void) { }
  175. static inline void s3c6410_default_sdhci1(void) { }
  176. static inline void s3c6410_default_sdhci2(void) { }
  177. static inline void s3c6400_default_sdhci0(void) { }
  178. static inline void s3c6400_default_sdhci1(void) { }
  179. static inline void s3c6400_default_sdhci2(void) { }
  180. #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
  181. /* S5P64X0 SDHCI setup */
  182. #ifdef CONFIG_S5P64X0_SETUP_SDHCI
  183. static inline void s5p64x0_default_sdhci0(void)
  184. {
  185. #ifdef CONFIG_S3C_DEV_HSMMC
  186. s3c_hsmmc0_def_platdata.cfg_gpio = s5p64x0_setup_sdhci0_cfg_gpio;
  187. #endif
  188. }
  189. static inline void s5p64x0_default_sdhci1(void)
  190. {
  191. #ifdef CONFIG_S3C_DEV_HSMMC1
  192. s3c_hsmmc1_def_platdata.cfg_gpio = s5p64x0_setup_sdhci1_cfg_gpio;
  193. #endif
  194. }
  195. static inline void s5p6440_default_sdhci2(void)
  196. {
  197. #ifdef CONFIG_S3C_DEV_HSMMC2
  198. s3c_hsmmc2_def_platdata.cfg_gpio = s5p6440_setup_sdhci2_cfg_gpio;
  199. #endif
  200. }
  201. static inline void s5p6450_default_sdhci2(void)
  202. {
  203. #ifdef CONFIG_S3C_DEV_HSMMC2
  204. s3c_hsmmc2_def_platdata.cfg_gpio = s5p6450_setup_sdhci2_cfg_gpio;
  205. #endif
  206. }
  207. #else
  208. static inline void s5p64x0_default_sdhci0(void) { }
  209. static inline void s5p64x0_default_sdhci1(void) { }
  210. static inline void s5p6440_default_sdhci2(void) { }
  211. static inline void s5p6450_default_sdhci2(void) { }
  212. #endif /* CONFIG_S5P64X0_SETUP_SDHCI */
  213. /* S5PC100 SDHCI setup */
  214. #ifdef CONFIG_S5PC100_SETUP_SDHCI
  215. static inline void s5pc100_default_sdhci0(void)
  216. {
  217. #ifdef CONFIG_S3C_DEV_HSMMC
  218. s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
  219. #endif
  220. }
  221. static inline void s5pc100_default_sdhci1(void)
  222. {
  223. #ifdef CONFIG_S3C_DEV_HSMMC1
  224. s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
  225. #endif
  226. }
  227. static inline void s5pc100_default_sdhci2(void)
  228. {
  229. #ifdef CONFIG_S3C_DEV_HSMMC2
  230. s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
  231. #endif
  232. }
  233. #else
  234. static inline void s5pc100_default_sdhci0(void) { }
  235. static inline void s5pc100_default_sdhci1(void) { }
  236. static inline void s5pc100_default_sdhci2(void) { }
  237. #endif /* CONFIG_S5PC100_SETUP_SDHCI */
  238. /* S5PV210 SDHCI setup */
  239. #ifdef CONFIG_S5PV210_SETUP_SDHCI
  240. static inline void s5pv210_default_sdhci0(void)
  241. {
  242. #ifdef CONFIG_S3C_DEV_HSMMC
  243. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
  244. #endif
  245. }
  246. static inline void s5pv210_default_sdhci1(void)
  247. {
  248. #ifdef CONFIG_S3C_DEV_HSMMC1
  249. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
  250. #endif
  251. }
  252. static inline void s5pv210_default_sdhci2(void)
  253. {
  254. #ifdef CONFIG_S3C_DEV_HSMMC2
  255. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
  256. #endif
  257. }
  258. static inline void s5pv210_default_sdhci3(void)
  259. {
  260. #ifdef CONFIG_S3C_DEV_HSMMC3
  261. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
  262. #endif
  263. }
  264. #else
  265. static inline void s5pv210_default_sdhci0(void) { }
  266. static inline void s5pv210_default_sdhci1(void) { }
  267. static inline void s5pv210_default_sdhci2(void) { }
  268. static inline void s5pv210_default_sdhci3(void) { }
  269. #endif /* CONFIG_S5PV210_SETUP_SDHCI */
  270. /* EXYNOS4 SDHCI setup */
  271. #ifdef CONFIG_EXYNOS4_SETUP_SDHCI
  272. static inline void exynos4_default_sdhci0(void)
  273. {
  274. #ifdef CONFIG_S3C_DEV_HSMMC
  275. s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
  276. #endif
  277. }
  278. static inline void exynos4_default_sdhci1(void)
  279. {
  280. #ifdef CONFIG_S3C_DEV_HSMMC1
  281. s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
  282. #endif
  283. }
  284. static inline void exynos4_default_sdhci2(void)
  285. {
  286. #ifdef CONFIG_S3C_DEV_HSMMC2
  287. s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
  288. #endif
  289. }
  290. static inline void exynos4_default_sdhci3(void)
  291. {
  292. #ifdef CONFIG_S3C_DEV_HSMMC3
  293. s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
  294. #endif
  295. }
  296. #else
  297. static inline void exynos4_default_sdhci0(void) { }
  298. static inline void exynos4_default_sdhci1(void) { }
  299. static inline void exynos4_default_sdhci2(void) { }
  300. static inline void exynos4_default_sdhci3(void) { }
  301. #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
  302. #endif /* __PLAT_S3C_SDHCI_H */