MTD for FPGA framegrabber

Clemens Koller clemens.koller at
Fri Jun 3 12:38:55 EDT 2005

Hi, Joern!

Okay... it seems to be my lucky day.
I know that using map_rom was bullsomething.

 > Since you want to access sram, you want to create a standalone mtd
 > driver, similar to phram.  As a starter, you can simply use phram and
 > switch from memcpy() to dma later.

Well, my idea was to use map_ram also instead of map_rom... and
instead of patching around in physmap, I copied the code which looked
essential to me out of physmap and phram and some others like the sram
part of cdb89712.c... into my own driver... and... voila!
It works! Which means that I get read and write accesses on my local
bus. :-)

Just FYI:
static struct mtd_info *ecam_mtd;

struct map_info ecam_map = {
         .name = "eCam FPGA-SRAM",
         .phys = 0xfc000000,
         .size = 0x00100000,
         .bankwidth = 4,
         .virt = NULL,

static int mminfo_mtdinit(void)
         int err;

         DBG("----- mtdinit()\n");
         DBG("Anagramm eCam MTD: FPGA-SRAM 0x%lX at 0x%lX\n",ecam_map.size,ecam_map.phys);

         ecam_map.virt = ioremap(ecam_map.phys, ecam_map.size);
         if (!ecam_map.virt) {
                 DBG("Failed to ioremap FPGA-SRAM space\n");
                 err = -EIO;
                 goto out;
         ecam_mtd = do_map_probe("map_ram", &ecam_map);
         if (!ecam_mtd) {
                 DBG("FPGA-SRAM probe failed\n");
                 err = -ENXIO;
                 goto out_ioremap;
         ecam_mtd->owner = THIS_MODULE;
         ecam_mtd->erasesize = 16;
         if (add_mtd_device(ecam_mtd)) {
                 DBG("FGPA-SRAM device addition failed\n");
                 err = -ENOMEM;
                 goto out_probe;
         return 0;
         ecam_mtd = 0;
         iounmap((void *)ecam_map.virt);
         return err;

static void mminfo_mtdexit(void)

         DBG("----- mtdexit()\n");
         iounmap((void *)ecam_map.virt);

I don't have separate read and write routines yet... I'll see
if there is room for more optimization as I want to copy the data
from the SRAM directly to the application's memory. (via DMA)
As I want to achieve some 100 MBytes/sec.

Maybe I need some special point() functions and this direct io flags?
Well... I will see.

Okay, there are still some open questions, but I will have to continue to
fix some other things in my hardware first.

Thanks so far,

Clemens Koller
R&D Imaging Devices
Anagramm GmbH
Rupert-Mayer-Str. 45/1
81379 Muenchen
Phone: +49-89-741518-50
Fax: +49-89-741518-19

More information about the linux-mtd mailing list