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