Subject: Problems mapping OCM memory from 460EX to user space

From: [email-masked]
Date: Wed, 7 Jul 2010 14:48:46 -0500

I've got an issue with the new rev B 460EX processors that I am trying to isolate.
(Rev A worked fine).  In order to do that, I am trying to modify my driver to 
map the OCM (on chip memory) from the 460EX to user space so that the rest of the
application and codebase don't really know the difference.

My driver implements the mmap and this works fine when I point it to areas of 
memory that have been setup with kmalloc.  My sequence is basically kmalloc, 
adjust for page boundaries, and then remap_pfn_range.  For regular DRAM this 
works fine.

Now I want to modfiy it to use OCM.  I've modified the code to use ioremap so 
that the driver has access to the memory. This seems to work.  But the kernel 
gives a register dump when I call 

#define PLB_OCM_BASE_ADDR        0x400040000ull
...

static int mapper_mmap(struct file *fip, struct vm_area_struct *vma)
{
  int rc;
  
  /* 
   * make sure to allocate the proper number of pages when using
   * mmap.  We check it for correctness here.
   */
  
  unsigned long len = vma->vm_end - vma->vm_start;

  /* if user tries to map bigger space than we have, error */
 if (PAGE_COUNT * PAGE_SIZE < len) 
    return -EIO;

 rc = io_remap_pfn_range(vma, PLB_OCM_BASE_ADDR>>PAGE_SHIFT, vma->vm_start, len, vma->vm_page_prot);

#if 0
  /* map the physical area into one buffer */
  rc = remap_pfn_range(vma, vma->vm_start, 
		       virt_to_phys( (void*)km.pal)>>PAGE_SHIFT,
		       len,
		       vma->vm_page_prot);
#endif

  MDEBUG("Mapped %ld bytes at virt address 0x%lx to mapper file descriptor...\n", len, vma->vm_start);

  /* return an error to the caller if remap fails */
  return (rc < 0 ? rc : 0);

}

The "#if 0" code is the working code for using DRAM.  MDEBUG is just a printk.

I am fairly certain the physical address is correct, I've verified that the
TLB entries in u-boot look ok.  Any tips on how to make this work?

Thanks