sdhci-pltfm.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. struct sdhci_ops *ops;
  17. unsigned int quirks;
  18. };
  19. struct sdhci_pltfm_host {
  20. struct clk *clk;
  21. void *priv; /* to handle quirks across io-accessor calls */
  22. /* migrate from sdhci_of_host */
  23. unsigned int clock;
  24. u16 xfer_mode_shadow;
  25. };
  26. #ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
  27. /*
  28. * These accessors are designed for big endian hosts doing I/O to
  29. * little endian controllers incorporating a 32-bit hardware byte swapper.
  30. */
  31. static inline u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg)
  32. {
  33. return in_be32(host->ioaddr + reg);
  34. }
  35. static inline u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg)
  36. {
  37. return in_be16(host->ioaddr + (reg ^ 0x2));
  38. }
  39. static inline u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg)
  40. {
  41. return in_8(host->ioaddr + (reg ^ 0x3));
  42. }
  43. static inline void sdhci_be32bs_writel(struct sdhci_host *host,
  44. u32 val, int reg)
  45. {
  46. out_be32(host->ioaddr + reg, val);
  47. }
  48. static inline void sdhci_be32bs_writew(struct sdhci_host *host,
  49. u16 val, int reg)
  50. {
  51. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  52. int base = reg & ~0x3;
  53. int shift = (reg & 0x2) * 8;
  54. switch (reg) {
  55. case SDHCI_TRANSFER_MODE:
  56. /*
  57. * Postpone this write, we must do it together with a
  58. * command write that is down below.
  59. */
  60. pltfm_host->xfer_mode_shadow = val;
  61. return;
  62. case SDHCI_COMMAND:
  63. sdhci_be32bs_writel(host,
  64. val << 16 | pltfm_host->xfer_mode_shadow,
  65. SDHCI_TRANSFER_MODE);
  66. return;
  67. }
  68. clrsetbits_be32(host->ioaddr + base, 0xffff << shift, val << shift);
  69. }
  70. static inline void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg)
  71. {
  72. int base = reg & ~0x3;
  73. int shift = (reg & 0x3) * 8;
  74. clrsetbits_be32(host->ioaddr + base , 0xff << shift, val << shift);
  75. }
  76. #endif /* CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER */
  77. extern void sdhci_get_of_property(struct platform_device *pdev);
  78. extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
  79. struct sdhci_pltfm_data *pdata);
  80. extern void sdhci_pltfm_free(struct platform_device *pdev);
  81. extern int sdhci_pltfm_register(struct platform_device *pdev,
  82. struct sdhci_pltfm_data *pdata);
  83. extern int sdhci_pltfm_unregister(struct platform_device *pdev);
  84. #ifdef CONFIG_PM
  85. extern const struct dev_pm_ops sdhci_pltfm_pmops;
  86. #define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops)
  87. #else
  88. #define SDHCI_PLTFM_PMOPS NULL
  89. #endif
  90. #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */