sdhci.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /* linux/arch/arm/plat-s3c/include/plat/sdhci.h
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * http://armlinux.simtec.co.uk/
  6. * Ben Dooks <ben@simtec.co.uk>
  7. *
  8. * S3C Platform - SDHCI (HSMMC) platform data definitions
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __PLAT_S3C_SDHCI_H
  15. #define __PLAT_S3C_SDHCI_H __FILE__
  16. struct platform_device;
  17. struct mmc_host;
  18. struct mmc_card;
  19. struct mmc_ios;
  20. enum cd_types {
  21. S3C_SDHCI_CD_INTERNAL, /* use mmc internal CD line */
  22. S3C_SDHCI_CD_EXTERNAL, /* use external callback */
  23. S3C_SDHCI_CD_GPIO, /* use external gpio pin for CD line */
  24. S3C_SDHCI_CD_NONE, /* no CD line, use polling to detect card */
  25. S3C_SDHCI_CD_PERMANENT, /* no CD line, card permanently wired to host */
  26. };
  27. enum clk_types {
  28. S3C_SDHCI_CLK_DIV_INTERNAL, /* use mmc internal clock divider */
  29. S3C_SDHCI_CLK_DIV_EXTERNAL, /* use external clock divider */
  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. * @cd_type: Type of Card Detection method (see cd_types enum above)
  36. * @clk_type: Type of clock divider method (see clk_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. * @cfg_card: Configure the interface for a specific card and speed. This
  51. * is necessary the controllers and/or GPIO blocks require the
  52. * changing of driver-strength and other controls dependant on
  53. * the card and speed of operation.
  54. *
  55. * Initialisation data specific to either the machine or the platform
  56. * for the device driver to use or call-back when configuring gpio or
  57. * card speed information.
  58. */
  59. struct s3c_sdhci_platdata {
  60. unsigned int max_width;
  61. unsigned int host_caps;
  62. enum cd_types cd_type;
  63. enum clk_types clk_type;
  64. char **clocks; /* set of clock sources */
  65. int ext_cd_gpio;
  66. bool ext_cd_gpio_invert;
  67. int (*ext_cd_init)(void (*notify_func)(struct platform_device *,
  68. int state));
  69. int (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
  70. int state));
  71. void (*cfg_gpio)(struct platform_device *dev, int width);
  72. void (*cfg_card)(struct platform_device *dev,
  73. void __iomem *regbase,
  74. struct mmc_ios *ios,
  75. struct mmc_card *card);
  76. };
  77. /**
  78. * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
  79. * @pd: Platform data to register to device.
  80. *
  81. * Register the given platform data for use withe S3C SDHCI device.
  82. * The call will copy the platform data, so the board definitions can
  83. * make the structure itself __initdata.
  84. */
  85. extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
  86. extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
  87. extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
  88. extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
  89. /* Default platform data, exported so that per-cpu initialisation can
  90. * set the correct one when there are more than one cpu type selected.
  91. */
  92. extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
  93. extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
  94. extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
  95. extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
  96. /* Helper function availablity */
  97. extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  98. extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  99. extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  100. extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  101. extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  102. extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  103. extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  104. extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  105. extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  106. extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  107. extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  108. extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  109. extern void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
  110. extern void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
  111. extern void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
  112. extern void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
  113. /* S3C2416 SDHCI setup */
  114. #ifdef CONFIG_S3C2416_SETUP_SDHCI
  115. extern char *s3c2416_hsmmc_clksrcs[4];
  116. extern void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,
  117. void __iomem *r,
  118. struct mmc_ios *ios,
  119. struct mmc_card *card);
  120. static inline void s3c2416_default_sdhci0(void)
  121. {
  122. #ifdef CONFIG_S3C_DEV_HSMMC
  123. s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
  124. s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
  125. s3c_hsmmc0_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
  126. #endif /* CONFIG_S3C_DEV_HSMMC */
  127. }
  128. static inline void s3c2416_default_sdhci1(void)
  129. {
  130. #ifdef CONFIG_S3C_DEV_HSMMC1
  131. s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
  132. s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
  133. s3c_hsmmc1_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
  134. #endif /* CONFIG_S3C_DEV_HSMMC1 */
  135. }
  136. #else
  137. static inline void s3c2416_default_sdhci0(void) { }
  138. static inline void s3c2416_default_sdhci1(void) { }
  139. #endif /* CONFIG_S3C2416_SETUP_SDHCI */
  140. /* S3C64XX SDHCI setup */
  141. #ifdef CONFIG_S3C64XX_SETUP_SDHCI
  142. extern char *s3c64xx_hsmmc_clksrcs[4];
  143. extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
  144. void __iomem *r,
  145. struct mmc_ios *ios,
  146. struct mmc_card *card);
  147. static inline void s3c6400_default_sdhci0(void)
  148. {
  149. #ifdef CONFIG_S3C_DEV_HSMMC
  150. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  151. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  152. s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  153. #endif
  154. }
  155. static inline void s3c6400_default_sdhci1(void)
  156. {
  157. #ifdef CONFIG_S3C_DEV_HSMMC1
  158. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  159. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  160. s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  161. #endif
  162. }
  163. static inline void s3c6400_default_sdhci2(void)
  164. {
  165. #ifdef CONFIG_S3C_DEV_HSMMC2
  166. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  167. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  168. s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
  169. #endif
  170. }
  171. extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
  172. void __iomem *r,
  173. struct mmc_ios *ios,
  174. struct mmc_card *card);
  175. static inline void s3c6410_default_sdhci0(void)
  176. {
  177. #ifdef CONFIG_S3C_DEV_HSMMC
  178. s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  179. s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
  180. s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  181. #endif
  182. }
  183. static inline void s3c6410_default_sdhci1(void)
  184. {
  185. #ifdef CONFIG_S3C_DEV_HSMMC1
  186. s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  187. s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
  188. s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  189. #endif
  190. }
  191. static inline void s3c6410_default_sdhci2(void)
  192. {
  193. #ifdef CONFIG_S3C_DEV_HSMMC2
  194. s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
  195. s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
  196. s3c_hsmmc2_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
  197. #endif
  198. }
  199. #else
  200. static inline void s3c6410_default_sdhci0(void) { }
  201. static inline void s3c6410_default_sdhci1(void) { }
  202. static inline void s3c6410_default_sdhci2(void) { }
  203. static inline void s3c6400_default_sdhci0(void) { }
  204. static inline void s3c6400_default_sdhci1(void) { }
  205. static inline void s3c6400_default_sdhci2(void) { }
  206. #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
  207. /* S5PC100 SDHCI setup */
  208. #ifdef CONFIG_S5PC100_SETUP_SDHCI
  209. extern char *s5pc100_hsmmc_clksrcs[4];
  210. extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
  211. void __iomem *r,
  212. struct mmc_ios *ios,
  213. struct mmc_card *card);
  214. static inline void s5pc100_default_sdhci0(void)
  215. {
  216. #ifdef CONFIG_S3C_DEV_HSMMC
  217. s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  218. s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
  219. s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  220. #endif
  221. }
  222. static inline void s5pc100_default_sdhci1(void)
  223. {
  224. #ifdef CONFIG_S3C_DEV_HSMMC1
  225. s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  226. s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
  227. s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  228. #endif
  229. }
  230. static inline void s5pc100_default_sdhci2(void)
  231. {
  232. #ifdef CONFIG_S3C_DEV_HSMMC2
  233. s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
  234. s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
  235. s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
  236. #endif
  237. }
  238. #else
  239. static inline void s5pc100_default_sdhci0(void) { }
  240. static inline void s5pc100_default_sdhci1(void) { }
  241. static inline void s5pc100_default_sdhci2(void) { }
  242. #endif /* CONFIG_S5PC100_SETUP_SDHCI */
  243. /* S5PV210 SDHCI setup */
  244. #ifdef CONFIG_S5PV210_SETUP_SDHCI
  245. extern char *s5pv210_hsmmc_clksrcs[4];
  246. extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
  247. void __iomem *r,
  248. struct mmc_ios *ios,
  249. struct mmc_card *card);
  250. static inline void s5pv210_default_sdhci0(void)
  251. {
  252. #ifdef CONFIG_S3C_DEV_HSMMC
  253. s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  254. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
  255. s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  256. #endif
  257. }
  258. static inline void s5pv210_default_sdhci1(void)
  259. {
  260. #ifdef CONFIG_S3C_DEV_HSMMC1
  261. s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  262. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
  263. s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  264. #endif
  265. }
  266. static inline void s5pv210_default_sdhci2(void)
  267. {
  268. #ifdef CONFIG_S3C_DEV_HSMMC2
  269. s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  270. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
  271. s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  272. #endif
  273. }
  274. static inline void s5pv210_default_sdhci3(void)
  275. {
  276. #ifdef CONFIG_S3C_DEV_HSMMC3
  277. s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
  278. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
  279. s3c_hsmmc3_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
  280. #endif
  281. }
  282. #else
  283. static inline void s5pv210_default_sdhci0(void) { }
  284. static inline void s5pv210_default_sdhci1(void) { }
  285. static inline void s5pv210_default_sdhci2(void) { }
  286. static inline void s5pv210_default_sdhci3(void) { }
  287. #endif /* CONFIG_S5PV210_SETUP_SDHCI */
  288. /* S5PV310 SDHCI setup */
  289. #ifdef CONFIG_S5PV310_SETUP_SDHCI
  290. extern char *s5pv310_hsmmc_clksrcs[4];
  291. extern void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev,
  292. void __iomem *r,
  293. struct mmc_ios *ios,
  294. struct mmc_card *card);
  295. static inline void s5pv310_default_sdhci0(void)
  296. {
  297. #ifdef CONFIG_S3C_DEV_HSMMC
  298. s3c_hsmmc0_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
  299. s3c_hsmmc0_def_platdata.cfg_gpio = s5pv310_setup_sdhci0_cfg_gpio;
  300. s3c_hsmmc0_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
  301. #endif
  302. }
  303. static inline void s5pv310_default_sdhci1(void)
  304. {
  305. #ifdef CONFIG_S3C_DEV_HSMMC1
  306. s3c_hsmmc1_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
  307. s3c_hsmmc1_def_platdata.cfg_gpio = s5pv310_setup_sdhci1_cfg_gpio;
  308. s3c_hsmmc1_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
  309. #endif
  310. }
  311. static inline void s5pv310_default_sdhci2(void)
  312. {
  313. #ifdef CONFIG_S3C_DEV_HSMMC2
  314. s3c_hsmmc2_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
  315. s3c_hsmmc2_def_platdata.cfg_gpio = s5pv310_setup_sdhci2_cfg_gpio;
  316. s3c_hsmmc2_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
  317. #endif
  318. }
  319. static inline void s5pv310_default_sdhci3(void)
  320. {
  321. #ifdef CONFIG_S3C_DEV_HSMMC3
  322. s3c_hsmmc3_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
  323. s3c_hsmmc3_def_platdata.cfg_gpio = s5pv310_setup_sdhci3_cfg_gpio;
  324. s3c_hsmmc3_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
  325. #endif
  326. }
  327. #else
  328. static inline void s5pv310_default_sdhci0(void) { }
  329. static inline void s5pv310_default_sdhci1(void) { }
  330. static inline void s5pv310_default_sdhci2(void) { }
  331. static inline void s5pv310_default_sdhci3(void) { }
  332. #endif /* CONFIG_S5PV310_SETUP_SDHCI */
  333. #endif /* __PLAT_S3C_SDHCI_H */