Merge branch 'master' into for-next
[pandora-kernel.git] / arch / arm / plat-samsung / include / plat / sdhci.h
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
15 #ifndef __PLAT_S3C_SDHCI_H
16 #define __PLAT_S3C_SDHCI_H __FILE__
17
18 struct platform_device;
19 struct mmc_host;
20 struct mmc_card;
21 struct mmc_ios;
22
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
31 enum clk_types {
32         S3C_SDHCI_CLK_DIV_INTERNAL,     /* use mmc internal clock divider */
33         S3C_SDHCI_CLK_DIV_EXTERNAL,     /* use external clock divider */
34 };
35
36 /**
37  * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
38  * @max_width: The maximum number of data bits supported.
39  * @host_caps: Standard MMC host capabilities bit field.
40  * @cd_type: Type of Card Detection method (see cd_types enum above)
41  * @clk_type: Type of clock divider method (see clk_types enum above)
42  * @ext_cd_init: Initialize external card detect subsystem. Called on
43  *               sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
44  *               notify_func argument is a callback to the sdhci-s3c driver
45  *               that triggers the card detection event. Callback arguments:
46  *               dev is pointer to platform device of the host controller,
47  *               state is new state of the card (0 - removed, 1 - inserted).
48  * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
49  *               sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
50  *               notify_func argument is the same callback as for ext_cd_init.
51  * @ext_cd_gpio: gpio pin used for external CD line, valid only if
52  *               cd_type == S3C_SDHCI_CD_GPIO
53  * @ext_cd_gpio_invert: invert values for external CD gpio line
54  * @cfg_gpio: Configure the GPIO for a specific card bit-width
55  * @cfg_card: Configure the interface for a specific card and speed. This
56  *            is necessary the controllers and/or GPIO blocks require the
57  *            changing of driver-strength and other controls dependant on
58  *            the card and speed of operation.
59  *
60  * Initialisation data specific to either the machine or the platform
61  * for the device driver to use or call-back when configuring gpio or
62  * card speed information.
63 */
64 struct s3c_sdhci_platdata {
65         unsigned int    max_width;
66         unsigned int    host_caps;
67         enum cd_types   cd_type;
68         enum clk_types  clk_type;
69
70         char            **clocks;       /* set of clock sources */
71
72         int             ext_cd_gpio;
73         bool            ext_cd_gpio_invert;
74         int     (*ext_cd_init)(void (*notify_func)(struct platform_device *,
75                                                    int state));
76         int     (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
77                                                       int state));
78
79         void    (*cfg_gpio)(struct platform_device *dev, int width);
80         void    (*cfg_card)(struct platform_device *dev,
81                             void __iomem *regbase,
82                             struct mmc_ios *ios,
83                             struct mmc_card *card);
84 };
85
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
99 /* Default platform data, exported so that per-cpu initialisation can
100  * set the correct one when there are more than one cpu type selected.
101 */
102
103 extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
104 extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
105 extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
106 extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
107
108 /* Helper function availablity */
109
110 extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
111 extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
112 extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
113 extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
114 extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
115 extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
116 extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
117 extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
118 extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
119 extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
120 extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
121 extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
122 extern void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
123 extern void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
124 extern void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
125 extern void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
126
127 /* S3C2416 SDHCI setup */
128
129 #ifdef CONFIG_S3C2416_SETUP_SDHCI
130 extern char *s3c2416_hsmmc_clksrcs[4];
131
132 extern void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,
133                                            void __iomem *r,
134                                            struct mmc_ios *ios,
135                                            struct mmc_card *card);
136
137 static inline void s3c2416_default_sdhci0(void)
138 {
139 #ifdef CONFIG_S3C_DEV_HSMMC
140         s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
141         s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
142         s3c_hsmmc0_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
143 #endif /* CONFIG_S3C_DEV_HSMMC */
144 }
145
146 static inline void s3c2416_default_sdhci1(void)
147 {
148 #ifdef CONFIG_S3C_DEV_HSMMC1
149         s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
150         s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
151         s3c_hsmmc1_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
152 #endif /* CONFIG_S3C_DEV_HSMMC1 */
153 }
154
155 #else
156 static inline void s3c2416_default_sdhci0(void) { }
157 static inline void s3c2416_default_sdhci1(void) { }
158
159 #endif /* CONFIG_S3C2416_SETUP_SDHCI */
160 /* S3C64XX SDHCI setup */
161
162 #ifdef CONFIG_S3C64XX_SETUP_SDHCI
163 extern char *s3c64xx_hsmmc_clksrcs[4];
164
165 extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
166                                          void __iomem *r,
167                                          struct mmc_ios *ios,
168                                          struct mmc_card *card);
169
170 static inline void s3c6400_default_sdhci0(void)
171 {
172 #ifdef CONFIG_S3C_DEV_HSMMC
173         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
174         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
175         s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
176 #endif
177 }
178
179 static inline void s3c6400_default_sdhci1(void)
180 {
181 #ifdef CONFIG_S3C_DEV_HSMMC1
182         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
183         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
184         s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
185 #endif
186 }
187
188 static inline void s3c6400_default_sdhci2(void)
189 {
190 #ifdef CONFIG_S3C_DEV_HSMMC2
191         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
192         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
193         s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
194 #endif
195 }
196
197 extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
198                                          void __iomem *r,
199                                          struct mmc_ios *ios,
200                                          struct mmc_card *card);
201
202 static inline void s3c6410_default_sdhci0(void)
203 {
204 #ifdef CONFIG_S3C_DEV_HSMMC
205         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
206         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
207         s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
208 #endif
209 }
210
211 static inline void s3c6410_default_sdhci1(void)
212 {
213 #ifdef CONFIG_S3C_DEV_HSMMC1
214         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
215         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
216         s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
217 #endif
218 }
219
220 static inline void s3c6410_default_sdhci2(void)
221 {
222 #ifdef CONFIG_S3C_DEV_HSMMC2
223         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
224         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
225         s3c_hsmmc2_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
226 #endif
227 }
228
229 #else
230 static inline void s3c6410_default_sdhci0(void) { }
231 static inline void s3c6410_default_sdhci1(void) { }
232 static inline void s3c6410_default_sdhci2(void) { }
233 static inline void s3c6400_default_sdhci0(void) { }
234 static inline void s3c6400_default_sdhci1(void) { }
235 static inline void s3c6400_default_sdhci2(void) { }
236
237 #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
238
239 /* S5PC100 SDHCI setup */
240
241 #ifdef CONFIG_S5PC100_SETUP_SDHCI
242 extern char *s5pc100_hsmmc_clksrcs[4];
243
244 extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
245                                            void __iomem *r,
246                                            struct mmc_ios *ios,
247                                            struct mmc_card *card);
248
249 static inline void s5pc100_default_sdhci0(void)
250 {
251 #ifdef CONFIG_S3C_DEV_HSMMC
252         s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
253         s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
254         s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
255 #endif
256 }
257
258 static inline void s5pc100_default_sdhci1(void)
259 {
260 #ifdef CONFIG_S3C_DEV_HSMMC1
261         s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
262         s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
263         s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
264 #endif
265 }
266
267 static inline void s5pc100_default_sdhci2(void)
268 {
269 #ifdef CONFIG_S3C_DEV_HSMMC2
270         s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
271         s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
272         s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
273 #endif
274 }
275
276 #else
277 static inline void s5pc100_default_sdhci0(void) { }
278 static inline void s5pc100_default_sdhci1(void) { }
279 static inline void s5pc100_default_sdhci2(void) { }
280
281 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
282
283 /* S5PV210 SDHCI setup */
284
285 #ifdef CONFIG_S5PV210_SETUP_SDHCI
286 extern char *s5pv210_hsmmc_clksrcs[4];
287
288 extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
289                                            void __iomem *r,
290                                            struct mmc_ios *ios,
291                                            struct mmc_card *card);
292
293 static inline void s5pv210_default_sdhci0(void)
294 {
295 #ifdef CONFIG_S3C_DEV_HSMMC
296         s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
297         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
298         s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
299 #endif
300 }
301
302 static inline void s5pv210_default_sdhci1(void)
303 {
304 #ifdef CONFIG_S3C_DEV_HSMMC1
305         s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
306         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
307         s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
308 #endif
309 }
310
311 static inline void s5pv210_default_sdhci2(void)
312 {
313 #ifdef CONFIG_S3C_DEV_HSMMC2
314         s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
315         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
316         s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
317 #endif
318 }
319
320 static inline void s5pv210_default_sdhci3(void)
321 {
322 #ifdef CONFIG_S3C_DEV_HSMMC3
323         s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
324         s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
325         s3c_hsmmc3_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
326 #endif
327 }
328
329 #else
330 static inline void s5pv210_default_sdhci0(void) { }
331 static inline void s5pv210_default_sdhci1(void) { }
332 static inline void s5pv210_default_sdhci2(void) { }
333 static inline void s5pv210_default_sdhci3(void) { }
334
335 #endif /* CONFIG_S5PV210_SETUP_SDHCI */
336
337 /* S5PV310 SDHCI setup */
338 #ifdef CONFIG_S5PV310_SETUP_SDHCI
339 extern char *s5pv310_hsmmc_clksrcs[4];
340
341 extern void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev,
342                                            void __iomem *r,
343                                            struct mmc_ios *ios,
344                                            struct mmc_card *card);
345
346 static inline void s5pv310_default_sdhci0(void)
347 {
348 #ifdef CONFIG_S3C_DEV_HSMMC
349         s3c_hsmmc0_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
350         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv310_setup_sdhci0_cfg_gpio;
351         s3c_hsmmc0_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
352 #endif
353 }
354
355 static inline void s5pv310_default_sdhci1(void)
356 {
357 #ifdef CONFIG_S3C_DEV_HSMMC1
358         s3c_hsmmc1_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
359         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv310_setup_sdhci1_cfg_gpio;
360         s3c_hsmmc1_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
361 #endif
362 }
363
364 static inline void s5pv310_default_sdhci2(void)
365 {
366 #ifdef CONFIG_S3C_DEV_HSMMC2
367         s3c_hsmmc2_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
368         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv310_setup_sdhci2_cfg_gpio;
369         s3c_hsmmc2_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
370 #endif
371 }
372
373 static inline void s5pv310_default_sdhci3(void)
374 {
375 #ifdef CONFIG_S3C_DEV_HSMMC3
376         s3c_hsmmc3_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
377         s3c_hsmmc3_def_platdata.cfg_gpio = s5pv310_setup_sdhci3_cfg_gpio;
378         s3c_hsmmc3_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
379 #endif
380 }
381
382 #else
383 static inline void s5pv310_default_sdhci0(void) { }
384 static inline void s5pv310_default_sdhci1(void) { }
385 static inline void s5pv310_default_sdhci2(void) { }
386 static inline void s5pv310_default_sdhci3(void) { }
387
388 #endif /* CONFIG_S5PV310_SETUP_SDHCI */
389
390 #endif /* __PLAT_S3C_SDHCI_H */