sdhci-pltfm.h 3.0 KB

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