sdhci.h 11.0 KB
Newer Older
K
Kukjin Kim 已提交
1 2 3 4
/* linux/arch/arm/plat-samsung/include/plat/sdhci.h
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * Copyright 2008 Openmoko, Inc.
 * Copyright 2008 Simtec Electronics
 *	http://armlinux.simtec.co.uk/
 *	Ben Dooks <ben@simtec.co.uk>
 *
 * S3C Platform - SDHCI (HSMMC) platform data definitions
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#ifndef __PLAT_S3C_SDHCI_H
#define __PLAT_S3C_SDHCI_H __FILE__

struct platform_device;
struct mmc_host;
struct mmc_card;
struct mmc_ios;

26 27 28 29 30 31 32 33
enum cd_types {
	S3C_SDHCI_CD_INTERNAL,	/* use mmc internal CD line */
	S3C_SDHCI_CD_EXTERNAL,	/* use external callback */
	S3C_SDHCI_CD_GPIO,	/* use external gpio pin for CD line */
	S3C_SDHCI_CD_NONE,	/* no CD line, use polling to detect card */
	S3C_SDHCI_CD_PERMANENT,	/* no CD line, card permanently wired to host */
};

34 35 36 37 38
enum clk_types {
	S3C_SDHCI_CLK_DIV_INTERNAL,	/* use mmc internal clock divider */
	S3C_SDHCI_CLK_DIV_EXTERNAL,	/* use external clock divider */
};

39 40 41 42
/**
 * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
 * @max_width: The maximum number of data bits supported.
 * @host_caps: Standard MMC host capabilities bit field.
43
 * @cd_type: Type of Card Detection method (see cd_types enum above)
44
 * @clk_type: Type of clock divider method (see clk_types enum above)
45 46 47 48 49 50 51 52 53 54 55 56
 * @ext_cd_init: Initialize external card detect subsystem. Called on
 *		 sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
 *		 notify_func argument is a callback to the sdhci-s3c driver
 *		 that triggers the card detection event. Callback arguments:
 *		 dev is pointer to platform device of the host controller,
 *		 state is new state of the card (0 - removed, 1 - inserted).
 * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
 *		 sdhci-s3c driver remove when cd_type == S3C_SDHCI_CD_EXTERNAL.
 *		 notify_func argument is the same callback as for ext_cd_init.
 * @ext_cd_gpio: gpio pin used for external CD line, valid only if
 *		 cd_type == S3C_SDHCI_CD_GPIO
 * @ext_cd_gpio_invert: invert values for external CD gpio line
57 58 59 60 61 62 63 64 65
 * @cfg_gpio: Configure the GPIO for a specific card bit-width
 *
 * Initialisation data specific to either the machine or the platform
 * for the device driver to use or call-back when configuring gpio or
 * card speed information.
*/
struct s3c_sdhci_platdata {
	unsigned int	max_width;
	unsigned int	host_caps;
66
	enum cd_types	cd_type;
67
	enum clk_types	clk_type;
68 69 70

	char		**clocks;	/* set of clock sources */

71 72 73 74 75 76 77
	int		ext_cd_gpio;
	bool		ext_cd_gpio_invert;
	int	(*ext_cd_init)(void (*notify_func)(struct platform_device *,
						   int state));
	int	(*ext_cd_cleanup)(void (*notify_func)(struct platform_device *,
						      int state));

78 79 80
	void	(*cfg_gpio)(struct platform_device *dev, int width);
};

81 82 83 84 85 86 87
/* s3c_sdhci_set_platdata() - common helper for setting SDHCI platform data
 * @pd: The default platform data for this device.
 * @set: Pointer to the platform data to fill in.
 */
extern void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
				    struct s3c_sdhci_platdata *set);

88 89 90 91 92 93 94 95 96
/**
 * s3c_sdhci0_set_platdata - Set platform data for S3C SDHCI device.
 * @pd: Platform data to register to device.
 *
 * Register the given platform data for use withe S3C SDHCI device.
 * The call will copy the platform data, so the board definitions can
 * make the structure itself __initdata.
 */
extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
97
extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
98
extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
99
extern void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd);
100 101 102 103 104

/* Default platform data, exported so that per-cpu initialisation can
 * set the correct one when there are more than one cpu type selected.
*/

105 106
extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
107
extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
108
extern struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata;
109

L
Lucas De Marchi 已提交
110
/* Helper function availability */
111

112 113
extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
114 115
extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
116 117 118
extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
119
extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
120 121 122
extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
123
extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
K
Kukjin Kim 已提交
124 125 126 127
extern void exynos4_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
extern void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
extern void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
extern void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
128

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
/* S3C2416 SDHCI setup */

#ifdef CONFIG_S3C2416_SETUP_SDHCI
extern char *s3c2416_hsmmc_clksrcs[4];

static inline void s3c2416_default_sdhci0(void)
{
#ifdef CONFIG_S3C_DEV_HSMMC
	s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
	s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
#endif /* CONFIG_S3C_DEV_HSMMC */
}

static inline void s3c2416_default_sdhci1(void)
{
#ifdef CONFIG_S3C_DEV_HSMMC1
	s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
	s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
#endif /* CONFIG_S3C_DEV_HSMMC1 */
}

#else
static inline void s3c2416_default_sdhci0(void) { }
static inline void s3c2416_default_sdhci1(void) { }

#endif /* CONFIG_S3C2416_SETUP_SDHCI */
155
/* S3C64XX SDHCI setup */
156

157 158
#ifdef CONFIG_S3C64XX_SETUP_SDHCI
extern char *s3c64xx_hsmmc_clksrcs[4];
159 160 161

static inline void s3c6400_default_sdhci0(void)
{
162
#ifdef CONFIG_S3C_DEV_HSMMC
163
	s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
164
	s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
165
#endif
166 167 168 169
}

static inline void s3c6400_default_sdhci1(void)
{
170
#ifdef CONFIG_S3C_DEV_HSMMC1
171
	s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
172
	s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
173
#endif
174 175
}

176 177
static inline void s3c6400_default_sdhci2(void)
{
178
#ifdef CONFIG_S3C_DEV_HSMMC2
179
	s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
180
	s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
181
#endif
182
}
183

184 185
static inline void s3c6410_default_sdhci0(void)
{
186
#ifdef CONFIG_S3C_DEV_HSMMC
187
	s3c_hsmmc0_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
188
	s3c_hsmmc0_def_platdata.cfg_gpio = s3c64xx_setup_sdhci0_cfg_gpio;
189
#endif
190
}
191 192 193

static inline void s3c6410_default_sdhci1(void)
{
194
#ifdef CONFIG_S3C_DEV_HSMMC1
195
	s3c_hsmmc1_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
196
	s3c_hsmmc1_def_platdata.cfg_gpio = s3c64xx_setup_sdhci1_cfg_gpio;
197
#endif
198
}
B
Ben Dooks 已提交
199

200 201
static inline void s3c6410_default_sdhci2(void)
{
202
#ifdef CONFIG_S3C_DEV_HSMMC2
203
	s3c_hsmmc2_def_platdata.clocks = s3c64xx_hsmmc_clksrcs;
204
	s3c_hsmmc2_def_platdata.cfg_gpio = s3c64xx_setup_sdhci2_cfg_gpio;
205
#endif
206 207
}

208 209
#else
static inline void s3c6410_default_sdhci0(void) { }
210
static inline void s3c6410_default_sdhci1(void) { }
211
static inline void s3c6410_default_sdhci2(void) { }
212 213
static inline void s3c6400_default_sdhci0(void) { }
static inline void s3c6400_default_sdhci1(void) { }
214
static inline void s3c6400_default_sdhci2(void) { }
215 216

#endif /* CONFIG_S3C64XX_SETUP_SDHCI */
217

218 219 220 221 222 223 224
/* S5PC100 SDHCI setup */

#ifdef CONFIG_S5PC100_SETUP_SDHCI
extern char *s5pc100_hsmmc_clksrcs[4];

static inline void s5pc100_default_sdhci0(void)
{
225
#ifdef CONFIG_S3C_DEV_HSMMC
226 227
	s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
	s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
228
#endif
229 230 231 232
}

static inline void s5pc100_default_sdhci1(void)
{
233
#ifdef CONFIG_S3C_DEV_HSMMC1
234 235
	s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
	s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
236
#endif
237 238 239 240
}

static inline void s5pc100_default_sdhci2(void)
{
241
#ifdef CONFIG_S3C_DEV_HSMMC2
242 243
	s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
	s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
244
#endif
245 246 247 248 249 250
}

#else
static inline void s5pc100_default_sdhci0(void) { }
static inline void s5pc100_default_sdhci1(void) { }
static inline void s5pc100_default_sdhci2(void) { }
251

252 253
#endif /* CONFIG_S5PC100_SETUP_SDHCI */

254
/* S5PV210 SDHCI setup */
255 256 257 258 259 260

#ifdef CONFIG_S5PV210_SETUP_SDHCI
extern char *s5pv210_hsmmc_clksrcs[4];

static inline void s5pv210_default_sdhci0(void)
{
261
#ifdef CONFIG_S3C_DEV_HSMMC
262 263
	s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
	s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
264
#endif
265 266 267 268
}

static inline void s5pv210_default_sdhci1(void)
{
269
#ifdef CONFIG_S3C_DEV_HSMMC1
270 271
	s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
	s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
272
#endif
273 274 275 276
}

static inline void s5pv210_default_sdhci2(void)
{
277
#ifdef CONFIG_S3C_DEV_HSMMC2
278 279
	s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
	s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
280
#endif
281 282
}

283 284
static inline void s5pv210_default_sdhci3(void)
{
285
#ifdef CONFIG_S3C_DEV_HSMMC3
286 287
	s3c_hsmmc3_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
	s3c_hsmmc3_def_platdata.cfg_gpio = s5pv210_setup_sdhci3_cfg_gpio;
288
#endif
289 290
}

291 292 293 294
#else
static inline void s5pv210_default_sdhci0(void) { }
static inline void s5pv210_default_sdhci1(void) { }
static inline void s5pv210_default_sdhci2(void) { }
295
static inline void s5pv210_default_sdhci3(void) { }
296

297
#endif /* CONFIG_S5PV210_SETUP_SDHCI */
298

K
Kukjin Kim 已提交
299 300 301
/* EXYNOS4 SDHCI setup */
#ifdef CONFIG_EXYNOS4_SETUP_SDHCI
extern char *exynos4_hsmmc_clksrcs[4];
H
Hyuk Lee 已提交
302

K
Kukjin Kim 已提交
303
static inline void exynos4_default_sdhci0(void)
H
Hyuk Lee 已提交
304 305
{
#ifdef CONFIG_S3C_DEV_HSMMC
K
Kukjin Kim 已提交
306 307
	s3c_hsmmc0_def_platdata.clocks = exynos4_hsmmc_clksrcs;
	s3c_hsmmc0_def_platdata.cfg_gpio = exynos4_setup_sdhci0_cfg_gpio;
H
Hyuk Lee 已提交
308 309 310
#endif
}

K
Kukjin Kim 已提交
311
static inline void exynos4_default_sdhci1(void)
H
Hyuk Lee 已提交
312 313
{
#ifdef CONFIG_S3C_DEV_HSMMC1
K
Kukjin Kim 已提交
314 315
	s3c_hsmmc1_def_platdata.clocks = exynos4_hsmmc_clksrcs;
	s3c_hsmmc1_def_platdata.cfg_gpio = exynos4_setup_sdhci1_cfg_gpio;
H
Hyuk Lee 已提交
316 317 318
#endif
}

K
Kukjin Kim 已提交
319
static inline void exynos4_default_sdhci2(void)
H
Hyuk Lee 已提交
320 321
{
#ifdef CONFIG_S3C_DEV_HSMMC2
K
Kukjin Kim 已提交
322 323
	s3c_hsmmc2_def_platdata.clocks = exynos4_hsmmc_clksrcs;
	s3c_hsmmc2_def_platdata.cfg_gpio = exynos4_setup_sdhci2_cfg_gpio;
H
Hyuk Lee 已提交
324 325 326
#endif
}

K
Kukjin Kim 已提交
327
static inline void exynos4_default_sdhci3(void)
H
Hyuk Lee 已提交
328 329
{
#ifdef CONFIG_S3C_DEV_HSMMC3
K
Kukjin Kim 已提交
330 331
	s3c_hsmmc3_def_platdata.clocks = exynos4_hsmmc_clksrcs;
	s3c_hsmmc3_def_platdata.cfg_gpio = exynos4_setup_sdhci3_cfg_gpio;
H
Hyuk Lee 已提交
332 333 334 335
#endif
}

#else
K
Kukjin Kim 已提交
336 337 338 339
static inline void exynos4_default_sdhci0(void) { }
static inline void exynos4_default_sdhci1(void) { }
static inline void exynos4_default_sdhci2(void) { }
static inline void exynos4_default_sdhci3(void) { }
H
Hyuk Lee 已提交
340

K
Kukjin Kim 已提交
341
#endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
H
Hyuk Lee 已提交
342

343
#endif /* __PLAT_S3C_SDHCI_H */