sdhci.h 11 KB

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