forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/mmc/host/renesas_sdhi_sys_dmac.c
....@@ -1,14 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * DMA support use of SYS DMAC with SDHI SD/SDIO controller
34 *
4
- * Copyright (C) 2016-17 Renesas Electronics Corporation
5
- * Copyright (C) 2016-17 Sang Engineering, Wolfram Sang
5
+ * Copyright (C) 2016-19 Renesas Electronics Corporation
6
+ * Copyright (C) 2016-19 Sang Engineering, Wolfram Sang
67 * Copyright (C) 2017 Horms Solutions, Simon Horman
78 * Copyright (C) 2010-2011 Guennadi Liakhovetski
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
1411 #include <linux/device.h>
....@@ -68,40 +65,7 @@
6865 .scc_offset = 0x0300,
6966 .taps = rcar_gen2_scc_taps,
7067 .taps_num = ARRAY_SIZE(rcar_gen2_scc_taps),
71
- .max_blk_count = 0xffffffff,
72
-};
73
-
74
-/* Definitions for sampling clocks */
75
-static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = {
76
- {
77
- .clk_rate = 0,
78
- .tap = 0x00000300,
79
- },
80
-};
81
-
82
-static const struct renesas_sdhi_of_data of_rcar_r8a7795_compatible = {
83
- .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
84
- TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 |
85
- TMIO_MMC_HAVE_4TAP_HS400,
86
- .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
87
- MMC_CAP_CMD23,
88
- .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
89
- .bus_shift = 2,
90
- .scc_offset = 0x1000,
91
- .taps = rcar_gen3_scc_taps,
92
- .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps),
93
-};
94
-
95
-static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
96
- .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
97
- TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
98
- .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
99
- MMC_CAP_CMD23,
100
- .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
101
- .bus_shift = 2,
102
- .scc_offset = 0x1000,
103
- .taps = rcar_gen3_scc_taps,
104
- .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps),
68
+ .max_blk_count = UINT_MAX / TMIO_MAX_BLK_SIZE,
10569 };
10670
10771 static const struct of_device_id renesas_sdhi_sys_dmac_of_match[] = {
....@@ -118,11 +82,8 @@
11882 { .compatible = "renesas,sdhi-r8a7792", .data = &of_rcar_gen2_compatible, },
11983 { .compatible = "renesas,sdhi-r8a7793", .data = &of_rcar_gen2_compatible, },
12084 { .compatible = "renesas,sdhi-r8a7794", .data = &of_rcar_gen2_compatible, },
121
- { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_r8a7795_compatible, },
122
- { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_r8a7795_compatible, },
12385 { .compatible = "renesas,rcar-gen1-sdhi", .data = &of_rcar_gen1_compatible, },
12486 { .compatible = "renesas,rcar-gen2-sdhi", .data = &of_rcar_gen2_compatible, },
125
- { .compatible = "renesas,rcar-gen3-sdhi", .data = &of_rcar_gen3_compatible, },
12687 { .compatible = "renesas,sdhi-shmobile" },
12788 {},
12889 };
....@@ -214,10 +175,8 @@
214175 goto pio;
215176 }
216177
217
- if (sg->length < TMIO_MMC_MIN_DMA_LEN) {
218
- host->force_pio = true;
178
+ if (sg->length < TMIO_MMC_MIN_DMA_LEN)
219179 return;
220
- }
221180
222181 /* The only sg element can be unaligned, use our bounce buffer then */
223182 if (!aligned) {
....@@ -241,6 +200,7 @@
241200 desc = NULL;
242201 ret = cookie;
243202 }
203
+ host->dma_on = true;
244204 }
245205 pio:
246206 if (!desc) {
....@@ -287,10 +247,8 @@
287247 goto pio;
288248 }
289249
290
- if (sg->length < TMIO_MMC_MIN_DMA_LEN) {
291
- host->force_pio = true;
250
+ if (sg->length < TMIO_MMC_MIN_DMA_LEN)
292251 return;
293
- }
294252
295253 /* The only sg element can be unaligned, use our bounce buffer then */
296254 if (!aligned) {
....@@ -319,6 +277,7 @@
319277 desc = NULL;
320278 ret = cookie;
321279 }
280
+ host->dma_on = true;
322281 }
323282 pio:
324283 if (!desc) {
....@@ -488,22 +447,8 @@
488447 .dataend = renesas_sdhi_sys_dmac_dataend_dma,
489448 };
490449
491
-/*
492
- * Whitelist of specific R-Car Gen3 SoC ES versions to use this DMAC
493
- * implementation. Currently empty as all supported ES versions use
494
- * the internal DMAC.
495
- */
496
-static const struct soc_device_attribute gen3_soc_whitelist[] = {
497
- { /* sentinel */ }
498
-};
499
-
500450 static int renesas_sdhi_sys_dmac_probe(struct platform_device *pdev)
501451 {
502
- if ((of_device_get_match_data(&pdev->dev) == &of_rcar_gen3_compatible ||
503
- of_device_get_match_data(&pdev->dev) == &of_rcar_r8a7795_compatible) &&
504
- !soc_device_match(gen3_soc_whitelist))
505
- return -ENODEV;
506
-
507452 return renesas_sdhi_probe(pdev, &renesas_sdhi_sys_dmac_dma_ops);
508453 }
509454
....@@ -518,6 +463,7 @@
518463 static struct platform_driver renesas_sys_dmac_sdhi_driver = {
519464 .driver = {
520465 .name = "sh_mobile_sdhi",
466
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
521467 .pm = &renesas_sdhi_sys_dmac_dev_pm_ops,
522468 .of_match_table = renesas_sdhi_sys_dmac_of_match,
523469 },