diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-03-16 17:13:46 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2009-03-24 16:30:07 -0400 |
commit | 4e4141a526dd7f5ac3ce1458ae79ea6e5a515b06 (patch) | |
tree | 06f374b2e3a7a22eb66261d79d3374b1d23e5350 /drivers/mmc/host/sdhci.h | |
parent | f079a8fc61e3dc35830f6abc58c21ae815ab4297 (diff) |
sdhci: Add support for bus-specific IO memory accessors
Currently the SDHCI driver works with PCI accessors (write{l,b,w} and
read{l,b,w}).
With this patch drivers may change memory accessors, so that we can
support hosts with "weird" IO memory access requirments.
For example, in "FSL eSDHC" SDHCI hardware all registers are 32 bit
width, with big-endian addressing. That is, readb(0x2f) should turn
into readb(0x2c), and readw(0x2c) should be translated to
le16_to_cpu(readw(0x2e)).
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/host/sdhci.h')
-rw-r--r-- | drivers/mmc/host/sdhci.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 43c37c68d07a..d9733f841061 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 |
@@ -267,9 +270,101 @@ struct sdhci_host { | |||
267 | 270 | ||
268 | 271 | ||
269 | struct sdhci_ops { | 272 | struct sdhci_ops { |
273 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | ||
274 | u32 (*readl)(struct sdhci_host *host, int reg); | ||
275 | u16 (*readw)(struct sdhci_host *host, int reg); | ||
276 | u8 (*readb)(struct sdhci_host *host, int reg); | ||
277 | void (*writel)(struct sdhci_host *host, u32 val, int reg); | ||
278 | void (*writew)(struct sdhci_host *host, u16 val, int reg); | ||
279 | void (*writeb)(struct sdhci_host *host, u8 val, int reg); | ||
280 | #endif | ||
281 | |||
270 | int (*enable_dma)(struct sdhci_host *host); | 282 | int (*enable_dma)(struct sdhci_host *host); |
271 | }; | 283 | }; |
272 | 284 | ||
285 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | ||
286 | |||
287 | static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg) | ||
288 | { | ||
289 | if (unlikely(host->ops->writel)) | ||
290 | host->ops->writel(host, val, reg); | ||
291 | else | ||
292 | writel(val, host->ioaddr + reg); | ||
293 | } | ||
294 | |||
295 | static inline void sdhci_writew(struct sdhci_host *host, u16 val, int reg) | ||
296 | { | ||
297 | if (unlikely(host->ops->writew)) | ||
298 | host->ops->writew(host, val, reg); | ||
299 | else | ||
300 | writew(val, host->ioaddr + reg); | ||
301 | } | ||
302 | |||
303 | static inline void sdhci_writeb(struct sdhci_host *host, u8 val, int reg) | ||
304 | { | ||
305 | if (unlikely(host->ops->writeb)) | ||
306 | host->ops->writeb(host, val, reg); | ||
307 | else | ||
308 | writeb(val, host->ioaddr + reg); | ||
309 | } | ||
310 | |||
311 | static inline u32 sdhci_readl(struct sdhci_host *host, int reg) | ||
312 | { | ||
313 | if (unlikely(host->ops->readl)) | ||
314 | return host->ops->readl(host, reg); | ||
315 | else | ||
316 | return readl(host->ioaddr + reg); | ||
317 | } | ||
318 | |||
319 | static inline u16 sdhci_readw(struct sdhci_host *host, int reg) | ||
320 | { | ||
321 | if (unlikely(host->ops->readw)) | ||
322 | return host->ops->readw(host, reg); | ||
323 | else | ||
324 | return readw(host->ioaddr + reg); | ||
325 | } | ||
326 | |||
327 | static inline u8 sdhci_readb(struct sdhci_host *host, int reg) | ||
328 | { | ||
329 | if (unlikely(host->ops->readb)) | ||
330 | return host->ops->readb(host, reg); | ||
331 | else | ||
332 | return readb(host->ioaddr + reg); | ||
333 | } | ||
334 | |||
335 | #else | ||
336 | |||
337 | static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg) | ||
338 | { | ||
339 | writel(val, host->ioaddr + reg); | ||
340 | } | ||
341 | |||
342 | static inline void sdhci_writew(struct sdhci_host *host, u16 val, int reg) | ||
343 | { | ||
344 | writew(val, host->ioaddr + reg); | ||
345 | } | ||
346 | |||
347 | static inline void sdhci_writeb(struct sdhci_host *host, u8 val, int reg) | ||
348 | { | ||
349 | writeb(val, host->ioaddr + reg); | ||
350 | } | ||
351 | |||
352 | static inline u32 sdhci_readl(struct sdhci_host *host, int reg) | ||
353 | { | ||
354 | return readl(host->ioaddr + reg); | ||
355 | } | ||
356 | |||
357 | static inline u16 sdhci_readw(struct sdhci_host *host, int reg) | ||
358 | { | ||
359 | return readw(host->ioaddr + reg); | ||
360 | } | ||
361 | |||
362 | static inline u8 sdhci_readb(struct sdhci_host *host, int reg) | ||
363 | { | ||
364 | return readb(host->ioaddr + reg); | ||
365 | } | ||
366 | |||
367 | #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */ | ||
273 | 368 | ||
274 | extern struct sdhci_host *sdhci_alloc_host(struct device *dev, | 369 | extern struct sdhci_host *sdhci_alloc_host(struct device *dev, |
275 | size_t priv_size); | 370 | size_t priv_size); |