renesas_sdhi.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Renesas Mobile SDHI
  4. *
  5. * Copyright (C) 2017 Horms Solutions Ltd., Simon Horman
  6. * Copyright (C) 2017-19 Renesas Electronics Corporation
  7. */
  8. #ifndef RENESAS_SDHI_H
  9. #define RENESAS_SDHI_H
  10. #include <linux/dmaengine.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/workqueue.h>
  13. #include "tmio_mmc.h"
  14. struct renesas_sdhi_scc {
  15. unsigned long clk_rate; /* clock rate for SDR104 */
  16. u32 tap; /* sampling clock position for SDR104/HS400 (8 TAP) */
  17. u32 tap_hs400_4tap; /* sampling clock position for HS400 (4 TAP) */
  18. };
  19. #define SDHI_FLAG_NEED_CLKH_FALLBACK BIT(0)
  20. struct renesas_sdhi_of_data {
  21. unsigned long tmio_flags;
  22. u32 tmio_ocr_mask;
  23. unsigned long capabilities;
  24. unsigned long capabilities2;
  25. enum dma_slave_buswidth dma_buswidth;
  26. dma_addr_t dma_rx_offset;
  27. unsigned int bus_shift;
  28. int scc_offset;
  29. struct renesas_sdhi_scc *taps;
  30. int taps_num;
  31. unsigned int max_blk_count;
  32. unsigned short max_segs;
  33. unsigned long sdhi_flags;
  34. };
  35. #define SDHI_CALIB_TABLE_MAX 32
  36. #define sdhi_has_quirk(p, q) ((p)->quirks && (p)->quirks->q)
  37. struct renesas_sdhi_quirks {
  38. bool hs400_disabled;
  39. bool hs400_4taps;
  40. bool fixed_addr_mode;
  41. bool dma_one_rx_only;
  42. bool manual_tap_correction;
  43. bool old_info1_layout;
  44. u32 hs400_bad_taps;
  45. const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX];
  46. };
  47. struct renesas_sdhi_of_data_with_quirks {
  48. const struct renesas_sdhi_of_data *of_data;
  49. const struct renesas_sdhi_quirks *quirks;
  50. };
  51. /* We want both end_flags to be set before we mark DMA as finished */
  52. #define SDHI_DMA_END_FLAG_DMA 0
  53. #define SDHI_DMA_END_FLAG_ACCESS 1
  54. struct renesas_sdhi_dma {
  55. unsigned long end_flags;
  56. enum dma_slave_buswidth dma_buswidth;
  57. dma_filter_fn filter;
  58. void (*enable)(struct tmio_mmc_host *host, bool enable);
  59. struct completion dma_dataend;
  60. struct work_struct dma_complete;
  61. };
  62. struct renesas_sdhi {
  63. struct clk *clk;
  64. struct clk *clkh;
  65. struct clk *clk_cd;
  66. struct tmio_mmc_data mmc_data;
  67. struct renesas_sdhi_dma dma_priv;
  68. const struct renesas_sdhi_quirks *quirks;
  69. struct pinctrl *pinctrl;
  70. struct pinctrl_state *pins_default, *pins_uhs;
  71. void __iomem *scc_ctl;
  72. u32 scc_tappos;
  73. u32 scc_tappos_hs400;
  74. const u8 *adjust_hs400_calib_table;
  75. bool needs_adjust_hs400;
  76. /* Tuning values: 1 for success, 0 for failure */
  77. DECLARE_BITMAP(taps, BITS_PER_LONG);
  78. /* Sampling data comparison: 1 for match, 0 for mismatch */
  79. DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
  80. unsigned int tap_num;
  81. unsigned int tap_set;
  82. struct reset_control *rstc;
  83. struct tmio_mmc_host *host;
  84. };
  85. #define host_to_priv(host) \
  86. container_of((host)->pdata, struct renesas_sdhi, mmc_data)
  87. int renesas_sdhi_probe(struct platform_device *pdev,
  88. const struct tmio_mmc_dma_ops *dma_ops,
  89. const struct renesas_sdhi_of_data *of_data,
  90. const struct renesas_sdhi_quirks *quirks);
  91. void renesas_sdhi_remove(struct platform_device *pdev);
  92. #endif