sdhci.h 11 KB

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