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