hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/mmc/host/meson-gx-mmc.c
....@@ -1,32 +1,19 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Amlogic SD/eMMC driver for the GX/S905 family SoCs
34 *
45 * Copyright (c) 2016 BayLibre, SAS.
56 * Author: Kevin Hilman <khilman@baylibre.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of version 2 of the GNU General Public License as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful, but
12
- * WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- * General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
18
- * The full GNU General Public License is included in this distribution
19
- * in the file called COPYING.
207 */
218 #include <linux/kernel.h>
229 #include <linux/module.h>
2310 #include <linux/init.h>
2411 #include <linux/delay.h>
2512 #include <linux/device.h>
13
+#include <linux/iopoll.h>
2614 #include <linux/of_device.h>
2715 #include <linux/platform_device.h>
2816 #include <linux/ioport.h>
29
-#include <linux/spinlock.h>
3017 #include <linux/dma-mapping.h>
3118 #include <linux/mmc/host.h>
3219 #include <linux/mmc/mmc.h>
....@@ -49,6 +36,8 @@
4936 #define CLK_CORE_PHASE_MASK GENMASK(9, 8)
5037 #define CLK_TX_PHASE_MASK GENMASK(11, 10)
5138 #define CLK_RX_PHASE_MASK GENMASK(13, 12)
39
+#define CLK_PHASE_0 0
40
+#define CLK_PHASE_180 2
5241 #define CLK_V2_TX_DELAY_MASK GENMASK(19, 16)
5342 #define CLK_V2_RX_DELAY_MASK GENMASK(23, 20)
5443 #define CLK_V2_ALWAYS_ON BIT(24)
....@@ -57,16 +46,15 @@
5746 #define CLK_V3_RX_DELAY_MASK GENMASK(27, 22)
5847 #define CLK_V3_ALWAYS_ON BIT(28)
5948
60
-#define CLK_DELAY_STEP_PS 200
61
-#define CLK_PHASE_STEP 30
62
-#define CLK_PHASE_POINT_NUM (360 / CLK_PHASE_STEP)
63
-
6449 #define CLK_TX_DELAY_MASK(h) (h->data->tx_delay_mask)
6550 #define CLK_RX_DELAY_MASK(h) (h->data->rx_delay_mask)
6651 #define CLK_ALWAYS_ON(h) (h->data->always_on)
6752
6853 #define SD_EMMC_DELAY 0x4
6954 #define SD_EMMC_ADJUST 0x8
55
+#define ADJUST_ADJ_DELAY_MASK GENMASK(21, 16)
56
+#define ADJUST_DS_EN BIT(15)
57
+#define ADJUST_ADJ_EN BIT(13)
7058
7159 #define SD_EMMC_DELAY1 0x4
7260 #define SD_EMMC_DELAY2 0x8
....@@ -128,6 +116,9 @@
128116 #define SD_EMMC_TXD 0x94
129117 #define SD_EMMC_LAST_REG SD_EMMC_TXD
130118
119
+#define SD_EMMC_SRAM_DATA_BUF_LEN 1536
120
+#define SD_EMMC_SRAM_DATA_BUF_OFF 0x200
121
+
131122 #define SD_EMMC_CFG_BLK_SIZE 512 /* internal buffer max: 512 bytes */
132123 #define SD_EMMC_CFG_RESP_TIMEOUT 256 /* in clock cycles */
133124 #define SD_EMMC_CMD_TIMEOUT 1024 /* in ms */
....@@ -144,6 +135,7 @@
144135 unsigned int tx_delay_mask;
145136 unsigned int rx_delay_mask;
146137 unsigned int always_on;
138
+ unsigned int adjust;
147139 };
148140
149141 struct sd_emmc_desc {
....@@ -159,20 +151,21 @@
159151 struct mmc_host *mmc;
160152 struct mmc_command *cmd;
161153
162
- spinlock_t lock;
163154 void __iomem *regs;
164155 struct clk *core_clk;
156
+ struct clk *mux_clk;
165157 struct clk *mmc_clk;
166
- struct clk *rx_clk;
167
- struct clk *tx_clk;
168158 unsigned long req_rate;
159
+ bool ddr;
160
+
161
+ bool dram_access_quirk;
169162
170163 struct pinctrl *pinctrl;
171
- struct pinctrl_state *pins_default;
172164 struct pinctrl_state *pins_clk_gate;
173165
174166 unsigned int bounce_buf_size;
175167 void *bounce_buf;
168
+ void __iomem *bounce_iomem_buf;
176169 dma_addr_t bounce_dma_addr;
177170 struct sd_emmc_desc *descs;
178171 dma_addr_t descs_dma_addr;
....@@ -180,6 +173,8 @@
180173 int irq;
181174
182175 bool vqmmc_enabled;
176
+ bool needs_pre_post_req;
177
+
183178 };
184179
185180 #define CMD_CFG_LENGTH_MASK GENMASK(8, 0)
....@@ -204,90 +199,6 @@
204199 #define CMD_DATA_SRAM BIT(0)
205200 #define CMD_RESP_MASK GENMASK(31, 1)
206201 #define CMD_RESP_SRAM BIT(0)
207
-
208
-struct meson_mmc_phase {
209
- struct clk_hw hw;
210
- void __iomem *reg;
211
- unsigned long phase_mask;
212
- unsigned long delay_mask;
213
- unsigned int delay_step_ps;
214
-};
215
-
216
-#define to_meson_mmc_phase(_hw) container_of(_hw, struct meson_mmc_phase, hw)
217
-
218
-static int meson_mmc_clk_get_phase(struct clk_hw *hw)
219
-{
220
- struct meson_mmc_phase *mmc = to_meson_mmc_phase(hw);
221
- unsigned int phase_num = 1 << hweight_long(mmc->phase_mask);
222
- unsigned long period_ps, p, d;
223
- int degrees;
224
- u32 val;
225
-
226
- val = readl(mmc->reg);
227
- p = (val & mmc->phase_mask) >> __ffs(mmc->phase_mask);
228
- degrees = p * 360 / phase_num;
229
-
230
- if (mmc->delay_mask) {
231
- period_ps = DIV_ROUND_UP((unsigned long)NSEC_PER_SEC * 1000,
232
- clk_get_rate(hw->clk));
233
- d = (val & mmc->delay_mask) >> __ffs(mmc->delay_mask);
234
- degrees += d * mmc->delay_step_ps * 360 / period_ps;
235
- degrees %= 360;
236
- }
237
-
238
- return degrees;
239
-}
240
-
241
-static void meson_mmc_apply_phase_delay(struct meson_mmc_phase *mmc,
242
- unsigned int phase,
243
- unsigned int delay)
244
-{
245
- u32 val;
246
-
247
- val = readl(mmc->reg);
248
- val &= ~mmc->phase_mask;
249
- val |= phase << __ffs(mmc->phase_mask);
250
-
251
- if (mmc->delay_mask) {
252
- val &= ~mmc->delay_mask;
253
- val |= delay << __ffs(mmc->delay_mask);
254
- }
255
-
256
- writel(val, mmc->reg);
257
-}
258
-
259
-static int meson_mmc_clk_set_phase(struct clk_hw *hw, int degrees)
260
-{
261
- struct meson_mmc_phase *mmc = to_meson_mmc_phase(hw);
262
- unsigned int phase_num = 1 << hweight_long(mmc->phase_mask);
263
- unsigned long period_ps, d = 0, r;
264
- uint64_t p;
265
-
266
- p = degrees % 360;
267
-
268
- if (!mmc->delay_mask) {
269
- p = DIV_ROUND_CLOSEST_ULL(p, 360 / phase_num);
270
- } else {
271
- period_ps = DIV_ROUND_UP((unsigned long)NSEC_PER_SEC * 1000,
272
- clk_get_rate(hw->clk));
273
-
274
- /* First compute the phase index (p), the remainder (r) is the
275
- * part we'll try to acheive using the delays (d).
276
- */
277
- r = do_div(p, 360 / phase_num);
278
- d = DIV_ROUND_CLOSEST(r * period_ps,
279
- 360 * mmc->delay_step_ps);
280
- d = min(d, mmc->delay_mask >> __ffs(mmc->delay_mask));
281
- }
282
-
283
- meson_mmc_apply_phase_delay(mmc, p, d);
284
- return 0;
285
-}
286
-
287
-static const struct clk_ops meson_mmc_clk_phase_ops = {
288
- .get_phase = meson_mmc_clk_get_phase,
289
- .set_phase = meson_mmc_clk_set_phase,
290
-};
291202
292203 static unsigned int meson_mmc_get_timeout_msecs(struct mmc_data *data)
293204 {
....@@ -315,10 +226,19 @@
315226 static void meson_mmc_get_transfer_mode(struct mmc_host *mmc,
316227 struct mmc_request *mrq)
317228 {
229
+ struct meson_host *host = mmc_priv(mmc);
318230 struct mmc_data *data = mrq->data;
319231 struct scatterlist *sg;
320232 int i;
321233 bool use_desc_chain_mode = true;
234
+
235
+ /*
236
+ * When Controller DMA cannot directly access DDR memory, disable
237
+ * support for Chain Mode to directly use the internal SRAM using
238
+ * the bounce buffer mode.
239
+ */
240
+ if (host->dram_access_quirk)
241
+ return;
322242
323243 /*
324244 * Broken SDIO with AP6255-based WiFi on Khadas VIM Pro has been
....@@ -381,16 +301,6 @@
381301 mmc_get_dma_dir(data));
382302 }
383303
384
-static bool meson_mmc_timing_is_ddr(struct mmc_ios *ios)
385
-{
386
- if (ios->timing == MMC_TIMING_MMC_DDR52 ||
387
- ios->timing == MMC_TIMING_UHS_DDR50 ||
388
- ios->timing == MMC_TIMING_MMC_HS400)
389
- return true;
390
-
391
- return false;
392
-}
393
-
394304 /*
395305 * Gating the clock on this controller is tricky. It seems the mmc clock
396306 * is also used by the controller. It may crash during some operation if the
....@@ -419,7 +329,7 @@
419329 u32 cfg;
420330
421331 if (host->pins_clk_gate)
422
- pinctrl_select_state(host->pinctrl, host->pins_default);
332
+ pinctrl_select_default_state(host->dev);
423333
424334 /* Make sure the clock is not stopped in the controller */
425335 cfg = readl(host->regs + SD_EMMC_CFG);
....@@ -427,35 +337,40 @@
427337 writel(cfg, host->regs + SD_EMMC_CFG);
428338 }
429339
430
-static int meson_mmc_clk_set(struct meson_host *host, struct mmc_ios *ios)
340
+static int meson_mmc_clk_set(struct meson_host *host, unsigned long rate,
341
+ bool ddr)
431342 {
432343 struct mmc_host *mmc = host->mmc;
433
- unsigned long rate = ios->clock;
434344 int ret;
435345 u32 cfg;
436346
437
- /* DDR modes require higher module clock */
438
- if (meson_mmc_timing_is_ddr(ios))
439
- rate <<= 1;
440
-
441347 /* Same request - bail-out */
442
- if (host->req_rate == rate)
348
+ if (host->ddr == ddr && host->req_rate == rate)
443349 return 0;
444350
445351 /* stop clock */
446352 meson_mmc_clk_gate(host);
447353 host->req_rate = 0;
354
+ mmc->actual_clock = 0;
448355
449
- if (!rate) {
450
- mmc->actual_clock = 0;
451
- /* return with clock being stopped */
356
+ /* return with clock being stopped */
357
+ if (!rate)
452358 return 0;
453
- }
454359
455360 /* Stop the clock during rate change to avoid glitches */
456361 cfg = readl(host->regs + SD_EMMC_CFG);
457362 cfg |= CFG_STOP_CLOCK;
458363 writel(cfg, host->regs + SD_EMMC_CFG);
364
+
365
+ if (ddr) {
366
+ /* DDR modes require higher module clock */
367
+ rate <<= 1;
368
+ cfg |= CFG_DDR;
369
+ } else {
370
+ cfg &= ~CFG_DDR;
371
+ }
372
+ writel(cfg, host->regs + SD_EMMC_CFG);
373
+ host->ddr = ddr;
459374
460375 ret = clk_set_rate(host->mmc_clk, rate);
461376 if (ret) {
....@@ -468,12 +383,14 @@
468383 mmc->actual_clock = clk_get_rate(host->mmc_clk);
469384
470385 /* We should report the real output frequency of the controller */
471
- if (meson_mmc_timing_is_ddr(ios))
386
+ if (ddr) {
387
+ host->req_rate >>= 1;
472388 mmc->actual_clock >>= 1;
389
+ }
473390
474391 dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock);
475
- if (ios->clock != mmc->actual_clock)
476
- dev_dbg(host->dev, "requested rate was %u\n", ios->clock);
392
+ if (rate != mmc->actual_clock)
393
+ dev_dbg(host->dev, "requested rate was %lu\n", rate);
477394
478395 /* (re)start clock */
479396 meson_mmc_clk_ungate(host);
....@@ -491,8 +408,6 @@
491408 struct clk_init_data init;
492409 struct clk_mux *mux;
493410 struct clk_divider *div;
494
- struct meson_mmc_phase *core, *tx, *rx;
495
- struct clk *clk;
496411 char clk_name[32];
497412 int i, ret = 0;
498413 const char *mux_parent_names[MUX_CLK_NUM_PARENTS];
....@@ -500,9 +415,11 @@
500415 u32 clk_reg;
501416
502417 /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */
503
- clk_reg = 0;
504
- clk_reg |= CLK_ALWAYS_ON(host);
418
+ clk_reg = CLK_ALWAYS_ON(host);
505419 clk_reg |= CLK_DIV_MASK;
420
+ clk_reg |= FIELD_PREP(CLK_CORE_PHASE_MASK, CLK_PHASE_180);
421
+ clk_reg |= FIELD_PREP(CLK_TX_PHASE_MASK, CLK_PHASE_0);
422
+ clk_reg |= FIELD_PREP(CLK_RX_PHASE_MASK, CLK_PHASE_0);
506423 writel(clk_reg, host->regs + SD_EMMC_CLOCK);
507424
508425 /* get the mux parents */
....@@ -512,11 +429,9 @@
512429
513430 snprintf(name, sizeof(name), "clkin%d", i);
514431 clk = devm_clk_get(host->dev, name);
515
- if (IS_ERR(clk)) {
516
- if (clk != ERR_PTR(-EPROBE_DEFER))
517
- dev_err(host->dev, "Missing clock %s\n", name);
518
- return PTR_ERR(clk);
519
- }
432
+ if (IS_ERR(clk))
433
+ return dev_err_probe(host->dev, PTR_ERR(clk),
434
+ "Missing clock %s\n", name);
520435
521436 mux_parent_names[i] = __clk_get_name(clk);
522437 }
....@@ -538,9 +453,9 @@
538453 mux->mask = CLK_SRC_MASK >> mux->shift;
539454 mux->hw.init = &init;
540455
541
- clk = devm_clk_register(host->dev, &mux->hw);
542
- if (WARN_ON(IS_ERR(clk)))
543
- return PTR_ERR(clk);
456
+ host->mux_clk = devm_clk_register(host->dev, &mux->hw);
457
+ if (WARN_ON(IS_ERR(host->mux_clk)))
458
+ return PTR_ERR(host->mux_clk);
544459
545460 /* create the divider */
546461 div = devm_kzalloc(host->dev, sizeof(*div), GFP_KERNEL);
....@@ -551,7 +466,7 @@
551466 init.name = clk_name;
552467 init.ops = &clk_divider_ops;
553468 init.flags = CLK_SET_RATE_PARENT;
554
- clk_parent[0] = __clk_get_name(clk);
469
+ clk_parent[0] = __clk_get_name(host->mux_clk);
555470 init.parent_names = clk_parent;
556471 init.num_parents = 1;
557472
....@@ -561,76 +476,9 @@
561476 div->hw.init = &init;
562477 div->flags = CLK_DIVIDER_ONE_BASED;
563478
564
- clk = devm_clk_register(host->dev, &div->hw);
565
- if (WARN_ON(IS_ERR(clk)))
566
- return PTR_ERR(clk);
567
-
568
- /* create the mmc core clock */
569
- core = devm_kzalloc(host->dev, sizeof(*core), GFP_KERNEL);
570
- if (!core)
571
- return -ENOMEM;
572
-
573
- snprintf(clk_name, sizeof(clk_name), "%s#core", dev_name(host->dev));
574
- init.name = clk_name;
575
- init.ops = &meson_mmc_clk_phase_ops;
576
- init.flags = CLK_SET_RATE_PARENT;
577
- clk_parent[0] = __clk_get_name(clk);
578
- init.parent_names = clk_parent;
579
- init.num_parents = 1;
580
-
581
- core->reg = host->regs + SD_EMMC_CLOCK;
582
- core->phase_mask = CLK_CORE_PHASE_MASK;
583
- core->hw.init = &init;
584
-
585
- host->mmc_clk = devm_clk_register(host->dev, &core->hw);
586
- if (WARN_ON(PTR_ERR_OR_ZERO(host->mmc_clk)))
479
+ host->mmc_clk = devm_clk_register(host->dev, &div->hw);
480
+ if (WARN_ON(IS_ERR(host->mmc_clk)))
587481 return PTR_ERR(host->mmc_clk);
588
-
589
- /* create the mmc tx clock */
590
- tx = devm_kzalloc(host->dev, sizeof(*tx), GFP_KERNEL);
591
- if (!tx)
592
- return -ENOMEM;
593
-
594
- snprintf(clk_name, sizeof(clk_name), "%s#tx", dev_name(host->dev));
595
- init.name = clk_name;
596
- init.ops = &meson_mmc_clk_phase_ops;
597
- init.flags = 0;
598
- clk_parent[0] = __clk_get_name(host->mmc_clk);
599
- init.parent_names = clk_parent;
600
- init.num_parents = 1;
601
-
602
- tx->reg = host->regs + SD_EMMC_CLOCK;
603
- tx->phase_mask = CLK_TX_PHASE_MASK;
604
- tx->delay_mask = CLK_TX_DELAY_MASK(host);
605
- tx->delay_step_ps = CLK_DELAY_STEP_PS;
606
- tx->hw.init = &init;
607
-
608
- host->tx_clk = devm_clk_register(host->dev, &tx->hw);
609
- if (WARN_ON(PTR_ERR_OR_ZERO(host->tx_clk)))
610
- return PTR_ERR(host->tx_clk);
611
-
612
- /* create the mmc rx clock */
613
- rx = devm_kzalloc(host->dev, sizeof(*rx), GFP_KERNEL);
614
- if (!rx)
615
- return -ENOMEM;
616
-
617
- snprintf(clk_name, sizeof(clk_name), "%s#rx", dev_name(host->dev));
618
- init.name = clk_name;
619
- init.ops = &meson_mmc_clk_phase_ops;
620
- init.flags = 0;
621
- clk_parent[0] = __clk_get_name(host->mmc_clk);
622
- init.parent_names = clk_parent;
623
- init.num_parents = 1;
624
-
625
- rx->reg = host->regs + SD_EMMC_CLOCK;
626
- rx->phase_mask = CLK_RX_PHASE_MASK;
627
- rx->delay_mask = CLK_RX_DELAY_MASK(host);
628
- rx->delay_step_ps = CLK_DELAY_STEP_PS;
629
- rx->hw.init = &init;
630
-
631
- host->rx_clk = devm_clk_register(host->dev, &rx->hw);
632
- if (WARN_ON(PTR_ERR_OR_ZERO(host->rx_clk)))
633
- return PTR_ERR(host->rx_clk);
634482
635483 /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */
636484 host->mmc->f_min = clk_round_rate(host->mmc_clk, 400000);
....@@ -638,114 +486,94 @@
638486 if (ret)
639487 return ret;
640488
641
- /*
642
- * Set phases : These values are mostly the datasheet recommended ones
643
- * except for the Tx phase. Datasheet recommends 180 but some cards
644
- * fail at initialisation with it. 270 works just fine, it fixes these
645
- * initialisation issues and enable eMMC DDR52 mode.
646
- */
647
- clk_set_phase(host->mmc_clk, 180);
648
- clk_set_phase(host->tx_clk, 270);
649
- clk_set_phase(host->rx_clk, 0);
650
-
651489 return clk_prepare_enable(host->mmc_clk);
652490 }
653491
654
-static void meson_mmc_shift_map(unsigned long *map, unsigned long shift)
492
+static void meson_mmc_disable_resampling(struct meson_host *host)
655493 {
656
- DECLARE_BITMAP(left, CLK_PHASE_POINT_NUM);
657
- DECLARE_BITMAP(right, CLK_PHASE_POINT_NUM);
494
+ unsigned int val = readl(host->regs + host->data->adjust);
658495
659
- /*
660
- * shift the bitmap right and reintroduce the dropped bits on the left
661
- * of the bitmap
662
- */
663
- bitmap_shift_right(right, map, shift, CLK_PHASE_POINT_NUM);
664
- bitmap_shift_left(left, map, CLK_PHASE_POINT_NUM - shift,
665
- CLK_PHASE_POINT_NUM);
666
- bitmap_or(map, left, right, CLK_PHASE_POINT_NUM);
496
+ val &= ~ADJUST_ADJ_EN;
497
+ writel(val, host->regs + host->data->adjust);
667498 }
668499
669
-static void meson_mmc_find_next_region(unsigned long *map,
670
- unsigned long *start,
671
- unsigned long *stop)
500
+static void meson_mmc_reset_resampling(struct meson_host *host)
672501 {
673
- *start = find_next_bit(map, CLK_PHASE_POINT_NUM, *start);
674
- *stop = find_next_zero_bit(map, CLK_PHASE_POINT_NUM, *start);
502
+ unsigned int val;
503
+
504
+ meson_mmc_disable_resampling(host);
505
+
506
+ val = readl(host->regs + host->data->adjust);
507
+ val &= ~ADJUST_ADJ_DELAY_MASK;
508
+ writel(val, host->regs + host->data->adjust);
675509 }
676510
677
-static int meson_mmc_find_tuning_point(unsigned long *test)
678
-{
679
- unsigned long shift, stop, offset = 0, start = 0, size = 0;
680
-
681
- /* Get the all good/all bad situation out the way */
682
- if (bitmap_full(test, CLK_PHASE_POINT_NUM))
683
- return 0; /* All points are good so point 0 will do */
684
- else if (bitmap_empty(test, CLK_PHASE_POINT_NUM))
685
- return -EIO; /* No successful tuning point */
686
-
687
- /*
688
- * Now we know there is a least one region find. Make sure it does
689
- * not wrap by the shifting the bitmap if necessary
690
- */
691
- shift = find_first_zero_bit(test, CLK_PHASE_POINT_NUM);
692
- if (shift != 0)
693
- meson_mmc_shift_map(test, shift);
694
-
695
- while (start < CLK_PHASE_POINT_NUM) {
696
- meson_mmc_find_next_region(test, &start, &stop);
697
-
698
- if ((stop - start) > size) {
699
- offset = start;
700
- size = stop - start;
701
- }
702
-
703
- start = stop;
704
- }
705
-
706
- /* Get the center point of the region */
707
- offset += (size / 2);
708
-
709
- /* Shift the result back */
710
- offset = (offset + shift) % CLK_PHASE_POINT_NUM;
711
-
712
- return offset;
713
-}
714
-
715
-static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode,
716
- struct clk *clk)
717
-{
718
- int point, ret;
719
- DECLARE_BITMAP(test, CLK_PHASE_POINT_NUM);
720
-
721
- dev_dbg(mmc_dev(mmc), "%s phase/delay tunning...\n",
722
- __clk_get_name(clk));
723
- bitmap_zero(test, CLK_PHASE_POINT_NUM);
724
-
725
- /* Explore tuning points */
726
- for (point = 0; point < CLK_PHASE_POINT_NUM; point++) {
727
- clk_set_phase(clk, point * CLK_PHASE_STEP);
728
- ret = mmc_send_tuning(mmc, opcode, NULL);
729
- if (!ret)
730
- set_bit(point, test);
731
- }
732
-
733
- /* Find the optimal tuning point and apply it */
734
- point = meson_mmc_find_tuning_point(test);
735
- if (point < 0)
736
- return point; /* tuning failed */
737
-
738
- clk_set_phase(clk, point * CLK_PHASE_STEP);
739
- dev_dbg(mmc_dev(mmc), "success with phase: %d\n",
740
- clk_get_phase(clk));
741
- return 0;
742
-}
743
-
744
-static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
511
+static int meson_mmc_resampling_tuning(struct mmc_host *mmc, u32 opcode)
745512 {
746513 struct meson_host *host = mmc_priv(mmc);
514
+ unsigned int val, dly, max_dly, i;
515
+ int ret;
747516
748
- return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk);
517
+ /* Resampling is done using the source clock */
518
+ max_dly = DIV_ROUND_UP(clk_get_rate(host->mux_clk),
519
+ clk_get_rate(host->mmc_clk));
520
+
521
+ val = readl(host->regs + host->data->adjust);
522
+ val |= ADJUST_ADJ_EN;
523
+ writel(val, host->regs + host->data->adjust);
524
+
525
+ if (mmc_doing_retune(mmc))
526
+ dly = FIELD_GET(ADJUST_ADJ_DELAY_MASK, val) + 1;
527
+ else
528
+ dly = 0;
529
+
530
+ for (i = 0; i < max_dly; i++) {
531
+ val &= ~ADJUST_ADJ_DELAY_MASK;
532
+ val |= FIELD_PREP(ADJUST_ADJ_DELAY_MASK, (dly + i) % max_dly);
533
+ writel(val, host->regs + host->data->adjust);
534
+
535
+ ret = mmc_send_tuning(mmc, opcode, NULL);
536
+ if (!ret) {
537
+ dev_dbg(mmc_dev(mmc), "resampling delay: %u\n",
538
+ (dly + i) % max_dly);
539
+ return 0;
540
+ }
541
+ }
542
+
543
+ meson_mmc_reset_resampling(host);
544
+ return -EIO;
545
+}
546
+
547
+static int meson_mmc_prepare_ios_clock(struct meson_host *host,
548
+ struct mmc_ios *ios)
549
+{
550
+ bool ddr;
551
+
552
+ switch (ios->timing) {
553
+ case MMC_TIMING_MMC_DDR52:
554
+ case MMC_TIMING_UHS_DDR50:
555
+ ddr = true;
556
+ break;
557
+
558
+ default:
559
+ ddr = false;
560
+ break;
561
+ }
562
+
563
+ return meson_mmc_clk_set(host, ios->clock, ddr);
564
+}
565
+
566
+static void meson_mmc_check_resampling(struct meson_host *host,
567
+ struct mmc_ios *ios)
568
+{
569
+ switch (ios->timing) {
570
+ case MMC_TIMING_LEGACY:
571
+ case MMC_TIMING_MMC_HS:
572
+ case MMC_TIMING_SD_HS:
573
+ case MMC_TIMING_MMC_DDR52:
574
+ meson_mmc_disable_resampling(host);
575
+ break;
576
+ }
749577 }
750578
751579 static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
....@@ -773,9 +601,6 @@
773601 case MMC_POWER_UP:
774602 if (!IS_ERR(mmc->supply.vmmc))
775603 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
776
-
777
- /* Reset rx phase */
778
- clk_set_phase(host->rx_clk, 0);
779604
780605 break;
781606
....@@ -813,20 +638,13 @@
813638 val = readl(host->regs + SD_EMMC_CFG);
814639 val &= ~CFG_BUS_WIDTH_MASK;
815640 val |= FIELD_PREP(CFG_BUS_WIDTH_MASK, bus_width);
641
+ writel(val, host->regs + SD_EMMC_CFG);
816642
817
- val &= ~CFG_DDR;
818
- if (meson_mmc_timing_is_ddr(ios))
819
- val |= CFG_DDR;
820
-
821
- val &= ~CFG_CHK_DS;
822
- if (ios->timing == MMC_TIMING_MMC_HS400)
823
- val |= CFG_CHK_DS;
824
-
825
- err = meson_mmc_clk_set(host, ios);
643
+ meson_mmc_check_resampling(host, ios);
644
+ err = meson_mmc_prepare_ios_clock(host, ios);
826645 if (err)
827646 dev_err(host->dev, "Failed to set clock: %d\n,", err);
828647
829
- writel(val, host->regs + SD_EMMC_CFG);
830648 dev_dbg(host->dev, "SD_EMMC_CFG: 0x%08x\n", val);
831649 }
832650
....@@ -836,6 +654,8 @@
836654 struct meson_host *host = mmc_priv(mmc);
837655
838656 host->cmd = NULL;
657
+ if (host->needs_pre_post_req)
658
+ meson_mmc_post_req(mmc, mrq, 0);
839659 mmc_request_done(host->mmc, mrq);
840660 }
841661
....@@ -919,6 +739,53 @@
919739 writel(start, host->regs + SD_EMMC_START);
920740 }
921741
742
+/* local sg copy for dram_access_quirk */
743
+static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
744
+ size_t buflen, bool to_buffer)
745
+{
746
+ unsigned int sg_flags = SG_MITER_ATOMIC;
747
+ struct scatterlist *sgl = data->sg;
748
+ unsigned int nents = data->sg_len;
749
+ struct sg_mapping_iter miter;
750
+ unsigned int offset = 0;
751
+
752
+ if (to_buffer)
753
+ sg_flags |= SG_MITER_FROM_SG;
754
+ else
755
+ sg_flags |= SG_MITER_TO_SG;
756
+
757
+ sg_miter_start(&miter, sgl, nents, sg_flags);
758
+
759
+ while ((offset < buflen) && sg_miter_next(&miter)) {
760
+ unsigned int buf_offset = 0;
761
+ unsigned int len, left;
762
+ u32 *buf = miter.addr;
763
+
764
+ len = min(miter.length, buflen - offset);
765
+ left = len;
766
+
767
+ if (to_buffer) {
768
+ do {
769
+ writel(*buf++, host->bounce_iomem_buf + offset + buf_offset);
770
+
771
+ buf_offset += 4;
772
+ left -= 4;
773
+ } while (left);
774
+ } else {
775
+ do {
776
+ *buf++ = readl(host->bounce_iomem_buf + offset + buf_offset);
777
+
778
+ buf_offset += 4;
779
+ left -= 4;
780
+ } while (left);
781
+ }
782
+
783
+ offset += len;
784
+ }
785
+
786
+ sg_miter_stop(&miter);
787
+}
788
+
922789 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
923790 {
924791 struct meson_host *host = mmc_priv(mmc);
....@@ -962,8 +829,11 @@
962829 if (data->flags & MMC_DATA_WRITE) {
963830 cmd_cfg |= CMD_CFG_DATA_WR;
964831 WARN_ON(xfer_bytes > host->bounce_buf_size);
965
- sg_copy_to_buffer(data->sg, data->sg_len,
966
- host->bounce_buf, xfer_bytes);
832
+ if (host->dram_access_quirk)
833
+ meson_mmc_copy_buffer(host, data, xfer_bytes, true);
834
+ else
835
+ sg_copy_to_buffer(data->sg, data->sg_len,
836
+ host->bounce_buf, xfer_bytes);
967837 dma_wmb();
968838 }
969839
....@@ -982,28 +852,56 @@
982852 writel(cmd->arg, host->regs + SD_EMMC_CMD_ARG);
983853 }
984854
855
+static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data *data)
856
+{
857
+ struct scatterlist *sg;
858
+ int i;
859
+
860
+ /* Reject request if any element offset or size is not 32bit aligned */
861
+ for_each_sg(data->sg, sg, data->sg_len, i) {
862
+ if (!IS_ALIGNED(sg->offset, sizeof(u32)) ||
863
+ !IS_ALIGNED(sg->length, sizeof(u32))) {
864
+ dev_err(mmc_dev(mmc), "unaligned sg offset %u len %u\n",
865
+ data->sg->offset, data->sg->length);
866
+ return -EINVAL;
867
+ }
868
+ }
869
+
870
+ return 0;
871
+}
872
+
985873 static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
986874 {
987875 struct meson_host *host = mmc_priv(mmc);
988
- bool needs_pre_post_req = mrq->data &&
876
+ host->needs_pre_post_req = mrq->data &&
989877 !(mrq->data->host_cookie & SD_EMMC_PRE_REQ_DONE);
990878
991
- if (needs_pre_post_req) {
992
- meson_mmc_get_transfer_mode(mmc, mrq);
993
- if (!meson_mmc_desc_chain_mode(mrq->data))
994
- needs_pre_post_req = false;
879
+ /*
880
+ * The memory at the end of the controller used as bounce buffer for
881
+ * the dram_access_quirk only accepts 32bit read/write access,
882
+ * check the aligment and length of the data before starting the request.
883
+ */
884
+ if (host->dram_access_quirk && mrq->data) {
885
+ mrq->cmd->error = meson_mmc_validate_dram_access(mmc, mrq->data);
886
+ if (mrq->cmd->error) {
887
+ mmc_request_done(mmc, mrq);
888
+ return;
889
+ }
995890 }
996891
997
- if (needs_pre_post_req)
892
+ if (host->needs_pre_post_req) {
893
+ meson_mmc_get_transfer_mode(mmc, mrq);
894
+ if (!meson_mmc_desc_chain_mode(mrq->data))
895
+ host->needs_pre_post_req = false;
896
+ }
897
+
898
+ if (host->needs_pre_post_req)
998899 meson_mmc_pre_req(mmc, mrq);
999900
1000901 /* Stop execution */
1001902 writel(0, host->regs + SD_EMMC_START);
1002903
1003904 meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd);
1004
-
1005
- if (needs_pre_post_req)
1006
- meson_mmc_post_req(mmc, mrq, 0);
1007905 }
1008906
1009907 static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)
....@@ -1042,7 +940,8 @@
1042940 if (WARN_ON(!host) || WARN_ON(!host->cmd))
1043941 return IRQ_NONE;
1044942
1045
- spin_lock(&host->lock);
943
+ /* ack all raised interrupts */
944
+ writel(status, host->regs + SD_EMMC_STATUS);
1046945
1047946 cmd = host->cmd;
1048947 data = cmd->data;
....@@ -1071,17 +970,11 @@
1071970 if (status & (IRQ_END_OF_CHAIN | IRQ_RESP_STATUS)) {
1072971 if (data && !cmd->error)
1073972 data->bytes_xfered = data->blksz * data->blocks;
1074
- if (meson_mmc_bounce_buf_read(data) ||
1075
- meson_mmc_get_next_command(cmd))
1076
- ret = IRQ_WAKE_THREAD;
1077
- else
1078
- ret = IRQ_HANDLED;
973
+
974
+ return IRQ_WAKE_THREAD;
1079975 }
1080976
1081977 out:
1082
- /* ack all enabled interrupts */
1083
- writel(irq_en, host->regs + SD_EMMC_STATUS);
1084
-
1085978 if (cmd->error) {
1086979 /* Stop desc in case of errors */
1087980 u32 start = readl(host->regs + SD_EMMC_START);
....@@ -1090,16 +983,11 @@
1090983 writel(start, host->regs + SD_EMMC_START);
1091984 }
1092985
1093
- if (ret == IRQ_HANDLED)
1094
- meson_mmc_request_done(host->mmc, cmd->mrq);
1095
-
1096
- spin_unlock(&host->lock);
1097986 return ret;
1098987 }
1099988
1100989 static int meson_mmc_wait_desc_stop(struct meson_host *host)
1101990 {
1102
- int loop;
1103991 u32 status;
1104992
1105993 /*
....@@ -1109,20 +997,10 @@
1109997 * If we don't confirm the descriptor is stopped, it might raise new
1110998 * IRQs after we have called mmc_request_done() which is bad.
1111999 */
1112
- for (loop = 50; loop; loop--) {
1113
- status = readl(host->regs + SD_EMMC_STATUS);
1114
- if (status & (STATUS_BUSY | STATUS_DESC_BUSY))
1115
- udelay(100);
1116
- else
1117
- break;
1118
- }
11191000
1120
- if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) {
1121
- dev_err(host->dev, "Timed out waiting for host to stop\n");
1122
- return -ETIMEDOUT;
1123
- }
1124
-
1125
- return 0;
1001
+ return readl_poll_timeout(host->regs + SD_EMMC_STATUS, status,
1002
+ !(status & (STATUS_BUSY | STATUS_DESC_BUSY)),
1003
+ 100, 5000);
11261004 }
11271005
11281006 static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
....@@ -1146,8 +1024,11 @@
11461024 if (meson_mmc_bounce_buf_read(data)) {
11471025 xfer_bytes = data->blksz * data->blocks;
11481026 WARN_ON(xfer_bytes > host->bounce_buf_size);
1149
- sg_copy_from_buffer(data->sg, data->sg_len,
1150
- host->bounce_buf, xfer_bytes);
1027
+ if (host->dram_access_quirk)
1028
+ meson_mmc_copy_buffer(host, data, xfer_bytes, false);
1029
+ else
1030
+ sg_copy_from_buffer(data->sg, data->sg_len,
1031
+ host->bounce_buf, xfer_bytes);
11511032 }
11521033
11531034 next_cmd = meson_mmc_get_next_command(cmd);
....@@ -1201,6 +1082,8 @@
12011082
12021083 static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
12031084 {
1085
+ int ret;
1086
+
12041087 /* vqmmc regulator is available */
12051088 if (!IS_ERR(mmc->supply.vqmmc)) {
12061089 /*
....@@ -1210,7 +1093,8 @@
12101093 * to 1.8v. Please make sure the regulator framework is aware
12111094 * of your own regulator constraints
12121095 */
1213
- return mmc_regulator_set_vqmmc(mmc, ios);
1096
+ ret = mmc_regulator_set_vqmmc(mmc, ios);
1097
+ return ret < 0 ? ret : 0;
12141098 }
12151099
12161100 /* no vqmmc regulator, assume fixed regulator at 3/3.3V */
....@@ -1226,7 +1110,7 @@
12261110 .get_cd = meson_mmc_get_cd,
12271111 .pre_req = meson_mmc_pre_req,
12281112 .post_req = meson_mmc_post_req,
1229
- .execute_tuning = meson_mmc_execute_tuning,
1113
+ .execute_tuning = meson_mmc_resampling_tuning,
12301114 .card_busy = meson_mmc_card_busy,
12311115 .start_signal_voltage_switch = meson_mmc_voltage_switch,
12321116 };
....@@ -1238,7 +1122,7 @@
12381122 struct mmc_host *mmc;
12391123 int ret;
12401124
1241
- mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev);
1125
+ mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct meson_host));
12421126 if (!mmc)
12431127 return -ENOMEM;
12441128 host = mmc_priv(mmc);
....@@ -1246,62 +1130,41 @@
12461130 host->dev = &pdev->dev;
12471131 dev_set_drvdata(&pdev->dev, host);
12481132
1249
- spin_lock_init(&host->lock);
1133
+ /* The G12A SDIO Controller needs an SRAM bounce buffer */
1134
+ host->dram_access_quirk = device_property_read_bool(&pdev->dev,
1135
+ "amlogic,dram-access-quirk");
12501136
12511137 /* Get regulators and the supported OCR mask */
12521138 host->vqmmc_enabled = false;
12531139 ret = mmc_regulator_get_supply(mmc);
12541140 if (ret)
1255
- goto free_host;
1141
+ return ret;
12561142
12571143 ret = mmc_of_parse(mmc);
1258
- if (ret) {
1259
- if (ret != -EPROBE_DEFER)
1260
- dev_warn(&pdev->dev, "error parsing DT: %d\n", ret);
1261
- goto free_host;
1262
- }
1144
+ if (ret)
1145
+ return dev_err_probe(&pdev->dev, ret, "error parsing DT\n");
12631146
12641147 host->data = (struct meson_mmc_data *)
12651148 of_device_get_match_data(&pdev->dev);
1266
- if (!host->data) {
1267
- ret = -EINVAL;
1268
- goto free_host;
1269
- }
1149
+ if (!host->data)
1150
+ return -EINVAL;
12701151
12711152 ret = device_reset_optional(&pdev->dev);
1272
- if (ret) {
1273
- if (ret != -EPROBE_DEFER)
1274
- dev_err(&pdev->dev, "device reset failed: %d\n", ret);
1275
-
1276
- return ret;
1277
- }
1153
+ if (ret)
1154
+ return dev_err_probe(&pdev->dev, ret, "device reset failed\n");
12781155
12791156 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
12801157 host->regs = devm_ioremap_resource(&pdev->dev, res);
1281
- if (IS_ERR(host->regs)) {
1282
- ret = PTR_ERR(host->regs);
1283
- goto free_host;
1284
- }
1158
+ if (IS_ERR(host->regs))
1159
+ return PTR_ERR(host->regs);
12851160
12861161 host->irq = platform_get_irq(pdev, 0);
1287
- if (host->irq <= 0) {
1288
- dev_err(&pdev->dev, "failed to get interrupt resource.\n");
1289
- ret = -EINVAL;
1290
- goto free_host;
1291
- }
1162
+ if (host->irq < 0)
1163
+ return host->irq;
12921164
12931165 host->pinctrl = devm_pinctrl_get(&pdev->dev);
1294
- if (IS_ERR(host->pinctrl)) {
1295
- ret = PTR_ERR(host->pinctrl);
1296
- goto free_host;
1297
- }
1298
-
1299
- host->pins_default = pinctrl_lookup_state(host->pinctrl,
1300
- PINCTRL_STATE_DEFAULT);
1301
- if (IS_ERR(host->pins_default)) {
1302
- ret = PTR_ERR(host->pins_default);
1303
- goto free_host;
1304
- }
1166
+ if (IS_ERR(host->pinctrl))
1167
+ return PTR_ERR(host->pinctrl);
13051168
13061169 host->pins_clk_gate = pinctrl_lookup_state(host->pinctrl,
13071170 "clk-gate");
....@@ -1312,14 +1175,12 @@
13121175 }
13131176
13141177 host->core_clk = devm_clk_get(&pdev->dev, "core");
1315
- if (IS_ERR(host->core_clk)) {
1316
- ret = PTR_ERR(host->core_clk);
1317
- goto free_host;
1318
- }
1178
+ if (IS_ERR(host->core_clk))
1179
+ return PTR_ERR(host->core_clk);
13191180
13201181 ret = clk_prepare_enable(host->core_clk);
13211182 if (ret)
1322
- goto free_host;
1183
+ return ret;
13231184
13241185 ret = meson_mmc_clk_init(host);
13251186 if (ret)
....@@ -1339,26 +1200,54 @@
13391200 host->regs + SD_EMMC_IRQ_EN);
13401201
13411202 ret = request_threaded_irq(host->irq, meson_mmc_irq,
1342
- meson_mmc_irq_thread, IRQF_SHARED,
1203
+ meson_mmc_irq_thread, IRQF_ONESHOT,
13431204 dev_name(&pdev->dev), host);
13441205 if (ret)
13451206 goto err_init_clk;
13461207
13471208 mmc->caps |= MMC_CAP_CMD23;
1348
- mmc->max_blk_count = CMD_CFG_LENGTH_MASK;
1209
+ if (host->dram_access_quirk) {
1210
+ /* Limit segments to 1 due to low available sram memory */
1211
+ mmc->max_segs = 1;
1212
+ /* Limit to the available sram memory */
1213
+ mmc->max_blk_count = SD_EMMC_SRAM_DATA_BUF_LEN /
1214
+ mmc->max_blk_size;
1215
+ } else {
1216
+ mmc->max_blk_count = CMD_CFG_LENGTH_MASK;
1217
+ mmc->max_segs = SD_EMMC_DESC_BUF_LEN /
1218
+ sizeof(struct sd_emmc_desc);
1219
+ }
13491220 mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size;
1350
- mmc->max_segs = SD_EMMC_DESC_BUF_LEN / sizeof(struct sd_emmc_desc);
13511221 mmc->max_seg_size = mmc->max_req_size;
13521222
1353
- /* data bounce buffer */
1354
- host->bounce_buf_size = mmc->max_req_size;
1355
- host->bounce_buf =
1356
- dma_alloc_coherent(host->dev, host->bounce_buf_size,
1357
- &host->bounce_dma_addr, GFP_KERNEL);
1358
- if (host->bounce_buf == NULL) {
1359
- dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n");
1360
- ret = -ENOMEM;
1361
- goto err_free_irq;
1223
+ /*
1224
+ * At the moment, we don't know how to reliably enable HS400.
1225
+ * From the different datasheets, it is not even clear if this mode
1226
+ * is officially supported by any of the SoCs
1227
+ */
1228
+ mmc->caps2 &= ~MMC_CAP2_HS400;
1229
+
1230
+ if (host->dram_access_quirk) {
1231
+ /*
1232
+ * The MMC Controller embeds 1,5KiB of internal SRAM
1233
+ * that can be used to be used as bounce buffer.
1234
+ * In the case of the G12A SDIO controller, use these
1235
+ * instead of the DDR memory
1236
+ */
1237
+ host->bounce_buf_size = SD_EMMC_SRAM_DATA_BUF_LEN;
1238
+ host->bounce_iomem_buf = host->regs + SD_EMMC_SRAM_DATA_BUF_OFF;
1239
+ host->bounce_dma_addr = res->start + SD_EMMC_SRAM_DATA_BUF_OFF;
1240
+ } else {
1241
+ /* data bounce buffer */
1242
+ host->bounce_buf_size = mmc->max_req_size;
1243
+ host->bounce_buf =
1244
+ dma_alloc_coherent(host->dev, host->bounce_buf_size,
1245
+ &host->bounce_dma_addr, GFP_KERNEL);
1246
+ if (host->bounce_buf == NULL) {
1247
+ dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n");
1248
+ ret = -ENOMEM;
1249
+ goto err_free_irq;
1250
+ }
13621251 }
13631252
13641253 host->descs = dma_alloc_coherent(host->dev, SD_EMMC_DESC_BUF_LEN,
....@@ -1370,21 +1259,22 @@
13701259 }
13711260
13721261 mmc->ops = &meson_mmc_ops;
1373
- mmc_add_host(mmc);
1262
+ ret = mmc_add_host(mmc);
1263
+ if (ret)
1264
+ goto err_free_irq;
13741265
13751266 return 0;
13761267
13771268 err_bounce_buf:
1378
- dma_free_coherent(host->dev, host->bounce_buf_size,
1379
- host->bounce_buf, host->bounce_dma_addr);
1269
+ if (!host->dram_access_quirk)
1270
+ dma_free_coherent(host->dev, host->bounce_buf_size,
1271
+ host->bounce_buf, host->bounce_dma_addr);
13801272 err_free_irq:
13811273 free_irq(host->irq, host);
13821274 err_init_clk:
13831275 clk_disable_unprepare(host->mmc_clk);
13841276 err_core_clk:
13851277 clk_disable_unprepare(host->core_clk);
1386
-free_host:
1387
- mmc_free_host(mmc);
13881278 return ret;
13891279 }
13901280
....@@ -1400,13 +1290,14 @@
14001290
14011291 dma_free_coherent(host->dev, SD_EMMC_DESC_BUF_LEN,
14021292 host->descs, host->descs_dma_addr);
1403
- dma_free_coherent(host->dev, host->bounce_buf_size,
1404
- host->bounce_buf, host->bounce_dma_addr);
1293
+
1294
+ if (!host->dram_access_quirk)
1295
+ dma_free_coherent(host->dev, host->bounce_buf_size,
1296
+ host->bounce_buf, host->bounce_dma_addr);
14051297
14061298 clk_disable_unprepare(host->mmc_clk);
14071299 clk_disable_unprepare(host->core_clk);
14081300
1409
- mmc_free_host(host->mmc);
14101301 return 0;
14111302 }
14121303
....@@ -1414,12 +1305,14 @@
14141305 .tx_delay_mask = CLK_V2_TX_DELAY_MASK,
14151306 .rx_delay_mask = CLK_V2_RX_DELAY_MASK,
14161307 .always_on = CLK_V2_ALWAYS_ON,
1308
+ .adjust = SD_EMMC_ADJUST,
14171309 };
14181310
14191311 static const struct meson_mmc_data meson_axg_data = {
14201312 .tx_delay_mask = CLK_V3_TX_DELAY_MASK,
14211313 .rx_delay_mask = CLK_V3_RX_DELAY_MASK,
14221314 .always_on = CLK_V3_ALWAYS_ON,
1315
+ .adjust = SD_EMMC_V3_ADJUST,
14231316 };
14241317
14251318 static const struct of_device_id meson_mmc_of_match[] = {
....@@ -1437,6 +1330,7 @@
14371330 .remove = meson_mmc_remove,
14381331 .driver = {
14391332 .name = DRIVER_NAME,
1333
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
14401334 .of_match_table = of_match_ptr(meson_mmc_of_match),
14411335 },
14421336 };