sdhci.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. char **clocks; /* set of clock sources */
  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. /* S3C2416 SDHCI setup */
  115. #ifdef CONFIG_S3C2416_SETUP_SDHCI
  116. extern char *s3c2416_hsmmc_clksrcs[4];
  117. static inline void s3c2416_default_sdhci0(void)
  118. {
  119. #ifdef CONFIG_S3C_DEV_HSMMC
  120. s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
  121. s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
  122. #endif /* CONFIG_S3C_DEV_HSMMC */
  123. }
  124. static inline void s3c2416_default_sdhci1(void)
  125. {
  126. #ifdef CONFIG_S3C_DEV_HSMMC1
  127. s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
  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. extern char *s3c64xx_hsmmc_clksrcs[4];
  138. static inline void s3c6400_default_sdhci0(void)
  139. {
  140. #ifdef CONFIG_S3C_DEV_HSMMC
  141. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  142. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  143. #endif
  144. }
  145. static inline void s3c6400_default_sdhci1(void)
  146. {
  147. #ifdef CONFIG_S3C_DEV_HSMMC1
  148. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  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.clocks = s3c64xx_hsmmc_clksrcs;
  156. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  157. #endif
  158. }
  159. static inline void s3c6410_default_sdhci0(void)
  160. {
  161. #ifdef CONFIG_S3C_DEV_HSMMC
  162. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  163. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  164. #endif
  165. }
  166. static inline void s3c6410_default_sdhci1(void)
  167. {
  168. #ifdef CONFIG_S3C_DEV_HSMMC1
  169. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  170. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  171. #endif
  172. }
  173. static inline void s3c6410_default_sdhci2(void)
  174. {
  175. #ifdef CONFIG_S3C_DEV_HSMMC2
  176. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  177. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  178. #endif
  179. }
  180. #else
  181. static inline void s3c6410_default_sdhci0(void) { }
  182. static inline void s3c6410_default_sdhci1(void) { }
  183. static inline void s3c6410_default_sdhci2(void) { }
  184. static inline void s3c6400_default_sdhci0(void) { }
  185. static inline void s3c6400_default_sdhci1(void) { }
  186. static inline void s3c6400_default_sdhci2(void) { }
  187. #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
  188. /* S5PC100 SDHCI setup */
  189. #ifdef CONFIG_S5PC100_SETUP_SDHCI
  190. extern char *s5pc100_hsmmc_clksrcs[4];
  191. static inline void s5pc100_default_sdhci0(void)
  192. {
  193. #ifdef CONFIG_S3C_DEV_HSMMC
  194. s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  195. s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
  196. #endif
  197. }
  198. static inline void s5pc100_default_sdhci1(void)
  199. {
  200. #ifdef CONFIG_S3C_DEV_HSMMC1
  201. s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  202. s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
  203. #endif
  204. }
  205. static inline void s5pc100_default_sdhci2(void)
  206. {
  207. #ifdef CONFIG_S3C_DEV_HSMMC2
  208. s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  209. s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
  210. #endif
  211. }
  212. #else
  213. static inline void s5pc100_default_sdhci0(void) { }
  214. static inline void s5pc100_default_sdhci1(void) { }
  215. static inline void s5pc100_default_sdhci2(void) { }
  216. #endif /* CONFIG_S5PC100_SETUP_SDHCI */
  217. /* S5PV210 SDHCI setup */
  218. #ifdef CONFIG_S5PV210_SETUP_SDHCI
  219. extern char *s5pv210_hsmmc_clksrcs[4];
  220. static inline void s5pv210_default_sdhci0(void)
  221. {
  222. #ifdef CONFIG_S3C_DEV_HSMMC
  223. s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  224. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
  225. #endif
  226. }
  227. static inline void s5pv210_default_sdhci1(void)
  228. {
  229. #ifdef CONFIG_S3C_DEV_HSMMC1
  230. s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  231. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
  232. #endif
  233. }
  234. static inline void s5pv210_default_sdhci2(void)
  235. {
  236. #ifdef CONFIG_S3C_DEV_HSMMC2
  237. s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  238. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
  239. #endif
  240. }
  241. static inline void s5pv210_default_sdhci3(void)
  242. {
  243. #ifdef CONFIG_S3C_DEV_HSMMC3
  244. s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  245. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
  246. #endif
  247. }
  248. #else
  249. static inline void s5pv210_default_sdhci0(void) { }
  250. static inline void s5pv210_default_sdhci1(void) { }
  251. static inline void s5pv210_default_sdhci2(void) { }
  252. static inline void s5pv210_default_sdhci3(void) { }
  253. #endif /* CONFIG_S5PV210_SETUP_SDHCI */
  254. /* EXYNOS4 SDHCI setup */
  255. #ifdef CONFIG_EXYNOS4_SETUP_SDHCI
  256. extern char *exynos4_hsmmc_clksrcs[4];
  257. static inline void exynos4_default_sdhci0(void)
  258. {
  259. #ifdef CONFIG_S3C_DEV_HSMMC
  260. s3c_hsmmc0_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  261. s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
  262. #endif
  263. }
  264. static inline void exynos4_default_sdhci1(void)
  265. {
  266. #ifdef CONFIG_S3C_DEV_HSMMC1
  267. s3c_hsmmc1_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  268. s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
  269. #endif
  270. }
  271. static inline void exynos4_default_sdhci2(void)
  272. {
  273. #ifdef CONFIG_S3C_DEV_HSMMC2
  274. s3c_hsmmc2_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  275. s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
  276. #endif
  277. }
  278. static inline void exynos4_default_sdhci3(void)
  279. {
  280. #ifdef CONFIG_S3C_DEV_HSMMC3
  281. s3c_hsmmc3_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  282. s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
  283. #endif
  284. }
  285. #else
  286. static inline void exynos4_default_sdhci0(void) { }
  287. static inline void exynos4_default_sdhci1(void) { }
  288. static inline void exynos4_default_sdhci2(void) { }
  289. static inline void exynos4_default_sdhci3(void) { }
  290. #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
  291. #endif /* __PLAT_S3C_SDHCI_H */