diff options
Diffstat (limited to 'drivers/mmc/host/sdhci.h')
-rw-r--r-- | drivers/mmc/host/sdhci.h | 150 |
1 files changed, 21 insertions, 129 deletions
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index d316bc79b636..b7b8a3b28b01 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -1,6 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/mmc/host/sdhci.h - Secure Digital Host Controller Interface driver | 2 | * linux/drivers/mmc/host/sdhci.h - Secure Digital Host Controller Interface driver |
3 | * | 3 | * |
4 | * Header file for Host Controller registers and I/O accessors. | ||
5 | * | ||
4 | * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved. | 6 | * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved. |
5 | * | 7 | * |
6 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
@@ -8,14 +10,16 @@ | |||
8 | * the Free Software Foundation; either version 2 of the License, or (at | 10 | * the Free Software Foundation; either version 2 of the License, or (at |
9 | * your option) any later version. | 11 | * your option) any later version. |
10 | */ | 12 | */ |
11 | #ifndef __SDHCI_H | 13 | #ifndef __SDHCI_HW_H |
12 | #define __SDHCI_H | 14 | #define __SDHCI_HW_H |
13 | 15 | ||
14 | #include <linux/scatterlist.h> | 16 | #include <linux/scatterlist.h> |
15 | #include <linux/compiler.h> | 17 | #include <linux/compiler.h> |
16 | #include <linux/types.h> | 18 | #include <linux/types.h> |
17 | #include <linux/io.h> | 19 | #include <linux/io.h> |
18 | 20 | ||
21 | #include <linux/mmc/sdhci.h> | ||
22 | |||
19 | /* | 23 | /* |
20 | * Controller registers | 24 | * Controller registers |
21 | */ | 25 | */ |
@@ -86,6 +90,10 @@ | |||
86 | 90 | ||
87 | #define SDHCI_CLOCK_CONTROL 0x2C | 91 | #define SDHCI_CLOCK_CONTROL 0x2C |
88 | #define SDHCI_DIVIDER_SHIFT 8 | 92 | #define SDHCI_DIVIDER_SHIFT 8 |
93 | #define SDHCI_DIVIDER_HI_SHIFT 6 | ||
94 | #define SDHCI_DIV_MASK 0xFF | ||
95 | #define SDHCI_DIV_MASK_LEN 8 | ||
96 | #define SDHCI_DIV_HI_MASK 0x300 | ||
89 | #define SDHCI_CLOCK_CARD_EN 0x0004 | 97 | #define SDHCI_CLOCK_CARD_EN 0x0004 |
90 | #define SDHCI_CLOCK_INT_STABLE 0x0002 | 98 | #define SDHCI_CLOCK_INT_STABLE 0x0002 |
91 | #define SDHCI_CLOCK_INT_EN 0x0001 | 99 | #define SDHCI_CLOCK_INT_EN 0x0001 |
@@ -140,6 +148,7 @@ | |||
140 | #define SDHCI_TIMEOUT_CLK_SHIFT 0 | 148 | #define SDHCI_TIMEOUT_CLK_SHIFT 0 |
141 | #define SDHCI_TIMEOUT_CLK_UNIT 0x00000080 | 149 | #define SDHCI_TIMEOUT_CLK_UNIT 0x00000080 |
142 | #define SDHCI_CLOCK_BASE_MASK 0x00003F00 | 150 | #define SDHCI_CLOCK_BASE_MASK 0x00003F00 |
151 | #define SDHCI_CLOCK_V3_BASE_MASK 0x0000FF00 | ||
143 | #define SDHCI_CLOCK_BASE_SHIFT 8 | 152 | #define SDHCI_CLOCK_BASE_SHIFT 8 |
144 | #define SDHCI_MAX_BLOCK_MASK 0x00030000 | 153 | #define SDHCI_MAX_BLOCK_MASK 0x00030000 |
145 | #define SDHCI_MAX_BLOCK_SHIFT 16 | 154 | #define SDHCI_MAX_BLOCK_SHIFT 16 |
@@ -178,134 +187,14 @@ | |||
178 | #define SDHCI_SPEC_VER_SHIFT 0 | 187 | #define SDHCI_SPEC_VER_SHIFT 0 |
179 | #define SDHCI_SPEC_100 0 | 188 | #define SDHCI_SPEC_100 0 |
180 | #define SDHCI_SPEC_200 1 | 189 | #define SDHCI_SPEC_200 1 |
190 | #define SDHCI_SPEC_300 2 | ||
181 | 191 | ||
182 | struct sdhci_ops; | 192 | /* |
183 | 193 | * End of controller registers. | |
184 | struct sdhci_host { | 194 | */ |
185 | /* Data set by hardware interface driver */ | ||
186 | const char *hw_name; /* Hardware bus name */ | ||
187 | |||
188 | unsigned int quirks; /* Deviations from spec. */ | ||
189 | |||
190 | /* Controller doesn't honor resets unless we touch the clock register */ | ||
191 | #define SDHCI_QUIRK_CLOCK_BEFORE_RESET (1<<0) | ||
192 | /* Controller has bad caps bits, but really supports DMA */ | ||
193 | #define SDHCI_QUIRK_FORCE_DMA (1<<1) | ||
194 | /* Controller doesn't like to be reset when there is no card inserted. */ | ||
195 | #define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2) | ||
196 | /* Controller doesn't like clearing the power reg before a change */ | ||
197 | #define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3) | ||
198 | /* Controller has flaky internal state so reset it on each ios change */ | ||
199 | #define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4) | ||
200 | /* Controller has an unusable DMA engine */ | ||
201 | #define SDHCI_QUIRK_BROKEN_DMA (1<<5) | ||
202 | /* Controller has an unusable ADMA engine */ | ||
203 | #define SDHCI_QUIRK_BROKEN_ADMA (1<<6) | ||
204 | /* Controller can only DMA from 32-bit aligned addresses */ | ||
205 | #define SDHCI_QUIRK_32BIT_DMA_ADDR (1<<7) | ||
206 | /* Controller can only DMA chunk sizes that are a multiple of 32 bits */ | ||
207 | #define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<8) | ||
208 | /* Controller can only ADMA chunks that are a multiple of 32 bits */ | ||
209 | #define SDHCI_QUIRK_32BIT_ADMA_SIZE (1<<9) | ||
210 | /* Controller needs to be reset after each request to stay stable */ | ||
211 | #define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<10) | ||
212 | /* Controller needs voltage and power writes to happen separately */ | ||
213 | #define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<11) | ||
214 | /* Controller provides an incorrect timeout value for transfers */ | ||
215 | #define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12) | ||
216 | /* Controller has an issue with buffer bits for small transfers */ | ||
217 | #define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13) | ||
218 | /* Controller does not provide transfer-complete interrupt when not busy */ | ||
219 | #define SDHCI_QUIRK_NO_BUSY_IRQ (1<<14) | ||
220 | /* Controller has unreliable card detection */ | ||
221 | #define SDHCI_QUIRK_BROKEN_CARD_DETECTION (1<<15) | ||
222 | /* Controller reports inverted write-protect state */ | ||
223 | #define SDHCI_QUIRK_INVERTED_WRITE_PROTECT (1<<16) | ||
224 | /* Controller has nonstandard clock management */ | ||
225 | #define SDHCI_QUIRK_NONSTANDARD_CLOCK (1<<17) | ||
226 | /* Controller does not like fast PIO transfers */ | ||
227 | #define SDHCI_QUIRK_PIO_NEEDS_DELAY (1<<18) | ||
228 | /* Controller losing signal/interrupt enable states after reset */ | ||
229 | #define SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET (1<<19) | ||
230 | /* Controller has to be forced to use block size of 2048 bytes */ | ||
231 | #define SDHCI_QUIRK_FORCE_BLK_SZ_2048 (1<<20) | ||
232 | /* Controller cannot do multi-block transfers */ | ||
233 | #define SDHCI_QUIRK_NO_MULTIBLOCK (1<<21) | ||
234 | /* Controller can only handle 1-bit data transfers */ | ||
235 | #define SDHCI_QUIRK_FORCE_1_BIT_DATA (1<<22) | ||
236 | /* Controller needs 10ms delay between applying power and clock */ | ||
237 | #define SDHCI_QUIRK_DELAY_AFTER_POWER (1<<23) | ||
238 | /* Controller uses SDCLK instead of TMCLK for data timeouts */ | ||
239 | #define SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK (1<<24) | ||
240 | /* Controller reports wrong base clock capability */ | ||
241 | #define SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN (1<<25) | ||
242 | /* Controller cannot support End Attribute in NOP ADMA descriptor */ | ||
243 | #define SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC (1<<26) | ||
244 | /* Controller is missing device caps. Use caps provided by host */ | ||
245 | #define SDHCI_QUIRK_MISSING_CAPS (1<<27) | ||
246 | /* Controller uses Auto CMD12 command to stop the transfer */ | ||
247 | #define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28) | ||
248 | /* Controller doesn't have HISPD bit field in HI-SPEED SD card */ | ||
249 | #define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) | ||
250 | |||
251 | int irq; /* Device IRQ */ | ||
252 | void __iomem * ioaddr; /* Mapped address */ | ||
253 | |||
254 | const struct sdhci_ops *ops; /* Low level hw interface */ | ||
255 | |||
256 | struct regulator *vmmc; /* Power regulator */ | ||
257 | |||
258 | /* Internal data */ | ||
259 | struct mmc_host *mmc; /* MMC structure */ | ||
260 | u64 dma_mask; /* custom DMA mask */ | ||
261 | |||
262 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) | ||
263 | struct led_classdev led; /* LED control */ | ||
264 | char led_name[32]; | ||
265 | #endif | ||
266 | |||
267 | spinlock_t lock; /* Mutex */ | ||
268 | |||
269 | int flags; /* Host attributes */ | ||
270 | #define SDHCI_USE_SDMA (1<<0) /* Host is SDMA capable */ | ||
271 | #define SDHCI_USE_ADMA (1<<1) /* Host is ADMA capable */ | ||
272 | #define SDHCI_REQ_USE_DMA (1<<2) /* Use DMA for this req. */ | ||
273 | #define SDHCI_DEVICE_DEAD (1<<3) /* Device unresponsive */ | ||
274 | |||
275 | unsigned int version; /* SDHCI spec. version */ | ||
276 | |||
277 | unsigned int max_clk; /* Max possible freq (MHz) */ | ||
278 | unsigned int timeout_clk; /* Timeout freq (KHz) */ | ||
279 | |||
280 | unsigned int clock; /* Current clock (MHz) */ | ||
281 | u8 pwr; /* Current voltage */ | ||
282 | |||
283 | struct mmc_request *mrq; /* Current request */ | ||
284 | struct mmc_command *cmd; /* Current command */ | ||
285 | struct mmc_data *data; /* Current data request */ | ||
286 | unsigned int data_early:1; /* Data finished before cmd */ | ||
287 | |||
288 | struct sg_mapping_iter sg_miter; /* SG state for PIO */ | ||
289 | unsigned int blocks; /* remaining PIO blocks */ | ||
290 | |||
291 | int sg_count; /* Mapped sg entries */ | ||
292 | |||
293 | u8 *adma_desc; /* ADMA descriptor table */ | ||
294 | u8 *align_buffer; /* Bounce buffer */ | ||
295 | |||
296 | dma_addr_t adma_addr; /* Mapped ADMA descr. table */ | ||
297 | dma_addr_t align_addr; /* Mapped bounce buffer */ | ||
298 | |||
299 | struct tasklet_struct card_tasklet; /* Tasklet structures */ | ||
300 | struct tasklet_struct finish_tasklet; | ||
301 | |||
302 | struct timer_list timer; /* Timer for timeouts */ | ||
303 | |||
304 | unsigned int caps; /* Alternative capabilities */ | ||
305 | |||
306 | unsigned long private[0] ____cacheline_aligned; | ||
307 | }; | ||
308 | 195 | ||
196 | #define SDHCI_MAX_DIV_SPEC_200 256 | ||
197 | #define SDHCI_MAX_DIV_SPEC_300 2046 | ||
309 | 198 | ||
310 | struct sdhci_ops { | 199 | struct sdhci_ops { |
311 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | 200 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS |
@@ -323,6 +212,9 @@ struct sdhci_ops { | |||
323 | unsigned int (*get_max_clock)(struct sdhci_host *host); | 212 | unsigned int (*get_max_clock)(struct sdhci_host *host); |
324 | unsigned int (*get_min_clock)(struct sdhci_host *host); | 213 | unsigned int (*get_min_clock)(struct sdhci_host *host); |
325 | unsigned int (*get_timeout_clock)(struct sdhci_host *host); | 214 | unsigned int (*get_timeout_clock)(struct sdhci_host *host); |
215 | void (*platform_send_init_74_clocks)(struct sdhci_host *host, | ||
216 | u8 power_mode); | ||
217 | unsigned int (*get_ro)(struct sdhci_host *host); | ||
326 | }; | 218 | }; |
327 | 219 | ||
328 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | 220 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS |
@@ -427,4 +319,4 @@ extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state); | |||
427 | extern int sdhci_resume_host(struct sdhci_host *host); | 319 | extern int sdhci_resume_host(struct sdhci_host *host); |
428 | #endif | 320 | #endif |
429 | 321 | ||
430 | #endif /* __SDHCI_H */ | 322 | #endif /* __SDHCI_HW_H */ |