aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2013-04-19 16:50:41 -0400
committerArnd Bergmann <arnd@arndb.de>2013-04-19 16:50:52 -0400
commitf54ae513d3d39b60bcc2ef446f1219f501d859bf (patch)
treea60c22feaee5265fa9b017bc504793ae1b531972 /drivers/spi
parent1b361942b53c33f38d55065c13785aadb5103a18 (diff)
parente34d3865ee4a71195f91b23fd09e2619a5f727d3 (diff)
Merge branch 'spear/dwdma' into late/cleanup
This is a series originally prepared for inclusion in 3.9, which did not work out because of dependencies on the dmaengine driver. All the changes for the dmaengine code are merged in 3.9 now, so we can finally do the switchover and remove the now unnecessary dma definitions for spear13xx from the platform code. The dma platform_data actually made up the majority of the spear13xx platform code overall, so moving that into device tree files makes the code substantially smaller. * spear/dwdma: ata: arasan: remove the need for platform_data ARM: SPEAr13xx: Pass generic DW DMAC platform data from DT serial: pl011: use generic DMA slave configuration if possible spi: pl022: use generic DMA slave configuration if possible Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-pl022.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index b0fe393c882c..371cc66f1a0e 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1139,6 +1139,35 @@ err_no_rxchan:
1139 return -ENODEV; 1139 return -ENODEV;
1140} 1140}
1141 1141
1142static int pl022_dma_autoprobe(struct pl022 *pl022)
1143{
1144 struct device *dev = &pl022->adev->dev;
1145
1146 /* automatically configure DMA channels from platform, normally using DT */
1147 pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx");
1148 if (!pl022->dma_rx_channel)
1149 goto err_no_rxchan;
1150
1151 pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx");
1152 if (!pl022->dma_tx_channel)
1153 goto err_no_txchan;
1154
1155 pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
1156 if (!pl022->dummypage)
1157 goto err_no_dummypage;
1158
1159 return 0;
1160
1161err_no_dummypage:
1162 dma_release_channel(pl022->dma_tx_channel);
1163 pl022->dma_tx_channel = NULL;
1164err_no_txchan:
1165 dma_release_channel(pl022->dma_rx_channel);
1166 pl022->dma_rx_channel = NULL;
1167err_no_rxchan:
1168 return -ENODEV;
1169}
1170
1142static void terminate_dma(struct pl022 *pl022) 1171static void terminate_dma(struct pl022 *pl022)
1143{ 1172{
1144 struct dma_chan *rxchan = pl022->dma_rx_channel; 1173 struct dma_chan *rxchan = pl022->dma_rx_channel;
@@ -1167,6 +1196,11 @@ static inline int configure_dma(struct pl022 *pl022)
1167 return -ENODEV; 1196 return -ENODEV;
1168} 1197}
1169 1198
1199static inline int pl022_dma_autoprobe(struct pl022 *pl022)
1200{
1201 return 0;
1202}
1203
1170static inline int pl022_dma_probe(struct pl022 *pl022) 1204static inline int pl022_dma_probe(struct pl022 *pl022)
1171{ 1205{
1172 return 0; 1206 return 0;
@@ -2226,8 +2260,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
2226 goto err_no_irq; 2260 goto err_no_irq;
2227 } 2261 }
2228 2262
2229 /* Get DMA channels */ 2263 /* Get DMA channels, try autoconfiguration first */
2230 if (platform_info->enable_dma) { 2264 status = pl022_dma_autoprobe(pl022);
2265
2266 /* If that failed, use channels from platform_info */
2267 if (status == 0)
2268 platform_info->enable_dma = 1;
2269 else if (platform_info->enable_dma) {
2231 status = pl022_dma_probe(pl022); 2270 status = pl022_dma_probe(pl022);
2232 if (status != 0) 2271 if (status != 0)
2233 platform_info->enable_dma = 0; 2272 platform_info->enable_dma = 0;