1 /* linux/arch/arm/plat-samsung/include/plat/sdhci.h
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * Copyright 2008 Openmoko, Inc.
7 * Copyright 2008 Simtec Electronics
8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk>
11 * S3C Platform - SDHCI (HSMMC) platform data definitions
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.
18 #ifndef __PLAT_S3C_SDHCI_H
19 #define __PLAT_S3C_SDHCI_H __FILE__
21 #include <plat/devs.h>
23 struct platform_device;
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 */
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 * @host_caps2: The second standard MMC host capabilities bit field.
41 * @cd_type: Type of Card Detection method (see cd_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
56 * Initialisation data specific to either the machine or the platform
57 * for the device driver to use or call-back when configuring gpio or
58 * card speed information.
60 struct s3c_sdhci_platdata {
61 unsigned int max_width;
62 unsigned int host_caps;
63 unsigned int host_caps2;
65 enum cd_types cd_type;
68 bool ext_cd_gpio_invert;
69 int (*ext_cd_init)(void (*notify_func)(struct platform_device *,
71 int (*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
74 void (*cfg_gpio)(struct platform_device *dev, int width);
77 /* s3c_sdhci_set_platdata() - common helper for setting SDHCI platform data
78 * @pd: The default platform data for this device.
79 * @set: Pointer to the platform data to fill in.
81 extern void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
82 struct s3c_sdhci_platdata *set);
85 * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
86 * @pd: Platform data to register to device.
88 * Register the given platform data for use withe S3C SDHCI device.
89 * The call will copy the platform data, so the board definitions can
90 * make the structure itself __initdata.
92 extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
93 extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
94 extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
95 extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
97 /* Default platform data, exported so that per-cpu initialisation can
98 * set the correct one when there are more than one cpu type selected.
101 extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
102 extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
103 extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
104 extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
106 /* Helper function availability */
108 extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
109 extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
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 exynos4_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
121 extern void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
122 extern void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
123 extern void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
124 extern void s5p64x0_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
125 extern void s5p64x0_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
126 extern void s5p6440_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
127 extern void s5p6450_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
129 /* S3C2416 SDHCI setup */
131 #ifdef CONFIG_S3C2416_SETUP_SDHCI
132 static inline void s3c2416_default_sdhci0(void)
134 #ifdef CONFIG_S3C_DEV_HSMMC
135 s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
136 #endif /* CONFIG_S3C_DEV_HSMMC */
139 static inline void s3c2416_default_sdhci1(void)
141 #ifdef CONFIG_S3C_DEV_HSMMC1
142 s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
143 #endif /* CONFIG_S3C_DEV_HSMMC1 */
147 static inline void s3c2416_default_sdhci0(void) { }
148 static inline void s3c2416_default_sdhci1(void) { }
150 #endif /* CONFIG_S3C2416_SETUP_SDHCI */
152 /* S3C64XX SDHCI setup */
154 #ifdef CONFIG_S3C64XX_SETUP_SDHCI
155 static inline void s3c6400_default_sdhci0(void)
157 #ifdef CONFIG_S3C_DEV_HSMMC
158 s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
162 static inline void s3c6400_default_sdhci1(void)
164 #ifdef CONFIG_S3C_DEV_HSMMC1
165 s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
169 static inline void s3c6400_default_sdhci2(void)
171 #ifdef CONFIG_S3C_DEV_HSMMC2
172 s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
176 static inline void s3c6410_default_sdhci0(void)
178 #ifdef CONFIG_S3C_DEV_HSMMC
179 s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
183 static inline void s3c6410_default_sdhci1(void)
185 #ifdef CONFIG_S3C_DEV_HSMMC1
186 s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
190 static inline void s3c6410_default_sdhci2(void)
192 #ifdef CONFIG_S3C_DEV_HSMMC2
193 s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
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) { }
205 #endif /* CONFIG_S3C64XX_SETUP_SDHCI */
207 /* S5P64X0 SDHCI setup */
209 #ifdef CONFIG_S5P64X0_SETUP_SDHCI
210 static inline void s5p64x0_default_sdhci0(void)
212 #ifdef CONFIG_S3C_DEV_HSMMC
213 s3c_hsmmc0_def_platdata.cfg_gpio = s5p64x0_setup_sdhci0_cfg_gpio;
217 static inline void s5p64x0_default_sdhci1(void)
219 #ifdef CONFIG_S3C_DEV_HSMMC1
220 s3c_hsmmc1_def_platdata.cfg_gpio = s5p64x0_setup_sdhci1_cfg_gpio;
224 static inline void s5p6440_default_sdhci2(void)
226 #ifdef CONFIG_S3C_DEV_HSMMC2
227 s3c_hsmmc2_def_platdata.cfg_gpio = s5p6440_setup_sdhci2_cfg_gpio;
231 static inline void s5p6450_default_sdhci2(void)
233 #ifdef CONFIG_S3C_DEV_HSMMC2
234 s3c_hsmmc2_def_platdata.cfg_gpio = s5p6450_setup_sdhci2_cfg_gpio;
239 static inline void s5p64x0_default_sdhci0(void) { }
240 static inline void s5p64x0_default_sdhci1(void) { }
241 static inline void s5p6440_default_sdhci2(void) { }
242 static inline void s5p6450_default_sdhci2(void) { }
244 #endif /* CONFIG_S5P64X0_SETUP_SDHCI */
246 /* S5PC100 SDHCI setup */
248 #ifdef CONFIG_S5PC100_SETUP_SDHCI
249 static inline void s5pc100_default_sdhci0(void)
251 #ifdef CONFIG_S3C_DEV_HSMMC
252 s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
256 static inline void s5pc100_default_sdhci1(void)
258 #ifdef CONFIG_S3C_DEV_HSMMC1
259 s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
263 static inline void s5pc100_default_sdhci2(void)
265 #ifdef CONFIG_S3C_DEV_HSMMC2
266 s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
271 static inline void s5pc100_default_sdhci0(void) { }
272 static inline void s5pc100_default_sdhci1(void) { }
273 static inline void s5pc100_default_sdhci2(void) { }
275 #endif /* CONFIG_S5PC100_SETUP_SDHCI */
277 /* S5PV210 SDHCI setup */
279 #ifdef CONFIG_S5PV210_SETUP_SDHCI
280 static inline void s5pv210_default_sdhci0(void)
282 #ifdef CONFIG_S3C_DEV_HSMMC
283 s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
287 static inline void s5pv210_default_sdhci1(void)
289 #ifdef CONFIG_S3C_DEV_HSMMC1
290 s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
294 static inline void s5pv210_default_sdhci2(void)
296 #ifdef CONFIG_S3C_DEV_HSMMC2
297 s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
301 static inline void s5pv210_default_sdhci3(void)
303 #ifdef CONFIG_S3C_DEV_HSMMC3
304 s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
309 static inline void s5pv210_default_sdhci0(void) { }
310 static inline void s5pv210_default_sdhci1(void) { }
311 static inline void s5pv210_default_sdhci2(void) { }
312 static inline void s5pv210_default_sdhci3(void) { }
314 #endif /* CONFIG_S5PV210_SETUP_SDHCI */
316 /* EXYNOS4 SDHCI setup */
317 #ifdef CONFIG_EXYNOS4_SETUP_SDHCI
318 static inline void exynos4_default_sdhci0(void)
320 #ifdef CONFIG_S3C_DEV_HSMMC
321 s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
325 static inline void exynos4_default_sdhci1(void)
327 #ifdef CONFIG_S3C_DEV_HSMMC1
328 s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
332 static inline void exynos4_default_sdhci2(void)
334 #ifdef CONFIG_S3C_DEV_HSMMC2
335 s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
339 static inline void exynos4_default_sdhci3(void)
341 #ifdef CONFIG_S3C_DEV_HSMMC3
342 s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
347 static inline void exynos4_default_sdhci0(void) { }
348 static inline void exynos4_default_sdhci1(void) { }
349 static inline void exynos4_default_sdhci2(void) { }
350 static inline void exynos4_default_sdhci3(void) { }
352 #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
354 static inline void s3c_sdhci_setname(int id, char *name)
357 #ifdef CONFIG_S3C_DEV_HSMMC
359 s3c_device_hsmmc0.name = name;
362 #ifdef CONFIG_S3C_DEV_HSMMC1
364 s3c_device_hsmmc1.name = name;
367 #ifdef CONFIG_S3C_DEV_HSMMC2
369 s3c_device_hsmmc2.name = name;
372 #ifdef CONFIG_S3C_DEV_HSMMC3
374 s3c_device_hsmmc3.name = name;
380 #endif /* __PLAT_S3C_SDHCI_H */