sdhci.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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. * @cfg_card: Configure the interface for a specific card and speed. This
  54. * is necessary the controllers and/or GPIO blocks require the
  55. * changing of driver-strength and other controls dependant on
  56. * the card and speed of operation.
  57. *
  58. * Initialisation data specific to either the machine or the platform
  59. * for the device driver to use or call-back when configuring gpio or
  60. * card speed information.
  61. */
  62. struct s3c_sdhci_platdata {
  63. unsigned int max_width;
  64. unsigned int host_caps;
  65. enum cd_types cd_type;
  66. enum clk_types clk_type;
  67. char **clocks; /* set of clock sources */
  68. int ext_cd_gpio;
  69. bool ext_cd_gpio_invert;
  70. int (*ext_cd_init)(void (*notify_func)(struct platform_device *,
  71. int state));
  72. int (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
  73. int state));
  74. void (*cfg_gpio)(struct platform_device *dev, int width);
  75. void (*cfg_card)(struct platform_device *dev,
  76. void __iomem *regbase,
  77. struct mmc_ios *ios,
  78. struct mmc_card *card);
  79. };
  80. /**
  81. * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
  82. * @pd: Platform data to register to device.
  83. *
  84. * Register the given platform data for use withe S3C SDHCI device.
  85. * The call will copy the platform data, so the board definitions can
  86. * make the structure itself __initdata.
  87. */
  88. extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
  89. extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
  90. extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
  91. extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
  92. /* Default platform data, exported so that per-cpu initialisation can
  93. * set the correct one when there are more than one cpu type selected.
  94. */
  95. extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
  96. extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
  97. extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
  98. extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
  99. /* Helper function availablity */
  100. extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  101. extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  102. extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  103. extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  104. extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  105. extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  106. extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  107. extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  108. extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  109. extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  110. extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  111. extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  112. extern void exynos4_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  113. extern void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  114. extern void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  115. extern void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  116. /* S3C2416 SDHCI setup */
  117. #ifdef CONFIG_S3C2416_SETUP_SDHCI
  118. extern char *s3c2416_hsmmc_clksrcs[4];
  119. extern void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,
  120. void __iomem *r,
  121. struct mmc_ios *ios,
  122. struct mmc_card *card);
  123. static inline void s3c2416_default_sdhci0(void)
  124. {
  125. #ifdef CONFIG_S3C_DEV_HSMMC
  126. s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
  127. s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
  128. s3c_hsmmc0_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
  129. #endif /* CONFIG_S3C_DEV_HSMMC */
  130. }
  131. static inline void s3c2416_default_sdhci1(void)
  132. {
  133. #ifdef CONFIG_S3C_DEV_HSMMC1
  134. s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
  135. s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
  136. s3c_hsmmc1_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
  137. #endif /* CONFIG_S3C_DEV_HSMMC1 */
  138. }
  139. #else
  140. static inline void s3c2416_default_sdhci0(void) { }
  141. static inline void s3c2416_default_sdhci1(void) { }
  142. #endif /* CONFIG_S3C2416_SETUP_SDHCI */
  143. /* S3C64XX SDHCI setup */
  144. #ifdef CONFIG_S3C64XX_SETUP_SDHCI
  145. extern char *s3c64xx_hsmmc_clksrcs[4];
  146. extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
  147. void __iomem *r,
  148. struct mmc_ios *ios,
  149. struct mmc_card *card);
  150. static inline void s3c6400_default_sdhci0(void)
  151. {
  152. #ifdef CONFIG_S3C_DEV_HSMMC
  153. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  154. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  155. s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  156. #endif
  157. }
  158. static inline void s3c6400_default_sdhci1(void)
  159. {
  160. #ifdef CONFIG_S3C_DEV_HSMMC1
  161. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  162. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  163. s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  164. #endif
  165. }
  166. static inline void s3c6400_default_sdhci2(void)
  167. {
  168. #ifdef CONFIG_S3C_DEV_HSMMC2
  169. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  170. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  171. s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  172. #endif
  173. }
  174. extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
  175. void __iomem *r,
  176. struct mmc_ios *ios,
  177. struct mmc_card *card);
  178. static inline void s3c6410_default_sdhci0(void)
  179. {
  180. #ifdef CONFIG_S3C_DEV_HSMMC
  181. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  182. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  183. s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  184. #endif
  185. }
  186. static inline void s3c6410_default_sdhci1(void)
  187. {
  188. #ifdef CONFIG_S3C_DEV_HSMMC1
  189. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  190. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  191. s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  192. #endif
  193. }
  194. static inline void s3c6410_default_sdhci2(void)
  195. {
  196. #ifdef CONFIG_S3C_DEV_HSMMC2
  197. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  198. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  199. s3c_hsmmc2_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  200. #endif
  201. }
  202. #else
  203. static inline void s3c6410_default_sdhci0(void) { }
  204. static inline void s3c6410_default_sdhci1(void) { }
  205. static inline void s3c6410_default_sdhci2(void) { }
  206. static inline void s3c6400_default_sdhci0(void) { }
  207. static inline void s3c6400_default_sdhci1(void) { }
  208. static inline void s3c6400_default_sdhci2(void) { }
  209. #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
  210. /* S5PC100 SDHCI setup */
  211. #ifdef CONFIG_S5PC100_SETUP_SDHCI
  212. extern char *s5pc100_hsmmc_clksrcs[4];
  213. extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
  214. void __iomem *r,
  215. struct mmc_ios *ios,
  216. struct mmc_card *card);
  217. static inline void s5pc100_default_sdhci0(void)
  218. {
  219. #ifdef CONFIG_S3C_DEV_HSMMC
  220. s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  221. s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
  222. s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  223. #endif
  224. }
  225. static inline void s5pc100_default_sdhci1(void)
  226. {
  227. #ifdef CONFIG_S3C_DEV_HSMMC1
  228. s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  229. s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
  230. s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  231. #endif
  232. }
  233. static inline void s5pc100_default_sdhci2(void)
  234. {
  235. #ifdef CONFIG_S3C_DEV_HSMMC2
  236. s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  237. s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
  238. s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  239. #endif
  240. }
  241. #else
  242. static inline void s5pc100_default_sdhci0(void) { }
  243. static inline void s5pc100_default_sdhci1(void) { }
  244. static inline void s5pc100_default_sdhci2(void) { }
  245. #endif /* CONFIG_S5PC100_SETUP_SDHCI */
  246. /* S5PV210 SDHCI setup */
  247. #ifdef CONFIG_S5PV210_SETUP_SDHCI
  248. extern char *s5pv210_hsmmc_clksrcs[4];
  249. extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
  250. void __iomem *r,
  251. struct mmc_ios *ios,
  252. struct mmc_card *card);
  253. static inline void s5pv210_default_sdhci0(void)
  254. {
  255. #ifdef CONFIG_S3C_DEV_HSMMC
  256. s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  257. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
  258. s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  259. #endif
  260. }
  261. static inline void s5pv210_default_sdhci1(void)
  262. {
  263. #ifdef CONFIG_S3C_DEV_HSMMC1
  264. s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  265. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
  266. s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  267. #endif
  268. }
  269. static inline void s5pv210_default_sdhci2(void)
  270. {
  271. #ifdef CONFIG_S3C_DEV_HSMMC2
  272. s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  273. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
  274. s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  275. #endif
  276. }
  277. static inline void s5pv210_default_sdhci3(void)
  278. {
  279. #ifdef CONFIG_S3C_DEV_HSMMC3
  280. s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  281. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
  282. s3c_hsmmc3_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  283. #endif
  284. }
  285. #else
  286. static inline void s5pv210_default_sdhci0(void) { }
  287. static inline void s5pv210_default_sdhci1(void) { }
  288. static inline void s5pv210_default_sdhci2(void) { }
  289. static inline void s5pv210_default_sdhci3(void) { }
  290. #endif /* CONFIG_S5PV210_SETUP_SDHCI */
  291. /* EXYNOS4 SDHCI setup */
  292. #ifdef CONFIG_EXYNOS4_SETUP_SDHCI
  293. extern char *exynos4_hsmmc_clksrcs[4];
  294. extern void exynos4_setup_sdhci_cfg_card(struct platform_device *dev,
  295. void __iomem *r,
  296. struct mmc_ios *ios,
  297. struct mmc_card *card);
  298. static inline void exynos4_default_sdhci0(void)
  299. {
  300. #ifdef CONFIG_S3C_DEV_HSMMC
  301. s3c_hsmmc0_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  302. s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
  303. s3c_hsmmc0_def_platdata.cfg_card = exynos4_setup_sdhci_cfg_card;
  304. #endif
  305. }
  306. static inline void exynos4_default_sdhci1(void)
  307. {
  308. #ifdef CONFIG_S3C_DEV_HSMMC1
  309. s3c_hsmmc1_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  310. s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
  311. s3c_hsmmc1_def_platdata.cfg_card = exynos4_setup_sdhci_cfg_card;
  312. #endif
  313. }
  314. static inline void exynos4_default_sdhci2(void)
  315. {
  316. #ifdef CONFIG_S3C_DEV_HSMMC2
  317. s3c_hsmmc2_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  318. s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
  319. s3c_hsmmc2_def_platdata.cfg_card = exynos4_setup_sdhci_cfg_card;
  320. #endif
  321. }
  322. static inline void exynos4_default_sdhci3(void)
  323. {
  324. #ifdef CONFIG_S3C_DEV_HSMMC3
  325. s3c_hsmmc3_def_platdata.clocks = exynos4_hsmmc_clksrcs;
  326. s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
  327. s3c_hsmmc3_def_platdata.cfg_card = exynos4_setup_sdhci_cfg_card;
  328. #endif
  329. }
  330. #else
  331. static inline void exynos4_default_sdhci0(void) { }
  332. static inline void exynos4_default_sdhci1(void) { }
  333. static inline void exynos4_default_sdhci2(void) { }
  334. static inline void exynos4_default_sdhci3(void) { }
  335. #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
  336. #endif /* __PLAT_S3C_SDHCI_H */