Hi,
I am trying to read the BCSR register of my PPC460ex board.But when I load
the module, then I get the "Machine Check Error".
I am not sure if I missed out something.
I would really appreciate it if somebody could help me on this.
I have posted the source code below, as well as the complete message.
Thanks,
efti
Source code
------------
#include <linux/init.h> // to use module_init and module_exit
#include <linux/module.h>// macros for modules
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <asm/io.h>
static unsigned int reg1 = 1; // test data
static unsigned int reg2 = 2; // test data
static unsigned int reg3 = 3; // test data
static unsigned int *virtual_base = 0; // remapped address
static unsigned long mem_addr = 0xC0000000;// IP base address
static unsigned long mem_size = 0x10000; // 64KB
int io_driver_init(void)
{
int i;
if(check_mem_region(mem_addr,mem_size))
{
printk("simp_mult: memory already in use\n");
return -EBUSY;
}
// request memory for the device
request_mem_region(mem_addr,mem_size,"simp_mult");
// remap
virtual_base = ioremap(mem_addr,mem_size);
printk("ioremap: Virtual Address %08x\n",(unsigned int)virtual_base);
if( virtual_base==0 )
{
printk("ioremap failed\n");
return -EBUSY ;
}
else
{
unsigned int value;
value = in_be32(virtual_base);
printk("Data to Read : %08x\n",value);
return 0; // indicate a success
}
}
void io_driver_exit(void)
{
printk("Release Memory Region...\n") ;
iounmap(virtual_base) ;
release_mem_region(mem_addr,mem_size) ;
}
module_init(io_driver_init);
module_exit(io_driver_exit);
--
View this message in context: http://old.nabble.com/Read-write-BCSR-registers-of-PPC460EX-tp31522823p31522823.html
Sent from the linuxppc-dev mailing list archive at Nabble.com.
On Mon, May 02, 2011 at 04:50:30AM -0700, linuxppc-dev wrote:
Hi,
I am trying to read the BCSR register of my PPC460ex board.But when I load
the module, then I get the "Machine Check Error".
I am not sure if I missed out something.
I would really appreciate it if somebody could help me on this.
I have posted the source code below, as well as the complete message.
Thanks,
efti
Source code
------------
#include <linux/init.h> // to use module_init and module_exit
#include <linux/module.h>// macros for modules
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <asm/io.h>
static unsigned int reg1 = 1; // test data
static unsigned int reg2 = 2; // test data
static unsigned int reg3 = 3; // test data
static unsigned int *virtual_base = 0; // remapped address
static unsigned long mem_addr = 0xC0000000;// IP base address
Is this the correct address for the BCSR? On the 460EX Canyonlands
board, the CPLD/BCSR is at 0xE1000000.
static unsigned long mem_size = 0x10000; // 64KB
int io_driver_init(void)
{
int i;
if(check_mem_region(mem_addr,mem_size))
{
printk("simp_mult: memory already in use\n");
return -EBUSY;
}
// request memory for the device
request_mem_region(mem_addr,mem_size,"simp_mult");
// remap
virtual_base = ioremap(mem_addr,mem_size);
printk("ioremap: Virtual Address %08x\n",(unsigned int)virtual_base);
if( virtual_base==0 )
{
printk("ioremap failed\n");
return -EBUSY ;
}
else
{
unsigned int value;
value = in_be32(virtual_base);
printk("Data to Read : %08x\n",value);
return 0; // indicate a success
}
}
Aside from minor things like using unsigned int instead of unsigned
long, the code looks correct. The thing to check is if you are
ioremapping the right physical address, and making sure you're reading a
proper location.
josh
From: Stefan Roese <sr@denx.de> Date: 2011-05-02 13:42:55
Hi Efti,
On Monday 02 May 2011 15:36:15 linuxppc-dev wrote:
Dear Stefan,
I have changed CPLD/BCSR address with 0x4E1000000.
static unsigned long mem_addr = 0x4E1000000;
Thats a 64bit address, so you need this:
static unsigned long long mem_addr = 0x4E1000000ULL;
You should have seen a compilation warning about this too.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2011-05-04 05:37:23
On Mon, 2011-05-02 at 08:40 -0400, Josh Boyer wrote:
Aside from minor things like using unsigned int instead of unsigned
long, the code looks correct. The thing to check is if you are
ioremapping the right physical address, and making sure you're reading
a
proper location.
Which is why he should obtain the location from the device-tree rather
than hard coding it !
Cheers,
Ben.
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2011-05-04 05:37:36
On Mon, 2011-05-02 at 15:42 +0200, Stefan Roese wrote:
Thats a 64bit address, so you need this:
static unsigned long long mem_addr = 0x4E1000000ULL;
You should have seen a compilation warning about this too.
No, he should use the device-tree :-)
Cheers,
Ben.