ARM: SAMSUNG: Add new s3c-sdhci card detection methods for Samsung SoCs
[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 /**
32  * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
33  * @max_width: The maximum number of data bits supported.
34  * @host_caps: Standard MMC host capabilities bit field.
35  * @cd_type: Type of Card Detection method (see cd_types enum above)
36  * @ext_cd_init: Initialize external card detect subsystem. Called on
37  *               sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
38  *               notify_func argument is a callback to the sdhci-s3c driver
39  *               that triggers the card detection event. Callback arguments:
40  *               dev is pointer to platform device of the host controller,
41  *               state is new state of the card (0 - removed, 1 - inserted).
42  * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
43  *               sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
44  *               notify_func argument is the same callback as for ext_cd_init.
45  * @ext_cd_gpio: gpio pin used for external CD line, valid only if
46  *               cd_type == S3C_SDHCI_CD_GPIO
47  * @ext_cd_gpio_invert: invert values for external CD gpio line
48  * @cfg_gpio: Configure the GPIO for a specific card bit-width
49  * @cfg_card: Configure the interface for a specific card and speed. This
50  *            is necessary the controllers and/or GPIO blocks require the
51  *            changing of driver-strength and other controls dependant on
52  *            the card and speed of operation.
53  *
54  * Initialisation data specific to either the machine or the platform
55  * for the device driver to use or call-back when configuring gpio or
56  * card speed information.
57 */
58 struct s3c_sdhci_platdata {
59         unsigned int    max_width;
60         unsigned int    host_caps;
61         enum cd_types   cd_type;
62
63         char            **clocks;       /* set of clock sources */
64
65         int             ext_cd_gpio;
66         bool            ext_cd_gpio_invert;
67         int     (*ext_cd_init)(void (*notify_func)(struct platform_device *,
68                                                    int state));
69         int     (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
70                                                       int state));
71
72         void    (*cfg_gpio)(struct platform_device *dev, int width);
73         void    (*cfg_card)(struct platform_device *dev,
74                             void __iomem *regbase,
75                             struct mmc_ios *ios,
76                             struct mmc_card *card);
77 };
78
79 /**
80  * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
81  * @pd: Platform data to register to device.
82  *
83  * Register the given platform data for use withe S3C SDHCI device.
84  * The call will copy the platform data, so the board definitions can
85  * make the structure itself __initdata.
86  */
87 extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
88 extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
89 extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
90 extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
91
92 /* Default platform data, exported so that per-cpu initialisation can
93  * set the correct one when there are more than one cpu type selected.
94 */
95
96 extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
97 extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
98 extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
99 extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
100
101 /* Helper function availablity */
102
103 extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
104 extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
105 extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
106 extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
107 extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
108 extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
109 extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
110 extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
111 extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
112
113 /* S3C6400 SDHCI setup */
114
115 #ifdef CONFIG_S3C64XX_SETUP_SDHCI
116 extern char *s3c64xx_hsmmc_clksrcs[4];
117
118 #ifdef CONFIG_S3C_DEV_HSMMC
119 extern void s3c6400_setup_sdhci_cfg_card(struct platform_device *dev,
120                                          void __iomem *r,
121                                          struct mmc_ios *ios,
122                                          struct mmc_card *card);
123
124 static inline void s3c6400_default_sdhci0(void)
125 {
126         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
127         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
128         s3c_hsmmc0_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
129 }
130
131 #else
132 static inline void s3c6400_default_sdhci0(void) { }
133 #endif  /* CONFIG_S3C_DEV_HSMMC */
134
135 #ifdef CONFIG_S3C_DEV_HSMMC1
136 static inline void s3c6400_default_sdhci1(void)
137 {
138         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
139         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
140         s3c_hsmmc1_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
141 }
142 #else
143 static inline void s3c6400_default_sdhci1(void) { }
144 #endif /* CONFIG_S3C_DEV_HSMMC1 */
145
146 #ifdef CONFIG_S3C_DEV_HSMMC2
147 static inline void s3c6400_default_sdhci2(void)
148 {
149         s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
150         s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
151         s3c_hsmmc2_def_platdata.cfg_card = s3c6400_setup_sdhci_cfg_card;
152 }
153 #else
154 static inline void s3c6400_default_sdhci2(void) { }
155 #endif /* CONFIG_S3C_DEV_HSMMC2 */
156
157 /* S3C6410 SDHCI setup */
158
159 extern void s3c6410_setup_sdhci_cfg_card(struct platform_device *dev,
160                                          void __iomem *r,
161                                          struct mmc_ios *ios,
162                                          struct mmc_card *card);
163
164 #ifdef CONFIG_S3C_DEV_HSMMC
165 static inline void s3c6410_default_sdhci0(void)
166 {
167         s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
168         s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
169         s3c_hsmmc0_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
170 }
171 #else
172 static inline void s3c6410_default_sdhci0(void) { }
173 #endif /* CONFIG_S3C_DEV_HSMMC */
174
175 #ifdef CONFIG_S3C_DEV_HSMMC1
176 static inline void s3c6410_default_sdhci1(void)
177 {
178         s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
179         s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
180         s3c_hsmmc1_def_platdata.cfg_card = s3c6410_setup_sdhci_cfg_card;
181 }
182 #else
183 static inline void s3c6410_default_sdhci1(void) { }
184 #endif /* CONFIG_S3C_DEV_HSMMC1 */
185
186 #ifdef CONFIG_S3C_DEV_HSMMC2
187 static inline void s3c6410_default_sdhci2(void)
188 {
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 }
193 #else
194 static inline void s3c6410_default_sdhci2(void) { }
195 #endif /* CONFIG_S3C_DEV_HSMMC2 */
196
197 #else
198 static inline void s3c6410_default_sdhci0(void) { }
199 static inline void s3c6410_default_sdhci1(void) { }
200 static inline void s3c6410_default_sdhci2(void) { }
201 static inline void s3c6400_default_sdhci0(void) { }
202 static inline void s3c6400_default_sdhci1(void) { }
203 static inline void s3c6400_default_sdhci2(void) { }
204
205 #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
206
207 /* S5PC100 SDHCI setup */
208
209 #ifdef CONFIG_S5PC100_SETUP_SDHCI
210 extern char *s5pc100_hsmmc_clksrcs[4];
211
212 extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
213                                            void __iomem *r,
214                                            struct mmc_ios *ios,
215                                            struct mmc_card *card);
216
217 #ifdef CONFIG_S3C_DEV_HSMMC
218 static inline void s5pc100_default_sdhci0(void)
219 {
220         s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
221         s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
222         s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
223 }
224 #else
225 static inline void s5pc100_default_sdhci0(void) { }
226 #endif /* CONFIG_S3C_DEV_HSMMC */
227
228 #ifdef CONFIG_S3C_DEV_HSMMC1
229 static inline void s5pc100_default_sdhci1(void)
230 {
231         s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
232         s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
233         s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
234 }
235 #else
236 static inline void s5pc100_default_sdhci1(void) { }
237 #endif /* CONFIG_S3C_DEV_HSMMC1 */
238
239 #ifdef CONFIG_S3C_DEV_HSMMC2
240 static inline void s5pc100_default_sdhci2(void)
241 {
242         s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
243         s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
244         s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
245 }
246 #else
247 static inline void s5pc100_default_sdhci2(void) { }
248 #endif /* CONFIG_S3C_DEV_HSMMC1 */
249
250
251 #else
252 static inline void s5pc100_default_sdhci0(void) { }
253 static inline void s5pc100_default_sdhci1(void) { }
254 static inline void s5pc100_default_sdhci2(void) { }
255 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
256
257
258 /* S5PC110 SDHCI setup */
259 #ifdef CONFIG_S5PV210_SETUP_SDHCI
260 extern char *s5pv210_hsmmc_clksrcs[4];
261
262 extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
263                                            void __iomem *r,
264                                            struct mmc_ios *ios,
265                                            struct mmc_card *card);
266
267 #ifdef CONFIG_S3C_DEV_HSMMC
268 static inline void s5pv210_default_sdhci0(void)
269 {
270         s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
271         s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
272         s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
273 }
274 #else
275 static inline void s5pv210_default_sdhci0(void) { }
276 #endif /* CONFIG_S3C_DEV_HSMMC */
277
278 #ifdef CONFIG_S3C_DEV_HSMMC1
279 static inline void s5pv210_default_sdhci1(void)
280 {
281         s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
282         s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
283         s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
284 }
285 #else
286 static inline void s5pv210_default_sdhci1(void) { }
287 #endif /* CONFIG_S3C_DEV_HSMMC1 */
288
289 #ifdef CONFIG_S3C_DEV_HSMMC2
290 static inline void s5pv210_default_sdhci2(void)
291 {
292         s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
293         s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
294         s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
295 }
296 #else
297 static inline void s5pv210_default_sdhci2(void) { }
298 #endif /* CONFIG_S3C_DEV_HSMMC2 */
299
300 #else
301 static inline void s5pv210_default_sdhci0(void) { }
302 static inline void s5pv210_default_sdhci1(void) { }
303 static inline void s5pv210_default_sdhci2(void) { }
304 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
305
306
307
308
309 #endif /* __PLAT_S3C_SDHCI_H */