Read/write BCSR registers of PPC460EX

Josh Boyer jwboyer at linux.vnet.ibm.com
Mon May 2 22:40:39 EST 2011


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


More information about the Linuxppc-dev mailing list