aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2013-01-28 11:24:37 -0500
committerArnd Bergmann <arnd@arndb.de>2013-03-12 12:56:08 -0400
commitdc715452e9145156840b09df765ea2ede4851eda (patch)
tree5e5916cbb0ef6562f444cfb54b5cf3fabef92aca /drivers/spi
parentf6161aa153581da4a3867a2d1a7caf4be19b6ec9 (diff)
spi: pl022: use generic DMA slave configuration if possible
With the new OF DMA binding, it is possible to completely avoid the need for platform_data for configuring a DMA channel. In cases where the platform has already been converted, calling dma_request_slave_channel should get all the necessary information from the device tree. Like the patch that converts the dw_dma controller, this is completely untested and is looking for someone to try it out. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Cc: spi-devel-general@lists.sourceforge.net Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Vinod Koul <vinod.koul@linux.intel.com> Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-arm-kernel@lists.infradead.org
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;