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