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 #include <plat/devs.h>
22 
23 struct platform_device;
24 struct mmc_host;
25 struct mmc_card;
26 struct mmc_ios;
27 
28 enum cd_types {
29 	S3C_SDHCI_CD_INTERNAL,	/* use mmc internal CD line */
30 	S3C_SDHCI_CD_EXTERNAL,	/* use external callback */
31 	S3C_SDHCI_CD_GPIO,	/* use external gpio pin for CD line */
32 	S3C_SDHCI_CD_NONE,	/* no CD line, use polling to detect card */
33 	S3C_SDHCI_CD_PERMANENT,	/* no CD line, card permanently wired to host */
34 };
35 
36 enum clk_types {
37 	S3C_SDHCI_CLK_DIV_INTERNAL,	/* use mmc internal clock divider */
38 	S3C_SDHCI_CLK_DIV_EXTERNAL,	/* use external clock divider */
39 };
40 
41 /**
42  * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
43  * @max_width: The maximum number of data bits supported.
44  * @host_caps: Standard MMC host capabilities bit field.
45  * @host_caps2: The second standard MMC host capabilities bit field.
46  * @cd_type: Type of Card Detection method (see cd_types enum above)
47  * @clk_type: Type of clock divider method (see clk_types enum above)
48  * @ext_cd_init: Initialize external card detect subsystem. Called on
49  *		 sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
50  *		 notify_func argument is a callback to the sdhci-s3c driver
51  *		 that triggers the card detection event. Callback arguments:
52  *		 dev is pointer to platform device of the host controller,
53  *		 state is new state of the card (0 - removed, 1 - inserted).
54  * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
55  *		 sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
56  *		 notify_func argument is the same callback as for ext_cd_init.
57  * @ext_cd_gpio: gpio pin used for external CD line, valid only if
58  *		 cd_type == S3C_SDHCI_CD_GPIO
59  * @ext_cd_gpio_invert: invert values for external CD gpio line
60  * @cfg_gpio: Configure the GPIO for a specific card bit-width
61  *
62  * Initialisation data specific to either the machine or the platform
63  * for the device driver to use or call-back when configuring gpio or
64  * card speed information.
65 */
66 struct s3c_sdhci_platdata {
67 	unsigned int	max_width;
68 	unsigned int	host_caps;
69 	unsigned int	host_caps2;
70 	unsigned int	pm_caps;
71 	enum cd_types	cd_type;
72 	enum clk_types	clk_type;
73 
74 	int		ext_cd_gpio;
75 	bool		ext_cd_gpio_invert;
76 	int	(*ext_cd_init)(void (*notify_func)(struct platform_device *,
77 						   int state));
78 	int	(*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
79 						      int state));
80 
81 	void	(*cfg_gpio)(struct platform_device *dev, int width);
82 };
83 
84 /* s3c_sdhci_set_platdata() - common helper for setting SDHCI platform data
85  * @pd: The default platform data for this device.
86  * @set: Pointer to the platform data to fill in.
87  */
88 extern void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
89 				    struct s3c_sdhci_platdata *set);
90 
91 /**
92  * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
93  * @pd: Platform data to register to device.
94  *
95  * Register the given platform data for use withe S3C SDHCI device.
96  * The call will copy the platform data, so the board definitions can
97  * make the structure itself __initdata.
98  */
99 extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
100 extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
101 extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
102 extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
103 
104 /* Default platform data, exported so that per-cpu initialisation can
105  * set the correct one when there are more than one cpu type selected.
106 */
107 
108 extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
109 extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
110 extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
111 extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
112 
113 /* Helper function availability */
114 
115 extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
116 extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
117 extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
118 extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
119 extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
120 extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
121 extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
122 extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
123 extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
124 extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
125 extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
126 extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
127 extern void exynos4_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
128 extern void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
129 extern void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
130 extern void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
131 extern void s5p64x0_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
132 extern void s5p64x0_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
133 extern void s5p6440_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
134 extern void s5p6450_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
135 
136 /* S3C2416 SDHCI setup */
137 
138 #ifdef CONFIG_S3C2416_SETUP_SDHCI
s3c2416_default_sdhci0(void)139 static inline void s3c2416_default_sdhci0(void)
140 {
141 #ifdef CONFIG_S3C_DEV_HSMMC
142 	s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
143 #endif /* CONFIG_S3C_DEV_HSMMC */
144 }
145 
s3c2416_default_sdhci1(void)146 static inline void s3c2416_default_sdhci1(void)
147 {
148 #ifdef CONFIG_S3C_DEV_HSMMC1
149 	s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
150 #endif /* CONFIG_S3C_DEV_HSMMC1 */
151 }
152 
153 #else
s3c2416_default_sdhci0(void)154 static inline void s3c2416_default_sdhci0(void) { }
s3c2416_default_sdhci1(void)155 static inline void s3c2416_default_sdhci1(void) { }
156 
157 #endif /* CONFIG_S3C2416_SETUP_SDHCI */
158 
159 /* S3C64XX SDHCI setup */
160 
161 #ifdef CONFIG_S3C64XX_SETUP_SDHCI
s3c6400_default_sdhci0(void)162 static inline void s3c6400_default_sdhci0(void)
163 {
164 #ifdef CONFIG_S3C_DEV_HSMMC
165 	s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
166 #endif
167 }
168 
s3c6400_default_sdhci1(void)169 static inline void s3c6400_default_sdhci1(void)
170 {
171 #ifdef CONFIG_S3C_DEV_HSMMC1
172 	s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
173 #endif
174 }
175 
s3c6400_default_sdhci2(void)176 static inline void s3c6400_default_sdhci2(void)
177 {
178 #ifdef CONFIG_S3C_DEV_HSMMC2
179 	s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
180 #endif
181 }
182 
s3c6410_default_sdhci0(void)183 static inline void s3c6410_default_sdhci0(void)
184 {
185 #ifdef CONFIG_S3C_DEV_HSMMC
186 	s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
187 #endif
188 }
189 
s3c6410_default_sdhci1(void)190 static inline void s3c6410_default_sdhci1(void)
191 {
192 #ifdef CONFIG_S3C_DEV_HSMMC1
193 	s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
194 #endif
195 }
196 
s3c6410_default_sdhci2(void)197 static inline void s3c6410_default_sdhci2(void)
198 {
199 #ifdef CONFIG_S3C_DEV_HSMMC2
200 	s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
201 #endif
202 }
203 
204 #else
s3c6410_default_sdhci0(void)205 static inline void s3c6410_default_sdhci0(void) { }
s3c6410_default_sdhci1(void)206 static inline void s3c6410_default_sdhci1(void) { }
s3c6410_default_sdhci2(void)207 static inline void s3c6410_default_sdhci2(void) { }
s3c6400_default_sdhci0(void)208 static inline void s3c6400_default_sdhci0(void) { }
s3c6400_default_sdhci1(void)209 static inline void s3c6400_default_sdhci1(void) { }
s3c6400_default_sdhci2(void)210 static inline void s3c6400_default_sdhci2(void) { }
211 
212 #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
213 
214 /* S5P64X0 SDHCI setup */
215 
216 #ifdef CONFIG_S5P64X0_SETUP_SDHCI
s5p64x0_default_sdhci0(void)217 static inline void s5p64x0_default_sdhci0(void)
218 {
219 #ifdef CONFIG_S3C_DEV_HSMMC
220 	s3c_hsmmc0_def_platdata.cfg_gpio = s5p64x0_setup_sdhci0_cfg_gpio;
221 #endif
222 }
223 
s5p64x0_default_sdhci1(void)224 static inline void s5p64x0_default_sdhci1(void)
225 {
226 #ifdef CONFIG_S3C_DEV_HSMMC1
227 	s3c_hsmmc1_def_platdata.cfg_gpio = s5p64x0_setup_sdhci1_cfg_gpio;
228 #endif
229 }
230 
s5p6440_default_sdhci2(void)231 static inline void s5p6440_default_sdhci2(void)
232 {
233 #ifdef CONFIG_S3C_DEV_HSMMC2
234 	s3c_hsmmc2_def_platdata.cfg_gpio = s5p6440_setup_sdhci2_cfg_gpio;
235 #endif
236 }
237 
s5p6450_default_sdhci2(void)238 static inline void s5p6450_default_sdhci2(void)
239 {
240 #ifdef CONFIG_S3C_DEV_HSMMC2
241 	s3c_hsmmc2_def_platdata.cfg_gpio = s5p6450_setup_sdhci2_cfg_gpio;
242 #endif
243 }
244 
245 #else
s5p64x0_default_sdhci0(void)246 static inline void s5p64x0_default_sdhci0(void) { }
s5p64x0_default_sdhci1(void)247 static inline void s5p64x0_default_sdhci1(void) { }
s5p6440_default_sdhci2(void)248 static inline void s5p6440_default_sdhci2(void) { }
s5p6450_default_sdhci2(void)249 static inline void s5p6450_default_sdhci2(void) { }
250 
251 #endif /* CONFIG_S5P64X0_SETUP_SDHCI */
252 
253 /* S5PC100 SDHCI setup */
254 
255 #ifdef CONFIG_S5PC100_SETUP_SDHCI
s5pc100_default_sdhci0(void)256 static inline void s5pc100_default_sdhci0(void)
257 {
258 #ifdef CONFIG_S3C_DEV_HSMMC
259 	s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
260 #endif
261 }
262 
s5pc100_default_sdhci1(void)263 static inline void s5pc100_default_sdhci1(void)
264 {
265 #ifdef CONFIG_S3C_DEV_HSMMC1
266 	s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
267 #endif
268 }
269 
s5pc100_default_sdhci2(void)270 static inline void s5pc100_default_sdhci2(void)
271 {
272 #ifdef CONFIG_S3C_DEV_HSMMC2
273 	s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
274 #endif
275 }
276 
277 #else
s5pc100_default_sdhci0(void)278 static inline void s5pc100_default_sdhci0(void) { }
s5pc100_default_sdhci1(void)279 static inline void s5pc100_default_sdhci1(void) { }
s5pc100_default_sdhci2(void)280 static inline void s5pc100_default_sdhci2(void) { }
281 
282 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
283 
284 /* S5PV210 SDHCI setup */
285 
286 #ifdef CONFIG_S5PV210_SETUP_SDHCI
s5pv210_default_sdhci0(void)287 static inline void s5pv210_default_sdhci0(void)
288 {
289 #ifdef CONFIG_S3C_DEV_HSMMC
290 	s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
291 #endif
292 }
293 
s5pv210_default_sdhci1(void)294 static inline void s5pv210_default_sdhci1(void)
295 {
296 #ifdef CONFIG_S3C_DEV_HSMMC1
297 	s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
298 #endif
299 }
300 
s5pv210_default_sdhci2(void)301 static inline void s5pv210_default_sdhci2(void)
302 {
303 #ifdef CONFIG_S3C_DEV_HSMMC2
304 	s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
305 #endif
306 }
307 
s5pv210_default_sdhci3(void)308 static inline void s5pv210_default_sdhci3(void)
309 {
310 #ifdef CONFIG_S3C_DEV_HSMMC3
311 	s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
312 #endif
313 }
314 
315 #else
s5pv210_default_sdhci0(void)316 static inline void s5pv210_default_sdhci0(void) { }
s5pv210_default_sdhci1(void)317 static inline void s5pv210_default_sdhci1(void) { }
s5pv210_default_sdhci2(void)318 static inline void s5pv210_default_sdhci2(void) { }
s5pv210_default_sdhci3(void)319 static inline void s5pv210_default_sdhci3(void) { }
320 
321 #endif /* CONFIG_S5PV210_SETUP_SDHCI */
322 
323 /* EXYNOS4 SDHCI setup */
324 #ifdef CONFIG_EXYNOS4_SETUP_SDHCI
exynos4_default_sdhci0(void)325 static inline void exynos4_default_sdhci0(void)
326 {
327 #ifdef CONFIG_S3C_DEV_HSMMC
328 	s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
329 #endif
330 }
331 
exynos4_default_sdhci1(void)332 static inline void exynos4_default_sdhci1(void)
333 {
334 #ifdef CONFIG_S3C_DEV_HSMMC1
335 	s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
336 #endif
337 }
338 
exynos4_default_sdhci2(void)339 static inline void exynos4_default_sdhci2(void)
340 {
341 #ifdef CONFIG_S3C_DEV_HSMMC2
342 	s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
343 #endif
344 }
345 
exynos4_default_sdhci3(void)346 static inline void exynos4_default_sdhci3(void)
347 {
348 #ifdef CONFIG_S3C_DEV_HSMMC3
349 	s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
350 #endif
351 }
352 
353 #else
exynos4_default_sdhci0(void)354 static inline void exynos4_default_sdhci0(void) { }
exynos4_default_sdhci1(void)355 static inline void exynos4_default_sdhci1(void) { }
exynos4_default_sdhci2(void)356 static inline void exynos4_default_sdhci2(void) { }
exynos4_default_sdhci3(void)357 static inline void exynos4_default_sdhci3(void) { }
358 
359 #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
360 
s3c_sdhci_setname(int id,char * name)361 static inline void s3c_sdhci_setname(int id, char *name)
362 {
363 	switch (id) {
364 #ifdef CONFIG_S3C_DEV_HSMMC
365 	case 0:
366 		s3c_device_hsmmc0.name = name;
367 		break;
368 #endif
369 #ifdef CONFIG_S3C_DEV_HSMMC1
370 	case 1:
371 		s3c_device_hsmmc1.name = name;
372 		break;
373 #endif
374 #ifdef CONFIG_S3C_DEV_HSMMC2
375 	case 2:
376 		s3c_device_hsmmc2.name = name;
377 		break;
378 #endif
379 #ifdef CONFIG_S3C_DEV_HSMMC3
380 	case 3:
381 		s3c_device_hsmmc3.name = name;
382 		break;
383 #endif
384 	}
385 }
386 
387 #endif /* __PLAT_S3C_SDHCI_H */
388