diff options
Diffstat (limited to 'drivers/mmc/host/sdhci.h')
-rw-r--r-- | drivers/mmc/host/sdhci.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 43c37c68d07a..f20a834f4309 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -10,6 +10,9 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/scatterlist.h> | 12 | #include <linux/scatterlist.h> |
13 | #include <linux/compiler.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/io.h> | ||
13 | 16 | ||
14 | /* | 17 | /* |
15 | * Controller registers | 18 | * Controller registers |
@@ -123,6 +126,7 @@ | |||
123 | SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ | 126 | SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ |
124 | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ | 127 | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ |
125 | SDHCI_INT_DATA_END_BIT) | 128 | SDHCI_INT_DATA_END_BIT) |
129 | #define SDHCI_INT_ALL_MASK ((unsigned int)-1) | ||
126 | 130 | ||
127 | #define SDHCI_ACMD12_ERR 0x3C | 131 | #define SDHCI_ACMD12_ERR 0x3C |
128 | 132 | ||
@@ -210,6 +214,18 @@ struct sdhci_host { | |||
210 | #define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13) | 214 | #define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13) |
211 | /* Controller does not provide transfer-complete interrupt when not busy */ | 215 | /* Controller does not provide transfer-complete interrupt when not busy */ |
212 | #define SDHCI_QUIRK_NO_BUSY_IRQ (1<<14) | 216 | #define SDHCI_QUIRK_NO_BUSY_IRQ (1<<14) |
217 | /* Controller has unreliable card detection */ | ||
218 | #define SDHCI_QUIRK_BROKEN_CARD_DETECTION (1<<15) | ||
219 | /* Controller reports inverted write-protect state */ | ||
220 | #define SDHCI_QUIRK_INVERTED_WRITE_PROTECT (1<<16) | ||
221 | /* Controller has nonstandard clock management */ | ||
222 | #define SDHCI_QUIRK_NONSTANDARD_CLOCK (1<<17) | ||
223 | /* Controller does not like fast PIO transfers */ | ||
224 | #define SDHCI_QUIRK_PIO_NEEDS_DELAY (1<<18) | ||
225 | /* Controller losing signal/interrupt enable states after reset */ | ||
226 | #define SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET (1<<19) | ||
227 | /* Controller has to be forced to use block size of 2048 bytes */ | ||
228 | #define SDHCI_QUIRK_FORCE_BLK_SZ_2048 (1<<20) | ||
213 | 229 | ||
214 | int irq; /* Device IRQ */ | 230 | int irq; /* Device IRQ */ |
215 | void __iomem * ioaddr; /* Mapped address */ | 231 | void __iomem * ioaddr; /* Mapped address */ |
@@ -267,9 +283,105 @@ struct sdhci_host { | |||
267 | 283 | ||
268 | 284 | ||
269 | struct sdhci_ops { | 285 | struct sdhci_ops { |
286 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | ||
287 | u32 (*readl)(struct sdhci_host *host, int reg); | ||
288 | u16 (*readw)(struct sdhci_host *host, int reg); | ||
289 | u8 (*readb)(struct sdhci_host *host, int reg); | ||
290 | void (*writel)(struct sdhci_host *host, u32 val, int reg); | ||
291 | void (*writew)(struct sdhci_host *host, u16 val, int reg); | ||
292 | void (*writeb)(struct sdhci_host *host, u8 val, int reg); | ||
293 | #endif | ||
294 | |||
295 | void (*set_clock)(struct sdhci_host *host, unsigned int clock); | ||
296 | |||
270 | int (*enable_dma)(struct sdhci_host *host); | 297 | int (*enable_dma)(struct sdhci_host *host); |
298 | unsigned int (*get_max_clock)(struct sdhci_host *host); | ||
299 | unsigned int (*get_timeout_clock)(struct sdhci_host *host); | ||
271 | }; | 300 | }; |
272 | 301 | ||
302 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | ||
303 | |||
304 | static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg) | ||
305 | { | ||
306 | if (unlikely(host->ops->writel)) | ||
307 | host->ops->writel(host, val, reg); | ||
308 | else | ||
309 | writel(val, host->ioaddr + reg); | ||
310 | } | ||
311 | |||
312 | static inline void sdhci_writew(struct sdhci_host *host, u16 val, int reg) | ||
313 | { | ||
314 | if (unlikely(host->ops->writew)) | ||
315 | host->ops->writew(host, val, reg); | ||
316 | else | ||
317 | writew(val, host->ioaddr + reg); | ||
318 | } | ||
319 | |||
320 | static inline void sdhci_writeb(struct sdhci_host *host, u8 val, int reg) | ||
321 | { | ||
322 | if (unlikely(host->ops->writeb)) | ||
323 | host->ops->writeb(host, val, reg); | ||
324 | else | ||
325 | writeb(val, host->ioaddr + reg); | ||
326 | } | ||
327 | |||
328 | static inline u32 sdhci_readl(struct sdhci_host *host, int reg) | ||
329 | { | ||
330 | if (unlikely(host->ops->readl)) | ||
331 | return host->ops->readl(host, reg); | ||
332 | else | ||
333 | return readl(host->ioaddr + reg); | ||
334 | } | ||
335 | |||
336 | static inline u16 sdhci_readw(struct sdhci_host *host, int reg) | ||
337 | { | ||
338 | if (unlikely(host->ops->readw)) | ||
339 | return host->ops->readw(host, reg); | ||
340 | else | ||
341 | return readw(host->ioaddr + reg); | ||
342 | } | ||
343 | |||
344 | static inline u8 sdhci_readb(struct sdhci_host *host, int reg) | ||
345 | { | ||
346 | if (unlikely(host->ops->readb)) | ||
347 | return host->ops->readb(host, reg); | ||
348 | else | ||
349 | return readb(host->ioaddr + reg); | ||
350 | } | ||
351 | |||
352 | #else | ||
353 | |||
354 | static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg) | ||
355 | { | ||
356 | writel(val, host->ioaddr + reg); | ||
357 | } | ||
358 | |||
359 | static inline void sdhci_writew(struct sdhci_host *host, u16 val, int reg) | ||
360 | { | ||
361 | writew(val, host->ioaddr + reg); | ||
362 | } | ||
363 | |||
364 | static inline void sdhci_writeb(struct sdhci_host *host, u8 val, int reg) | ||
365 | { | ||
366 | writeb(val, host->ioaddr + reg); | ||
367 | } | ||
368 | |||
369 | static inline u32 sdhci_readl(struct sdhci_host *host, int reg) | ||
370 | { | ||
371 | return readl(host->ioaddr + reg); | ||
372 | } | ||
373 | |||
374 | static inline u16 sdhci_readw(struct sdhci_host *host, int reg) | ||
375 | { | ||
376 | return readw(host->ioaddr + reg); | ||
377 | } | ||
378 | |||
379 | static inline u8 sdhci_readb(struct sdhci_host *host, int reg) | ||
380 | { | ||
381 | return readb(host->ioaddr + reg); | ||
382 | } | ||
383 | |||
384 | #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */ | ||
273 | 385 | ||
274 | extern struct sdhci_host *sdhci_alloc_host(struct device *dev, | 386 | extern struct sdhci_host *sdhci_alloc_host(struct device *dev, |
275 | size_t priv_size); | 387 | size_t priv_size); |