sdhci-pltfm.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright 2010 MontaVista Software, LLC.
  3. *
  4. * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef _DRIVERS_MMC_SDHCI_PLTFM_H
  11. #define _DRIVERS_MMC_SDHCI_PLTFM_H
  12. #include <linux/clk.h>
  13. #include <linux/platform_device.h>
  14. #include "sdhci.h"
  15. struct sdhci_pltfm_data {
  16. const struct sdhci_ops *ops;
  17. unsigned int quirks;
  18. unsigned int quirks2;
  19. };
  20. struct sdhci_pltfm_host {
  21. struct clk *clk;
  22. void *priv; /* to handle quirks across io-accessor calls */
  23. /* migrate from sdhci_of_host */
  24. unsigned int clock;
  25. u16 xfer_mode_shadow;
  26. unsigned long private[0] ____cacheline_aligned;
  27. };
  28. #ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
  29. /*
  30. * These accessors are designed for big endian hosts doing I/O to
  31. * little endian controllers incorporating a 32-bit hardware byte swapper.
  32. */
  33. static inline u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg)
  34. {
  35. return in_be32(host->ioaddr + reg);
  36. }
  37. static inline u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg)
  38. {
  39. return in_be16(host->ioaddr + (reg ^ 0x2));
  40. }
  41. static inline u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg)
  42. {
  43. return in_8(host->ioaddr + (reg ^ 0x3));
  44. }
  45. static inline void sdhci_be32bs_writel(struct sdhci_host *host,
  46. u32 val, int reg)
  47. {
  48. out_be32(host->ioaddr + reg, val);
  49. }
  50. static inline void sdhci_be32bs_writew(struct sdhci_host *host,
  51. u16 val, int reg)
  52. {
  53. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  54. int base = reg & ~0x3;
  55. int shift = (reg & 0x2) * 8;
  56. switch (reg) {
  57. case SDHCI_TRANSFER_MODE:
  58. /*
  59. * Postpone this write, we must do it together with a
  60. * command write that is down below.
  61. */
  62. pltfm_host->xfer_mode_shadow = val;
  63. return;
  64. case SDHCI_COMMAND:
  65. sdhci_be32bs_writel(host,
  66. val << 16 | pltfm_host->xfer_mode_shadow,
  67. SDHCI_TRANSFER_MODE);
  68. return;
  69. }
  70. clrsetbits_be32(host->ioaddr + base, 0xffff << shift, val << shift);
  71. }
  72. static inline void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg)
  73. {
  74. int base = reg & ~0x3;
  75. int shift = (reg & 0x3) * 8;
  76. clrsetbits_be32(host->ioaddr + base , 0xff << shift, val << shift);
  77. }
  78. #endif /* CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER */
  79. extern void sdhci_get_of_property(struct platform_device *pdev);
  80. extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
  81. const struct sdhci_pltfm_data *pdata,
  82. size_t priv_size);
  83. extern void sdhci_pltfm_free(struct platform_device *pdev);
  84. extern int sdhci_pltfm_register(struct platform_device *pdev,
  85. const struct sdhci_pltfm_data *pdata,
  86. size_t priv_size);
  87. extern int sdhci_pltfm_unregister(struct platform_device *pdev);
  88. extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host);
  89. static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host)
  90. {
  91. return (void *)host->private;
  92. }
  93. #ifdef CONFIG_PM
  94. extern const struct dev_pm_ops sdhci_pltfm_pmops;
  95. #define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops)
  96. #else
  97. #define SDHCI_PLTFM_PMOPS NULL
  98. #endif
  99. #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */