Merge branch 'x86/amd-nb' into x86/apic-cleanups
[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 s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
111 extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
112 extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
113 extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
114 extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
115 extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
116 extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
117 extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
118 extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
119 extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
120 extern void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
121 extern void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
122 extern void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
123 extern void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
124
125 /* S3C64XX SDHCI setup */
126
127 #ifdef CONFIG_S3C64XX_SETUP_SDHCI
128 extern char *s3c64xx_hsmmc_clksrcs[4];
129
130 extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
131                                          void __iomem *r,
132                                          struct mmc_ios *ios,
133                                          struct mmc_card *card);
134
135 static inline void s3c6400_default_sdhci0(void)
136 {
137 #ifdef CONFIG_S3C_DEV_HSMMC
138         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
139         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
140         s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
141 #endif
142 }
143
144 static inline void s3c6400_default_sdhci1(void)
145 {
146 #ifdef CONFIG_S3C_DEV_HSMMC1
147         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
148         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
149         s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
150 #endif
151 }
152
153 static inline void s3c6400_default_sdhci2(void)
154 {
155 #ifdef CONFIG_S3C_DEV_HSMMC2
156         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
157         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
158         s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
159 #endif
160 }
161
162 extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
163                                          void __iomem *r,
164                                          struct mmc_ios *ios,
165                                          struct mmc_card *card);
166
167 static inline void s3c6410_default_sdhci0(void)
168 {
169 #ifdef CONFIG_S3C_DEV_HSMMC
170         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
171         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
172         s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
173 #endif
174 }
175
176 static inline void s3c6410_default_sdhci1(void)
177 {
178 #ifdef CONFIG_S3C_DEV_HSMMC1
179         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
180         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
181         s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
182 #endif
183 }
184
185 static inline void s3c6410_default_sdhci2(void)
186 {
187 #ifdef CONFIG_S3C_DEV_HSMMC2
188         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
189         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
190         s3c_hsmmc2_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
191 #endif
192 }
193
194 #else
195 static inline void s3c6410_default_sdhci0(void) { }
196 static inline void s3c6410_default_sdhci1(void) { }
197 static inline void s3c6410_default_sdhci2(void) { }
198 static inline void s3c6400_default_sdhci0(void) { }
199 static inline void s3c6400_default_sdhci1(void) { }
200 static inline void s3c6400_default_sdhci2(void) { }
201
202 #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
203
204 /* S5PC100 SDHCI setup */
205
206 #ifdef CONFIG_S5PC100_SETUP_SDHCI
207 extern char *s5pc100_hsmmc_clksrcs[4];
208
209 extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
210                                            void __iomem *r,
211                                            struct mmc_ios *ios,
212                                            struct mmc_card *card);
213
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
223 static inline void s5pc100_default_sdhci1(void)
224 {
225 #ifdef CONFIG_S3C_DEV_HSMMC1
226         s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
227         s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
228         s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
229 #endif
230 }
231
232 static inline void s5pc100_default_sdhci2(void)
233 {
234 #ifdef CONFIG_S3C_DEV_HSMMC2
235         s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
236         s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
237         s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
238 #endif
239 }
240
241 #else
242 static inline void s5pc100_default_sdhci0(void) { }
243 static inline void s5pc100_default_sdhci1(void) { }
244 static inline void s5pc100_default_sdhci2(void) { }
245
246 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
247
248 /* S5PV210 SDHCI setup */
249
250 #ifdef CONFIG_S5PV210_SETUP_SDHCI
251 extern char *s5pv210_hsmmc_clksrcs[4];
252
253 extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
254                                            void __iomem *r,
255                                            struct mmc_ios *ios,
256                                            struct mmc_card *card);
257
258 static inline void s5pv210_default_sdhci0(void)
259 {
260 #ifdef CONFIG_S3C_DEV_HSMMC
261         s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
262         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
263         s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
264 #endif
265 }
266
267 static inline void s5pv210_default_sdhci1(void)
268 {
269 #ifdef CONFIG_S3C_DEV_HSMMC1
270         s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
271         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
272         s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
273 #endif
274 }
275
276 static inline void s5pv210_default_sdhci2(void)
277 {
278 #ifdef CONFIG_S3C_DEV_HSMMC2
279         s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
280         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
281         s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
282 #endif
283 }
284
285 static inline void s5pv210_default_sdhci3(void)
286 {
287 #ifdef CONFIG_S3C_DEV_HSMMC3
288         s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
289         s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
290         s3c_hsmmc3_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
291 #endif
292 }
293
294 #else
295 static inline void s5pv210_default_sdhci0(void) { }
296 static inline void s5pv210_default_sdhci1(void) { }
297 static inline void s5pv210_default_sdhci2(void) { }
298 static inline void s5pv210_default_sdhci3(void) { }
299
300 #endif /* CONFIG_S5PV210_SETUP_SDHCI */
301
302 /* S5PV310 SDHCI setup */
303 #ifdef CONFIG_S5PV310_SETUP_SDHCI
304 extern char *s5pv310_hsmmc_clksrcs[4];
305
306 extern void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev,
307                                            void __iomem *r,
308                                            struct mmc_ios *ios,
309                                            struct mmc_card *card);
310
311 static inline void s5pv310_default_sdhci0(void)
312 {
313 #ifdef CONFIG_S3C_DEV_HSMMC
314         s3c_hsmmc0_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
315         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv310_setup_sdhci0_cfg_gpio;
316         s3c_hsmmc0_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
317 #endif
318 }
319
320 static inline void s5pv310_default_sdhci1(void)
321 {
322 #ifdef CONFIG_S3C_DEV_HSMMC1
323         s3c_hsmmc1_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
324         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv310_setup_sdhci1_cfg_gpio;
325         s3c_hsmmc1_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
326 #endif
327 }
328
329 static inline void s5pv310_default_sdhci2(void)
330 {
331 #ifdef CONFIG_S3C_DEV_HSMMC2
332         s3c_hsmmc2_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
333         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv310_setup_sdhci2_cfg_gpio;
334         s3c_hsmmc2_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
335 #endif
336 }
337
338 static inline void s5pv310_default_sdhci3(void)
339 {
340 #ifdef CONFIG_S3C_DEV_HSMMC3
341         s3c_hsmmc3_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
342         s3c_hsmmc3_def_platdata.cfg_gpio = s5pv310_setup_sdhci3_cfg_gpio;
343         s3c_hsmmc3_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
344 #endif
345 }
346
347 #else
348 static inline void s5pv310_default_sdhci0(void) { }
349 static inline void s5pv310_default_sdhci1(void) { }
350 static inline void s5pv310_default_sdhci2(void) { }
351 static inline void s5pv310_default_sdhci3(void) { }
352
353 #endif /* CONFIG_S5PV310_SETUP_SDHCI */
354
355 #endif /* __PLAT_S3C_SDHCI_H */