From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from phobos.lunarpages.com (phobos.lunarpages.com [67.210.120.30]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 40F1ADDEFD for ; Mon, 20 Apr 2009 23:58:25 +1000 (EST) Received: from [202.78.230.98] (helo=[192.168.3.61]) by phobos.lunarpages.com with esmtpa (Exim 4.69) (envelope-from ) id 1Lvsnd-0004py-Bx for linuxppc-dev@ozlabs.org; Mon, 20 Apr 2009 05:40:37 -0700 Message-ID: <49EC6CB5.2020300@kobekara.com> Date: Mon, 20 Apr 2009 19:38:13 +0700 From: lhthanh MIME-Version: 1.0 To: linuxppc-dev@ozlabs.org Subject: MPC8349E's DMA controller like ISA controller but with more feature? Content-Type: text/html; charset=UTF-8 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi EveryOne!

This is first time I send a letter to everyone. If I make mistake, please free to correct me. :)

I'm trying to write the first driver which is concerned with DMA. I'm reading dmatest.c and have some confused problem. Oh! No! I have many problem..:D
MPC8349's DMA controller like ISA controller but with more features? I want to mean that MPC8349E's DMA controller will send -MEMR, -MEMW, -IOR, -IOW ?.
So in DMA APIs such as dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction)

*dev will pointer to DMA controller or to peripheral device(FPGA, ISA device)? From dmatest.c , *dev seem to pointer to a channel of DMA controller.
The channel is connected to a peripheral device. So calling the API, DMA controller will be able to access memory from cpu_addr, and peripheral device does too?

Look struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)(struct dma_chan *chan,   dma_addr_t        dest,       dma_addr_t        src,
                                                                                                                                size_t len, unsigned long flags);
I want to DMA from device to memory. So how to I can get address of peripheral device ?

Regards!
From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from az33egw02.freescale.net (az33egw02.freescale.net [192.88.158.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "az33egw02.freescale.net", Issuer "Thawte Premium Server CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 7B711DDEDA for ; Tue, 21 Apr 2009 01:55:17 +1000 (EST) Received: from az33smr02.freescale.net (az33smr02.freescale.net [10.64.34.200]) by az33egw02.freescale.net (8.14.3/az33egw02) with ESMTP id n3KFtD83012320 for ; Mon, 20 Apr 2009 08:55:13 -0700 (MST) Received: from ld0162-tx32.am.freescale.net (ld0162-tx32.am.freescale.net [10.82.19.112]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id n3KFtC1Z016177 for ; Mon, 20 Apr 2009 10:55:12 -0500 (CDT) Date: Mon, 20 Apr 2009 10:55:11 -0500 From: Scott Wood To: lhthanh Subject: Re: MPC8349E's DMA controller like ISA controller but with more feature? Message-ID: <20090420155511.GA25470@ld0162-tx32.am.freescale.net> References: <49EC6CB5.2020300@kobekara.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <49EC6CB5.2020300@kobekara.com> Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Mon, Apr 20, 2009 at 07:38:13PM +0700, lhthanh wrote: > > Hi EveryOne!
>
> This is first time I send a letter to everyone. If I make mistake, > please free to correct me. :)
Please post in plaintext, not HTML. > MPC8349's DMA controller like ISA controller but with more features? No. It is for software-directed memory-to-memory transfers (where "memory" can be main-memory, or the buffer of a device that doesn't do DMA itself). There is no need for anything like ISA's DMA controller, as devices that want to initiate DMA can master the bus themselves. > So in DMA APIs such as dma_addr_t dma_map_single(struct device *dev, > void *cpu_addr, size_t size, enum dma_data_direction direction) > *dev will pointer to DMA controller or to peripheral device(FPGA, > ISA device)? It is whatever device is going to be doing the DMA. > From dmatest.c , *dev seem to pointer to a channel of DMA > controller. That's because in that case, the DMA controller is the peripheral device being used. > I want to DMA from device to memory. What kind of device? > So how to I can get address of peripheral device ? If you have to ask that, it probably means you don't have a specific device buffer in mind that you want an external entity to stuff data into (or suck data from), but rather are dealing with device-initiated DMA. In that case, ignore the DMA controller. -Scott From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qy0-f123.google.com (mail-qy0-f123.google.com [209.85.221.123]) by ozlabs.org (Postfix) with ESMTP id 96A36DDE25 for ; Tue, 21 Apr 2009 03:24:01 +1000 (EST) Received: by qyk29 with SMTP id 29so1533460qyk.17 for ; Mon, 20 Apr 2009 10:23:59 -0700 (PDT) MIME-Version: 1.0 Sender: timur.tabi@gmail.com In-Reply-To: <20090420155511.GA25470@ld0162-tx32.am.freescale.net> References: <49EC6CB5.2020300@kobekara.com> <20090420155511.GA25470@ld0162-tx32.am.freescale.net> Date: Mon, 20 Apr 2009 12:23:52 -0500 Message-ID: Subject: Re: MPC8349E's DMA controller like ISA controller but with more feature? From: Timur Tabi To: Scott Wood Content-Type: text/plain; charset=ISO-8859-1 Cc: linuxppc-dev@ozlabs.org, lhthanh List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Mon, Apr 20, 2009 at 10:55 AM, Scott Wood wrot= e: > No. =A0It is for software-directed memory-to-memory transfers (where > "memory" can be main-memory, or the buffer of a device that doesn't do > DMA itself). It can also be used to transfer data to/from a single I/O register, which is how ISA DMA is frequently used. --=20 Timur Tabi Linux kernel developer at Freescale From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from phobos.lunarpages.com (phobos.lunarpages.com [67.210.120.30]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 10EA0DDEF3 for ; Fri, 24 Apr 2009 16:15:01 +1000 (EST) Message-ID: <49F15831.9080507@kobekara.com> Date: Fri, 24 Apr 2009 13:12:01 +0700 From: lhthanh MIME-Version: 1.0 To: Timur Tabi Subject: Re: MPC8349E's DMA controller like ISA controller but with more feature? References: <49EC6CB5.2020300@kobekara.com> <20090420155511.GA25470@ld0162-tx32.am.freescale.net> <49EFEA26.2010602@kobekara.com> <20090423154311.GA19717@ld0162-tx32.am.freescale.net> <49F08FBC.9010903@freescale.com> In-Reply-To: <49F08FBC.9010903@freescale.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Cc: Scott Wood , linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Thank Scott and Timur! > Scott Wood wrote: > >> Timur Tabi (CCed) has written an audio >> driver that does something very similar; he could probably tell you more >> about how to do that (this is why such discussions should be kept on the >> mailing list rather than taken to private e-mail). >> > > The code in drivers/dma cannot be used to send a buffer of data to a > single I/O port. That code is just an elaborate version of memcpy that > uses the DMA engine to copy data in the background. > > Thanks for your explaination! So if I want to transfer a buffer of data from a single I/O port, will not DMA framework also be able ? Have I to write aother driver? > If you want to transfer a buffer to a single I/O port, you will need to > write your own DMA driver, similar to what I've done in > sound/soc/fsl/fsl_dma.c. This is not trivial. You will need to > understand the DMA hardware programming model to determine whether you > can use direct mode or if you need to create link descriptors. > > Actually, I don't want write all because there are serveral DMA code at hand. I only want to use a framework instead of re-writing. And I afraid that I can not write code which assure sharing DMA channels. Regards! From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from az33egw02.freescale.net (az33egw02.freescale.net [192.88.158.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "az33egw02.freescale.net", Issuer "Thawte Premium Server CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id F1376DE447 for ; Sat, 25 Apr 2009 00:41:11 +1000 (EST) Message-ID: <49F1CF7B.2080703@freescale.com> Date: Fri, 24 Apr 2009 09:40:59 -0500 From: Timur Tabi MIME-Version: 1.0 To: lhthanh Subject: Re: MPC8349E's DMA controller like ISA controller but with more feature? References: <49EC6CB5.2020300@kobekara.com> <20090420155511.GA25470@ld0162-tx32.am.freescale.net> <49EFEA26.2010602@kobekara.com> <20090423154311.GA19717@ld0162-tx32.am.freescale.net> <49F08FBC.9010903@freescale.com> <49F15831.9080507@kobekara.com> In-Reply-To: <49F15831.9080507@kobekara.com> Content-Type: text/plain; charset=ISO-8859-1 Cc: Scott Wood , linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , lhthanh wrote: > Thanks for your explaination! So if I want to transfer a buffer of data > from a single I/O port, will not DMA framework > also be able ? No. > Have I to write aother driver? Yes. > Actually, I don't want write all because there are serveral DMA code at > hand. I only want to use a framework instead of re-writing. There is no framework for what you want to do. There is only one other driver that does what you want (sound/soc/fsl/fsl_dma.c), and that is a complicated driver that does many things besides transferring data to an I/O port. > And I afraid that I can not write code which assure sharing DMA channels. Look at arch/powerpc/boot/dts/mpc8610_hpcd.dts. The DMA channels that are needed by the 8610 audio driver have a different 'compatible' property. This is how you prevent the generic DMA driver from using a channel that you want. I'm afraid that you're going to have to study the DMA programming model, and my device driver, and write a brand new driver from scratch. -- Timur Tabi Linux kernel developer at Freescale From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from phobos.lunarpages.com (phobos.lunarpages.com [67.210.120.30]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3EC19DDF85 for ; Thu, 7 May 2009 12:02:58 +1000 (EST) Message-ID: <4A02409D.80500@kobekara.com> Date: Thu, 07 May 2009 08:59:57 +0700 From: lhthanh MIME-Version: 1.0 To: Timur Tabi Subject: Re: MPC8349E's DMA controller like ISA controller but with more feature? References: <49EC6CB5.2020300@kobekara.com> <20090420155511.GA25470@ld0162-tx32.am.freescale.net> <49EFEA26.2010602@kobekara.com> <20090423154311.GA19717@ld0162-tx32.am.freescale.net> <49F08FBC.9010903@freescale.com> <49F15831.9080507@kobekara.com> <49F1CF7B.2080703@freescale.com> In-Reply-To: <49F1CF7B.2080703@freescale.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Cc: Scott Wood , linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , lhthanh wrote: > >> Thanks for your explaination! So if I want to transfer a buffer of data >> from a single I/O port, will not DMA framework >> also be able ? >> > > No. > > >> Have I to write aother driver? >> > > Yes. > > >> Actually, I don't want write all because there are serveral DMA code at >> hand. I only want to use a framework instead of re-writing. >> > > There is no framework for what you want to do. There is only one other > driver that does what you want (sound/soc/fsl/fsl_dma.c), and that is a > complicated driver that does many things besides transferring data to an > I/O port. > > >> And I afraid that I can not write code which assure sharing DMA channels. >> > > Look at arch/powerpc/boot/dts/mpc8610_hpcd.dts. The DMA channels that > are needed by the 8610 audio driver have a different 'compatible' > property. This is how you prevent the generic DMA driver from using a > channel that you want. > > I'm afraid that you're going to have to study the DMA programming model, > and my device driver, and write a brand new driver from scratch. > > Thank Scott and Timur very much! I will study more DMA driver and come back later. :) Regard!