Re: [PARPORT] ECP mode

Alan Cox (
Fri, 16 Oct 1998 17:08:06 +0100 (BST)

> Can anyone point me to a Linux driver that illustrates the use of DMA?

There are quite a few candidates - the floppy driver is rather convoluted as
an example but some of the net cards are easier to follow.

The interfaces you need

        kmalloc(size, GFP_KERNEL|GFP_DMA);

to get ISA DMA'able memory or NULL if it fails.

        request_dma(n, "name");

Grab a DMA channel. Makes you appear in /proc/dma as owner too


Give it back


Turns a DMA channel off


Turns a DMA channel on

set_dma_mode(channel, DMA_MODE_READ or DMA_MODE_WRITE)
        (+0x10 if you need AUTOINIT)

This sets the direction of transfer


Clears the channel flip flop (do this before setting the addr/size)

set_dma_addr(chan, virt_to_bus(addr));

The virt_to_bus isnt needed in 2.0.x intel but is needed in 2.1 for all
architectures and 2.0 for some others. It translates the kernel CPU address
space to what is seen on the address bus.

set_dma_count(dma, count)

Sets the number of bytes to transfer

And get_dma_residue(chan) tells you what got left over

It tends to look something like

        if(request_dma(my_dma, "MyDriver"))
                printk("Someone has my DMA channel\n");
                return -EBUSY;
        set_dma_mode(my_dma, DMA_MODE_WRITE);


        set_dma_addr(my_dma, virt_to_phys(buffer));
        set_dma_count(my_dma, buffer_len);

and in the IRQ

                printk("Card left %d bytes!\n", n);


-- To unsubscribe, send mail to: --
-- with the single word "unsubscribe" in the body of the message. --

This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:18:36 EST