1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Copyright (C) 2017 Horms Solutions Ltd., Simon Horman
6 * Copyright (C) 2017-19 Renesas Electronics Corporation
10 #define RENESAS_SDHI_H
12 #include <linux/dmaengine.h>
13 #include <linux/platform_device.h>
16 struct renesas_sdhi_scc {
17 unsigned long clk_rate; /* clock rate for SDR104 */
18 u32 tap; /* sampling clock position for SDR104/HS400 (8 TAP) */
19 u32 tap_hs400_4tap; /* sampling clock position for HS400 (4 TAP) */
22 #define SDHI_FLAG_NEED_CLKH_FALLBACK BIT(0)
24 struct renesas_sdhi_of_data {
25 unsigned long tmio_flags;
27 unsigned long capabilities;
28 unsigned long capabilities2;
29 enum dma_slave_buswidth dma_buswidth;
30 dma_addr_t dma_rx_offset;
31 unsigned int bus_shift;
33 struct renesas_sdhi_scc *taps;
35 unsigned int max_blk_count;
36 unsigned short max_segs;
37 unsigned long sdhi_flags;
40 #define SDHI_CALIB_TABLE_MAX 32
42 #define sdhi_has_quirk(p, q) ((p)->quirks && (p)->quirks->q)
44 struct renesas_sdhi_quirks {
49 bool manual_tap_correction;
50 bool old_info1_layout;
52 const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX];
55 struct renesas_sdhi_of_data_with_quirks {
56 const struct renesas_sdhi_of_data *of_data;
57 const struct renesas_sdhi_quirks *quirks;
60 /* We want both end_flags to be set before we mark DMA as finished */
61 #define SDHI_DMA_END_FLAG_DMA 0
62 #define SDHI_DMA_END_FLAG_ACCESS 1
64 struct renesas_sdhi_dma {
65 unsigned long end_flags;
66 enum dma_slave_buswidth dma_buswidth;
68 void (*enable)(struct tmio_mmc_host *host, bool enable);
69 struct completion dma_dataend;
70 struct tasklet_struct dma_complete;
77 struct tmio_mmc_data mmc_data;
78 struct renesas_sdhi_dma dma_priv;
79 const struct renesas_sdhi_quirks *quirks;
80 struct pinctrl *pinctrl;
81 struct pinctrl_state *pins_default, *pins_uhs;
82 void __iomem *scc_ctl;
85 const u8 *adjust_hs400_calib_table;
86 bool needs_adjust_hs400;
88 /* Tuning values: 1 for success, 0 for failure */
89 DECLARE_BITMAP(taps, BITS_PER_LONG);
90 /* Sampling data comparison: 1 for match, 0 for mismatch */
91 DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
95 struct reset_control *rstc;
98 #define host_to_priv(host) \
99 container_of((host)->pdata, struct renesas_sdhi, mmc_data)
101 int renesas_sdhi_probe(struct platform_device *pdev,
102 const struct tmio_mmc_dma_ops *dma_ops,
103 const struct renesas_sdhi_of_data *of_data,
104 const struct renesas_sdhi_quirks *quirks);
105 void renesas_sdhi_remove(struct platform_device *pdev);