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