renesas_sdhi.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/platform_device.h>
  11. #include "tmio_mmc.h"
  12. struct renesas_sdhi_scc {
  13. unsigned long clk_rate; /* clock rate for SDR104 */
  14. u32 tap; /* sampling clock position for SDR104/HS400 (8 TAP) */
  15. u32 tap_hs400_4tap; /* sampling clock position for HS400 (4 TAP) */
  16. };
  17. #define SDHI_FLAG_NEED_CLKH_FALLBACK BIT(0)
  18. struct renesas_sdhi_of_data {
  19. unsigned long tmio_flags;
  20. u32 tmio_ocr_mask;
  21. unsigned long capabilities;
  22. unsigned long capabilities2;
  23. enum dma_slave_buswidth dma_buswidth;
  24. dma_addr_t dma_rx_offset;
  25. unsigned int bus_shift;
  26. int scc_offset;
  27. struct renesas_sdhi_scc *taps;
  28. int taps_num;
  29. unsigned int max_blk_count;
  30. unsigned short max_segs;
  31. unsigned long sdhi_flags;
  32. };
  33. #define SDHI_CALIB_TABLE_MAX 32
  34. struct renesas_sdhi_quirks {
  35. bool hs400_disabled;
  36. bool hs400_4taps;
  37. bool fixed_addr_mode;
  38. bool dma_one_rx_only;
  39. bool manual_tap_correction;
  40. bool old_info1_layout;
  41. u32 hs400_bad_taps;
  42. const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX];
  43. };
  44. struct renesas_sdhi_of_data_with_quirks {
  45. const struct renesas_sdhi_of_data *of_data;
  46. const struct renesas_sdhi_quirks *quirks;
  47. };
  48. struct tmio_mmc_dma {
  49. enum dma_slave_buswidth dma_buswidth;
  50. bool (*filter)(struct dma_chan *chan, void *arg);
  51. void (*enable)(struct tmio_mmc_host *host, bool enable);
  52. struct completion dma_dataend;
  53. struct tasklet_struct dma_complete;
  54. };
  55. struct renesas_sdhi {
  56. struct clk *clk;
  57. struct clk *clkh;
  58. struct clk *clk_cd;
  59. struct tmio_mmc_data mmc_data;
  60. struct tmio_mmc_dma dma_priv;
  61. const struct renesas_sdhi_quirks *quirks;
  62. struct pinctrl *pinctrl;
  63. struct pinctrl_state *pins_default, *pins_uhs;
  64. void __iomem *scc_ctl;
  65. u32 scc_tappos;
  66. u32 scc_tappos_hs400;
  67. const u8 *adjust_hs400_calib_table;
  68. bool needs_adjust_hs400;
  69. /* Tuning values: 1 for success, 0 for failure */
  70. DECLARE_BITMAP(taps, BITS_PER_LONG);
  71. /* Sampling data comparison: 1 for match, 0 for mismatch */
  72. DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
  73. unsigned int tap_num;
  74. unsigned int tap_set;
  75. struct reset_control *rstc;
  76. };
  77. #define host_to_priv(host) \
  78. container_of((host)->pdata, struct renesas_sdhi, mmc_data)
  79. int renesas_sdhi_probe(struct platform_device *pdev,
  80. const struct tmio_mmc_dma_ops *dma_ops,
  81. const struct renesas_sdhi_of_data *of_data,
  82. const struct renesas_sdhi_quirks *quirks);
  83. int renesas_sdhi_remove(struct platform_device *pdev);
  84. #endif