.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * |
---|
3 | 4 | * 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 | | - * |
---|
14 | 5 | */ |
---|
15 | 6 | #include <linux/of.h> |
---|
16 | 7 | #include <linux/of_dma.h> |
---|
.. | .. |
---|
54 | 45 | |
---|
55 | 46 | #define DML_OFFSET 0x800 |
---|
56 | 47 | |
---|
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) |
---|
58 | 49 | { |
---|
59 | 50 | u32 config; |
---|
60 | 51 | 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; |
---|
61 | 57 | |
---|
62 | 58 | if (data->flags & MMC_DATA_READ) { |
---|
63 | 59 | /* Read operation: configure DML for producer operation */ |
---|
.. | .. |
---|
96 | 92 | |
---|
97 | 93 | /* make sure the dml is configured before dma is triggered */ |
---|
98 | 94 | wmb(); |
---|
| 95 | + return 0; |
---|
99 | 96 | } |
---|
100 | 97 | |
---|
101 | 98 | static int of_get_dml_pipe_index(struct device_node *np, const char *name) |
---|
.. | .. |
---|
119 | 116 | } |
---|
120 | 117 | |
---|
121 | 118 | /* 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) |
---|
123 | 120 | { |
---|
124 | 121 | u32 config; |
---|
125 | 122 | void __iomem *base; |
---|
126 | 123 | int consumer_id, producer_id; |
---|
127 | 124 | struct device_node *np = host->mmc->parent->of_node; |
---|
128 | 125 | |
---|
| 126 | + if (mmci_dmae_setup(host)) |
---|
| 127 | + return -EINVAL; |
---|
| 128 | + |
---|
129 | 129 | consumer_id = of_get_dml_pipe_index(np, "tx"); |
---|
130 | 130 | producer_id = of_get_dml_pipe_index(np, "rx"); |
---|
131 | 131 | |
---|
132 | 132 | if (producer_id < 0 || consumer_id < 0) { |
---|
133 | | - host->variant->qcom_dml = false; |
---|
134 | | - return; |
---|
| 133 | + mmci_dmae_release(host); |
---|
| 134 | + return -EINVAL; |
---|
135 | 135 | } |
---|
136 | 136 | |
---|
137 | 137 | base = host->base + DML_OFFSET; |
---|
.. | .. |
---|
175 | 175 | |
---|
176 | 176 | /* Make sure dml initialization is finished */ |
---|
177 | 177 | 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); |
---|
178 | 185 | } |
---|
179 | 186 | |
---|
180 | 187 | 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, |
---|
181 | 192 | .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, |
---|
182 | 197 | }; |
---|
183 | 198 | |
---|
184 | 199 | void qcom_variant_init(struct mmci_host *host) |
---|