Skip to contentSkip to conversation

intel_mid: Add Mrst & Mfld DMA Drivers

PATCH In review Alan Cox 3 participants 3 messages Jun 18, 2010 – Jun 23, 2010 dmaengine

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 intel_mid: Add Mrst & Mfld DMA Drivers

From: Vinod Koul <[email protected]>

This patch add DMA drivers for DMA controllers in Langwell chipset of Intel(R) Moorestown platform and DMA controllers in Penwell of Intel(R) Medfield platfrom

This patch adds support for Moorestown DMAC1 and DMAC2 controllers. It also add support for Medfiled GP DMA and DMAC1 controllers. These controllers supports memory to peripheral and peripheral to memory transfers
It support only single block transfers
This driver is based on Kernel DMA engine
Anyone who wishes to use this controller should use DMA engine APIs

This controller exposes DMA_SLAVE capabilities and notifies the client drivers of DMA transaction completion

---

 drivers/dma/Kconfig              |   12 
 drivers/dma/Makefile             |    1 
 drivers/dma/intel_mid_dma.c      | 1147 ++++++++++++++++++++++++++++++++++++++
 drivers/dma/intel_mid_dma_regs.h |  263 +++++++++
 include/linux/intel_mid_dma.h    |   94 +++
 5 files changed, 1517 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/intel_mid_dma.c
 create mode 100644 drivers/dma/intel_mid_dma_regs.h
 create mode 100644 include/linux/intel_mid_dma.h
drivers/dma/Kconfig +12 -0
index 9e01e96..ce7c2b3 100644
@@ -33,6 +33,18 @@ if DMADEVICES
 
 comment "DMA Devices"
 
+config INTEL_MID_DMAC
+	bool "Intel MID DMA support for Peripheral DMA controllers"
+	depends on PCI && X86
+	select DMA_ENGINE
+	help
+	  Enable support for the Intel(R) MID DMA engine present
+	  in Intel MID chipsets.
+
+	  Say Y here if you have such a chipset.
+
+	  If unsure, say N.
+
 config ASYNC_TX_DISABLE_CHANNEL_SWITCH
 	bool
 
drivers/dma/Makefile +1 -0
index 0fe5ebb..27b6c69 100644
@@ -7,6 +7,7 @@ endif
 
 obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
 obj-$(CONFIG_NET_DMA) += iovlock.o
+obj-$(CONFIG_INTEL_MID_DMAC) += intel_mid_dma.o
 obj-$(CONFIG_DMATEST) += dmatest.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
drivers/dma/intel_mid_dma.c new file +1147 -0

1,147 lines not on this page · raw message

drivers/dma/intel_mid_dma_regs.h new file +263 -0

263 lines not on this page · raw message

include/linux/intel_mid_dma.h new file +94 -0

94 lines not on this page · raw message

#1 lore raw
Quoted 20 lines · Alan Cox

From: Vinod Koul <[email protected]>

This patch add DMA drivers for DMA controllers in Langwell chipset of Intel(R) Moorestown platform and DMA controllers in Penwell of Intel(R) Medfield platfrom

This patch adds support for Moorestown DMAC1 and DMAC2 controllers. It also add support for Medfiled GP DMA and DMAC1 controllers. These controllers supports memory to peripheral and peripheral to memory transfers
It support only single block transfers
This driver is based on Kernel DMA engine
Anyone who wishes to use this controller should use DMA engine APIs

This controller exposes DMA_SLAVE capabilities and notifies the client drivers of DMA transaction completion

---

[..]

Quoted 8 lines
++ *    midc_do_start           begin a transaction
++ *    @midc: channel
++ *    @first: first descriptor of series

++ *
++ * Load a transaction into the engine. This must be called with dwc->lock
++ * held and bh disabled.
++ */
+static void midc_dostart(struct intel_mid_dma_chan *midc, struct intel_mid_dma_desc

(nit) The function name does not match the kernel doc, and I don't know if those extra "+" characters will throw off the kernel-doc scripts. They also show up on midc_put_desc, but not midc_scan_descriptors.

Quoted 8 lines
drivers/dma/intel_mid_dma.c new file +8 -0
+/*check desc, mark as complete when tx is complete*/
+static void
+midc_scan_descriptors(struct middma_device *mid, struct intel_mid_dma_chan *midc)
+{
+       struct intel_mid_dma_desc *desc = NULL, *_desc = NULL;
+/*     u32 status_xfer; */
+
+       dma_dbg("called \n");

drivers/dma/intel_mid_dma.c line 342

Quoted 10 lines
drivers/dma/intel_mid_dma.c new file +10 -0
+/*     status_xfer = ioread32(midc->dma_base + RAW_TFR);
+       status_xfer = (status_xfer >> midc->ch_id) & 0x1;
+       dma_dbg("ch[%d]:  status_xfer %x \n", midc->ch_id, status_xfer);
+       if (!status_xfer)
+               return;
+*/
+       /*tx is complete*/
+       list_for_each_entry_safe(desc, _desc, &midc->active_list, desc_node) {
+               if (desc == NULL)
+                       continue;

How do we ever get desc == NULL at this point?

Quoted 8 lines

+               if (desc->status == DMA_IN_PROGRESS)  {
+                       desc->status = DMA_SUCCESS;
+                       midc_descriptor_complete(midc, desc);
+               }
+       }
+       return;

(quoted diff) +2 -0
+}
+

[..]

drivers/dma/intel_mid_dma_regs.h line 257

Quoted 8 lines
drivers/dma/intel_mid_dma_regs.h new file +8 -0
+#define _dma_printk(level, format, arg...)  \
+       printk(level "LNW_DMA: %s %d " format, __func__, __LINE__, ## arg)
+
+#ifdef CONFIG_LNW_DMA_DEBUG
+#define dma_dbg(format, arg...) _dma_printk(KERN_DEBUG, "DBG " format , ## arg)
+#else
+#define dma_dbg(format, arg...) do {} while (0);
+#endif

This makes us lose compile coverage of the debug statements so they bitrot until someone needs to debug a problem.

[..]

Quoted 10 lines

+struct intel_mid_dma_slave {
+       enum dma_data_direction         dirn;
+       enum intel_mid_dma_width        src_width; /*width of DMA src txn*/
+       enum intel_mid_dma_width        dst_width; /*width of DMA dst txn*/
+       enum intel_mid_dma_hs_mode      hs_mode;  /*handshaking*/
+       enum intel_mid_dma_mode         cfg_mode; /*mode configuration*/
+       enum intel_mid_dma_msize        src_msize; /*size if src burst*/
+       enum intel_mid_dma_msize        dst_msize; /*size of dst burst*/
+       dma_async_tx_callback           callback; /*callback function*/
+       void                            *callback_param; /*param for callback*/

Any advantage to having a default callback in the slave configuration?
Why not let the client specify the callback on each operation, is it
a callback that the client does not know about?

#2 lore raw
Quoted 9 lines

[..]

Quoted 8 lines
++ *    midc_do_start           begin a transaction
++ *    @midc: channel
++ *    @first: first descriptor of series

++ *
++ * Load a transaction into the engine. This must be called with dwc->lock
++ * held and bh disabled.
++ */
+static void midc_dostart(struct intel_mid_dma_chan *midc, struct

Quoted 6 lines

intel_mid_dma_desc

(nit) The function name does not match the kernel doc, and I don't know if those extra "+" characters will throw off the kernel-doc scripts. They also show up on midc_put_desc, but not midc_scan_descriptors.

Okay, will remove extra "+" char

Quoted 6 lines
Quoted 4 lines

+       /*tx is complete*/
+       list_for_each_entry_safe(desc, _desc, &midc->active_list, desc_node) {
+               if (desc == NULL)
+                       continue;

How do we ever get desc == NULL at this point?

Yes we won't, will remove

Quoted 12 lines

[..]

drivers/dma/intel_mid_dma_regs.h line 257

Quoted 8 lines
drivers/dma/intel_mid_dma_regs.h new file +8 -0
+#define _dma_printk(level, format, arg...)  \
+       printk(level "LNW_DMA: %s %d " format, __func__, __LINE__, ## arg)
+
+#ifdef CONFIG_LNW_DMA_DEBUG
+#define dma_dbg(format, arg...) _dma_printk(KERN_DEBUG, "DBG " format , ## arg)
+#else
+#define dma_dbg(format, arg...) do {} while (0);
+#endif

This makes us lose compile coverage of the debug statements so they bitrot until someone needs to debug a problem.

This was just for debug purposes, will be removed

Quoted 3 lines

Any advantage to having a default callback in the slave configuration?
Why not let the client specify the callback on each operation, is it
a callback that the client does not know about?

txd callback is enough, no need to keep here, will be removed

Thanks
Vinod