linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* mmap on 440gx
@ 2005-06-16 21:33 Ed Goforth
  2005-06-16 22:55 ` Matt Porter
  0 siblings, 1 reply; 6+ messages in thread
From: Ed Goforth @ 2005-06-16 21:33 UTC (permalink / raw)
  To: linuxppc-embedded

I've been struggling with implementing mmap on a 440gx-based custom
board.  I have been able to use ioremap(), but we really need a mmap()
for our software.  The kernel is 2.4.18 (TimeSys 4.0).

I'm trying to access one of our FPGA's located at 0x50000000.  Offsets
0x00000000 thru
0x000FFFFF are control and status registers.  Offsets 0x01000000 thru
0x017FFFFF are the QDR SRAM on the FPGA.

Using ioremap_nocache(0x50000000, bytes_to_map) works (so long as
bytes_to_map isn't too large).  I can then use in_be32() and
out_be32() to read/write the registers and the SRAM.  However, trying
to implement mmap() causes the board to lock up hard.  I have tried
iterations both where the driver first does an ioremap(), and where it
doesn't do the ioremap().  Some bits:

In driver module:
static struct file_operations test_mmap_fops =3D {
  read : test_mmap_read,
  mmap : test_mmap_mmap,
  open : test_mmap_open,
  release : test_mmap_release,
};

static int test_mmap_mmap (struct file *filp, struct vm_area_struct *vma) {
  vma->vm_flags |=3D (VM_SHM | VM_LOCKED | VM_IO | VM_RESERVED);

  if (remap_page_range(vma->vm_start, 0x50000000, 4096, vma->vm_page_prot))
    return(-EAGAIN);

  return(0);

} /* test_mmap_mmap() */


When the test code calls mmap():
  unsigned long *mmap_region;
  unsigned long data;
  mmap_region =3D mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
it seems to work.  However, dereferencing mmap_region, either thru
  data =3D *mmap_region;
or
  data =3D mmap_region[0];
causes the board to lock hard.

I would appreciate any suggestions or hints.

Thanks,
Ed

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-06-17  7:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16 21:33 mmap on 440gx Ed Goforth
2005-06-16 22:55 ` Matt Porter
2005-06-17  3:47   ` Ed Goforth
2005-06-17  4:41     ` Matt Porter
2005-06-17  5:42       ` Ed Goforth
2005-06-17  7:24         ` Matt Porter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).