upload tizen1.0 source
[kernel/linux-2.6.36.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_type {
32         S3C_SDHCI_CLK_DIV_INTERNAL, /* Use SD Host controller for clock div */
33         S3C_SDHCI_CLK_DIV_EXTERNAL, /* Use CMU controller for 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  * @ext_cd_init: Initialize external card detect subsystem. Called on
42  *               sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
43  *               notify_func argument is a callback to the sdhci-s3c driver
44  *               that triggers the card detection event. Callback arguments:
45  *               dev is pointer to platform device of the host controller,
46  *               state is new state of the card (0 - removed, 1 - inserted).
47  * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
48  *               sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
49  *               notify_func argument is the same callback as for ext_cd_init.
50  * @ext_cd_gpio: gpio pin used for external CD line, valid only if
51  *               cd_type == S3C_SDHCI_CD_GPIO
52  * @ext_cd_gpio_invert: invert values for external CD gpio line
53  * @cfg_gpio: Configure the GPIO for a specific card bit-width
54  * @cfg_card: Configure the interface for a specific card and speed. This
55  *            is necessary the controllers and/or GPIO blocks require the
56  *            changing of driver-strength and other controls dependant on
57  *            the card and speed of operation.
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_type   clk_type;
69
70         char            **clocks;       /* set of clock sources */
71
72         int             ext_cd_gpio;
73         bool            ext_cd_gpio_invert;
74         int             wakeup;
75         int     (*ext_cd_init)(void (*notify_func)(struct platform_device *,
76                                                    int state));
77         int     (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
78                                                       int state));
79
80         void    (*cfg_gpio)(struct platform_device *dev, int width);
81         void    (*cfg_card)(struct platform_device *dev,
82                             void __iomem *regbase,
83                             struct mmc_ios *ios,
84                             struct mmc_card *card);
85 };
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 availablity */
110
111 extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
112 extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
113 extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
114 extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
115 extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
116 extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
117 extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
118 extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
119 extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
120 extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
121 extern void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
122 extern void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
123 extern void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
124 extern void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
125
126 /* S3C64XX SDHCI setup */
127
128 #ifdef CONFIG_S3C64XX_SETUP_SDHCI
129 extern char *s3c64xx_hsmmc_clksrcs[4];
130
131 extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
132                                          void __iomem *r,
133                                          struct mmc_ios *ios,
134                                          struct mmc_card *card);
135
136 static inline void s3c6400_default_sdhci0(void)
137 {
138 #ifdef CONFIG_S3C_DEV_HSMMC
139         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
140         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
141         s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
142 #endif
143 }
144
145 static inline void s3c6400_default_sdhci1(void)
146 {
147 #ifdef CONFIG_S3C_DEV_HSMMC1
148         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
149         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
150         s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
151 #endif
152 }
153
154 static inline void s3c6400_default_sdhci2(void)
155 {
156 #ifdef CONFIG_S3C_DEV_HSMMC2
157         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
158         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
159         s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
160 #endif
161 }
162
163 extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
164                                          void __iomem *r,
165                                          struct mmc_ios *ios,
166                                          struct mmc_card *card);
167
168 static inline void s3c6410_default_sdhci0(void)
169 {
170 #ifdef CONFIG_S3C_DEV_HSMMC
171         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
172         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
173         s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
174 #endif
175 }
176
177 static inline void s3c6410_default_sdhci1(void)
178 {
179 #ifdef CONFIG_S3C_DEV_HSMMC1
180         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
181         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
182         s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
183 #endif
184 }
185
186 static inline void s3c6410_default_sdhci2(void)
187 {
188 #ifdef CONFIG_S3C_DEV_HSMMC2
189         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
190         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
191         s3c_hsmmc2_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
192 #endif
193 }
194
195 #else
196 static inline void s3c6410_default_sdhci0(void) { }
197 static inline void s3c6410_default_sdhci1(void) { }
198 static inline void s3c6410_default_sdhci2(void) { }
199 static inline void s3c6400_default_sdhci0(void) { }
200 static inline void s3c6400_default_sdhci1(void) { }
201 static inline void s3c6400_default_sdhci2(void) { }
202
203 #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
204
205 /* S5PC100 SDHCI setup */
206
207 #ifdef CONFIG_S5PC100_SETUP_SDHCI
208 extern char *s5pc100_hsmmc_clksrcs[4];
209
210 extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
211                                            void __iomem *r,
212                                            struct mmc_ios *ios,
213                                            struct mmc_card *card);
214
215 static inline void s5pc100_default_sdhci0(void)
216 {
217 #ifdef CONFIG_S3C_DEV_HSMMC
218         s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
219         s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
220         s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
221 #endif
222 }
223
224 static inline void s5pc100_default_sdhci1(void)
225 {
226 #ifdef CONFIG_S3C_DEV_HSMMC1
227         s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
228         s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
229         s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
230 #endif
231 }
232
233 static inline void s5pc100_default_sdhci2(void)
234 {
235 #ifdef CONFIG_S3C_DEV_HSMMC2
236         s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
237         s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
238         s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
239 #endif
240 }
241
242 #else
243 static inline void s5pc100_default_sdhci0(void) { }
244 static inline void s5pc100_default_sdhci1(void) { }
245 static inline void s5pc100_default_sdhci2(void) { }
246
247 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
248
249 /* S5PV210 SDHCI setup */
250
251 #ifdef CONFIG_S5PV210_SETUP_SDHCI
252 extern char *s5pv210_hsmmc_clksrcs[4];
253
254 extern void s5pv210_setup_sdhci_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 s5pv210_default_sdhci0(void)
260 {
261 #ifdef CONFIG_S3C_DEV_HSMMC
262         s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
263         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
264         s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
265 #endif
266 }
267
268 static inline void s5pv210_default_sdhci1(void)
269 {
270 #ifdef CONFIG_S3C_DEV_HSMMC1
271         s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
272         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
273         s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
274 #endif
275 }
276
277 static inline void s5pv210_default_sdhci2(void)
278 {
279 #ifdef CONFIG_S3C_DEV_HSMMC2
280         s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
281         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
282         s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
283 #endif
284 }
285
286 static inline void s5pv210_default_sdhci3(void)
287 {
288 #ifdef CONFIG_S3C_DEV_HSMMC3
289         s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
290         s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
291         s3c_hsmmc3_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
292 #endif
293 }
294
295 #else
296 static inline void s5pv210_default_sdhci0(void) { }
297 static inline void s5pv210_default_sdhci1(void) { }
298 static inline void s5pv210_default_sdhci2(void) { }
299 static inline void s5pv210_default_sdhci3(void) { }
300
301 #endif /* CONFIG_S5PV210_SETUP_SDHCI */
302
303 /* S5PV310 SDHCI setup */
304 #ifdef CONFIG_S5PV310_SETUP_SDHCI
305 extern char *s5pv310_hsmmc_clksrcs[4];
306
307 extern void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev,
308                                            void __iomem *r,
309                                            struct mmc_ios *ios,
310                                            struct mmc_card *card);
311
312 static inline void s5pv310_default_sdhci0(void)
313 {
314 #ifdef CONFIG_S3C_DEV_HSMMC
315         s3c_hsmmc0_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
316         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv310_setup_sdhci0_cfg_gpio;
317         s3c_hsmmc0_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
318 #endif /* CONFIG_S3C_DEV_HSMMC */
319 }
320
321 static inline void s5pv310_default_sdhci1(void)
322 {
323 #ifdef CONFIG_S3C_DEV_HSMMC1
324         s3c_hsmmc1_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
325         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv310_setup_sdhci1_cfg_gpio;
326         s3c_hsmmc1_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
327 #endif /* CONFIG_S3C_DEV_HSMMC1 */
328 }
329
330 static inline void s5pv310_default_sdhci2(void)
331 {
332 #ifdef CONFIG_S3C_DEV_HSMMC2
333         s3c_hsmmc2_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
334         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv310_setup_sdhci2_cfg_gpio;
335         s3c_hsmmc2_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
336 #endif /* CONFIG_S3C_DEV_HSMMC2 */
337 }
338
339 static inline void s5pv310_default_sdhci3(void)
340 {
341 #ifdef CONFIG_S3C_DEV_HSMMC3
342         s3c_hsmmc3_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
343         s3c_hsmmc3_def_platdata.cfg_gpio = s5pv310_setup_sdhci3_cfg_gpio;
344         s3c_hsmmc3_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
345 #endif /* CONFIG_S3C_DEV_HSMMC3 */
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 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
353
354 #endif /* __PLAT_S3C_SDHCI_H */