Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Renesas Mobile SDHI
0004  *
0005  * Copyright (C) 2017 Horms Solutions Ltd., Simon Horman
0006  * Copyright (C) 2017-19 Renesas Electronics Corporation
0007  */
0008 
0009 #ifndef RENESAS_SDHI_H
0010 #define RENESAS_SDHI_H
0011 
0012 #include <linux/platform_device.h>
0013 #include "tmio_mmc.h"
0014 
0015 struct renesas_sdhi_scc {
0016     unsigned long clk_rate; /* clock rate for SDR104 */
0017     u32 tap;        /* sampling clock position for SDR104/HS400 (8 TAP) */
0018     u32 tap_hs400_4tap; /* sampling clock position for HS400 (4 TAP) */
0019 };
0020 
0021 #define SDHI_FLAG_NEED_CLKH_FALLBACK    BIT(0)
0022 
0023 struct renesas_sdhi_of_data {
0024     unsigned long tmio_flags;
0025     u32       tmio_ocr_mask;
0026     unsigned long capabilities;
0027     unsigned long capabilities2;
0028     enum dma_slave_buswidth dma_buswidth;
0029     dma_addr_t dma_rx_offset;
0030     unsigned int bus_shift;
0031     int scc_offset;
0032     struct renesas_sdhi_scc *taps;
0033     int taps_num;
0034     unsigned int max_blk_count;
0035     unsigned short max_segs;
0036     unsigned long sdhi_flags;
0037 };
0038 
0039 #define SDHI_CALIB_TABLE_MAX 32
0040 
0041 struct renesas_sdhi_quirks {
0042     bool hs400_disabled;
0043     bool hs400_4taps;
0044     bool fixed_addr_mode;
0045     bool dma_one_rx_only;
0046     bool manual_tap_correction;
0047     u32 hs400_bad_taps;
0048     const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX];
0049 };
0050 
0051 struct renesas_sdhi_of_data_with_quirks {
0052     const struct renesas_sdhi_of_data *of_data;
0053     const struct renesas_sdhi_quirks *quirks;
0054 };
0055 
0056 struct tmio_mmc_dma {
0057     enum dma_slave_buswidth dma_buswidth;
0058     bool (*filter)(struct dma_chan *chan, void *arg);
0059     void (*enable)(struct tmio_mmc_host *host, bool enable);
0060     struct completion   dma_dataend;
0061     struct tasklet_struct   dma_complete;
0062 };
0063 
0064 struct renesas_sdhi {
0065     struct clk *clk;
0066     struct clk *clkh;
0067     struct clk *clk_cd;
0068     struct tmio_mmc_data mmc_data;
0069     struct tmio_mmc_dma dma_priv;
0070     const struct renesas_sdhi_quirks *quirks;
0071     struct pinctrl *pinctrl;
0072     struct pinctrl_state *pins_default, *pins_uhs;
0073     void __iomem *scc_ctl;
0074     u32 scc_tappos;
0075     u32 scc_tappos_hs400;
0076     const u8 *adjust_hs400_calib_table;
0077     bool needs_adjust_hs400;
0078 
0079     /* Tuning values: 1 for success, 0 for failure */
0080     DECLARE_BITMAP(taps, BITS_PER_LONG);
0081     /* Sampling data comparison: 1 for match, 0 for mismatch */
0082     DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
0083     unsigned int tap_num;
0084     unsigned int tap_set;
0085 
0086     struct reset_control *rstc;
0087 };
0088 
0089 #define host_to_priv(host) \
0090     container_of((host)->pdata, struct renesas_sdhi, mmc_data)
0091 
0092 int renesas_sdhi_probe(struct platform_device *pdev,
0093                const struct tmio_mmc_dma_ops *dma_ops,
0094                const struct renesas_sdhi_of_data *of_data,
0095                const struct renesas_sdhi_quirks *quirks);
0096 int renesas_sdhi_remove(struct platform_device *pdev);
0097 #endif