* Read/write BCSR registers of PPC460EX
@ 2011-05-02 11:50 linuxppc-dev
2011-05-02 12:40 ` Josh Boyer
0 siblings, 1 reply; 7+ messages in thread
From: linuxppc-dev @ 2011-05-02 11:50 UTC (permalink / raw)
To: linuxppc-dev
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Read/write BCSR registers of PPC460EX
2011-05-02 11:50 Read/write BCSR registers of PPC460EX linuxppc-dev
@ 2011-05-02 12:40 ` Josh Boyer
2011-05-02 12:53 ` Stefan Roese
2011-05-04 5:37 ` Benjamin Herrenschmidt
0 siblings, 2 replies; 7+ messages in thread
From: Josh Boyer @ 2011-05-02 12:40 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linuxppc-dev
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Read/write BCSR registers of PPC460EX
2011-05-02 12:40 ` Josh Boyer
@ 2011-05-02 12:53 ` Stefan Roese
2011-05-02 13:36 ` linuxppc-dev
2011-05-04 5:37 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Roese @ 2011-05-02 12:53 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linuxppc-dev, linuxppc-dev
On Monday 02 May 2011 14:40:39 Josh Boyer wrote:
> >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.
To be precise: It's 0x4.e100.0000 as 36bit physical address.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Read/write BCSR registers of PPC460EX
2011-05-02 12:53 ` Stefan Roese
@ 2011-05-02 13:36 ` linuxppc-dev
2011-05-02 13:42 ` Stefan Roese
0 siblings, 1 reply; 7+ messages in thread
From: linuxppc-dev @ 2011-05-02 13:36 UTC (permalink / raw)
To: linuxppc-dev
Dear Stefan,
I have changed CPLD/BCSR address with 0x4E1000000.
static unsigned long mem_addr = 0x4E1000000;
But still I get the Machine check error When I load my module. I have posted
the error Message below.
Error Message
-------------
<4>minimod: module license 'unspecified' taints kernel.
<4>Disabling lock debugging due to kernel taint
<4>ioremap: Virtual Address e8f20000
<4>Machine check in kernel mode.
<4>Data Read PLB Error
<4>Oops: Machine check, sig: 7 [#1]
<4>PowerPC 44x Platform
<4>Modules linked in: minimod(P+)
<4>NIP: e4ff60ec LR: e4ff60d8 CTR: c0167174
<4>REGS: dfff7f10 TRAP: 0214 Tainted: P (2.6.30.3)
<4>MSR: 00029000 <EE,ME,CE> CR: 24000028 XER: 20000007
<4>TASK = de518000[956] 'insmod' THREAD: da282000
<6>GPR00: e4ff60d8 da283e90 de518000 00000025 00000000 ffffffff c01646c8
0000321d
<6>GPR08: 00000000 e8f20000 0000321d 00004000 44000022 101c0dac 100ab618
10095434
<6>GPR16: 100f0000 100f0000 bfee5eec 00000002 bfee5ef0 00000000 101ebf80
bfd0c274
<6>GPR24: 10130a48 00000000 c0350000 c0326008 c0326014 e4ff0000 da282000
e4ff6524
<4>NIP [e4ff60ec] io_driver_init+0x9c/0x150 [minimod]
<4>LR [e4ff60d8] io_driver_init+0x88/0x150 [minimod]
<4>Call Trace:
<4>[da283e90] [e4ff60d8] io_driver_init+0x88/0x150 [minimod] (unreliable)
<4>[da283eb0] [c00013d8] do_one_initcall+0x34/0x1a0
<4>[da283f20] [c004dc14] sys_init_module+0xb0/0x1b8
<4>[da283f40] [c000de8c] ret_from_syscall+0x0/0x3c
<4>Instruction dump:
<4>7c601b78 3c60e4ff 3fa0e4ff 386361ec 7c040378 901d6658 4800007d 813d6658
<4>2f890000 419e004c 7c0004ac 80890000 <0c040000> 4c00012c 3c60e4ff 3863621c
<4>---[ end trace 0af1ade6d5d6a053 ]---
Thanks,
Efti
Stefan Roese wrote:
>
> On Monday 02 May 2011 14:40:39 Josh Boyer wrote:
>> >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.
>
> To be precise: It's 0x4.e100.0000 as 36bit physical address.
>
> 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
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
>
--
View this message in context: http://old.nabble.com/Read-write-BCSR-registers-of-PPC460EX-tp31522823p31523658.html
Sent from the linuxppc-dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Read/write BCSR registers of PPC460EX
2011-05-02 13:36 ` linuxppc-dev
@ 2011-05-02 13:42 ` Stefan Roese
2011-05-04 5:37 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Roese @ 2011-05-02 13:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linuxppc-dev
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Read/write BCSR registers of PPC460EX
2011-05-02 12:40 ` Josh Boyer
2011-05-02 12:53 ` Stefan Roese
@ 2011-05-04 5:37 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2011-05-04 5:37 UTC (permalink / raw)
To: Josh Boyer; +Cc: linuxppc-dev, linuxppc-dev
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Read/write BCSR registers of PPC460EX
2011-05-02 13:42 ` Stefan Roese
@ 2011-05-04 5:37 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2011-05-04 5:37 UTC (permalink / raw)
To: Stefan Roese; +Cc: linuxppc-dev, linuxppc-dev
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-05-04 5:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 11:50 Read/write BCSR registers of PPC460EX linuxppc-dev
2011-05-02 12:40 ` 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
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).