Did you enable the chipselect?
   CSMR2 = 0x00000074;    // BAM=0, AM=1, SD=0, UD=0,
should be CSMR2 = 0x00000075;

and don't use m5272sim.h which is not for 5282

On Wed, 07 Feb 2007 12:36:20 -0500, Martin Filtenborg <[EMAIL PROTECTED]> wrote:

I'm trying to put together a small driver-thing that does memory-mapped device reads/writes.

So far it's been a learning experience - but a rewarding one :)
Up till now I've used 'synthetic IO' in the form of assignments using internal counters etc. As far as actual IO is concerned, memory range allocations and chipselect assignments went well. But doing the actual read from memory produces an 'illegal instruction' at runtime. Compiles OK, but at runtime something's wrong...

I've tried using

data = inw(address);

and

data = *(volatile unsigned short *)HW_register;

but to no avail.


Pondering about what might generate an 'illegal instruction', i can't but think this might be caused by the compiler somehow generating garbage, causing the Coldfire to execute an exception. Which is caught by the kernel, displaying "Illegal Instruction" on my terminal.

Or it could be me doing something silly!

Hmmmm...

Pointers, anyone?

Best regards,
Martin Filtenborg

-----------
Reference info:
Arcturus Networks uCdimm 5282 + uCevolution eval-board.
A fast 16-bit FIFO attached to CS2.
Stock uClinux 2.4.24 and m68k-elf-tools:
uClinux-2.4.x-2004-11-19.tar.gz
uClinux-dist-2004-05-28.tar.gz
as found on the accompanying CD.

And then of course a source code excerpt:

#include <linux/module.h>
#include <linux/kernel.h>    // KERN_EMERG etc...
#include <linux/init.h>
#include <linux/fs.h>
#include <asm/coldfire.h>
#include <asm/m5272sim.h>    // MCF_IPSBAR, GPTA, GPTB etc found here
//#include <asm/m5307sim.h> // To get at the CSAR, CSMR and CSCR definitions
#include <linux/ioport.h>
#include <asm/io.h>
#include <asm/uaccess.h>    // copy_to/from_user() defs found here
#include "my_drv.h"

#define MCFSIM_CSAR1      0x8c        /* CS 1 Address reg (r/w) */
#define MCFSIM_CSMR1      0x90        /* CS 1 Mask reg (r/w) */
#define MCFSIM_CSCR1      0x96        /* CS 1 Control reg (r/w) */

#define MCFSIM_CSAR2      0x98        /* CS 2 Adress reg (r/w) */
#define MCFSIM_CSMR2      0x9c        /* CS 2 Mask reg (r/w) */
#define MCFSIM_CSCR2      0xa2        /* CS 2 Control reg (r/w) */

#define BUFFERSIZE        10000
#define HW_register       0x20010000

#define CSAR2 *((volatile unsigned  int *)(MCF_IPSBAR + MCFSIM_CSAR2 ))
#define CSMR2 *((volatile unsigned long *)(MCF_IPSBAR + MCFSIM_CSMR2 ))
#define CSCR2 *((volatile unsigned  int *)(MCF_IPSBAR + MCFSIM_CSCR2 ))
<snip>

unsigned short uiblock[BUFFERSIZE];
unsigned int ui_baseval = 0;
<snip>

   printk (KERN_ERR "my_dev: Grabbing mem\n");
   if(check_mem_region(0x20010000,0x00010000))
{
       printk(KERN_ERR " - mem occupied, aborting!\n");
       return -EBUSY;
}
   request_mem_region(0x20010000,0x00010000,"my_dev_mem");
   printk (KERN_ERR "my_dev: Setup dev CS\n");
   CSAR2 = 0x2001;        // Setup memory BaseAddress
   CSMR2 = 0x00000074;    // BAM=0, AM=1, SD=0, UD=0,
   CSCR2 = 0x01A0;        // WS=0000, AA=1, PS=10(16 bit), BSTR=0, BSTW=0
<snip>

static ssize_t dev_read (struct file *file, char *buf, size_t count, loff_t *ppos)
{
   unsigned int i;
   uiblock[0] = ui_baseval;
   for(i=1;i<BUFFERSIZE;i++)
{
//        uiblock[i] = inw(HW_register);
       uiblock[i] = *(volatile unsigned short *)HW_register;
//        uiblock[i] = ui_baseval+i;
}
   ui_baseval+=BUFFERSIZE;
   copy_to_user((unsigned short *)buf,&uiblock[0],BUFFERSIZE);
   return count;
}
--
David
[EMAIL PROTECTED]
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to