aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2018-07-13 07:15:23 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2018-07-30 09:07:43 -0400
commited9067fd5f299db7110861a0434d0e2ffb961649 (patch)
tree9657c4ce7e3f03864e6b2ab9baa8d6ab5475ee47
parent57d1654ec96a49f5a093f9cbe40718c92ab5daa0 (diff)
mmc: mmci: Initial support to manage variant specific callbacks
To be able to better support different mmci variants, we need to be able to use variant specific callbacks, rather than continue to sprinkle the code with additional variant data. To move in this direction, let's add an optional ->init() callback to the variant data struct, which variants shall use to assign the mmci_host_ops pointer. Using an ->init() callback enables us to partition the code between different files. To allow separate mmci variant files to implement the variant specifics, let's also move the definition of the struct variant_data to the common mmci header file. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Ludovic Barre <ludovic.barre@st.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/mmc/host/mmci.c75
-rw-r--r--drivers/mmc/host/mmci.h80
2 files changed, 82 insertions, 73 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f1849775e47e..e907a0a866da 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -48,78 +48,6 @@
48 48
49static unsigned int fmax = 515633; 49static unsigned int fmax = 515633;
50 50
51/**
52 * struct variant_data - MMCI variant-specific quirks
53 * @clkreg: default value for MCICLOCK register
54 * @clkreg_enable: enable value for MMCICLOCK register
55 * @clkreg_8bit_bus_enable: enable value for 8 bit bus
56 * @clkreg_neg_edge_enable: enable value for inverted data/cmd output
57 * @datalength_bits: number of bits in the MMCIDATALENGTH register
58 * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY
59 * is asserted (likewise for RX)
60 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
61 * is asserted (likewise for RX)
62 * @data_cmd_enable: enable value for data commands.
63 * @st_sdio: enable ST specific SDIO logic
64 * @st_clkdiv: true if using a ST-specific clock divider algorithm
65 * @datactrl_mask_ddrmode: ddr mode mask in datactrl register.
66 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register
67 * @blksz_datactrl4: true if Block size is at b4..b16 position in datactrl
68 * register
69 * @datactrl_mask_sdio: SDIO enable mask in datactrl register
70 * @pwrreg_powerup: power up value for MMCIPOWER register
71 * @f_max: maximum clk frequency supported by the controller.
72 * @signal_direction: input/out direction of bus signals can be indicated
73 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock
74 * @busy_detect: true if the variant supports busy detection on DAT0.
75 * @busy_dpsm_flag: bitmask enabling busy detection in the DPSM
76 * @busy_detect_flag: bitmask identifying the bit in the MMCISTATUS register
77 * indicating that the card is busy
78 * @busy_detect_mask: bitmask identifying the bit in the MMCIMASK0 to mask for
79 * getting busy end detection interrupts
80 * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply
81 * @explicit_mclk_control: enable explicit mclk control in driver.
82 * @qcom_fifo: enables qcom specific fifo pio read logic.
83 * @qcom_dml: enables qcom specific dma glue for dma transfers.
84 * @reversed_irq_handling: handle data irq before cmd irq.
85 * @mmcimask1: true if variant have a MMCIMASK1 register.
86 * @start_err: bitmask identifying the STARTBITERR bit inside MMCISTATUS
87 * register.
88 * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
89 */
90struct variant_data {
91 unsigned int clkreg;
92 unsigned int clkreg_enable;
93 unsigned int clkreg_8bit_bus_enable;
94 unsigned int clkreg_neg_edge_enable;
95 unsigned int datalength_bits;
96 unsigned int fifosize;
97 unsigned int fifohalfsize;
98 unsigned int data_cmd_enable;
99 unsigned int datactrl_mask_ddrmode;
100 unsigned int datactrl_mask_sdio;
101 bool st_sdio;
102 bool st_clkdiv;
103 bool blksz_datactrl16;
104 bool blksz_datactrl4;
105 u32 pwrreg_powerup;
106 u32 f_max;
107 bool signal_direction;
108 bool pwrreg_clkgate;
109 bool busy_detect;
110 u32 busy_dpsm_flag;
111 u32 busy_detect_flag;
112 u32 busy_detect_mask;
113 bool pwrreg_nopower;
114 bool explicit_mclk_control;
115 bool qcom_fifo;
116 bool qcom_dml;
117 bool reversed_irq_handling;
118 bool mmcimask1;
119 u32 start_err;
120 u32 opendrain;
121};
122
123static struct variant_data variant_arm = { 51static struct variant_data variant_arm = {
124 .fifosize = 16 * 4, 52 .fifosize = 16 * 4,
125 .fifohalfsize = 8 * 4, 53 .fifohalfsize = 8 * 4,
@@ -1706,6 +1634,9 @@ static int mmci_probe(struct amba_device *dev,
1706 goto clk_disable; 1634 goto clk_disable;
1707 } 1635 }
1708 1636
1637 if (variant->init)
1638 variant->init(host);
1639
1709 /* 1640 /*
1710 * The ARM and ST versions of the block have slightly different 1641 * The ARM and ST versions of the block have slightly different
1711 * clock divider equations which means that the minimum divider 1642 * clock divider equations which means that the minimum divider
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index f91cdf7f6dae..f2eff0cc6934 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -195,8 +195,85 @@
195#define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain" 195#define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain"
196 196
197struct clk; 197struct clk;
198struct variant_data;
199struct dma_chan; 198struct dma_chan;
199struct mmci_host;
200
201/**
202 * struct variant_data - MMCI variant-specific quirks
203 * @clkreg: default value for MCICLOCK register
204 * @clkreg_enable: enable value for MMCICLOCK register
205 * @clkreg_8bit_bus_enable: enable value for 8 bit bus
206 * @clkreg_neg_edge_enable: enable value for inverted data/cmd output
207 * @datalength_bits: number of bits in the MMCIDATALENGTH register
208 * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY
209 * is asserted (likewise for RX)
210 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
211 * is asserted (likewise for RX)
212 * @data_cmd_enable: enable value for data commands.
213 * @st_sdio: enable ST specific SDIO logic
214 * @st_clkdiv: true if using a ST-specific clock divider algorithm
215 * @datactrl_mask_ddrmode: ddr mode mask in datactrl register.
216 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register
217 * @blksz_datactrl4: true if Block size is at b4..b16 position in datactrl
218 * register
219 * @datactrl_mask_sdio: SDIO enable mask in datactrl register
220 * @pwrreg_powerup: power up value for MMCIPOWER register
221 * @f_max: maximum clk frequency supported by the controller.
222 * @signal_direction: input/out direction of bus signals can be indicated
223 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock
224 * @busy_detect: true if the variant supports busy detection on DAT0.
225 * @busy_dpsm_flag: bitmask enabling busy detection in the DPSM
226 * @busy_detect_flag: bitmask identifying the bit in the MMCISTATUS register
227 * indicating that the card is busy
228 * @busy_detect_mask: bitmask identifying the bit in the MMCIMASK0 to mask for
229 * getting busy end detection interrupts
230 * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply
231 * @explicit_mclk_control: enable explicit mclk control in driver.
232 * @qcom_fifo: enables qcom specific fifo pio read logic.
233 * @qcom_dml: enables qcom specific dma glue for dma transfers.
234 * @reversed_irq_handling: handle data irq before cmd irq.
235 * @mmcimask1: true if variant have a MMCIMASK1 register.
236 * @start_err: bitmask identifying the STARTBITERR bit inside MMCISTATUS
237 * register.
238 * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
239 */
240struct variant_data {
241 unsigned int clkreg;
242 unsigned int clkreg_enable;
243 unsigned int clkreg_8bit_bus_enable;
244 unsigned int clkreg_neg_edge_enable;
245 unsigned int datalength_bits;
246 unsigned int fifosize;
247 unsigned int fifohalfsize;
248 unsigned int data_cmd_enable;
249 unsigned int datactrl_mask_ddrmode;
250 unsigned int datactrl_mask_sdio;
251 bool st_sdio;
252 bool st_clkdiv;
253 bool blksz_datactrl16;
254 bool blksz_datactrl4;
255 u32 pwrreg_powerup;
256 u32 f_max;
257 bool signal_direction;
258 bool pwrreg_clkgate;
259 bool busy_detect;
260 u32 busy_dpsm_flag;
261 u32 busy_detect_flag;
262 u32 busy_detect_mask;
263 bool pwrreg_nopower;
264 bool explicit_mclk_control;
265 bool qcom_fifo;
266 bool qcom_dml;
267 bool reversed_irq_handling;
268 bool mmcimask1;
269 u32 start_err;
270 u32 opendrain;
271 void (*init)(struct mmci_host *host);
272};
273
274/* mmci variant callbacks */
275struct mmci_host_ops {
276};
200 277
201struct mmci_host_next { 278struct mmci_host_next {
202 struct dma_async_tx_descriptor *dma_desc; 279 struct dma_async_tx_descriptor *dma_desc;
@@ -228,6 +305,7 @@ struct mmci_host {
228 u32 mask1_reg; 305 u32 mask1_reg;
229 bool vqmmc_enabled; 306 bool vqmmc_enabled;
230 struct mmci_platform_data *plat; 307 struct mmci_platform_data *plat;
308 struct mmci_host_ops *ops;
231 struct variant_data *variant; 309 struct variant_data *variant;
232 struct pinctrl *pinctrl; 310 struct pinctrl *pinctrl;
233 struct pinctrl_state *pins_default; 311 struct pinctrl_state *pins_default;