diff options
| author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-06-05 08:26:45 -0400 |
|---|---|---|
| committer | Vinod Koul <vinod.koul@intel.com> | 2013-07-05 02:10:44 -0400 |
| commit | 9cade1a46c77dfc96d57a3ea6354e95b2a7fcf61 (patch) | |
| tree | 52340617645937017301473d5333abb47c4b33cd | |
| parent | 61a7649620d54a037c612f9a713abe5178cddc65 (diff) | |
dma: dw: split driver to library part and platform code
To simplify the driver development let's split driver to library and platform
code parts. It helps us to add PCI driver in future.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
[Fixed compile error and few checkpatch issues]
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
| -rw-r--r-- | drivers/dma/Makefile | 2 | ||||
| -rw-r--r-- | drivers/dma/dw/Kconfig | 8 | ||||
| -rw-r--r-- | drivers/dma/dw/Makefile | 6 | ||||
| -rw-r--r-- | drivers/dma/dw/core.c (renamed from drivers/dma/dw/dw_dmac.c) | 311 | ||||
| -rw-r--r-- | drivers/dma/dw/internal.h | 70 | ||||
| -rw-r--r-- | drivers/dma/dw/platform.c | 317 | ||||
| -rw-r--r-- | drivers/dma/dw/regs.h (renamed from drivers/dma/dw/dw_dmac_regs.h) | 1 |
7 files changed, 436 insertions, 279 deletions
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index ac44ca0d468a..6e2a521fbbe3 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile | |||
| @@ -15,7 +15,7 @@ obj-$(CONFIG_FSL_DMA) += fsldma.o | |||
| 15 | obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o | 15 | obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o |
| 16 | obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/ | 16 | obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/ |
| 17 | obj-$(CONFIG_MV_XOR) += mv_xor.o | 17 | obj-$(CONFIG_MV_XOR) += mv_xor.o |
| 18 | obj-$(CONFIG_DW_DMAC) += dw/ | 18 | obj-$(CONFIG_DW_DMAC_CORE) += dw/ |
| 19 | obj-$(CONFIG_AT_HDMAC) += at_hdmac.o | 19 | obj-$(CONFIG_AT_HDMAC) += at_hdmac.o |
| 20 | obj-$(CONFIG_MX3_IPU) += ipu/ | 20 | obj-$(CONFIG_MX3_IPU) += ipu/ |
| 21 | obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o | 21 | obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o |
diff --git a/drivers/dma/dw/Kconfig b/drivers/dma/dw/Kconfig index 38a215af5ccc..efd9e02a58eb 100644 --- a/drivers/dma/dw/Kconfig +++ b/drivers/dma/dw/Kconfig | |||
| @@ -2,10 +2,14 @@ | |||
| 2 | # DMA engine configuration for dw | 2 | # DMA engine configuration for dw |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | config DW_DMAC | 5 | config DW_DMAC_CORE |
| 6 | tristate "Synopsys DesignWare AHB DMA support" | 6 | tristate "Synopsys DesignWare AHB DMA support" |
| 7 | depends on GENERIC_HARDIRQS | 7 | depends on GENERIC_HARDIRQS |
| 8 | select DMA_ENGINE | 8 | select DMA_ENGINE |
| 9 | |||
| 10 | config DW_DMAC | ||
| 11 | tristate "Synopsys DesignWare AHB DMA platform driver" | ||
| 12 | select DW_DMAC_CORE | ||
| 9 | default y if CPU_AT32AP7000 | 13 | default y if CPU_AT32AP7000 |
| 10 | help | 14 | help |
| 11 | Support the Synopsys DesignWare AHB DMA controller. This | 15 | Support the Synopsys DesignWare AHB DMA controller. This |
| @@ -14,7 +18,7 @@ config DW_DMAC | |||
| 14 | config DW_DMAC_BIG_ENDIAN_IO | 18 | config DW_DMAC_BIG_ENDIAN_IO |
| 15 | bool "Use big endian I/O register access" | 19 | bool "Use big endian I/O register access" |
| 16 | default y if AVR32 | 20 | default y if AVR32 |
| 17 | depends on DW_DMAC | 21 | depends on DW_DMAC_CORE |
| 18 | help | 22 | help |
| 19 | Say yes here to use big endian I/O access when reading and writing | 23 | Say yes here to use big endian I/O access when reading and writing |
| 20 | to the DMA controller registers. This is needed on some platforms, | 24 | to the DMA controller registers. This is needed on some platforms, |
diff --git a/drivers/dma/dw/Makefile b/drivers/dma/dw/Makefile index dd8d9936beef..47f36746c559 100644 --- a/drivers/dma/dw/Makefile +++ b/drivers/dma/dw/Makefile | |||
| @@ -1 +1,5 @@ | |||
| 1 | obj-$(CONFIG_DW_DMAC) += dw_dmac.o | 1 | obj-$(CONFIG_DW_DMAC_CORE) += dw_dmac_core.o |
| 2 | dw_dmac_core-objs := core.o | ||
| 3 | |||
| 4 | obj-$(CONFIG_DW_DMAC) += dw_dmac.o | ||
| 5 | dw_dmac-objs := platform.o | ||
diff --git a/drivers/dma/dw/dw_dmac.c b/drivers/dma/dw/core.c index 15f3f4f79c10..eea479c12173 100644 --- a/drivers/dma/dw/dw_dmac.c +++ b/drivers/dma/dw/core.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2007-2008 Atmel Corporation | 4 | * Copyright (C) 2007-2008 Atmel Corporation |
| 5 | * Copyright (C) 2010-2011 ST Microelectronics | 5 | * Copyright (C) 2010-2011 ST Microelectronics |
| 6 | * Copyright (C) 2013 Intel Corporation | ||
| 6 | * | 7 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as | 9 | * it under the terms of the GNU General Public License version 2 as |
| @@ -19,17 +20,12 @@ | |||
| 19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 20 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
| 21 | #include <linux/io.h> | 22 | #include <linux/io.h> |
| 22 | #include <linux/of.h> | ||
| 23 | #include <linux/of_dma.h> | ||
| 24 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
| 25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 26 | #include <linux/platform_device.h> | ||
| 27 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 28 | #include <linux/acpi.h> | ||
| 29 | #include <linux/acpi_dma.h> | ||
| 30 | 26 | ||
| 31 | #include "../dmaengine.h" | 27 | #include "../dmaengine.h" |
| 32 | #include "dw_dmac_regs.h" | 28 | #include "internal.h" |
| 33 | 29 | ||
| 34 | /* | 30 | /* |
| 35 | * This supports the Synopsys "DesignWare AHB Central DMA Controller", | 31 | * This supports the Synopsys "DesignWare AHB Central DMA Controller", |
| @@ -41,16 +37,6 @@ | |||
| 41 | * which does not support descriptor writeback. | 37 | * which does not support descriptor writeback. |
| 42 | */ | 38 | */ |
| 43 | 39 | ||
| 44 | static inline unsigned int dwc_get_dms(struct dw_dma_slave *slave) | ||
| 45 | { | ||
| 46 | return slave ? slave->dst_master : 0; | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave) | ||
| 50 | { | ||
| 51 | return slave ? slave->src_master : 1; | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline void dwc_set_masters(struct dw_dma_chan *dwc) | 40 | static inline void dwc_set_masters(struct dw_dma_chan *dwc) |
| 55 | { | 41 | { |
| 56 | struct dw_dma *dw = to_dw_dma(dwc->chan.device); | 42 | struct dw_dma *dw = to_dw_dma(dwc->chan.device); |
| @@ -1225,99 +1211,6 @@ static void dwc_free_chan_resources(struct dma_chan *chan) | |||
| 1225 | dev_vdbg(chan2dev(chan), "%s: done\n", __func__); | 1211 | dev_vdbg(chan2dev(chan), "%s: done\n", __func__); |
| 1226 | } | 1212 | } |
| 1227 | 1213 | ||
| 1228 | /*----------------------------------------------------------------------*/ | ||
| 1229 | |||
| 1230 | struct dw_dma_of_filter_args { | ||
| 1231 | struct dw_dma *dw; | ||
| 1232 | unsigned int req; | ||
| 1233 | unsigned int src; | ||
| 1234 | unsigned int dst; | ||
| 1235 | }; | ||
| 1236 | |||
| 1237 | static bool dw_dma_of_filter(struct dma_chan *chan, void *param) | ||
| 1238 | { | ||
| 1239 | struct dw_dma_chan *dwc = to_dw_dma_chan(chan); | ||
| 1240 | struct dw_dma_of_filter_args *fargs = param; | ||
| 1241 | |||
| 1242 | /* Ensure the device matches our channel */ | ||
| 1243 | if (chan->device != &fargs->dw->dma) | ||
| 1244 | return false; | ||
| 1245 | |||
| 1246 | dwc->request_line = fargs->req; | ||
| 1247 | dwc->src_master = fargs->src; | ||
| 1248 | dwc->dst_master = fargs->dst; | ||
| 1249 | |||
| 1250 | return true; | ||
| 1251 | } | ||
| 1252 | |||
| 1253 | static struct dma_chan *dw_dma_of_xlate(struct of_phandle_args *dma_spec, | ||
| 1254 | struct of_dma *ofdma) | ||
| 1255 | { | ||
| 1256 | struct dw_dma *dw = ofdma->of_dma_data; | ||
| 1257 | struct dw_dma_of_filter_args fargs = { | ||
| 1258 | .dw = dw, | ||
| 1259 | }; | ||
| 1260 | dma_cap_mask_t cap; | ||
| 1261 | |||
| 1262 | if (dma_spec->args_count != 3) | ||
| 1263 | return NULL; | ||
| 1264 | |||
| 1265 | fargs.req = dma_spec->args[0]; | ||
| 1266 | fargs.src = dma_spec->args[1]; | ||
| 1267 | fargs.dst = dma_spec->args[2]; | ||
| 1268 | |||
| 1269 | if (WARN_ON(fargs.req >= DW_DMA_MAX_NR_REQUESTS || | ||
| 1270 | fargs.src >= dw->nr_masters || | ||
| 1271 | fargs.dst >= dw->nr_masters)) | ||
| 1272 | return NULL; | ||
| 1273 | |||
| 1274 | dma_cap_zero(cap); | ||
| 1275 | dma_cap_set(DMA_SLAVE, cap); | ||
| 1276 | |||
| 1277 | /* TODO: there should be a simpler way to do this */ | ||
| 1278 | return dma_request_channel(cap, dw_dma_of_filter, &fargs); | ||
| 1279 | } | ||
| 1280 | |||
| 1281 | #ifdef CONFIG_ACPI | ||
| 1282 | static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param) | ||
| 1283 | { | ||
| 1284 | struct dw_dma_chan *dwc = to_dw_dma_chan(chan); | ||
| 1285 | struct acpi_dma_spec *dma_spec = param; | ||
| 1286 | |||
| 1287 | if (chan->device->dev != dma_spec->dev || | ||
| 1288 | chan->chan_id != dma_spec->chan_id) | ||
| 1289 | return false; | ||
| 1290 | |||
| 1291 | dwc->request_line = dma_spec->slave_id; | ||
| 1292 | dwc->src_master = dwc_get_sms(NULL); | ||
| 1293 | dwc->dst_master = dwc_get_dms(NULL); | ||
| 1294 | |||
| 1295 | return true; | ||
| 1296 | } | ||
| 1297 | |||
| 1298 | static void dw_dma_acpi_controller_register(struct dw_dma *dw) | ||
| 1299 | { | ||
| 1300 | struct device *dev = dw->dma.dev; | ||
| 1301 | struct acpi_dma_filter_info *info; | ||
| 1302 | int ret; | ||
| 1303 | |||
| 1304 | |||
