hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/mmc/host/mmci_qcom_dml.c
....@@ -1,16 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 *
34 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 and
7
- * only version 2 as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
145 */
156 #include <linux/of.h>
167 #include <linux/of_dma.h>
....@@ -54,10 +45,15 @@
5445
5546 #define DML_OFFSET 0x800
5647
57
-void dml_start_xfer(struct mmci_host *host, struct mmc_data *data)
48
+static int qcom_dma_start(struct mmci_host *host, unsigned int *datactrl)
5849 {
5950 u32 config;
6051 void __iomem *base = host->base + DML_OFFSET;
52
+ struct mmc_data *data = host->data;
53
+ int ret = mmci_dmae_start(host, datactrl);
54
+
55
+ if (ret)
56
+ return ret;
6157
6258 if (data->flags & MMC_DATA_READ) {
6359 /* Read operation: configure DML for producer operation */
....@@ -96,6 +92,7 @@
9692
9793 /* make sure the dml is configured before dma is triggered */
9894 wmb();
95
+ return 0;
9996 }
10097
10198 static int of_get_dml_pipe_index(struct device_node *np, const char *name)
....@@ -119,19 +116,22 @@
119116 }
120117
121118 /* Initialize the dml hardware connected to SD Card controller */
122
-static void qcom_dma_setup(struct mmci_host *host)
119
+static int qcom_dma_setup(struct mmci_host *host)
123120 {
124121 u32 config;
125122 void __iomem *base;
126123 int consumer_id, producer_id;
127124 struct device_node *np = host->mmc->parent->of_node;
128125
126
+ if (mmci_dmae_setup(host))
127
+ return -EINVAL;
128
+
129129 consumer_id = of_get_dml_pipe_index(np, "tx");
130130 producer_id = of_get_dml_pipe_index(np, "rx");
131131
132132 if (producer_id < 0 || consumer_id < 0) {
133
- host->variant->qcom_dml = false;
134
- return;
133
+ mmci_dmae_release(host);
134
+ return -EINVAL;
135135 }
136136
137137 base = host->base + DML_OFFSET;
....@@ -175,10 +175,25 @@
175175
176176 /* Make sure dml initialization is finished */
177177 mb();
178
+
179
+ return 0;
180
+}
181
+
182
+static u32 qcom_get_dctrl_cfg(struct mmci_host *host)
183
+{
184
+ return MCI_DPSM_ENABLE | (host->data->blksz << 4);
178185 }
179186
180187 static struct mmci_host_ops qcom_variant_ops = {
188
+ .prep_data = mmci_dmae_prep_data,
189
+ .unprep_data = mmci_dmae_unprep_data,
190
+ .get_datactrl_cfg = qcom_get_dctrl_cfg,
191
+ .get_next_data = mmci_dmae_get_next_data,
181192 .dma_setup = qcom_dma_setup,
193
+ .dma_release = mmci_dmae_release,
194
+ .dma_start = qcom_dma_start,
195
+ .dma_finalize = mmci_dmae_finalize,
196
+ .dma_error = mmci_dmae_error,
182197 };
183198
184199 void qcom_variant_init(struct mmci_host *host)