sdhci.h 12 KB

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