linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: linuxppc-dev <eftakhar.chowdhury@yahoo.com>
To: linuxppc-dev@ozlabs.org
Subject: Read/write BCSR registers of PPC460EX
Date: Mon, 2 May 2011 04:50:30 -0700 (PDT)	[thread overview]
Message-ID: <31522823.post@talk.nabble.com> (raw)


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.

             reply	other threads:[~2011-05-02 11:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 11:50 linuxppc-dev [this message]
2011-05-02 12:40 ` Read/write BCSR registers of PPC460EX Josh Boyer
2011-05-02 12:53   ` Stefan Roese
2011-05-02 13:36     ` linuxppc-dev
2011-05-02 13:42       ` Stefan Roese
2011-05-04  5:37         ` Benjamin Herrenschmidt
2011-05-04  5:37   ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31522823.post@talk.nabble.com \
    --to=eftakhar.chowdhury@yahoo.com \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).