sdhci.h 14 KB

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